1
/* This file is part of Zanshin Todo.
3
Copyright 2008 Kevin Ottens <ervin@kde.org>
4
Copyright 2008, 2009 Mario Bensi <nef@ipsquad.net>
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.
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.
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,
25
#ifndef ZANSHIN_LIBRARYMODEL_H
26
#define ZANSHIN_LIBRARYMODEL_H
28
#include <QtCore/QHash>
29
#include <QtGui/QAbstractProxyModel>
31
class LibraryModel : public QAbstractProxyModel
42
LibraryModel(QObject *parent = 0);
43
virtual ~LibraryModel();
45
LibraryType type() const;
46
void setType(LibraryType type);
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;
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;
62
bool isInbox(const QModelIndex &index) const;
63
bool isLibraryRoot(const QModelIndex &index) const;
65
virtual void setSourceModel(QAbstractItemModel *sourceModel);
67
virtual QModelIndex mapToSource(const QModelIndex &proxyIndex) const;
68
virtual QModelIndex mapFromSource(const QModelIndex &sourceIndex) const;
70
virtual void sort(int column, Qt::SortOrder order=Qt::AscendingOrder);
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();
81
const qint64 m_inboxToken;
82
const qint64 m_libraryToken;
83
const qint64 m_tokenShift;
84
mutable QList<QPersistentModelIndex> m_sourceIndexesList;