1 /***************************************************************************
2 * Copyright (C) 2005-07 by The Quassel Team *
3 * devel@quassel-irc.org *
5 * This program 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 2 of the License, or *
8 * (at your option) any later version. *
10 * This program 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. *
15 * You should have received a copy of the GNU General Public License *
16 * along with this program; if not, write to the *
17 * Free Software Foundation, Inc., *
18 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
19 ***************************************************************************/
21 #ifndef _BUFFERTREEMODEL_H_
22 #define _BUFFERTREEMODEL_H_
26 #include "treemodel.h"
31 #include <QItemSelectionModel>
35 #include "selectionmodelsynchronizer.h"
36 #include "modelpropertymapper.h"
37 class MappedSelectionModel;
38 class QAbstractItemView;
40 /*****************************************
42 *****************************************/
43 class BufferTreeItem : public TreeItem {
47 BufferTreeItem(Buffer *, TreeItem *parent = 0);
49 virtual uint id() const;
50 QVariant data(int column, int role) const;
51 virtual Qt::ItemFlags flags() const;
53 Buffer *buffer() const { return buf; }
54 void setActivity(const Buffer::ActivityLevel &);
57 QString text(int column) const;
58 QColor foreground(int column) const;
61 Buffer::ActivityLevel activity;
64 /*****************************************
66 *****************************************/
67 class NetworkTreeItem : public TreeItem {
71 NetworkTreeItem(const QString &, TreeItem *parent = 0);
73 virtual uint id() const;
74 virtual Qt::ItemFlags flags() const;
81 /*****************************************
83 *****************************************/
84 class BufferTreeModel : public TreeModel {
89 BufferTypeRole = Qt::UserRole,
95 BufferTreeModel(QObject *parent = 0);
96 static QList<QVariant> defaultHeader();
98 inline SelectionModelSynchronizer *selectionModelSynchronizer() { return _selectionModelSynchronizer; }
99 inline ModelPropertyMapper *propertyMapper() { return _propertyMapper; }
101 void synchronizeSelectionModel(MappedSelectionModel *selectionModel);
102 void synchronizeView(QAbstractItemView *view);
103 void mapProperty(int column, int role, QObject *target, const QByteArray &property);
106 void bufferUpdated(Buffer *);
107 void setCurrentIndex(const QModelIndex &index, QItemSelectionModel::SelectionFlags command);
108 void selectBuffer(Buffer *buffer);
109 void bufferActivity(Buffer::ActivityLevel, Buffer *buffer);
112 void bufferSelected(Buffer *);
113 void invalidateFilter();
114 void selectionChanged(const QModelIndex &);
117 bool isBufferIndex(const QModelIndex &) const;
118 Buffer *getBufferByIndex(const QModelIndex &) const;
119 QModelIndex getOrCreateNetworkItemIndex(Buffer *buffer);
120 QModelIndex getOrCreateBufferItemIndex(Buffer *buffer);
122 QStringList mimeTypes() const;
123 QMimeData *mimeData(const QModelIndexList &) const;
124 bool dropMimeData(const QMimeData *, Qt::DropAction, int, int, const QModelIndex &);
126 QPointer<SelectionModelSynchronizer> _selectionModelSynchronizer;
127 QPointer<ModelPropertyMapper> _propertyMapper;
128 Buffer *currentBuffer;