X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=blobdiff_plain;f=src%2Fuisupport%2Fnickview.cpp;h=34fb554ec39bde4ac6915013e77af92acd4a77bc;hp=1a1c4bbaf9b966ee6732fb8dd11f487b109478cd;hb=79d9606c41f65c25df54758e064697208895d402;hpb=32a1f050b3292478f3b130c16ad66f22e6eb25c8 diff --git a/src/uisupport/nickview.cpp b/src/uisupport/nickview.cpp index 1a1c4bba..34fb554e 100644 --- a/src/uisupport/nickview.cpp +++ b/src/uisupport/nickview.cpp @@ -20,6 +20,7 @@ #include "nickview.h" +#include #include #include #include @@ -33,7 +34,6 @@ #include "nickviewfilter.h" #include "networkmodel.h" #include "types.h" -#include "uisettings.h" class ExpandAllEvent : public QEvent { public: @@ -43,13 +43,7 @@ public: NickView::NickView(QWidget *parent) : QTreeView(parent) { - QAbstractItemDelegate *oldDelegate = itemDelegate(); - NickViewDelegate *newDelegate = new NickViewDelegate(this); - setItemDelegate(newDelegate); - delete oldDelegate; - setIndentation(10); - setAnimated(true); header()->hide(); setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); setSortingEnabled(true); @@ -58,6 +52,10 @@ NickView::NickView(QWidget *parent) setContextMenuPolicy(Qt::CustomContextMenu); setSelectionMode(QAbstractItemView::ExtendedSelection); + // breaks with Qt 4.8 + if(QString("4.8.0") > qVersion()) // FIXME breaks with Qt versions >= 4.10! + setAnimated(true); + connect(this, SIGNAL(customContextMenuRequested(const QPoint&)), SLOT(showContextMenu(const QPoint&))); #if defined Q_WS_QWS || defined Q_WS_X11 @@ -104,9 +102,10 @@ QModelIndexList NickView::selectedIndexes() const { QModelIndexList indexList = QTreeView::selectedIndexes(); // make sure the item we clicked on is first - Q_ASSERT(indexList.contains(currentIndex())); - indexList.removeAll(currentIndex()); - indexList.prepend(currentIndex()); + if(indexList.contains(currentIndex())) { + indexList.removeAll(currentIndex()); + indexList.prepend(currentIndex()); + } return indexList; } @@ -128,11 +127,7 @@ void NickView::startQuery(const QModelIndex &index) { if(!ircUser || !networkId.isValid()) return; - BufferId bufId = Client::networkModel()->bufferId(networkId, ircUser->nick()); - if(bufId.isValid()) - Client::bufferModel()->switchToBuffer(bufId); - else - Client::userInput(index.data(NetworkModel::BufferInfoRole).value(), QString("/QUERY %1").arg(ircUser->nick())); + Client::bufferModel()->switchToOrStartQuery(networkId, ircUser->nick()); } void NickView::customEvent(QEvent *event) { @@ -148,6 +143,9 @@ void NickView::customEvent(QEvent *event) { if(event->type() != QEvent::User) return; + if(!model()) + return; + QModelIndex topLevelIdx; for(int i = 0; i < model()->rowCount(rootIndex()); i++) { topLevelIdx = model()->index(i, 0, rootIndex()); @@ -162,28 +160,3 @@ void NickView::customEvent(QEvent *event) { } event->accept(); } - - -// **************************************** -// NickViewDelgate -// **************************************** -NickViewDelegate::NickViewDelegate(QObject *parent) - : QStyledItemDelegate(parent) -{ - UiSettings s("QtUiStyle/Colors"); - _FgOnlineStatus = s.value("onlineStatusFG", QVariant(QColor(Qt::black))).value(); - _FgAwayStatus = s.value("awayStatusFG", QVariant(QColor(Qt::gray))).value(); -} - -void NickViewDelegate::initStyleOption(QStyleOptionViewItem *option, const QModelIndex &index) const { - QStyledItemDelegate::initStyleOption(option, index); - - if(!index.isValid()) - return; - - QColor fgColor = _FgOnlineStatus; - if(!index.data(NetworkModel::ItemActiveRole).toBool()) - fgColor = _FgAwayStatus; - - option->palette.setColor(QPalette::Text, fgColor); -}