1 /***************************************************************************
2 * Copyright (C) 2005-2015 by the Quassel Project *
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) version 3. *
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 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
19 ***************************************************************************/
26 #include <QDockWidget>
27 #include <QModelIndex>
28 #include <QStyledItemDelegate>
32 #include "actioncollection.h"
33 #include "bufferviewconfig.h"
34 #include "networkmodel.h"
37 /*****************************************
38 * The TreeView showing the Buffers
39 *****************************************/
40 class BufferView : public QTreeView
50 BufferView(QWidget *parent = 0);
53 void setModel(QAbstractItemModel *model);
54 void setFilteredModel(QAbstractItemModel *model, BufferViewConfig *config);
56 void setConfig(BufferViewConfig *config);
57 inline BufferViewConfig *config() { return _config; }
59 void addActionsToMenu(QMenu *menu, const QModelIndex &index);
60 void addFilterActions(QMenu *contextMenu, const QModelIndex &index);
63 void setRootIndexForNetworkId(const NetworkId &networkId);
64 void removeSelectedBuffers(bool permanently = false);
65 void menuActionTriggered(QAction *);
67 void previousBuffer();
68 void hideCurrentBuffer();
71 void removeBuffer(const QModelIndex &);
72 void removeBufferPermanently(const QModelIndex &);
75 virtual void keyPressEvent(QKeyEvent *);
76 virtual void dropEvent(QDropEvent *event);
77 virtual void rowsInserted(const QModelIndex &parent, int start, int end);
78 virtual void wheelEvent(QWheelEvent *);
79 virtual QSize sizeHint() const;
80 virtual void focusInEvent(QFocusEvent *event) { QAbstractScrollArea::focusInEvent(event); }
81 virtual void contextMenuEvent(QContextMenuEvent *event);
83 #if QT_VERSION < 0x050000
84 virtual void dataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight);
86 virtual void dataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight, const QVector<int> &roles);
90 void joinChannel(const QModelIndex &index);
91 void toggleHeader(bool checked);
93 void storeExpandedState(const QModelIndex &networkIdx);
94 void setExpandedState(const QModelIndex &networkIdx);
96 void on_configChanged();
97 void on_layoutChanged();
99 void changeBuffer(Direction direction);
102 QPointer<BufferViewConfig> _config;
108 QHash<NetworkId, short> _expandedState;
112 // ******************************
114 // ******************************
116 class BufferViewDelegate : public QStyledItemDelegate
121 BufferViewDelegate(QObject *parent = 0);
122 bool editorEvent(QEvent *event, QAbstractItemModel *model, const QStyleOptionViewItem &option, const QModelIndex &index);
125 virtual void customEvent(QEvent *event);
129 // ==============================
131 // ==============================
132 class BufferViewDock : public QDockWidget
135 Q_PROPERTY(bool active READ isActive WRITE setActive STORED true)
138 BufferViewDock(BufferViewConfig *config, QWidget *parent);
140 int bufferViewId() const;
141 BufferViewConfig *config() const;
142 inline BufferView *bufferView() const { return qobject_cast<BufferView *>(widget()); }
143 inline bool isActive() const { return _active; }
146 void setActive(bool active = true);
149 void bufferViewRenamed(const QString &newName);