X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=blobdiff_plain;f=src%2Fuisupport%2Fbufferviewfilter.cpp;h=a1744f6279b401aaa77a1d101a49c64e869765b4;hp=896bd116a021975566ce266ec86dec117b753ec0;hb=8db1c0298b0b9baf3af072a5ef368b2f2d14169d;hpb=cc5cdfa183fd1cf4b507d9791cb98acb74a4fcad diff --git a/src/uisupport/bufferviewfilter.cpp b/src/uisupport/bufferviewfilter.cpp index 896bd116..a1744f62 100644 --- a/src/uisupport/bufferviewfilter.cpp +++ b/src/uisupport/bufferviewfilter.cpp @@ -36,6 +36,8 @@ BufferViewFilter::BufferViewFilter(QAbstractItemModel *model, BufferViewConfig * { setConfig(config); setSourceModel(model); + connect(model, SIGNAL(rowsInserted(const QModelIndex &, int, int)), this, SLOT(source_rowsInserted(const QModelIndex &, int, int))); + // setSortCaseSensitivity(Qt::CaseInsensitive); setDynamicSortFilter(true); } @@ -88,6 +90,8 @@ bool BufferViewFilter::dropMimeData(const QMimeData *data, Qt::DropAction action networkId = bufferList[i].first; bufferId = bufferList[i].second; if(droppedNetworkId == networkId) { + if(row < 0) + row = 0; if(row < rowCount(parent)) { BufferId beforeBufferId = parent.child(row, 0).data(NetworkModel::BufferIdRole).value(); pos = config()->bufferList().indexOf(beforeBufferId); @@ -149,11 +153,12 @@ bool BufferViewFilter::filterAcceptBuffer(const QModelIndex &source_bufferIndex) if(_config->hideInactiveBuffers() && !source_bufferIndex.data(NetworkModel::ItemActiveRole).toBool()) return false; - if(_config->minimumActivity() > source_bufferIndex.data(NetworkModel::BufferActivityRole).toInt()) - return false; + // FIXME: this can result in bad loops :( + // if(_config->minimumActivity() > source_bufferIndex.data(NetworkModel::BufferActivityRole).toInt()) + // return false; - BufferId bufferId = sourceModel()->data(source_bufferIndex, NetworkModel::BufferIdRole).value(); - return _config->bufferList().contains(bufferId); + BufferId bufferId = sourceModel()->data(source_bufferIndex, NetworkModel::BufferIdRole).value(); + return _config->bufferList().contains(bufferId); } bool BufferViewFilter::filterAcceptNetwork(const QModelIndex &source_index) const { @@ -243,6 +248,17 @@ QVariant BufferViewFilter::foreground(const QModelIndex &index) const { } +void BufferViewFilter::source_rowsInserted(const QModelIndex &parent, int start, int end) { + if(parent.data(NetworkModel::ItemTypeRole) != NetworkModel::NetworkItemType) + return; + + if(!config() || !config()->addNewBuffersAutomatically()) + return; + + for(int row = start; row <= end; row++) { + addBuffer(parent.child(row, 0).data(NetworkModel::BufferIdRole).value()); + } +} // ****************************** // Helper