Fixed custom Views
authorMarcus Eggenberger <egs@quassel-irc.org>
Mon, 10 Dec 2007 18:38:20 +0000 (18:38 +0000)
committerMarcus Eggenberger <egs@quassel-irc.org>
Mon, 10 Dec 2007 18:38:20 +0000 (18:38 +0000)
src/client/buffertreemodel.cpp
src/client/buffertreemodel.h
src/uisupport/bufferviewfilter.cpp

index e433519..d62d804 100644 (file)
@@ -306,7 +306,6 @@ bool BufferTreeModel::dropMimeData(const QMimeData *data, Qt::DropAction action,
 
 void BufferTreeModel::bufferUpdated(Buffer *buffer) {
   QModelIndex itemindex = getOrCreateBufferItemIndex(buffer);
-  emit invalidateFilter();
   emit dataChanged(itemindex, itemindex);
 }
 
index 17330a4..05b390b 100644 (file)
@@ -117,7 +117,6 @@ public slots:
 
 signals:
   void bufferSelected(Buffer *);
-  void invalidateFilter();
   void selectionChanged(const QModelIndex &);
 
 private:
index 2969400..4f9f767 100644 (file)
@@ -30,10 +30,14 @@ BufferViewFilter::BufferViewFilter(QAbstractItemModel *model, const Modes &filte
 {
   setSourceModel(model);
   setSortCaseSensitivity(Qt::CaseInsensitive);
+
+  // FIXME
+  // ok the following basically sucks. therfore it's commented out. Justice served.
+  // a better solution would use dataChanged()
   
   // I have this feeling that this resulted in a fuckup once... no clue though right now and invalidateFilter isn't a slot -.-
   //connect(model, SIGNAL(invalidateFilter()), this, SLOT(invalidate()));
-  connect(model, SIGNAL(invalidateFilter()), this, SLOT(invalidateFilter_()));
+  // connect(model, SIGNAL(invalidateFilter()), this, SLOT(invalidateFilter_()));
 }
 
 void BufferViewFilter::invalidateFilter_() {
@@ -63,7 +67,9 @@ bool BufferViewFilter::dropMimeData(const QMimeData *data, Qt::DropAction action
   for(int i = 0; i < bufferList.count(); i++) {
     netId = bufferList[i].first;
     bufferId = bufferList[i].second;
-    networks << netId;
+    if(!networks.contains(netId)) {
+      networks << netId;
+    }
     addBuffer(bufferId);
   }
   return true;
@@ -86,10 +92,15 @@ void BufferViewFilter::removeBuffer(const QModelIndex &index) {
   bool lastBuffer = (rowCount(index.parent()) == 1);
   uint netId = index.data(BufferTreeModel::NetworkIdRole).toUInt();
   uint bufferuid = index.data(BufferTreeModel::BufferUidRole).toUInt();
+
   if(buffers.contains(bufferuid)) {
     buffers.remove(bufferuid);
-    if(lastBuffer)
+    
+    if(lastBuffer) {
       networks.remove(netId);
+      Q_ASSERT(!networks.contains(netId));
+    }
+
     invalidateFilter();
   }
   
@@ -112,11 +123,10 @@ bool BufferViewFilter::filterAcceptBuffer(const QModelIndex &source_bufferIndex)
 //   if((mode & NoInactive) && !isActive)
 //     return false;
 
-//   if((mode & FullCustom)) {
-//     uint bufferuid = source_bufferIndex.data(BufferTreeModel::BufferUidRole).toUInt();
-//     if(!buffers.contains(bufferuid))
-//       return false;
-//   }
+  if((mode & FullCustom)) {
+    uint bufferuid = source_bufferIndex.data(BufferTreeModel::BufferUidRole).toUInt();
+    return buffers.contains(bufferuid);
+  }
     
   return true;
 }