X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=blobdiff_plain;f=src%2Fclient%2Fbuffertreemodel.cpp;h=7117b07beaabfc71801999e52949c32599aad3c8;hp=633731b5f38d3931dc51385952b470424d388a35;hb=974b7adc16b798eda66e1fff1442b73b748f12f9;hpb=748f25bbae0e0ca8df58ec69df8d19c84ae77252 diff --git a/src/client/buffertreemodel.cpp b/src/client/buffertreemodel.cpp index 633731b5..7117b07b 100644 --- a/src/client/buffertreemodel.cpp +++ b/src/client/buffertreemodel.cpp @@ -21,6 +21,7 @@ #include // FIXME Dependency on QtGui! #include "buffertreemodel.h" +#include "selectionmodelsynchronizer.h" #include "bufferinfo.h" #include "client.h" @@ -117,9 +118,11 @@ Qt::ItemFlags NetworkTreeItem::flags() const { * BufferTreeModel *****************************************/ BufferTreeModel::BufferTreeModel(QObject *parent) - : TreeModel(BufferTreeModel::defaultHeader(), parent) + : TreeModel(BufferTreeModel::defaultHeader(), parent), + _selectionModelSynchronizer(new SelectionModelSynchronizer(this)) { - Client::signalProxy()->attachSignal(this, SIGNAL(fakeUserInput(BufferInfo, QString)), SIGNAL(sendInput(BufferInfo, QString))); + connect(_selectionModelSynchronizer, SIGNAL(setCurrentIndex(QModelIndex, QItemSelectionModel::SelectionFlags)), + this, SLOT(setCurrentIndex(QModelIndex, QItemSelectionModel::SelectionFlags))); } QListBufferTreeModel::defaultHeader() { @@ -229,12 +232,13 @@ 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*/) { - if(isBufferIndex(current)) { - currentBuffer = getBufferByIndex(current); +void BufferTreeModel::setCurrentIndex(const QModelIndex &index, QItemSelectionModel::SelectionFlags command) { + Q_UNUSED(command) + if(isBufferIndex(index)) { + currentBuffer = getBufferByIndex(index); bufferActivity(Buffer::NoActivity, currentBuffer); emit bufferSelected(currentBuffer); - emit selectionChanged(current); + emit selectionChanged(index); } } @@ -249,6 +253,6 @@ void BufferTreeModel::bufferActivity(Buffer::ActivityLevel level, Buffer *buffer void BufferTreeModel::selectBuffer(Buffer *buffer) { QModelIndex index = getOrCreateBufferItemIndex(buffer); - //emit selectionChanged(index); - changeCurrent(index, QModelIndex()); + // SUPER UGLY! + setCurrentIndex(index, 0); }