X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=blobdiff_plain;f=src%2Fuisupport%2Fnickview.cpp;h=0c4e853bcab080580c2d8e5ab99a22569b9f7bb8;hp=5db46c80a8d059c6aa20b00eb7255b31c0bb6000;hb=08aac67d4dc813ed541a81d06fb83d9c4fec5834;hpb=d6b056e936ec441258d291b7a8af7b83f9f53016 diff --git a/src/uisupport/nickview.cpp b/src/uisupport/nickview.cpp index 5db46c80..0c4e853b 100644 --- a/src/uisupport/nickview.cpp +++ b/src/uisupport/nickview.cpp @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2005-07 by the Quassel IRC Team * + * Copyright (C) 2005-08 by the Quassel Project * * devel@quassel-irc.org * * * * This program is free software; you can redistribute it and/or modify * @@ -18,39 +18,68 @@ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * ***************************************************************************/ -#include "nickview.h" -#include "nickmodel.h" - #include #include +#include -NickView::NickView(QWidget *parent) : QTreeView(parent) { - setGeometry(0, 0, 30, 30); - //setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum); +#include "nickview.h" +#include "nickmodel.h" +#include "networkmodel.h" +#include "types.h" +#include "client.h" + +NickView::NickView(QWidget *parent) + : QTreeView(parent) +{ setIndentation(10); - header()->hide(); - header()->hideSection(1); setAnimated(true); + header()->hide(); setSortingEnabled(true); sortByColumn(0, Qt::AscendingOrder); - filteredModel = new FilteredNickModel(this); - QTreeView::setModel(filteredModel); + setContextMenuPolicy(Qt::CustomContextMenu); + + connect(this, SIGNAL(customContextMenuRequested(const QPoint&)), + this, SLOT(showContextMenu(const QPoint&))); } NickView::~NickView() { +} +void NickView::init() { + if(!model()) + return; -} + for(int i = 1; i < model()->columnCount(); i++) + setColumnHidden(i, true); -void NickView::setModel(NickModel *model) { - filteredModel->setSourceModel(model); expandAll(); } +void NickView::setModel(QAbstractItemModel *model) { + QTreeView::setModel(model); + init(); +} + void NickView::rowsInserted(const QModelIndex &index, int start, int end) { QTreeView::rowsInserted(index, start, end); expandAll(); // FIXME We need to do this more intelligently. Maybe a pimped TreeView? } +void NickView::showContextMenu(const QPoint & pos ) { + QModelIndex index = indexAt(pos); + QString username = index.sibling(index.row(), 0).data().toString(); + BufferInfo bufferInfo = index.data(NetworkModel::BufferInfoRole).value(); + + QMenu nickContextMenu(this); + nickContextMenu.addAction(tr("context menu for %1").arg(username)); + nickContextMenu.addSeparator(); + + QAction *whoisAction = nickContextMenu.addAction(tr("WHOIS")); + QAction *result = nickContextMenu.exec(QCursor::pos()); + + if (result == whoisAction ) { + Client::userInput(bufferInfo, "/WHOIS "+username); + } +}