Throw out unneeded font setters, adapt to ItemViewSettings
[quassel.git] / src / uisupport / bufferview.h
index a98f41f..5d19a13 100644 (file)
@@ -1,5 +1,5 @@
 /***************************************************************************
- *   Copyright (C) 2005-08 by the Quassel Project                          *
+ *   Copyright (C) 2005-09 by the Quassel Project                          *
  *   devel@quassel-irc.org                                                 *
  *                                                                         *
  *   This program is free software; you can redistribute it and/or modify  *
 #include <QMenu>
 #include <QDockWidget>
 #include <QModelIndex>
+#include <QStyledItemDelegate>
 #include <QTreeView>
 #include <QPointer>
 
 #include "actioncollection.h"
 #include "bufferviewconfig.h"
 #include "networkmodel.h"
-
 #include "types.h"
 
 /*****************************************
@@ -52,10 +52,12 @@ public:
   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 &);
@@ -63,6 +65,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 *);
@@ -73,43 +76,38 @@ protected:
 private slots:
   void joinChannel(const QModelIndex &index);
   void toggleHeader(bool checked);
-  void actionTriggered(QAction *);
 
-  void on_collapse(const QModelIndex &index);
-  void on_expand(const QModelIndex &index);
+  void storeExpandedState(const QModelIndex &networkIdx);
+  void setExpandedState(const QModelIndex &networkIdx);
+
   void on_configChanged();
+  void on_layoutChanged();
 
 private:
-  enum ItemActiveState {
-    InactiveState = 0x01,
-    ActiveState = 0x02
+  QPointer<BufferViewConfig> _config;
+
+  enum ExpandedState {
+    WasExpanded = 0x01,
+    WasActive = 0x02
   };
+  QHash<NetworkId, short> _expandedState;
+
+};
+
+// ******************************
+//  BufferViewDelgate
+// ******************************
+
+class BufferViewDelegate : public QStyledItemDelegate {
+  Q_OBJECT
 
 public:
-  Q_DECLARE_FLAGS(ItemActiveStates, ItemActiveState)
-  QAction showChannelList;
+  BufferViewDelegate(QObject *parent = 0);
+  bool editorEvent(QEvent *event, QAbstractItemModel *model, const QStyleOptionViewItem &option, const QModelIndex &index);
 
-private:
-  QPointer<BufferViewConfig> _config;
-  ActionCollection _menuActions;
-  QModelIndex _menuIndex;
-  QHash<NetworkId, bool> _expandedState;
-
-  void storeExpandedState(NetworkId networkId, bool expanded);
-  void setupMenuActions();
-  bool checkRequirements(const QModelIndex &index,
-                          ItemActiveStates requiredActiveState = QFlags<ItemActiveState>(ActiveState | InactiveState));
-  void addItemToMenu(QAction *action, QMenu *menu, const QModelIndex &index,
-                     ItemActiveStates requiredActiveState = QFlags<ItemActiveState>(ActiveState | InactiveState));
-  void addItemToMenu(QAction *action, QMenu *menu, bool condition = true);
-  void addItemToMenu(QMenu *subMenu, QMenu *menu, const QModelIndex &index,
-                     ItemActiveStates requiredActiveState = QFlags<ItemActiveState>(ActiveState | InactiveState));
-  void addSeparatorToMenu(QMenu *menu, const QModelIndex &index,
-                          ItemActiveStates requiredActiveState = QFlags<ItemActiveState>(ActiveState | InactiveState));
-  QMenu *createHideEventsSubMenu(QMenu *menu, BufferId bufferId);
+protected:
+  virtual void customEvent(QEvent *event);
 };
-Q_DECLARE_OPERATORS_FOR_FLAGS(BufferView::ItemActiveStates)
-
 
 // ==============================
 //  BufferView Dock
@@ -119,8 +117,9 @@ class BufferViewDock : public QDockWidget {
 
 public:
   BufferViewDock(BufferViewConfig *config, QWidget *parent);
-  BufferViewDock(QWidget *parent);
 
+  int bufferViewId() const;
+  BufferViewConfig *config() const;
   inline BufferView *bufferView() const { return qobject_cast<BufferView *>(widget()); }
 
 public slots: