#include <QColor> // FIXME Dependency on QtGui!
#include "buffertreemodel.h"
+#include "selectionmodelsynchronizer.h"
#include "bufferinfo.h"
#include "client.h"
* 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)));
}
QList<QVariant >BufferTreeModel::defaultHeader() {
}
// 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);
}
}
void BufferTreeModel::selectBuffer(Buffer *buffer) {
QModelIndex index = getOrCreateBufferItemIndex(buffer);
- //emit selectionChanged(index);
- changeCurrent(index, QModelIndex());
+ // SUPER UGLY!
+ setCurrentIndex(index, 0);
}