X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=blobdiff_plain;f=src%2Fclient%2Fbuffertreemodel.cpp;h=741215f0915d4fa458a2d43f7003e31d580d851c;hp=43f624eaa97e76cca50301bdac86f86de52b32f3;hb=9a39bcb0e71d45140dc7f2390536cf4f7e13e9fe;hpb=64ff44560cc13569ab4968e3d974b0b7e9820607 diff --git a/src/client/buffertreemodel.cpp b/src/client/buffertreemodel.cpp index 43f624ea..741215f0 100644 --- a/src/client/buffertreemodel.cpp +++ b/src/client/buffertreemodel.cpp @@ -46,7 +46,7 @@ QString BufferTreeItem::text(int column) const { } } -QColor BufferTreeItem::foreground(int column) const { +QColor BufferTreeItem::foreground(int /*column*/) const { // for the time beeing we ignore the column :) if(activity & Buffer::Highlight) { return QColor(Qt::red); @@ -86,7 +86,8 @@ QVariant BufferTreeItem::data(int column, int role) const { * BufferTreeModel *****************************************/ BufferTreeModel::BufferTreeModel(QObject *parent) : TreeModel(BufferTreeModel::defaultHeader(), parent) { - connect(this, SIGNAL(fakeUserInput(BufferId, QString)), ClientProxy::instance(), SLOT(gsUserInput(BufferId, QString))); + connect(this, SIGNAL(fakeUserInput(BufferId, QString)), + ClientProxy::instance(), SLOT(gsUserInput(BufferId, QString))); } QListBufferTreeModel::defaultHeader() { @@ -181,7 +182,7 @@ QMimeData *BufferTreeModel::mimeData(const QModelIndexList &indexes) const { return mimeData; } -bool BufferTreeModel::dropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent) { +bool BufferTreeModel::dropMimeData(const QMimeData *data, Qt::DropAction /*action*/, int /*row*/, int /*column*/, const QModelIndex &parent) { if(!(data->hasFormat("application/Quassel/BufferItem/row") && data->hasFormat("application/Quassel/BufferItem/network") && data->hasFormat("application/Quassel/BufferItem/bufferId"))) @@ -190,24 +191,16 @@ bool BufferTreeModel::dropMimeData(const QMimeData *data, Qt::DropAction action, int sourcerow = data->data("application/Quassel/BufferItem/row").toInt(); QString network = QString::fromUtf8(data->data("application/Quassel/BufferItem/network")); - if(!networkItem.contains(network)) - return false; + Q_ASSERT(networkItem.contains(network)); + if(parent == QModelIndex()) // can't be a query... + return false; Buffer *sourceBuffer = static_cast(networkItem[network]->child(sourcerow))->buffer(); - - if(parent == QModelIndex()) { // droping into empty space - emit addBuffer(sourceBuffer->bufferId().uid(), network); - return true; - } - - if(!isBufferIndex(parent)) { // dropping at a network - emit addBuffer(sourceBuffer->bufferId().uid(), network); - return true; - } - - Buffer *targetBuffer = getBufferByIndex(parent); + + if(!(sourceBuffer->bufferType() & targetBuffer->bufferType() & Buffer::QueryBuffer)) // only queries can be merged + return false; if(sourceBuffer == targetBuffer) // we won't merge with ourself :) return false; @@ -234,12 +227,12 @@ void BufferTreeModel::bufferUpdated(Buffer *buffer) { } // This Slot indicates that the user has selected a different buffer in the gui -void BufferTreeModel::changeCurrent(const QModelIndex ¤t, const QModelIndex &previous) { +void BufferTreeModel::changeCurrent(const QModelIndex ¤t, const QModelIndex &/*previous*/) { if(isBufferIndex(current)) { currentBuffer = getBufferByIndex(current); bufferActivity(Buffer::NoActivity, currentBuffer); emit bufferSelected(currentBuffer); - emit updateSelection(current, QItemSelectionModel::ClearAndSelect); + emit selectionChanged(current); } } @@ -250,7 +243,6 @@ void BufferTreeModel::doubleClickReceived(const QModelIndex &clicked) { if(!buffer->isStatusBuffer()) emit fakeUserInput(buffer->bufferId(), QString("/join " + buffer->bufferName())); } - } void BufferTreeModel::bufferActivity(Buffer::ActivityLevel level, Buffer *buffer) { @@ -263,5 +255,5 @@ void BufferTreeModel::bufferActivity(Buffer::ActivityLevel level, Buffer *buffer void BufferTreeModel::selectBuffer(Buffer *buffer) { QModelIndex index = getOrCreateBufferItemIndex(buffer); - emit updateSelection(index, QItemSelectionModel::ClearAndSelect); + emit selectionChanged(index); }