+
+QModelIndexList NickView::selectedIndexes() const
+{
+ QModelIndexList indexList = QTreeView::selectedIndexes();
+
+ // make sure the item we clicked on is first
+ if (indexList.contains(currentIndex())) {
+ indexList.removeAll(currentIndex());
+ indexList.prepend(currentIndex());
+ }
+
+ return indexList;
+}
+
+
+void NickView::unanimatedExpandAll()
+{
+ // since of Qt Version 4.8.0 the default expandAll will not properly work if
+ // animations are enabled. Therefore we perform an unanimated expand when a
+ // model is set or a toplevel node is inserted.
+ bool wasAnimated = isAnimated();
+ setAnimated(false);
+ expandAll();
+ setAnimated(wasAnimated);
+}
+
+
+void NickView::showContextMenu(const QPoint &pos)
+{
+ Q_UNUSED(pos);
+
+ QMenu contextMenu(this);
+ GraphicalUi::contextMenuActionProvider()->addActions(&contextMenu, selectedIndexes());
+ contextMenu.exec(QCursor::pos());
+}
+
+
+void NickView::startQuery(const QModelIndex &index)
+{
+ if (index.data(NetworkModel::ItemTypeRole) != NetworkModel::IrcUserItemType)
+ return;
+
+ IrcUser *ircUser = qobject_cast<IrcUser *>(index.data(NetworkModel::IrcUserRole).value<QObject *>());
+ NetworkId networkId = index.data(NetworkModel::NetworkIdRole).value<NetworkId>();
+ if (!ircUser || !networkId.isValid())
+ return;
+
+ Client::bufferModel()->switchToOrStartQuery(networkId, ircUser->nick());
+}