Alt-A
authorMarcus Eggenberger <egs@quassel-irc.org>
Thu, 21 May 2009 20:00:32 +0000 (22:00 +0200)
committerMarcus Eggenberger <egs@quassel-irc.org>
Thu, 21 May 2009 20:02:38 +0000 (22:02 +0200)
src/client/CMakeLists.txt
src/qtui/mainwin.cpp
src/qtui/mainwin.h
src/uisupport/CMakeLists.txt
src/uisupport/bufferhotlistfilter.cpp [moved from src/client/bufferhotlistfilter.cpp with 83% similarity]
src/uisupport/bufferhotlistfilter.h [moved from src/client/bufferhotlistfilter.h with 97% similarity]
src/uisupport/flatproxymodel.cpp

index f9a60f2..f60f66c 100644 (file)
@@ -10,7 +10,6 @@ set(SOURCES
     abstractmessageprocessor.cpp
     abstractui.cpp
     backlogrequester.cpp
-    bufferhotlistfilter.cpp
     buffermodel.cpp
     buffersettings.cpp
     bufferviewoverlay.cpp
@@ -35,7 +34,6 @@ set(SOURCES
 set(MOC_HDRS
     abstractmessageprocessor.h
     abstractui.h
-    bufferhotlistfilter.h
     buffermodel.h
     bufferviewoverlay.h
     client.h
index 2c9e0f7..e0fff46 100644 (file)
@@ -37,6 +37,7 @@
 #include "awaylogview.h"
 #include "action.h"
 #include "actioncollection.h"
+#include "bufferhotlistfilter.h"
 #include "buffermodel.h"
 #include "bufferview.h"
 #include "bufferviewoverlay.h"
@@ -58,6 +59,7 @@
 #include "debugbufferviewoverlay.h"
 #include "debuglogwidget.h"
 #include "debugmessagemodelfilter.h"
+#include "flatproxymodel.h"
 #include "iconloader.h"
 #include "inputwidget.h"
 #include "inputline.h"
@@ -165,6 +167,7 @@ void MainWin::init() {
   setupToolBars();
   setupSystray();
   setupTitleSetter();
+  setupHotList();
 
 #ifndef HAVE_KDE
   QtUi::registerNotificationBackend(new TaskbarNotificationBackend(this));
@@ -293,8 +296,14 @@ void MainWin::setupActions() {
                                        this, SLOT(on_actionDebugBufferViewOverlay_triggered())));
   coll->addAction("DebugMessageModel", new Action(SmallIcon("tools-report-bug"), tr("Debug &MessageModel"), coll,
                                        this, SLOT(on_actionDebugMessageModel_triggered())));
+  coll->addAction("DebugHotList", new Action(SmallIcon("tools-report-bug"), tr("Debug &HotList"), coll,
+                                       this, SLOT(on_actionDebugHotList_triggered())));
   coll->addAction("DebugLog", new Action(SmallIcon("tools-report-bug"), tr("Debug &Log"), coll,
                                        this, SLOT(on_actionDebugLog_triggered())));
+
+  // Navigation
+  coll->addAction("JumpHotBuffer", new Action(tr("Jump to hot buffer"), coll,
+                                              this, SLOT(on_jumpHotBuffer_triggered()), QKeySequence(Qt::META + Qt::Key_A)));
 }
 
 void MainWin::setupMenus() {
@@ -353,6 +362,7 @@ void MainWin::setupMenus() {
   _helpDebugMenu->addAction(coll->action("DebugNetworkModel"));
   _helpDebugMenu->addAction(coll->action("DebugBufferViewOverlay"));
   _helpDebugMenu->addAction(coll->action("DebugMessageModel"));
+  _helpDebugMenu->addAction(coll->action("DebugHotList"));
   _helpDebugMenu->addAction(coll->action("DebugLog"));
 }
 
@@ -576,6 +586,12 @@ void MainWin::setupStatusBar() {
   connect(showStatusbar, SIGNAL(toggled(bool)), this, SLOT(saveStatusBarStatus(bool)));
 }
 
+void MainWin::setupHotList() {
+  FlatProxyModel *flatProxy = new FlatProxyModel(this);
+  flatProxy->setSourceModel(Client::bufferModel());
+  _bufferHotList = new BufferHotListFilter(flatProxy);
+}
+
 void MainWin::saveStatusBarStatus(bool enabled) {
   QtUiSettings uiSettings;
   uiSettings.setValue("ShowStatusBar", enabled);
@@ -1007,6 +1023,15 @@ void MainWin::connectOrDisconnectFromNet() {
   else net->requestDisconnect();
 }
 
+void MainWin::on_jumpHotBuffer_triggered() {
+  if(!_bufferHotList->rowCount())
+    return;
+
+  QModelIndex topIndex = _bufferHotList->index(0, 0);
+  BufferId bufferId = _bufferHotList->data(topIndex, NetworkModel::BufferIdRole).value<BufferId>();
+  Client::bufferModel()->switchToBuffer(bufferId);
+}
+
 void MainWin::on_actionDebugNetworkModel_triggered() {
   QTreeView *view = new QTreeView;
   view->setAttribute(Qt::WA_DeleteOnClose);
@@ -1019,6 +1044,13 @@ void MainWin::on_actionDebugNetworkModel_triggered() {
   view->show();
 }
 
+void MainWin::on_actionDebugHotList_triggered() {
+  QTreeView *view = new QTreeView;
+  view->setAttribute(Qt::WA_DeleteOnClose);
+  view->setModel(_bufferHotList);
+  view->show();
+}
+
 void MainWin::on_actionDebugBufferViewOverlay_triggered() {
   DebugBufferViewOverlay *overlay = new DebugBufferViewOverlay(0);
   overlay->setAttribute(Qt::WA_DeleteOnClose);
index 13b5466..d569094 100644 (file)
@@ -38,6 +38,7 @@
 #include "uisettings.h"
 
 class ActionCollection;
+class BufferHotListFilter;
 class BufferView;
 class BufferViewConfig;
 class ClientBufferViewConfig;
@@ -124,9 +125,11 @@ class MainWin
     void on_actionConfigureNetworks_triggered();
     void on_actionConfigureViews_triggered();
     void on_actionLockLayout_toggled(bool lock);
+    void on_jumpHotBuffer_triggered();
     void on_actionDebugNetworkModel_triggered();
     void on_actionDebugBufferViewOverlay_triggered();
     void on_actionDebugMessageModel_triggered();
+    void on_actionDebugHotList_triggered();
     void on_actionDebugLog_triggered();
 
     void clientNetworkCreated(NetworkId);
@@ -168,6 +171,7 @@ class MainWin
     void setupSystray();
     void setupTitleSetter();
     void setupToolBars();
+    void setupHotList();
 
     void updateIcon();
     void enableMenus();
@@ -195,6 +199,8 @@ class MainWin
     DWORD dwTickCount;
 #endif
 
+    BufferHotListFilter *_bufferHotList;
+
     friend class QtUi;
 };
 
index eccde9f..e31517f 100644 (file)
@@ -9,6 +9,7 @@ set(SOURCES
     abstractitemview.cpp
     action.cpp
     actioncollection.cpp
+    bufferhotlistfilter.cpp
     bufferview.cpp
     bufferviewfilter.cpp
     bufferviewoverlayfilter.cpp
@@ -37,6 +38,7 @@ set(MOC_HDRS
     abstractnotificationbackend.h
     action.h
     actioncollection.h
+    bufferhotlistfilter.h
     bufferview.h
     bufferviewfilter.h
     bufferviewoverlayfilter.h
similarity index 83%
rename from src/client/bufferhotlistfilter.cpp
rename to src/uisupport/bufferhotlistfilter.cpp
index e3f31da..1c26227 100644 (file)
@@ -44,30 +44,28 @@ bool BufferHotListFilter::filterAcceptsRow(int source_row, const QModelIndex &so
     NetworkModel::ItemType itemType = (NetworkModel::ItemType)sourceModel()->data(source_index, NetworkModel::ItemTypeRole).toInt();
     return itemType == NetworkModel::NetworkItemType;
   }
+
+  return true;
 }
 
 bool BufferHotListFilter::lessThan(const QModelIndex &source_left, const QModelIndex &source_right) const {
-  qDebug() << Q_FUNC_INFO;
-  qDebug() << source_left << source_right;
   int leftActivity = sourceModel()->data(source_left, NetworkModel::BufferActivityRole).toInt();
   int rightActivity = sourceModel()->data(source_right, NetworkModel::BufferActivityRole).toInt();
-  qDebug() << leftActivity << rightActivity;
   if(leftActivity != rightActivity)
     return leftActivity < rightActivity;
 
   MsgId leftUnreadMsgId = sourceModel()->data(source_left, NetworkModel::BufferFirstUnreadMsgIdRole).value<MsgId>();
   MsgId rightUnreadMsgId = sourceModel()->data(source_right, NetworkModel::BufferFirstUnreadMsgIdRole).value<MsgId>();
-  qDebug() << leftUnreadMsgId << rightUnreadMsgId;
   return leftUnreadMsgId > rightUnreadMsgId; // newer messages are treated to be "less"
 }
 
-QVariant BufferHotListFilter::data(const QModelIndex &index, int role) const {
-  QVariant d = QSortFilterProxyModel::data(index, role);
+// QVariant BufferHotListFilter::data(const QModelIndex &index, int role) const {
+//   QVariant d = QSortFilterProxyModel::data(index, role);
 
-  if(role == Qt::DisplayRole) {
-    int activity = QSortFilterProxyModel::data(index, NetworkModel::BufferActivityRole).toInt();    
-    MsgId unreadMsgId = QSortFilterProxyModel::data(index, NetworkModel::BufferFirstUnreadMsgIdRole).value<MsgId>();
-    return QString("%1 %2 %3").arg(d.toString()).arg(activity).arg(unreadMsgId.toInt());
-  }
-  return d;
-}
+//   if(role == Qt::DisplayRole) {
+//     int activity = QSortFilterProxyModel::data(index, NetworkModel::BufferActivityRole).toInt();    
+//     MsgId unreadMsgId = QSortFilterProxyModel::data(index, NetworkModel::BufferFirstUnreadMsgIdRole).value<MsgId>();
+//     return QString("%1 %2 %3").arg(d.toString()).arg(activity).arg(unreadMsgId.toInt());
+//   }
+//   return d;
+// }
similarity index 97%
rename from src/client/bufferhotlistfilter.h
rename to src/uisupport/bufferhotlistfilter.h
index a3577bd..72a7f3f 100644 (file)
@@ -30,7 +30,7 @@ public:
   BufferHotListFilter(QAbstractItemModel *source, QObject *parent = 0);
 
   virtual inline int columnCount(const QModelIndex &) const { return 1; }
-  QVariant data(const QModelIndex &index, int role) const;
+//   QVariant data(const QModelIndex &index, int role) const;
 
 protected:
   virtual bool filterAcceptsRow(int source_row, const QModelIndex &source_parent) const;
index ef19074..1d54380 100644 (file)
@@ -652,7 +652,7 @@ FlatProxyModel::SourceItem *FlatProxyModel::SourceItem::findChild(int proxyPos)
   int start = 0;
   int end = _childs.count() - 1;
   int pivot;
-  while(end - start != 1) {
+  while(end - start > 1) {
     pivot = (end + start) / 2;
     if(_childs[pivot]->pos() > proxyPos)
       end = pivot;