X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=blobdiff_plain;f=src%2Fuisupport%2Fbufferviewfilter.cpp;h=a5c3d156af991fe79e2d3df74f1321771ba8e6a3;hp=e76a400a923f9af618b0ef0266bb472b4b54b8a9;hb=f6f6f3e368543f0a4dce1dae772f161d7e357064;hpb=feb8ff0d7dfaebbaeb56450fb33dfb6c4584ba69 diff --git a/src/uisupport/bufferviewfilter.cpp b/src/uisupport/bufferviewfilter.cpp index e76a400a..a5c3d156 100644 --- a/src/uisupport/bufferviewfilter.cpp +++ b/src/uisupport/bufferviewfilter.cpp @@ -1,11 +1,11 @@ /*************************************************************************** - * Copyright (C) 2005-07 by The Quassel Team * + * Copyright (C) 2005-07 by the Quassel IRC Team * * devel@quassel-irc.org * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * - * (at your option) any later version. * + * (at your option) version 3. * * * * This program is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * @@ -20,6 +20,8 @@ #include "bufferviewfilter.h" +#include "networkmodel.h" + /***************************************** * The Filter for the Tree View *****************************************/ @@ -30,10 +32,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_() { @@ -54,16 +60,18 @@ bool BufferViewFilter::dropMimeData(const QMimeData *data, Qt::DropAction action if(parent != QModelIndex()) return QSortFilterProxyModel::dropMimeData(data, action, row, column, parent); - if(!BufferTreeModel::mimeContainsBufferList(data)) + if(!NetworkModel::mimeContainsBufferList(data)) return false; - QList< QPair > bufferList = BufferTreeModel::mimeDataToBufferList(data); + QList< QPair > bufferList = NetworkModel::mimeDataToBufferList(data); uint netId, bufferId; 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; @@ -84,12 +92,17 @@ void BufferViewFilter::removeBuffer(const QModelIndex &index) { return; // only child elements can be deleted bool lastBuffer = (rowCount(index.parent()) == 1); - uint netId = index.data(BufferTreeModel::NetworkIdRole).toUInt(); - uint bufferuid = index.data(BufferTreeModel::BufferUidRole).toUInt(); + uint netId = index.data(NetworkModel::NetworkIdRole).toUInt(); + uint bufferuid = index.data(NetworkModel::BufferUidRole).toUInt(); + if(buffers.contains(bufferuid)) { buffers.remove(bufferuid); - if(lastBuffer) + + if(lastBuffer) { networks.remove(netId); + Q_ASSERT(!networks.contains(netId)); + } + invalidateFilter(); } @@ -97,7 +110,7 @@ void BufferViewFilter::removeBuffer(const QModelIndex &index) { bool BufferViewFilter::filterAcceptBuffer(const QModelIndex &source_bufferIndex) const { - Buffer::Type bufferType = (Buffer::Type) source_bufferIndex.data(BufferTreeModel::BufferTypeRole).toInt(); + Buffer::Type bufferType = (Buffer::Type) source_bufferIndex.data(NetworkModel::BufferTypeRole).toInt(); if((mode & NoChannels) && bufferType == Buffer::ChannelType) return false; @@ -106,23 +119,22 @@ bool BufferViewFilter::filterAcceptBuffer(const QModelIndex &source_bufferIndex) if((mode & NoServers) && bufferType == Buffer::StatusType) return false; -// bool isActive = source_bufferIndex.data(BufferTreeModel::BufferActiveRole).toBool(); +// bool isActive = source_bufferIndex.data(NetworkModel::BufferActiveRole).toBool(); // if((mode & NoActive) && isActive) // return false; // 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(NetworkModel::BufferUidRole).toUInt(); + return buffers.contains(bufferuid); + } return true; } bool BufferViewFilter::filterAcceptNetwork(const QModelIndex &source_index) const { - uint net = source_index.data(BufferTreeModel::NetworkIdRole).toUInt(); + uint net = source_index.data(NetworkModel::NetworkIdRole).toUInt(); return !((mode & (SomeNets | FullCustom)) && !networks.contains(net)); } @@ -141,8 +153,8 @@ bool BufferViewFilter::filterAcceptsRow(int source_row, const QModelIndex &sourc } bool BufferViewFilter::lessThan(const QModelIndex &left, const QModelIndex &right) const { - int lefttype = left.data(BufferTreeModel::BufferTypeRole).toInt(); - int righttype = right.data(BufferTreeModel::BufferTypeRole).toInt(); + int lefttype = left.data(NetworkModel::BufferTypeRole).toInt(); + int righttype = right.data(NetworkModel::BufferTypeRole).toInt(); if(lefttype != righttype) return lefttype < righttype;