Throw out unneeded font setters, adapt to ItemViewSettings
[quassel.git] / src / uisupport / nickview.cpp
index 1a1c4bb..6d3f398 100644 (file)
@@ -20,6 +20,7 @@
 
 #include "nickview.h"
 
+#include <QApplication>
 #include <QHeaderView>
 #include <QScrollBar>
 #include <QDebug>
@@ -33,7 +34,6 @@
 #include "nickviewfilter.h"
 #include "networkmodel.h"
 #include "types.h"
-#include "uisettings.h"
 
 class ExpandAllEvent : public QEvent {
 public:
@@ -43,11 +43,6 @@ 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();
@@ -104,9 +99,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;
 }
@@ -162,28 +158,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<QColor>();
-  _FgAwayStatus = s.value("awayStatusFG", QVariant(QColor(Qt::gray))).value<QColor>();
-}
-
-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);
-}