X-Git-Url: https://git.quassel-irc.org/?a=blobdiff_plain;f=src%2Fclient%2Fbuffertreemodel.cpp;h=a881b5f3cf85ce8d5e33c9670af8c57f636e190f;hb=f123125ae33f48de4514a36b1518dab4a781b551;hp=7117b07beaabfc71801999e52949c32599aad3c8;hpb=974b7adc16b798eda66e1fff1442b73b748f12f9;p=quassel.git 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();