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 _BUFFERVIEW_H_
22
#define _BUFFERVIEW_H_
29
#include "gui/ui_bufferviewwidget.h"
30
#include "bufferview.h"
32
/*****************************************
33
* general item used in the Tree Model
34
*****************************************/
37
TreeItem(QList<QVariant> &data, TreeItem *parent = 0);
38
TreeItem(TreeItem *parent = 0);
41
void appendChild(TreeItem *child);
42
void removeChild(int row);
44
TreeItem *child(int row);
45
int childCount() const;
46
int columnCount() const;
47
virtual QVariant data(int column, int role) const;
51
void setForeground(QColor);
54
QList<TreeItem*> childItems;
56
QList<QVariant> itemData;
62
/*****************************************
64
*****************************************/
65
class BufferTreeItem : public TreeItem{
67
BufferTreeItem(Buffer *, TreeItem *parent = 0);
68
QVariant data(int column, int role) const;
69
Buffer *buffer() const { return buf; }
70
void setActivity(const Buffer::ActivityLevel &);
73
QString text(int column) const;
74
QColor foreground(int column) const;
76
Buffer::ActivityLevel activity;
80
/*****************************************
82
*****************************************/
83
class BufferTreeModel : public QAbstractItemModel {
88
BufferTypeRole = Qt::UserRole,
93
BufferTreeModel(QObject *parent = 0);
96
QVariant data(const QModelIndex &index, int role) const;
97
Qt::ItemFlags flags(const QModelIndex &index) const;
98
QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const;
99
QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const;
100
QModelIndex parent(const QModelIndex &index) const;
101
int rowCount(const QModelIndex &parent = QModelIndex()) const;
102
int columnCount(const QModelIndex &parent = QModelIndex()) const;
104
void clearActivity(Buffer *buffer);
107
void bufferUpdated(Buffer *);
108
void changeCurrent(const QModelIndex &, const QModelIndex &);
109
void selectBuffer(Buffer *buffer);
110
void doubleClickReceived(const QModelIndex &);
111
void bufferActivity(Buffer::ActivityLevel, Buffer *buffer);
114
void bufferSelected(Buffer *);
115
void invalidateFilter();
116
void fakeUserInput(BufferId, QString);
117
void updateSelection(const QModelIndex &, QItemSelectionModel::SelectionFlags);
120
bool isBufferIndex(const QModelIndex &) const;
121
Buffer *getBufferByIndex(const QModelIndex &) const;
122
QModelIndex getOrCreateNetworkItemIndex(Buffer *buffer);
123
QModelIndex getOrCreateBufferItemIndex(Buffer *buffer);
125
bool removeRow(int row, const QModelIndex &parent = QModelIndex());
127
QStringList mimeTypes() const;
128
QMimeData *mimeData(const QModelIndexList &) const;
129
bool dropMimeData(const QMimeData *, Qt::DropAction, int, int, const QModelIndex &);
132
QHash<QString, TreeItem*> networkItem;
133
QHash<Buffer *, BufferTreeItem*> bufferItem;
134
Buffer *currentBuffer;
140
/*****************************************
141
* This Widget Contains the BufferView
142
*****************************************/
143
class BufferViewWidget : public QWidget {
147
BufferViewWidget(QWidget *parent = 0);
148
virtual QSize sizeHint () const;
149
BufferView *treeView() { return ui.treeView; }
152
Ui::BufferViewWidget ui;
157
/*****************************************
158
* Dock and API for the BufferViews
159
*****************************************/
160
class BufferViewDock : public QDockWidget {
164
BufferViewDock(QAbstractItemModel *model, QString name, BufferViewFilter::Modes mode, QStringList nets = QStringList(), QWidget *parent = 0);