X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=blobdiff_plain;f=src%2Fuisupport%2Fbufferview.h;h=4e83369e5b178c8b907bdee984a7205e16a922a6;hp=d0ac2100091b2507bc541b1704ae37f4a17b0eeb;hb=0abe45a62eb5d9c8e1d8c0e783d77e07e705235b;hpb=8b896450a5fc56a2bde37b44e81dc5af6c338be1 diff --git a/src/uisupport/bufferview.h b/src/uisupport/bufferview.h index d0ac2100..4e83369e 100644 --- a/src/uisupport/bufferview.h +++ b/src/uisupport/bufferview.h @@ -28,9 +28,9 @@ #include #include +#include "actioncollection.h" #include "bufferviewconfig.h" #include "networkmodel.h" - #include "types.h" /***************************************** @@ -50,9 +50,13 @@ public: void setConfig(BufferViewConfig *config); inline BufferViewConfig *config() { return _config; } + void addActionsToMenu(QMenu *menu, const QModelIndex &index); + void addFilterActions(QMenu *contextMenu, const QModelIndex &index); + public slots: void setRootIndexForNetworkId(const NetworkId &networkId); void removeSelectedBuffers(bool permanently = false); + void menuActionTriggered(QAction *); signals: void removeBuffer(const QModelIndex &); @@ -60,6 +64,7 @@ signals: protected: virtual void keyPressEvent(QKeyEvent *); + virtual void dropEvent(QDropEvent *event); virtual void rowsInserted(const QModelIndex & parent, int start, int end); virtual void dataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight); virtual void wheelEvent(QWheelEvent *); @@ -75,53 +80,25 @@ private slots: void on_expand(const QModelIndex &index); void on_configChanged(); -private: - enum ItemActiveState { - InactiveState = 0x01, - ActiveState = 0x02 - }; - -public: - Q_DECLARE_FLAGS(ItemActiveStates, ItemActiveState) - QAction showChannelList; - private: QPointer _config; - - QAction _connectNetAction; - QAction _disconnectNetAction; - QAction _joinChannelAction; - - QAction _joinBufferAction; - QAction _partBufferAction; - QAction _hideBufferTemporarilyAction; - QAction _hideBufferPermanentlyAction; - QAction _removeBufferAction; - QAction _ignoreListAction; - - QAction _hideJoinAction; - QAction _hidePartAction; - QAction _hideQuitAction; - QAction _hideNickAction; - QAction _hideModeAction; - QAction _hideDayChangeAction; - QHash _expandedState; void storeExpandedState(NetworkId networkId, bool expanded); +}; + +// ****************************** +// TristateDelgate +// ****************************** +#include - bool checkRequirements(const QModelIndex &index, - ItemActiveStates requiredActiveState = QFlags(ActiveState) | QFlags(InactiveState)); - void addItemToMenu(QAction &action, QMenu &menu, const QModelIndex &index, - ItemActiveStates requiredActiveState = QFlags(ActiveState) | QFlags(InactiveState)); - void addItemToMenu(QAction &action, QMenu &menu, bool condition = true); - void addItemToMenu(QMenu &subMenu, QMenu &menu, const QModelIndex &index, - ItemActiveStates requiredActiveState = QFlags(ActiveState) | QFlags(InactiveState)); - void addSeparatorToMenu(QMenu &menu, const QModelIndex &index, - ItemActiveStates requiredActiveState = QFlags(ActiveState) | QFlags(InactiveState)); - QMenu *createHideEventsSubMenu(QMenu &menu, BufferId bufferId); +class TristateDelegate : public QStyledItemDelegate { + Q_OBJECT + +public: + TristateDelegate(QObject *parent = 0) : QStyledItemDelegate(parent) {} + bool editorEvent(QEvent *event, QAbstractItemModel *model, const QStyleOptionViewItem &option, const QModelIndex &index); }; -Q_DECLARE_OPERATORS_FOR_FLAGS(BufferView::ItemActiveStates) // ============================== @@ -132,7 +109,6 @@ class BufferViewDock : public QDockWidget { public: BufferViewDock(BufferViewConfig *config, QWidget *parent); - BufferViewDock(QWidget *parent); inline BufferView *bufferView() const { return qobject_cast(widget()); }