~ubuntu-branches/ubuntu/wily/zanshin/wily-proposed

« back to all changes in this revision

Viewing changes to src/librarymodel.h

  • Committer: Bazaar Package Importer
  • Author(s): Jonathan Riddell
  • Date: 2009-08-13 23:19:32 UTC
  • Revision ID: james.westby@ubuntu.com-20090813231932-lewqphiry1qs7w80
Tags: upstream-0.1+svn1006410
ImportĀ upstreamĀ versionĀ 0.1+svn1006410

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* This file is part of Zanshin Todo.
 
2
 
 
3
   Copyright 2008 Kevin Ottens <ervin@kde.org>
 
4
   Copyright 2008, 2009 Mario Bensi <nef@ipsquad.net>
 
5
 
 
6
   This program is free software; you can redistribute it and/or
 
7
   modify it under the terms of the GNU General Public License as
 
8
   published by the Free Software Foundation; either version 2 of
 
9
   the License or (at your option) version 3 or any later version
 
10
   accepted by the membership of KDE e.V. (or its successor approved
 
11
   by the membership of KDE e.V.), which shall act as a proxy
 
12
   defined in Section 14 of version 3 of the license.
 
13
 
 
14
   This program is distributed in the hope that it will be useful,
 
15
   but WITHOUT ANY WARRANTY; without even the implied warranty of
 
16
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 
17
   GNU General Public License for more details.
 
18
 
 
19
   You should have received a copy of the GNU General Public License
 
20
   along with this program; if not, write to the Free Software
 
21
   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
 
22
   USA.
 
23
*/
 
24
 
 
25
#ifndef ZANSHIN_LIBRARYMODEL_H
 
26
#define ZANSHIN_LIBRARYMODEL_H
 
27
 
 
28
#include <QtCore/QHash>
 
29
#include <QtGui/QAbstractProxyModel>
 
30
 
 
31
class LibraryModel : public QAbstractProxyModel
 
32
{
 
33
    Q_OBJECT
 
34
 
 
35
public:
 
36
    enum LibraryType {
 
37
        Projects = 0,
 
38
        Contexts
 
39
    };
 
40
 
 
41
 
 
42
    LibraryModel(QObject *parent = 0);
 
43
    virtual ~LibraryModel();
 
44
 
 
45
    LibraryType type() const;
 
46
    void setType(LibraryType type);
 
47
 
 
48
    virtual QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const;
 
49
    virtual QModelIndex parent(const QModelIndex &index) const;
 
50
    virtual int rowCount(const QModelIndex &parent = QModelIndex()) const;
 
51
    virtual int columnCount(const QModelIndex &parent = QModelIndex()) const;
 
52
 
 
53
    Qt::DropActions supportedDropActions() const;
 
54
    virtual QStringList mimeTypes() const;
 
55
    virtual Qt::ItemFlags flags(const QModelIndex &index) const;
 
56
    virtual QMimeData *mimeData(const QModelIndexList &indexes) const;
 
57
    virtual bool dropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent);
 
58
    virtual QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;
 
59
    virtual QVariant headerData(int section, Qt::Orientation orientation,
 
60
                                int role = Qt::DisplayRole) const;
 
61
 
 
62
    bool isInbox(const QModelIndex &index) const;
 
63
    bool isLibraryRoot(const QModelIndex &index) const;
 
64
 
 
65
    virtual void setSourceModel(QAbstractItemModel *sourceModel);
 
66
 
 
67
    virtual QModelIndex mapToSource(const QModelIndex &proxyIndex) const;
 
68
    virtual QModelIndex mapFromSource(const QModelIndex &sourceIndex) const;
 
69
 
 
70
    virtual void sort(int column, Qt::SortOrder order=Qt::AscendingOrder);
 
71
 
 
72
private slots:
 
73
    void onSourceDataChanged(const QModelIndex &begin, const QModelIndex &end);
 
74
    void onSourceRowsAboutToBeInserted(const QModelIndex &sourceIndex, int begin, int end);
 
75
    void onSourceRowsInserted(const QModelIndex &sourceIndex, int begin, int end);
 
76
    void onSourceRowsAboutToBeRemoved(const QModelIndex &sourceIndex, int begin, int end);
 
77
    void onSourceRowsRemoved(const QModelIndex &sourceIndex, int begin, int end);
 
78
    void onSourceLayoutChanged();
 
79
 
 
80
private:
 
81
    const qint64 m_inboxToken;
 
82
    const qint64 m_libraryToken;
 
83
    const qint64 m_tokenShift;
 
84
    mutable QList<QPersistentModelIndex> m_sourceIndexesList;
 
85
    LibraryType m_type;
 
86
};
 
87
 
 
88
#endif
 
89