X-Git-Url: https://git.quassel-irc.org/?a=blobdiff_plain;f=src%2Fqtui%2Fbufferviewfilter.cpp;h=d30c3133d0c71ea1540e91e7a7f0d939d6140bcc;hb=ef0e65458bf4e1cbc01399fe0e025a5b4fd327dc;hp=8dca8fa283430287d8f79feab064fe72145d7b84;hpb=9fd4619e9aca7d53d7c5df156a0b25956a1bf682;p=quassel.git diff --git a/src/qtui/bufferviewfilter.cpp b/src/qtui/bufferviewfilter.cpp index 8dca8fa2..d30c3133 100644 --- a/src/qtui/bufferviewfilter.cpp +++ b/src/qtui/bufferviewfilter.cpp @@ -23,41 +23,22 @@ /***************************************** * The Filter for the Tree View *****************************************/ -BufferViewFilter::BufferViewFilter(QAbstractItemModel *model, const Modes &filtermode, const QStringList &nets) : QSortFilterProxyModel(model) { +BufferViewFilter::BufferViewFilter(QAbstractItemModel *model, const Modes &filtermode, const QStringList &nets) + : QSortFilterProxyModel(model), + mode(filtermode), + networks(nets) +{ setSourceModel(model); setSortRole(BufferTreeModel::BufferNameRole); setSortCaseSensitivity(Qt::CaseInsensitive); - - mode = filtermode; - networks = nets; connect(model, SIGNAL(invalidateFilter()), this, SLOT(invalidateMe())); - connect(model, SIGNAL(selectionChanged(const QModelIndex &)), - this, SLOT(select(const QModelIndex &))); - - connect(this, SIGNAL(currentChanged(const QModelIndex &, const QModelIndex &)), - model, SLOT(changeCurrent(const QModelIndex &, const QModelIndex &))); - - connect(this, SIGNAL(doubleClicked(const QModelIndex &)), - model, SLOT(doubleClickReceived(const QModelIndex &))); } void BufferViewFilter::invalidateMe() { invalidateFilter(); } -void BufferViewFilter::select(const QModelIndex &index) { - emit selectionChanged(mapFromSource(index)); -} - -void BufferViewFilter::changeCurrent(const QModelIndex ¤t, const QModelIndex &previous) { - emit currentChanged(mapToSource(current), mapToSource(previous)); -} - -void BufferViewFilter::doubleClickReceived(const QModelIndex &clicked) { - emit doubleClicked(mapToSource(clicked)); -} - void BufferViewFilter::dropEvent(QDropEvent *event) { const QMimeData *data = event->mimeData(); if(!(mode & FullCustom)) @@ -99,7 +80,7 @@ void BufferViewFilter::removeBuffer(const QModelIndex &index) { if(index.parent() == QModelIndex()) return; // only child elements can be deleted - uint bufferuid = index.data(BufferTreeModel::BufferInfoRole).toUInt(); + uint bufferuid = index.data(BufferTreeModel::BufferUidRole).toUInt(); if(customBuffers.contains(bufferuid)) { beginRemoveRows(index.parent(), index.row(), index.row()); customBuffers.removeAt(customBuffers.indexOf(bufferuid)); @@ -112,16 +93,16 @@ 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(); - if((mode & NoChannels) && bufferType == Buffer::ChannelBuffer) return false; - if((mode & NoQueries) && bufferType == Buffer::QueryBuffer) return false; - if((mode & NoServers) && bufferType == Buffer::ServerBuffer) return false; + if((mode & NoChannels) && bufferType == Buffer::ChannelType) return false; + if((mode & NoQueries) && bufferType == Buffer::QueryType) return false; + if((mode & NoServers) && bufferType == Buffer::StatusType) return false; bool isActive = source_bufferIndex.data(BufferTreeModel::BufferActiveRole).toBool(); if((mode & NoActive) && isActive) return false; if((mode & NoInactive) && !isActive) return false; if((mode & FullCustom)) { - uint bufferuid = source_bufferIndex.data(BufferTreeModel::BufferInfoRole).toUInt(); + uint bufferuid = source_bufferIndex.data(BufferTreeModel::BufferUidRole).toUInt(); if(!customBuffers.contains(bufferuid)) return false; } @@ -138,7 +119,7 @@ bool BufferViewFilter::filterAcceptNetwork(const QModelIndex &source_index) cons int childcount = sourceModel()->rowCount(source_index); for(int rowid = 0; rowid < childcount; rowid++) { QModelIndex child = sourceModel()->index(rowid, 0, source_index); - uint bufferuid = child.data(BufferTreeModel::BufferInfoRole).toUInt(); + uint bufferuid = child.data(BufferTreeModel::BufferUidRole).toUInt(); if(customBuffers.contains(bufferuid)) return true; }