From: m5 Date: Sun, 3 Aug 2014 00:03:14 +0000 (-0700) Subject: fix buffer sorting for hot buffer hotkey X-Git-Tag: 0.11.0~2^2 X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=commitdiff_plain;h=refs%2Fpull%2F83%2Fhead fix buffer sorting for hot buffer hotkey --- diff --git a/src/qtui/mainwin.cpp b/src/qtui/mainwin.cpp index 2a1ce6f4..645ce366 100644 --- a/src/qtui/mainwin.cpp +++ b/src/qtui/mainwin.cpp @@ -1607,9 +1607,7 @@ void MainWin::on_jumpHotBuffer_triggered() if (!_bufferHotList->rowCount()) return; - QModelIndex topIndex = _bufferHotList->index(0, 0); - BufferId bufferId = _bufferHotList->data(topIndex, NetworkModel::BufferIdRole).value(); - Client::bufferModel()->switchToBuffer(bufferId); + Client::bufferModel()->switchToBuffer(_bufferHotList->hottestBuffer()); } @@ -1660,6 +1658,9 @@ void MainWin::on_actionDebugNetworkModel_triggered() void MainWin::on_actionDebugHotList_triggered() { + _bufferHotList->invalidate(); + _bufferHotList->sort(0, Qt::DescendingOrder); + QTreeView *view = new QTreeView; view->setAttribute(Qt::WA_DeleteOnClose); view->setModel(_bufferHotList); diff --git a/src/uisupport/bufferhotlistfilter.cpp b/src/uisupport/bufferhotlistfilter.cpp index b8ee379c..e40f9000 100644 --- a/src/uisupport/bufferhotlistfilter.cpp +++ b/src/uisupport/bufferhotlistfilter.cpp @@ -22,6 +22,7 @@ #include "networkmodel.h" + BufferHotListFilter::BufferHotListFilter(QAbstractItemModel *source, QObject *parent) : QSortFilterProxyModel(parent) { @@ -30,6 +31,13 @@ BufferHotListFilter::BufferHotListFilter(QAbstractItemModel *source, QObject *pa sort(0, Qt::DescendingOrder); // enable sorting... this is "usually" triggered by a enabling setSortingEnabled(true) on a view; } +BufferId BufferHotListFilter::hottestBuffer() +{ + invalidate(); + sort(0, Qt::DescendingOrder); + QModelIndex topIndex = index(0,0); + return data(topIndex, NetworkModel::BufferIdRole).value(); +} bool BufferHotListFilter::filterAcceptsRow(int source_row, const QModelIndex &source_parent) const { diff --git a/src/uisupport/bufferhotlistfilter.h b/src/uisupport/bufferhotlistfilter.h index 777ea5e7..3254d80e 100644 --- a/src/uisupport/bufferhotlistfilter.h +++ b/src/uisupport/bufferhotlistfilter.h @@ -22,6 +22,7 @@ #define BUFFERHOTLISTFILTER_H #include +#include "types.h" class BufferHotListFilter : public QSortFilterProxyModel { @@ -31,6 +32,7 @@ public: BufferHotListFilter(QAbstractItemModel *source, QObject *parent = 0); virtual inline int columnCount(const QModelIndex &) const { return 1; } + BufferId hottestBuffer(); // QVariant data(const QModelIndex &index, int role) const; protected: