X-Git-Url: https://git.quassel-irc.org/?a=blobdiff_plain;ds=sidebyside;f=gui%2Fnetworkview.cpp;fp=gui%2Fnetworkview.cpp;h=be08b3b55448f4987c0faa4704ea32333d52d0bf;hb=d6a96a47a3964b9c0b1ea2413601d70d0d327413;hp=0000000000000000000000000000000000000000;hpb=959e81d7ff35673870505331c012107cf67a5ab9;p=quassel.git diff --git a/gui/networkview.cpp b/gui/networkview.cpp new file mode 100644 index 00000000..be08b3b5 --- /dev/null +++ b/gui/networkview.cpp @@ -0,0 +1,91 @@ +/*************************************************************************** + * Copyright (C) 2005/06 by The Quassel Team * + * devel@quassel-irc.org * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ + +#include "global.h" +#include "networkview.h" + +NetworkViewWidget::NetworkViewWidget(QWidget *parent) : QWidget(parent) { + ui.setupUi(this); + +} + +QSize NetworkViewWidget::sizeHint() const { + return QSize(150,100); + +} + +/**************************************************************************/ + +NetworkView::NetworkView(QString net, QWidget *parent) : network(net), QDockWidget(parent) { + if(!net.isEmpty()) setWindowTitle(net); + else setWindowTitle(tr("All Buffers")); + setWidget(new NetworkViewWidget(this)); + tree = qobject_cast(widget())->tree(); + tree->setSortingEnabled(false); + connect(tree, SIGNAL(itemClicked(QTreeWidgetItem*, int)), this, SLOT(itemClicked(QTreeWidgetItem*))); +} + +void NetworkView::buffersUpdated(BufferHash buffers) { + tree->clear(); items.clear(); + if(network.isEmpty()) { + tree->setHeaderLabel(tr("Networks")); + foreach(QString net, buffers.keys()) { + QTreeWidgetItem *netItem = new QTreeWidgetItem(QStringList(net)); + foreach(QString buf, buffers[net].keys()) { + Buffer *b = buffers[net][buf]; + QStringList label; + if(buf.isEmpty()) label << tr("Status"); + else label << buf; + QTreeWidgetItem *item = new QTreeWidgetItem(netItem, label); + items[net][buf] = item; + VarMap d; + d["Network"] = net; + d["Buffer"] = buf; + item->setData(0, Qt::UserRole, d); + if(!b->isActive()) { + item->setForeground(0, QColor("grey")); + } + } + VarMap d; + d["Network"] = net; d["Buffer"] = ""; + netItem->setData(0, Qt::UserRole, d); + netItem->setFlags(netItem->flags() & ~Qt::ItemIsSelectable); + tree->addTopLevelItem(netItem); + netItem->setExpanded(true); + } + if(items[currentNetwork][currentBuffer]) items[currentNetwork][currentBuffer]->setSelected(true); + } +} + +void NetworkView::itemClicked(QTreeWidgetItem *item) { + if(network.isEmpty()) { + VarMap d = item->data(0, Qt::UserRole).toMap(); + QString net = d["Network"].toString(); QString buf = d["Buffer"].toString(); + if(!net.isEmpty()) { + emit bufferSelected(net, buf); + currentNetwork = net; currentBuffer = buf; + } + } +} + +void NetworkView::selectBuffer(QString net, QString buf) { + if(items[net][buf]) items[net][buf]->setSelected(true); + currentNetwork = net; currentBuffer = buf; +}