/***************************************************************************
- * Copyright (C) 2005-08 by the Quassel Project *
+ * Copyright (C) 2005-09 by the Quassel Project *
* devel@quassel-irc.org *
* *
* This program is free software; you can redistribute it and/or modify *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/
+#include "nickview.h"
+
#include <QHeaderView>
#include <QScrollBar>
#include <QDebug>
#include "buffermodel.h"
#include "client.h"
-#include "nickview.h"
#include "nickviewfilter.h"
#include "networkmodel.h"
#include "quasselui.h"
NickView::NickView(QWidget *parent)
: QTreeView(parent)
{
+ QAbstractItemDelegate *oldDelegate = itemDelegate();
+ NickViewDelegate *newDelegate = new NickViewDelegate(this);
+ setItemDelegate(newDelegate);
+ delete oldDelegate;
+
+
setIndentation(10);
setAnimated(true);
header()->hide();
sortByColumn(0, Qt::AscendingOrder);
setContextMenuPolicy(Qt::CustomContextMenu);
+ setSelectionMode(QAbstractItemView::ExtendedSelection);
connect(this, SIGNAL(customContextMenuRequested(const QPoint&)), SLOT(showContextMenu(const QPoint&)));
-#if defined Q_WS_QWS or defined Q_WS_X11
+#if defined Q_WS_QWS || defined Q_WS_X11
connect(this, SIGNAL(doubleClicked(QModelIndex)), SLOT(startQuery(QModelIndex)));
#else
// afaik this is better on Mac and Windows
if(index.data(NetworkModel::ItemTypeRole) != NetworkModel::IrcUserItemType)
return;
+ QModelIndexList indexList = selectedIndexes();
+ // make sure the item we clicked on is first
+ indexList.removeAll(index);
+ indexList.prepend(index);
+
QMenu contextMenu(this);
- Client::mainUi()->actionProvider()->addActions(&contextMenu, index);
+ Client::mainUi()->actionProvider()->addActions(&contextMenu, indexList);
contextMenu.exec(QCursor::pos());
}
}
event->accept();
}
+
+
+// ****************************************
+// NickViewDelgate
+// ****************************************
+NickViewDelegate::NickViewDelegate(QObject *parent)
+ : QStyledItemDelegate(parent)
+{
+}
+
+void NickViewDelegate::initStyleOption(QStyleOptionViewItem *option, const QModelIndex &index) const {
+ QStyledItemDelegate::initStyleOption(option, index);
+
+ if(!index.data(NetworkModel::ItemActiveRole).toBool())
+ option->palette.setColor(QPalette::Text, option->palette.color(QPalette::Dark));
+}