Merging -r 859:865 branches/0.2/ with trunk
[quassel.git] / src / uisupport / bufferviewfilter.h
index 2a91733..128b3e8 100644 (file)
@@ -1,5 +1,5 @@
 /***************************************************************************
- *   Copyright (C) 2005-07 by the Quassel IRC Team                         *
+ *   Copyright (C) 2005-08 by the Quassel Project                          *
  *   devel@quassel-irc.org                                                 *
  *                                                                         *
  *   This program is free software; you can redistribute it and/or modify  *
  *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
  ***************************************************************************/
 
-#ifndef _BUFFERVIEWFILTER_H_
-#define _BUFFERVIEWFILTER_H_
+#ifndef BUFFERVIEWFILTER_H_
+#define BUFFERVIEWFILTER_H_
 
-#include <QFlags>
+#include <QColor>
 #include <QDropEvent>
-#include <QSortFilterProxyModel>
+#include <QFlags>
+#include <QPointer>
 #include <QSet>
-#include "buffer.h"
-#include "buffertreemodel.h"
+#include <QSortFilterProxyModel>
+
+#include "types.h"
+#include "bufferviewconfig.h"
 
 /*****************************************
  * Buffer View Filter
@@ -47,30 +50,51 @@ public:
   };
   Q_DECLARE_FLAGS(Modes, Mode);
 
-  BufferViewFilter(QAbstractItemModel *model, const Modes &mode, const QList<uint> &nets);
+  BufferViewFilter(QAbstractItemModel *model, BufferViewConfig *config = 0);
   
   virtual Qt::ItemFlags flags(const QModelIndex &index) const;
   virtual bool dropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent);
-  
+
+  QVariant data(const QModelIndex &index, int role) const;
+  QVariant foreground(const QModelIndex &index) const;
+
+  void setConfig(BufferViewConfig *config);
+  inline BufferViewConfig *config() const { return _config; }
+
 public slots:
-  void removeBuffer(const QModelIndex &);
-  void invalidateFilter_();
+  void checkPreviousCurrentForRemoval(const QModelIndex &current, const QModelIndex &previous);
+  void checkItemForRemoval(const QModelIndex &index) { checkItemsForRemoval(index, index); }
+  void checkItemsForRemoval(const QModelIndex &topLeft, const QModelIndex &bottomRight);
   
 protected:
   bool filterAcceptsRow(int source_row, const QModelIndex &source_parent) const;
-  bool lessThan(const QModelIndex &, const QModelIndex &) const;
-  
+  bool lessThan(const QModelIndex &source_left, const QModelIndex &source_right) const;
+  bool bufferLessThan(const QModelIndex &source_left, const QModelIndex &source_right) const;
+  bool networkLessThan(const QModelIndex &source_left, const QModelIndex &source_right) const;
+  virtual void customEvent(QEvent *event);
+
+signals:
+  void _dataChanged(const QModelIndex &source_topLeft, const QModelIndex &source_bottomRight);
+
+private slots:
+  void configInitialized();
+    
 private:
-  Modes mode;
-  QSet<uint> networks;
-  QSet<uint> buffers;
+  QPointer<BufferViewConfig> _config;
+  
+  QColor _FgColorInactiveActivity;
+  QColor _FgColorNoActivity;
+  QColor _FgColorHighlightActivity;
+  QColor _FgColorNewMessageActivity;
+  QColor _FgColorOtherActivity;
+  void loadColors();
 
   bool filterAcceptBuffer(const QModelIndex &) const;
   bool filterAcceptNetwork(const QModelIndex &) const;
-  void addBuffer(const uint &);
-
+  void addBuffer(const BufferId &) const;
 };
 Q_DECLARE_OPERATORS_FOR_FLAGS(BufferViewFilter::Modes)    
 
-#endif
+bool bufferIdLessThan(const BufferId &, const BufferId &);
 
+#endif // BUFFERVIEWFILTER_H_