X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=blobdiff_plain;f=src%2Fuisupport%2Fbufferviewfilter.cpp;h=4ef0ec8c6ba284f23f9fc95ab336dce3915c6135;hp=a8b6fd25d4202ee940b851acad30e7a6b6c56c2f;hb=e9bb37281e0304db32d7dc8bfb8d49e9eabf7503;hpb=0d8b43cb8f3e1cedd57983c66f2b1108e1df010f diff --git a/src/uisupport/bufferviewfilter.cpp b/src/uisupport/bufferviewfilter.cpp index a8b6fd25..4ef0ec8c 100644 --- a/src/uisupport/bufferviewfilter.cpp +++ b/src/uisupport/bufferviewfilter.cpp @@ -28,6 +28,7 @@ #include "buffermodel.h" #include "buffersettings.h" #include "client.h" +#include "clientbufferviewconfig.h" #include "iconloader.h" #include "networkmodel.h" @@ -167,12 +168,16 @@ void BufferViewFilter::enableEditMode(bool enable) { Qt::ItemFlags BufferViewFilter::flags(const QModelIndex &index) const { QModelIndex source_index = mapToSource(index); Qt::ItemFlags flags = sourceModel()->flags(source_index); - if(_config) { + if(config()) { if(source_index == QModelIndex() || sourceModel()->data(source_index, NetworkModel::ItemTypeRole) == NetworkModel::NetworkItemType) { flags |= Qt::ItemIsDropEnabled; } else if(_editMode) { flags |= Qt::ItemIsUserCheckable | Qt::ItemIsTristate; } + ClientBufferViewConfig *clientConf = qobject_cast(config()); + if(clientConf && clientConf->isLocked()) { + flags &= ~(Qt::ItemIsDropEnabled | Qt::ItemIsDragEnabled); + } } return flags; } @@ -198,7 +203,7 @@ bool BufferViewFilter::dropMimeData(const QMimeData *data, Qt::DropAction action row = 0; if(row < rowCount(parent)) { - QModelIndex source_child = sourceModel()->index(row, 0, parent); + QModelIndex source_child = mapToSource(index(row, 0, parent)); BufferId beforeBufferId = sourceModel()->data(source_child, NetworkModel::BufferIdRole).value(); pos = config()->bufferList().indexOf(beforeBufferId); if(_sortOrder == Qt::DescendingOrder) @@ -262,7 +267,8 @@ bool BufferViewFilter::filterAcceptBuffer(const QModelIndex &source_bufferIndex) if(!config()->bufferList().contains(bufferId) && !_editMode) { // add the buffer if... - if(config()->isInitialized() && !config()->removedBuffers().contains(bufferId) // it hasn't been manually removed and either + if(config()->isInitialized() + && !config()->removedBuffers().contains(bufferId) // it hasn't been manually removed and either && ((config()->addNewBuffersAutomatically() && !config()->temporarilyRemovedBuffers().contains(bufferId)) // is totally unknown to us (a new buffer)... || (config()->temporarilyRemovedBuffers().contains(bufferId) && activityLevel > BufferInfo::OtherActivity))) { // or was just temporarily hidden and has a new message waiting for us. addBuffer(bufferId); @@ -313,10 +319,15 @@ bool BufferViewFilter::filterAcceptsRow(int source_row, const QModelIndex &sourc return false; } - if(!source_parent.isValid()) + NetworkModel::ItemType childType = (NetworkModel::ItemType)sourceModel()->data(child, NetworkModel::ItemTypeRole).toInt(); + switch(childType) { + case NetworkModel::NetworkItemType: return filterAcceptNetwork(child); - else + case NetworkModel::BufferItemType: return filterAcceptBuffer(child); + default: + return false; + } } bool BufferViewFilter::lessThan(const QModelIndex &source_left, const QModelIndex &source_right) const { @@ -352,10 +363,7 @@ bool BufferViewFilter::networkLessThan(const QModelIndex &source_left, const QMo NetworkId leftNetworkId = sourceModel()->data(source_left, NetworkModel::NetworkIdRole).value(); NetworkId rightNetworkId = sourceModel()->data(source_right, NetworkModel::NetworkIdRole).value(); - if(config() && config()->sortAlphabetically()) - return QSortFilterProxyModel::lessThan(source_left, source_right); - else - return leftNetworkId < rightNetworkId; + return QSortFilterProxyModel::lessThan(source_left, source_right); } QVariant BufferViewFilter::data(const QModelIndex &index, int role) const { @@ -377,13 +385,16 @@ QVariant BufferViewFilter::icon(const QModelIndex &index) const { return QVariant(); QModelIndex source_index = mapToSource(index); - if(sourceModel()->data(index, NetworkModel::BufferTypeRole).toInt() != BufferInfo::QueryBuffer) + if(sourceModel()->data(source_index, NetworkModel::ItemTypeRole).toInt() != NetworkModel::BufferItemType) + return QVariant(); + + if(sourceModel()->data(source_index, NetworkModel::BufferTypeRole).toInt() != BufferInfo::QueryBuffer) return QVariant(); - if(!sourceModel()->data(index, NetworkModel::ItemActiveRole).toBool()) + if(!sourceModel()->data(source_index, NetworkModel::ItemActiveRole).toBool()) return _userOfflineIcon; - if(sourceModel()->data(index, NetworkModel::UserAwayRole).toBool()) + if(sourceModel()->data(source_index, NetworkModel::UserAwayRole).toBool()) return _userAwayIcon; else return _userOnlineIcon;