1 /***************************************************************************
2 * Copyright (C) 2005-08 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 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
19 ***************************************************************************/
26 #include <QDockWidget>
27 #include <QModelIndex>
31 #include "actioncollection.h"
32 #include "bufferviewconfig.h"
33 #include "networkmodel.h"
36 /*****************************************
37 * The TreeView showing the Buffers
38 *****************************************/
39 class BufferView : public QTreeView {
43 BufferView(QWidget *parent = 0);
46 void setModel(QAbstractItemModel *model);
47 void setFilteredModel(QAbstractItemModel *model, BufferViewConfig *config);
48 virtual void setSelectionModel(QItemSelectionModel *selectionModel);
50 void setConfig(BufferViewConfig *config);
51 inline BufferViewConfig *config() { return _config; }
53 void addActionsToMenu(QMenu *menu, const QModelIndex &index);
56 void setRootIndexForNetworkId(const NetworkId &networkId);
57 void removeSelectedBuffers(bool permanently = false);
58 void menuActionTriggered(QAction *);
61 void removeBuffer(const QModelIndex &);
62 void removeBufferPermanently(const QModelIndex &);
65 virtual void keyPressEvent(QKeyEvent *);
66 virtual void dropEvent(QDropEvent *event);
67 virtual void rowsInserted(const QModelIndex & parent, int start, int end);
68 virtual void dataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight);
69 virtual void wheelEvent(QWheelEvent *);
70 virtual QSize sizeHint() const;
71 virtual void focusInEvent(QFocusEvent *event) { QAbstractScrollArea::focusInEvent(event); }
72 virtual void contextMenuEvent(QContextMenuEvent *event);
75 void joinChannel(const QModelIndex &index);
76 void toggleHeader(bool checked);
78 void on_collapse(const QModelIndex &index);
79 void on_expand(const QModelIndex &index);
80 void on_configChanged();
83 QPointer<BufferViewConfig> _config;
84 QHash<NetworkId, bool> _expandedState;
86 void storeExpandedState(NetworkId networkId, bool expanded);
89 // ==============================
91 // ==============================
92 class BufferViewDock : public QDockWidget {
96 BufferViewDock(BufferViewConfig *config, QWidget *parent);
97 BufferViewDock(QWidget *parent);
99 inline BufferView *bufferView() const { return qobject_cast<BufferView *>(widget()); }
102 void bufferViewRenamed(const QString &newName);