PageRenderTime 82ms CodeModel.GetById 41ms app.highlight 4ms RepoModel.GetById 36ms app.codeStats 0ms

/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
19#ifndef GENERIC_PAGE_ITEM_H
20#define GENERIC_PAGE_ITEM_H
21
22#include "SourceTreeItem.h"
23
24#include "boost/function.hpp"
25#include "boost/bind.hpp"
26
27// generic item that has some name, some text, and calls a certain slot when activated. badabing!
28class GenericPageItem : public SourceTreeItem
29{
30    Q_OBJECT
31public:
32    // 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
33    GenericPageItem( SourcesModel* model, SourceTreeItem* parent, const QString& text, const QIcon& icon, boost::function<Tomahawk::ViewPage*()> show, boost::function<Tomahawk::ViewPage*()> get );
34    virtual ~GenericPageItem();
35
36    virtual QString text() const;
37    virtual void activate();
38    virtual bool willAcceptDrag( const QMimeData* data ) const;
39    virtual QIcon icon() const;
40    virtual int peerSortValue() const; // How to sort relative to peers in the tree.
41    virtual bool isBeingPlayed() const;
42
43    void setText( const QString& text );
44    void setSortValue( int value );
45
46signals:
47    void activated();
48
49private:
50    QIcon m_icon;
51    QString m_text;
52    int m_sortValue;
53    boost::function< Tomahawk::ViewPage*() > m_show;
54    boost::function< Tomahawk::ViewPage*() > m_get;
55};
56
57#endif