X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=blobdiff_plain;f=src%2Fclient%2Fbuffertreemodel.cpp;fp=src%2Fclient%2Fbuffertreemodel.cpp;h=a881b5f3cf85ce8d5e33c9670af8c57f636e190f;hp=7117b07beaabfc71801999e52949c32599aad3c8;hb=cd122ca8e0d2c0ffc5397e0a813c75d791a7e6e3;hpb=fee1002dcb914ef9d47ceae97080b8c140e3b1ed diff --git a/src/client/buffertreemodel.cpp b/src/client/buffertreemodel.cpp index 7117b07b..a881b5f3 100644 --- a/src/client/buffertreemodel.cpp +++ b/src/client/buffertreemodel.cpp @@ -21,7 +21,9 @@ #include // FIXME Dependency on QtGui! #include "buffertreemodel.h" -#include "selectionmodelsynchronizer.h" + +#include "mappedselectionmodel.h" +#include #include "bufferinfo.h" #include "client.h" @@ -119,8 +121,15 @@ Qt::ItemFlags NetworkTreeItem::flags() const { *****************************************/ BufferTreeModel::BufferTreeModel(QObject *parent) : TreeModel(BufferTreeModel::defaultHeader(), parent), - _selectionModelSynchronizer(new SelectionModelSynchronizer(this)) + _selectionModelSynchronizer(new SelectionModelSynchronizer(this)), + _propertyMapper(new ModelPropertyMapper(this)) { + _propertyMapper->setModel(this); + delete _propertyMapper->selectionModel(); + MappedSelectionModel *mappedSelectionModel = new MappedSelectionModel(this); + _propertyMapper->setSelectionModel(mappedSelectionModel); + synchronizeSelectionModel(mappedSelectionModel); + connect(_selectionModelSynchronizer, SIGNAL(setCurrentIndex(QModelIndex, QItemSelectionModel::SelectionFlags)), this, SLOT(setCurrentIndex(QModelIndex, QItemSelectionModel::SelectionFlags))); } @@ -131,6 +140,22 @@ QListBufferTreeModel::defaultHeader() { return data; } +void BufferTreeModel::synchronizeSelectionModel(MappedSelectionModel *selectionModel) { + selectionModelSynchronizer()->addSelectionModel(selectionModel); +} + +void BufferTreeModel::synchronizeView(QAbstractItemView *view) { + MappedSelectionModel *mappedSelectionModel = new MappedSelectionModel(view->model()); + selectionModelSynchronizer()->addSelectionModel(mappedSelectionModel); + Q_ASSERT(mappedSelectionModel); + delete view->selectionModel(); + view->setSelectionModel(mappedSelectionModel); +} + +void BufferTreeModel::mapProperty(int column, int role, QObject *target, const QByteArray &property) { + propertyMapper()->addMapping(column, role, target, property); +} + bool BufferTreeModel::isBufferIndex(const QModelIndex &index) const { // not so purdy... return parent(index) != QModelIndex();