/src/sourcetree/items/genericpageitems.h

http://github.com/tomahawk-player/tomahawk · C Header · 57 lines · 29 code · 9 blank · 19 comment · 0 complexity · f6ee8dec56dda99b865f75ed49e7b0c5 MD5 · raw file

  1. /*
  2. * Copyright 2010-2011, Leo Franchi <lfranchi@kde.org>
  3. *
  4. * This program is free software; you can redistribute it and/or modify
  5. * it under the terms of the GNU General Public License as published by
  6. * the Free Software Foundation; either version 2 of the License, or
  7. * (at your option) any later version.
  8. *
  9. * This program is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. * GNU General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU General Public License along
  15. * with this program; if not, write to the Free Software Foundation, Inc.,
  16. * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  17. */
  18. #ifndef GENERIC_PAGE_ITEM_H
  19. #define GENERIC_PAGE_ITEM_H
  20. #include "SourceTreeItem.h"
  21. #include "boost/function.hpp"
  22. #include "boost/bind.hpp"
  23. // generic item that has some name, some text, and calls a certain slot when activated. badabing!
  24. class GenericPageItem : public SourceTreeItem
  25. {
  26. Q_OBJECT
  27. public:
  28. // takes 2 function pointers: show: called when wanting to show the desired view page. get: called to get the view page from ViewManager if it exists
  29. GenericPageItem( SourcesModel* model, SourceTreeItem* parent, const QString& text, const QIcon& icon, boost::function<Tomahawk::ViewPage*()> show, boost::function<Tomahawk::ViewPage*()> get );
  30. virtual ~GenericPageItem();
  31. virtual QString text() const;
  32. virtual void activate();
  33. virtual bool willAcceptDrag( const QMimeData* data ) const;
  34. virtual QIcon icon() const;
  35. virtual int peerSortValue() const; // How to sort relative to peers in the tree.
  36. virtual bool isBeingPlayed() const;
  37. void setText( const QString& text );
  38. void setSortValue( int value );
  39. signals:
  40. void activated();
  41. private:
  42. QIcon m_icon;
  43. QString m_text;
  44. int m_sortValue;
  45. boost::function< Tomahawk::ViewPage*() > m_show;
  46. boost::function< Tomahawk::ViewPage*() > m_get;
  47. };
  48. #endif