X-Git-Url: https://git.quassel-irc.org/?a=blobdiff_plain;f=src%2Fclient%2Fnetworkmodel.cpp;h=962c9f8fcd058f199cadc77ea67b6ff7f0353619;hb=de6fd75928284a7c8788e00a36e5de7e64b9e168;hp=9202036064785307fe8ed1c8f5315548de7d16ba;hpb=7857ea0a520226e856af8d275550b76627f59c56;p=quassel.git diff --git a/src/client/networkmodel.cpp b/src/client/networkmodel.cpp index 92020360..962c9f8f 100644 --- a/src/client/networkmodel.cpp +++ b/src/client/networkmodel.cpp @@ -244,7 +244,6 @@ QVariant BufferItem::data(int column, int role) const { } bool BufferItem::setData(int column, const QVariant &value, int role) { - qDebug() << "BufferItem::setData(int column, const QVariant &value, int role):" << this << column << value << role; switch(role) { case NetworkModel::BufferActivityRole: setActivityLevel((BufferInfo::ActivityLevel)value.toInt()); @@ -304,7 +303,7 @@ QueryBufferItem::QueryBufferItem(const BufferInfo &bufferInfo, NetworkItem *pare : BufferItem(bufferInfo, parent), _ircUser(0) { - setFlags(flags() | Qt::ItemIsDropEnabled); + setFlags(flags() | Qt::ItemIsDropEnabled | Qt::ItemIsEditable); const Network *net = Client::network(bufferInfo.networkId()); if(!net) @@ -326,6 +325,27 @@ QVariant QueryBufferItem::data(int column, int role) const { } } +bool QueryBufferItem::setData(int column, const QVariant &value, int role) { + if(column != 0) + return BufferItem::setData(column, value, role); + + switch(role) { + case Qt::EditRole: + { + QString newName = value.toString(); + if(!newName.isEmpty()) { + Client::renameBuffer(bufferId(), newName); + return true; + } else { + return false; + } + } + break; + default: + return BufferItem::setData(column, value, role); + } +} + QString QueryBufferItem::toolTip(int column) const { // pretty much code duplication of IrcUserItem::toolTip() but inheritance won't solve this... Q_UNUSED(column); @@ -871,49 +891,6 @@ QMimeData *NetworkModel::mimeData(const QModelIndexList &indexes) const { return mimeData; } -bool NetworkModel::dropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent) { - Q_UNUSED(action) - Q_UNUSED(row) - Q_UNUSED(column) - - if(!mimeContainsBufferList(data)) - return false; - - // target must be a query - BufferInfo::Type targetType = (BufferInfo::Type)parent.data(NetworkModel::BufferTypeRole).toInt(); - if(targetType != BufferInfo::QueryBuffer) - return false; - - QList< QPair > bufferList = mimeDataToBufferList(data); - - // exactly one buffer has to be dropped - if(bufferList.count() != 1) - return false; - - NetworkId netId = bufferList.first().first; - BufferId bufferId = bufferList.first().second; - - // no self merges (would kill us) - if(bufferId == parent.data(BufferIdRole).value()) - return false; - - NetworkItem *netItem = findNetworkItem(netId); - Q_ASSERT(netItem); - - BufferItem *bufferItem = netItem->findBufferItem(bufferId); - Q_ASSERT(bufferItem); - - // source must be a query too - if(bufferItem->bufferType() != BufferInfo::QueryBuffer) - return false; - - // TODO: warn user about buffermerge! - qDebug() << "merging" << bufferId << parent.data(BufferIdRole).value(); - removeRow(parent.row(), parent.parent()); - - return true; -} - void NetworkModel::attachNetwork(Network *net) { NetworkItem *netItem = networkItem(net->networkId()); netItem->attachNetwork(net);