PageRenderTime 202ms CodeModel.GetById 110ms app.highlight 6ms RepoModel.GetById 85ms app.codeStats 0ms

/src/libtomahawk/playlist/treemodelitem.h

http://github.com/tomahawk-player/tomahawk
C++ Header | 80 lines | 47 code | 16 blank | 17 comment | 0 complexity | f5af959517a9fe67c3d7aea4d891d9b6 MD5 | raw file
 1/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
 2 *
 3 *   Copyright 2010-2011, Christian Muehlhaeuser <muesli@tomahawk-player.org>
 4 *
 5 *   Tomahawk is free software: you can redistribute it and/or modify
 6 *   it under the terms of the GNU General Public License as published by
 7 *   the Free Software Foundation, either version 3 of the License, or
 8 *   (at your option) any later version.
 9 *
10 *   Tomahawk is distributed in the hope that it will be useful,
11 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
12 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 *   GNU General Public License for more details.
14 *
15 *   You should have received a copy of the GNU General Public License
16 *   along with Tomahawk. If not, see <http://www.gnu.org/licenses/>.
17 */
18
19#ifndef TREEMODELITEM_H
20#define TREEMODELITEM_H
21
22#include <QAbstractItemModel>
23#include <QHash>
24#include <QPersistentModelIndex>
25#include <QPixmap>
26
27#include "typedefs.h"
28#include "dllmacro.h"
29
30class DLLEXPORT TreeModelItem : public QObject
31{
32Q_OBJECT
33
34public:
35    ~TreeModelItem();
36
37    explicit TreeModelItem( TreeModelItem* parent = 0, QAbstractItemModel* model = 0 );
38    explicit TreeModelItem( const Tomahawk::artist_ptr& artist, TreeModelItem* parent = 0, int row = -1 );
39    explicit TreeModelItem( const Tomahawk::album_ptr& album, TreeModelItem* parent = 0, int row = -1 );
40    explicit TreeModelItem( const Tomahawk::result_ptr& result, TreeModelItem* parent = 0, int row = -1 );
41    explicit TreeModelItem( const Tomahawk::query_ptr& query, TreeModelItem* parent = 0, int row = -1 );
42
43    const Tomahawk::artist_ptr& artist() const { return m_artist; };
44    const Tomahawk::album_ptr& album() const { return m_album; };
45    const Tomahawk::query_ptr& query() const { return m_query; };
46    const Tomahawk::result_ptr& result() const;
47
48    bool isPlaying() { return m_isPlaying; }
49    void setIsPlaying( bool b ) { m_isPlaying = b; emit dataChanged(); }
50
51    QString name() const;
52    QString artistName() const;
53    QString albumName() const;
54
55    TreeModelItem* parent;
56    QList<TreeModelItem*> children;
57    QHash<QString, TreeModelItem*> hash;
58    int childCount;
59    QPersistentModelIndex index;
60    QAbstractItemModel* model;
61
62    bool toberemoved;
63    bool fetchingMore;
64
65signals:
66    void dataChanged();
67
68private slots:
69    void onResultsChanged();
70
71private:
72    Tomahawk::artist_ptr m_artist;
73    Tomahawk::album_ptr m_album;
74    Tomahawk::result_ptr m_result;
75    Tomahawk::query_ptr m_query;
76
77    bool m_isPlaying;
78};
79
80#endif // TREEMODELITEM_H