added a convenience method: Client::bufferModel()->switchToBuffer(bufferId)
authorMarcus Eggenberger <egs@quassel-irc.org>
Tue, 26 Aug 2008 11:37:54 +0000 (13:37 +0200)
committerMarcus Eggenberger <egs@quassel-irc.org>
Tue, 26 Aug 2008 11:37:54 +0000 (13:37 +0200)
src/client/buffermodel.cpp
src/client/buffermodel.h
src/qtui/chatmonitorview.cpp

index e124db6..faf6090 100644 (file)
 
 #include "buffermodel.h"
 
-#include "networkmodel.h"
-#include "mappedselectionmodel.h"
+#include "client.h"
 #include "global.h"
+#include "mappedselectionmodel.h"
+#include "networkmodel.h"
 
 #include <QAbstractItemView>
 
@@ -65,6 +66,11 @@ void BufferModel::setCurrentIndex(const QModelIndex &newCurrent) {
   _selectionModelSynchronizer.selectionModel()->select(newCurrent, QItemSelectionModel::ClearAndSelect | QItemSelectionModel::Rows);
 }
 
+void BufferModel::switchToBuffer(const BufferId &bufferId) {
+  QModelIndex source_index = Client::networkModel()->bufferIndex(bufferId);
+  setCurrentIndex(mapFromSource(source_index));
+}
+
 void BufferModel::debug_currentChanged(QModelIndex current, QModelIndex previous) {
   Q_UNUSED(previous);
   qDebug() << "Switched current Buffer: " << current << current.data().toString() << "Buffer:" << current.data(NetworkModel::BufferIdRole).value<BufferId>();
index 4794afe..7c00ea4 100644 (file)
@@ -45,8 +45,10 @@ public:
   void synchronizeSelectionModel(MappedSelectionModel *selectionModel);
   void synchronizeView(QAbstractItemView *view);
 
+public slots:
   inline QModelIndex currentIndex() { return standardSelectionModel()->currentIndex(); }
   void setCurrentIndex(const QModelIndex &newCurrent);
+  void switchToBuffer(const BufferId &bufferId);
 
 private slots:
   void debug_currentChanged(QModelIndex current, QModelIndex previous);
index 0c40998..45dbb41 100644 (file)
@@ -81,11 +81,7 @@ void ChatMonitorView::mouseDoubleClickEvent(QMouseEvent *event) {
   if(!bufferId.isValid())
     return;
 
-  QModelIndex bufferIdx = Client::networkModel()->bufferIndex(bufferId);
-  if(!bufferIdx.isValid())
-    return;
-
-  Client::bufferModel()->setCurrentIndex(Client::bufferModel()->mapFromSource(bufferIdx));
+  Client::bufferModel()->switchToBuffer(bufferId);
 }
 
 void ChatMonitorView::showFieldsChanged(bool checked) {