+bool BufferViewFilter::dropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent)
+{
+ if (!config() || !NetworkModel::mimeContainsBufferList(data))
+ return QSortFilterProxyModel::dropMimeData(data, action, row, column, parent);
+
+ NetworkId droppedNetworkId;
+ QModelIndex source_parent = mapToSource(parent);
+ if (sourceModel()->data(source_parent, NetworkModel::ItemTypeRole) == NetworkModel::NetworkItemType)
+ droppedNetworkId = sourceModel()->data(source_parent, NetworkModel::NetworkIdRole).value<NetworkId>();
+
+ QList<QPair<NetworkId, BufferId> > bufferList = NetworkModel::mimeDataToBufferList(data);
+ BufferId bufferId;
+ NetworkId networkId;
+ int pos;
+ for (int i = 0; i < bufferList.count(); i++) {
+ networkId = bufferList[i].first;
+ bufferId = bufferList[i].second;
+ if (droppedNetworkId == networkId) {
+ if (row < 0)
+ row = 0;
+
+ if (row < rowCount(parent)) {
+ QModelIndex source_child = mapToSource(index(row, 0, parent));
+ BufferId beforeBufferId = sourceModel()->data(source_child, NetworkModel::BufferIdRole).value<BufferId>();
+ pos = config()->bufferList().indexOf(beforeBufferId);
+ if (_sortOrder == Qt::DescendingOrder)
+ pos++;
+ }
+ else {
+ if (_sortOrder == Qt::AscendingOrder)
+ pos = config()->bufferList().count();
+ else
+ pos = 0;
+ }
+
+ if (config()->bufferList().contains(bufferId) && !config()->sortAlphabetically()) {
+ if (config()->bufferList().indexOf(bufferId) < pos)
+ pos--;
+ ClientBufferViewConfig *clientConf = qobject_cast<ClientBufferViewConfig *>(config());
+ if (!clientConf || !clientConf->isLocked())
+ config()->requestMoveBuffer(bufferId, pos);
+ }
+ else {
+ config()->requestAddBuffer(bufferId, pos);
+ }
+ }
+ else {
+ addBuffer(bufferId);
+ }