From 4d8086fa41a49c3b2ba31484ce3c59416f5de294 Mon Sep 17 00:00:00 2001 From: Marcus Eggenberger Date: Mon, 10 Dec 2007 18:38:20 +0000 Subject: [PATCH] Fixed custom Views --- src/client/buffertreemodel.cpp | 1 - src/client/buffertreemodel.h | 1 - src/uisupport/bufferviewfilter.cpp | 26 ++++++++++++++++++-------- 3 files changed, 18 insertions(+), 10 deletions(-) diff --git a/src/client/buffertreemodel.cpp b/src/client/buffertreemodel.cpp index e433519c..d62d8045 100644 --- a/src/client/buffertreemodel.cpp +++ b/src/client/buffertreemodel.cpp @@ -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); } diff --git a/src/client/buffertreemodel.h b/src/client/buffertreemodel.h index 17330a43..05b390b4 100644 --- a/src/client/buffertreemodel.h +++ b/src/client/buffertreemodel.h @@ -117,7 +117,6 @@ public slots: signals: void bufferSelected(Buffer *); - void invalidateFilter(); void selectionChanged(const QModelIndex &); private: diff --git a/src/uisupport/bufferviewfilter.cpp b/src/uisupport/bufferviewfilter.cpp index 29694002..4f9f7675 100644 --- a/src/uisupport/bufferviewfilter.cpp +++ b/src/uisupport/bufferviewfilter.cpp @@ -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; } -- 2.20.1