From: Marcus Eggenberger Date: Mon, 23 Jun 2008 10:44:15 +0000 (+0200) Subject: Implemented a channel browser (BR #176). X-Git-Tag: 0.3.0~356 X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=commitdiff_plain;h=fe4b38e66592f11fdf4c4651863968983daecd2d Implemented a channel browser (BR #176). The Channel Browser is currently only via contextmenu of the networks accessible. Some minor fixes. Conflicts: src/client/client.cpp src/client/client.pri src/qtui/CMakeLists.txt src/qtui/mainwin.cpp src/qtui/qtui.pri --- diff --git a/src/client/CMakeLists.txt b/src/client/CMakeLists.txt index 39436cb6..6877a0b7 100644 --- a/src/client/CMakeLists.txt +++ b/src/client/CMakeLists.txt @@ -11,8 +11,10 @@ set(SOURCES buffersettings.cpp client.cpp clientbacklogmanager.cpp + clientirclisthelper.cpp clientsettings.cpp clientsyncer.cpp + irclistmodel.cpp mappedselectionmodel.cpp networkmodel.cpp selectionmodelsynchronizer.cpp @@ -23,7 +25,9 @@ set(MOC_HDRS buffermodel.h client.h clientbacklogmanager.h + clientirclisthelper.h clientsyncer.h + irclistmodel.h networkmodel.h mappedselectionmodel.h quasselui.h diff --git a/src/client/client.cpp b/src/client/client.cpp index 6a7faa9c..a6f7b4b6 100644 --- a/src/client/client.cpp +++ b/src/client/client.cpp @@ -26,6 +26,7 @@ #include "buffersyncer.h" #include "bufferviewmanager.h" #include "clientbacklogmanager.h" +#include "clientirclisthelper.h" #include "global.h" #include "identity.h" #include "ircchannel.h" @@ -72,10 +73,13 @@ Client::Client(QObject *parent) _backlogManager(new ClientBacklogManager(this)), _bufferViewManager(0), _messageModel(0), + _ircListHelper(new ClientIrcListHelper(this)), _connectedToCore(false), _syncedToCore(false) { _monitorBuffer = new Buffer(BufferInfo(), this); + _signalProxy->synchronize(_ircListHelper); + connect(_backlogManager, SIGNAL(backlog(BufferId, const QVariantList &)), this, SLOT(receiveBacklog(BufferId, const QVariantList &))); } diff --git a/src/client/client.h b/src/client/client.h index 4e7eb0e2..ad5740c1 100644 --- a/src/client/client.h +++ b/src/client/client.h @@ -41,6 +41,7 @@ class NetworkModel; class BufferModel; class BufferSyncer; class ClientBacklogManager; +class ClientIrcListHelper; class BufferViewManager; class IrcUser; class IrcChannel; @@ -97,6 +98,7 @@ public: static inline SignalProxy *signalProxy() { return instance()->_signalProxy; } static inline ClientBacklogManager *backlogManager() { return instance()->_backlogManager; } + static inline ClientIrcListHelper *ircListHelper() { return instance()->_ircListHelper; } static inline BufferViewManager *bufferViewManager() { return instance()->_bufferViewManager; } static AccountId currentCoreAccount(); @@ -215,6 +217,7 @@ private: BufferSyncer * _bufferSyncer; ClientBacklogManager *_backlogManager; BufferViewManager *_bufferViewManager; + ClientIrcListHelper *_ircListHelper; MessageModel *_messageModel; diff --git a/src/client/client.pri b/src/client/client.pri index dab9cf94..91b4d946 100644 --- a/src/client/client.pri +++ b/src/client/client.pri @@ -1,13 +1,12 @@ DEPMOD = common QT_MOD = core network gui -SRCS += buffer.cpp buffersettings.cpp clientbacklogmanager.cpp treemodel.cpp networkmodel.cpp buffermodel.cpp \ - client.cpp clientsettings.cpp clientsyncer.cpp mappedselectionmodel.cpp selectionmodelsynchronizer.cpp -HDRS += buffer.h buffersettings.h clientbacklogmanager.h treemodel.h networkmodel.h buffermodel.h \ - client.h clientsettings.h clientsyncer.h quasselui.h mappedselectionmodel.h selectionmodelsynchronizer.h +SRCS += buffer.cpp buffersettings.cpp clientbacklogmanager.cpp clientirclisthelper.cpp treemodel.cpp networkmodel.cpp buffermodel.cpp \ + client.cpp clientsettings.cpp clientsyncer.cpp irclistmodel.cpp mappedselectionmodel.cpp selectionmodelsynchronizer.cpp +HDRS += buffer.h buffersettings.h clientbacklogmanager.h clientirclisthelper.h treemodel.h networkmodel.h buffermodel.h \ + client.h clientsettings.h clientsyncer.h quasselui.h irclistmodel.h mappedselectionmodel.h selectionmodelsynchronizer.h sputdev { SRCS += messagefilter.cpp messagemodel.cpp HDRS += messagefilter.h messagemodel.h } - diff --git a/src/client/clientirclisthelper.cpp b/src/client/clientirclisthelper.cpp new file mode 100644 index 00000000..65775de2 --- /dev/null +++ b/src/client/clientirclisthelper.cpp @@ -0,0 +1,54 @@ +/*************************************************************************** + * Copyright (C) 2005-08 by the Quassel Project * + * 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) version 3. * + * * + * 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 "clientirclisthelper.h" + +#include + +#include "client.h" +#include "irclistmodel.h" + +QVariantList ClientIrcListHelper::requestChannelList(const NetworkId &netId, const QStringList &channelFilters) { + _netId = netId; + return IrcListHelper::requestChannelList(netId, channelFilters); +} + +void ClientIrcListHelper::receiveChannelList(const NetworkId &netId, const QStringList &channelFilters, const QVariantList &channels) { + QVariantList::const_iterator iter = channels.constBegin(); + QVariantList::const_iterator iterEnd = channels.constEnd(); + + QList channelList; + while(iter != iterEnd) { + QVariantList channelVar = iter->toList(); + ChannelDescription channelDescription(channelVar[0].toString(), channelVar[1].toUInt(), channelVar[2].toString()); + channelList << channelDescription; + iter++; + } + + emit channelListReceived(netId, channelFilters, channelList); +} + +void ClientIrcListHelper::reportFinishedList(const NetworkId &netId) { + if(_netId == netId) { + requestChannelList(netId, QStringList()); + emit finishedListReported(netId); + } +} + diff --git a/src/client/clientirclisthelper.h b/src/client/clientirclisthelper.h new file mode 100644 index 00000000..194f3ef0 --- /dev/null +++ b/src/client/clientirclisthelper.h @@ -0,0 +1,46 @@ +/*************************************************************************** + * Copyright (C) 2005-08 by the Quassel Project * + * 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) version 3. * + * * + * 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. * + ***************************************************************************/ + +#ifndef CLIENTIRCLISTHELPER_H +#define CLIENTIRCLISTHELPER_H + +#include "irclisthelper.h" + +class ClientIrcListHelper : public IrcListHelper { + Q_OBJECT + +public: + inline ClientIrcListHelper(QObject *object = 0) : IrcListHelper(object) {}; + + inline virtual const QMetaObject *syncMetaObject() const { return &IrcListHelper::staticMetaObject; } + +public slots: + virtual QVariantList requestChannelList(const NetworkId &netId, const QStringList &channelFilters); + virtual void receiveChannelList(const NetworkId &netId, const QStringList &channelFilters, const QVariantList &channels); + virtual void reportFinishedList(const NetworkId &netId); + +signals: + void channelListReceived(const NetworkId &netId, const QStringList &channelFilters, const QList &channelList); + +private: + NetworkId _netId; +}; + +#endif //CLIENTIRCLISTHELPER_H diff --git a/src/client/irclistmodel.cpp b/src/client/irclistmodel.cpp new file mode 100644 index 00000000..5da6804e --- /dev/null +++ b/src/client/irclistmodel.cpp @@ -0,0 +1,89 @@ +/*************************************************************************** + * Copyright (C) 2005-08 by the Quassel Project * + * 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) version 3. * + * * + * 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 "irclistmodel.h" + +#include + +IrcListModel::IrcListModel(QObject *parent) + : QAbstractItemModel(parent) +{ +} + +QVariant IrcListModel::data(const QModelIndex &index, int role) const { + if(!index.isValid() || index.row() >= rowCount() || index.column() >= columnCount() || role != Qt::DisplayRole) + return QVariant(); + + IrcListHelper::ChannelDescription channel = _channelList[index.row()]; + + switch(index.column()) { + case 0: + return channel.channelName; + case 1: + return channel.userCount; + case 2: + return channel.topic; + default: + return QVariant(); + } +} + +Qt::ItemFlags IrcListModel::flags(const QModelIndex &index) const { + if(!index.isValid()) { + return Qt::ItemIsDropEnabled; + } else { + return Qt::ItemIsSelectable | Qt::ItemIsEnabled; + } +} + + +QVariant IrcListModel::headerData(int section, Qt::Orientation orientation, int role) const { + QStringList header; + header << tr("Channel") + << tr("Users") + << tr("Topic"); + + if(orientation == Qt::Horizontal && role == Qt::DisplayRole) + return header[section]; + + return QVariant(); +} + +QModelIndex IrcListModel::index(int row, int column, const QModelIndex &parent) const { + Q_UNUSED(parent); + if(row >= rowCount() || column >= columnCount()) + return QModelIndex(); + + return createIndex(row, column); +} + +void IrcListModel::setChannelList(const QList &channelList) { + if(rowCount() > 0) { + beginRemoveRows(QModelIndex(), 0, _channelList.count() - 1); + _channelList.clear(); + endRemoveRows(); + } + + if(channelList.count() > 0) { + beginInsertRows(QModelIndex(), 0, channelList.count() - 1); + _channelList = channelList; + endInsertRows(); + } +} diff --git a/src/client/irclistmodel.h b/src/client/irclistmodel.h new file mode 100644 index 00000000..bb905f6f --- /dev/null +++ b/src/client/irclistmodel.h @@ -0,0 +1,53 @@ +/*************************************************************************** + * Copyright (C) 2005-08 by the Quassel Project * + * 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) version 3. * + * * + * 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. * + ***************************************************************************/ + +#ifndef IRCLISTMODEL_H +#define IRCLISTMODEL_H + +#include "irclisthelper.h" + +#include + +class IrcListModel : public QAbstractItemModel { + Q_OBJECT + +public: + IrcListModel(QObject *parent = 0); + + virtual QVariant data(const QModelIndex &index, int role) const; + virtual Qt::ItemFlags flags(const QModelIndex &index) const; + + QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const; + + QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const; + + inline QModelIndex parent(const QModelIndex &) const { return QModelIndex(); } + + inline int rowCount(const QModelIndex &parent = QModelIndex()) const { Q_UNUSED(parent) return _channelList.count(); } + inline int columnCount(const QModelIndex &parent = QModelIndex()) const { Q_UNUSED(parent) return 3; } + +public slots: + void setChannelList(const QList &channelList = QList()); + +private: + QList _channelList; +}; + +#endif //IRCLISTMODEL_H diff --git a/src/common/CMakeLists.txt b/src/common/CMakeLists.txt index 3b1f2ab1..f725398e 100644 --- a/src/common/CMakeLists.txt +++ b/src/common/CMakeLists.txt @@ -29,6 +29,7 @@ set(MOC_HDRS bufferviewmanager.h identity.h ircchannel.h + irclisthelper.h ircuser.h logger.h network.h diff --git a/src/common/backlogmanager.h b/src/common/backlogmanager.h index 6ff6b9cc..c060f9c2 100644 --- a/src/common/backlogmanager.h +++ b/src/common/backlogmanager.h @@ -32,7 +32,7 @@ public: public slots: virtual QVariantList requestBacklog(BufferId bufferId, int lastMsgs = -1, int offset = -1); - virtual void receiveBacklog(BufferId, int, int, QVariantList) {}; + inline virtual void receiveBacklog(BufferId, int, int, QVariantList) {}; signals: void backlogRequested(BufferId, int, int); diff --git a/src/common/bufferinfo.cpp b/src/common/bufferinfo.cpp index 19e62791..c45c8aa7 100644 --- a/src/common/bufferinfo.cpp +++ b/src/common/bufferinfo.cpp @@ -45,6 +45,10 @@ BufferInfo::BufferInfo(BufferId id, NetworkId networkid, Type type, uint gid, Q { } +BufferInfo BufferInfo::fakeStatusBuffer(NetworkId networkId) { + return BufferInfo(0, networkId, StatusBuffer); +} + QString BufferInfo::bufferName() const { if(isChannelName(_bufferName)) return _bufferName; diff --git a/src/common/bufferinfo.h b/src/common/bufferinfo.h index 4eec164e..9a7292c6 100644 --- a/src/common/bufferinfo.h +++ b/src/common/bufferinfo.h @@ -39,6 +39,8 @@ public: BufferInfo(); BufferInfo(BufferId id, NetworkId networkid, Type type, uint gid = 0, QString buf = QString()); + static BufferInfo fakeStatusBuffer(NetworkId networkId); + inline bool isValid() const { return _bufferId != 0; } inline BufferId bufferId() const { return _bufferId; } inline NetworkId networkId() const { return _netid; } diff --git a/src/common/common.pri b/src/common/common.pri index 0942f1a3..38153c83 100644 --- a/src/common/common.pri +++ b/src/common/common.pri @@ -5,5 +5,5 @@ SRCS += backlogmanager.cpp bufferinfo.cpp buffersyncer.cpp bufferviewconfig.cpp logger.cpp message.cpp settings.cpp signalproxy.cpp syncableobject.cpp \ util.cpp network.cpp ircuser.cpp ircchannel.cpp HDRS += backlogmanager.h bufferinfo.h buffersyncer.h bufferviewconfig.h bufferviewmanager.h global.h identity.h \ - logger.h message.h settings.h signalproxy.h syncableobject.h \ + irclisthelper.h logger.h message.h settings.h signalproxy.h syncableobject.h \ util.h network.h ircuser.h ircchannel.h types.h diff --git a/src/common/irclisthelper.h b/src/common/irclisthelper.h new file mode 100644 index 00000000..8bf7f94e --- /dev/null +++ b/src/common/irclisthelper.h @@ -0,0 +1,58 @@ +/*************************************************************************** + * Copyright (C) 2005-08 by the Quassel Project * + * 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) version 3. * + * * + * 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. * + ***************************************************************************/ + +#ifndef IRCLISTHELPER_H +#define IRCLISTHELPER_H + +#include "syncableobject.h" +#include "types.h" + +/* + * This is a little helper to display channel lists of a network. + * The whole process is done in 3 steps: + * 1.) the client requests to issue a LIST command with requestChannelList() + * 2.) RPL_LIST fills on the core the list of available channels + * when RPL_LISTEND is received the clients will be informed, that they can pull the data + * 3.) client pulls the data by calling requestChannelList again. receiving the data in receiveChannelList + */ +class IrcListHelper : public SyncableObject { + Q_OBJECT + +public: + inline IrcListHelper(QObject *parent = 0) : SyncableObject(parent) {}; + + struct ChannelDescription { + QString channelName; + quint32 userCount; + QString topic; + ChannelDescription(const QString &channelName_, quint32 userCount_, const QString &topic_) : channelName(channelName_), userCount(userCount_), topic(topic_) {}; + }; + +public slots: + inline virtual QVariantList requestChannelList(const NetworkId &netId, const QStringList &channelFilters) { emit channelListRequested(netId, channelFilters); return QVariantList(); } + inline virtual void receiveChannelList(const NetworkId &, const QStringList &, const QVariantList &) {}; + inline virtual void reportFinishedList(const NetworkId &netId) { emit finishedListReported(netId); } + +signals: + void channelListRequested(const NetworkId &netId, const QStringList &channelFilters); + void finishedListReported(const NetworkId &netId); +}; + +#endif //IRCLISTHELPER_H diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt index 2219f0a7..0046153b 100644 --- a/src/core/CMakeLists.txt +++ b/src/core/CMakeLists.txt @@ -13,6 +13,7 @@ set(SOURCES corebacklogmanager.cpp corebufferviewconfig.cpp corebufferviewmanager.cpp + coreirclisthelper.cpp corenetwork.cpp coresession.cpp coresettings.cpp @@ -32,6 +33,7 @@ set(MOC_HDRS corebacklogmanager.h corebufferviewconfig.h corebufferviewmanager.h + coreirclisthelper.h corenetwork.h coresession.h ctcphandler.h diff --git a/src/core/basichandler.cpp b/src/core/basichandler.cpp index a00966d2..adf9fa47 100644 --- a/src/core/basichandler.cpp +++ b/src/core/basichandler.cpp @@ -22,7 +22,6 @@ #include #include "util.h" -#include "networkconnection.h" BasicHandler::BasicHandler(NetworkConnection *parent) : QObject(parent), @@ -158,15 +157,6 @@ QList BasicHandler::userEncode(const QString &userNick, const QStrin // ==================== // protected: // ==================== - -Network *BasicHandler::network() const { - return networkConnection()->network(); -} - -NetworkConnection *BasicHandler::networkConnection() const { - return _networkConnection; -} - BufferInfo::Type BasicHandler::typeByTarget(const QString &target) const { if(target.isEmpty()) return BufferInfo::StatusBuffer; diff --git a/src/core/basichandler.h b/src/core/basichandler.h index f641a30b..ebac6dd3 100644 --- a/src/core/basichandler.h +++ b/src/core/basichandler.h @@ -29,8 +29,7 @@ #include "message.h" -class NetworkConnection; -class Network; +#include "networkconnection.h" class BasicHandler : public QObject { Q_OBJECT @@ -71,8 +70,9 @@ protected: QGenericArgument val7 = QGenericArgument(), QGenericArgument val8 = QGenericArgument()); - Network * network() const; - NetworkConnection * networkConnection() const; + inline Network *network() const { return _networkConnection->network(); } + inline NetworkConnection *networkConnection() const { return _networkConnection; } + BufferInfo::Type typeByTarget(const QString &target) const; private: diff --git a/src/core/core.pri b/src/core/core.pri index 8c0f01a6..1d9650f4 100644 --- a/src/core/core.pri +++ b/src/core/core.pri @@ -1,9 +1,9 @@ DEPMOD = common QT_MOD = core network sql script -SRCS = core.cpp corebacklogmanager.cpp corebufferviewconfig.cpp corebufferviewmanager.cpp corenetwork.cpp coresession.cpp coresettings.cpp networkconnection.cpp sqlitestorage.cpp abstractsqlstorage.cpp storage.cpp basichandler.cpp \ +SRCS = core.cpp corebacklogmanager.cpp corebufferviewconfig.cpp corebufferviewmanager.cpp coreirclisthelper.cpp corenetwork.cpp coresession.cpp coresettings.cpp networkconnection.cpp sqlitestorage.cpp abstractsqlstorage.cpp storage.cpp basichandler.cpp \ ircserverhandler.cpp userinputhandler.cpp ctcphandler.cpp coreusersettings.cpp sessionthread.cpp -HDRS = core.h corebacklogmanager.h corebufferviewconfig.h corebufferviewmanager.h corenetwork.h coresession.h coresettings.h networkconnection.h sqlitestorage.h abstractsqlstorage.h storage.h basichandler.h \ +HDRS = core.h corebacklogmanager.h corebufferviewconfig.h corebufferviewmanager.h coreirclisthelper.h corenetwork.h coresession.h coresettings.h networkconnection.h sqlitestorage.h abstractsqlstorage.h storage.h basichandler.h \ ircserverhandler.h userinputhandler.h ctcphandler.h coreusersettings.h sessionthread.h contains(QT_CONFIG, openssl) | contains(QT_CONFIG, openssl-linked) { diff --git a/src/core/corebacklogmanager.h b/src/core/corebacklogmanager.h index 0272bbbe..7d7e1d89 100644 --- a/src/core/corebacklogmanager.h +++ b/src/core/corebacklogmanager.h @@ -31,7 +31,7 @@ class CoreBacklogManager : public BacklogManager { public: CoreBacklogManager(CoreSession *coreSession = 0); - virtual const QMetaObject *syncMetaObject() const { return &BacklogManager::staticMetaObject; } + inline virtual const QMetaObject *syncMetaObject() const { return &BacklogManager::staticMetaObject; } CoreSession *coreSession() { return _coreSession; } diff --git a/src/core/corebufferviewconfig.h b/src/core/corebufferviewconfig.h index bb7eb95f..80c2ae30 100644 --- a/src/core/corebufferviewconfig.h +++ b/src/core/corebufferviewconfig.h @@ -30,7 +30,7 @@ public: CoreBufferViewConfig(int bufferViewId, QObject *parent = 0); CoreBufferViewConfig(int bufferViewId, const QVariantMap &properties, QObject *parent = 0); - virtual const QMetaObject *syncMetaObject() const { return &BufferViewConfig::staticMetaObject; } + inline virtual const QMetaObject *syncMetaObject() const { return &BufferViewConfig::staticMetaObject; } public slots: virtual inline void requestSetBufferViewName(const QString &bufferViewName) { setBufferViewName(bufferViewName); } diff --git a/src/core/corebufferviewmanager.h b/src/core/corebufferviewmanager.h index 072b4558..c2510021 100644 --- a/src/core/corebufferviewmanager.h +++ b/src/core/corebufferviewmanager.h @@ -32,7 +32,7 @@ public: CoreBufferViewManager(SignalProxy *proxy, CoreSession *parent); ~CoreBufferViewManager(); - virtual const QMetaObject *syncMetaObject() const { return &BufferViewManager::staticMetaObject; } + inline virtual const QMetaObject *syncMetaObject() const { return &BufferViewManager::staticMetaObject; } public slots: virtual void requestCreateBufferView(const QVariantMap &properties); diff --git a/src/core/coreirclisthelper.cpp b/src/core/coreirclisthelper.cpp new file mode 100644 index 00000000..d8a317cd --- /dev/null +++ b/src/core/coreirclisthelper.cpp @@ -0,0 +1,80 @@ +/*************************************************************************** + * Copyright (C) 2005-08 by the Quassel Project * + * 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) version 3. * + * * + * 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 "coreirclisthelper.h" + +#include "networkconnection.h" +#include "userinputhandler.h" + + +QVariantList CoreIrcListHelper::requestChannelList(const NetworkId &netId, const QStringList &channelFilters) { + if(_finishedChannelLists.contains(netId)) + return _finishedChannelLists.take(netId); + + if(_channelLists.contains(netId)) { + _queuedQuery[netId] = channelFilters.join(","); + } else { + _channelLists[netId] = QList(); + + NetworkConnection *networkConnection = coreSession()->networkConnection(netId); + if(networkConnection) + networkConnection->userInputHandler()->handleList(BufferInfo(), channelFilters.join(",")); + } + + return QVariantList(); +} + +bool CoreIrcListHelper::addChannel(const NetworkId &netId, const QString &channelName, quint32 userCount, const QString &topic) { + if(!_channelLists.contains(netId)) + return false; + + _channelLists[netId] << ChannelDescription(channelName, userCount, topic); + return true; +} + +bool CoreIrcListHelper::endOfChannelList(const NetworkId &netId) { + if(_queuedQuery.contains(netId)) { + // we're no longer interessted in the current data. drop it and issue a new request. + _channelLists[netId] = QList(); + + NetworkConnection *networkConnection = coreSession()->networkConnection(netId); + if(networkConnection) + networkConnection->userInputHandler()->handleList(BufferInfo(), _queuedQuery[netId]); + + _queuedQuery.remove(netId); + return true; + } else if(_channelLists.contains(netId)) { + QVariantList channelList; + foreach(ChannelDescription channel, _channelLists[netId]) { + QVariantList channelVariant; + channelVariant << channel.channelName + << channel.userCount + << channel.topic; + channelList << qVariantFromValue(channelVariant); + } + _finishedChannelLists[netId] = channelList; + _channelLists.remove(netId); + reportFinishedList(netId); + return true; + } else { + return false; + } +} + diff --git a/src/core/coreirclisthelper.h b/src/core/coreirclisthelper.h new file mode 100644 index 00000000..84303ad6 --- /dev/null +++ b/src/core/coreirclisthelper.h @@ -0,0 +1,51 @@ +/*************************************************************************** + * Copyright (C) 2005-08 by the Quassel Project * + * 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) version 3. * + * * + * 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. * + ***************************************************************************/ + +#ifndef COREIRCLISTHELPER_H +#define COREIRCLISTHELPER_H + +#include "irclisthelper.h" + +#include "coresession.h" + +class CoreIrcListHelper : public IrcListHelper { + Q_OBJECT + +public: + inline CoreIrcListHelper(CoreSession *coreSession) : IrcListHelper(coreSession), _coreSession(coreSession) {}; + + inline virtual const QMetaObject *syncMetaObject() const { return &IrcListHelper::staticMetaObject; } + + inline CoreSession *coreSession() const { return _coreSession; } + +public slots: + virtual QVariantList requestChannelList(const NetworkId &netId, const QStringList &channelFilters); + bool addChannel(const NetworkId &netId, const QString &channelName, quint32 userCount, const QString &topic); + bool endOfChannelList(const NetworkId &netId); + +private: + CoreSession *_coreSession; + + QHash _queuedQuery; + QHash > _channelLists; + QHash _finishedChannelLists; +}; + +#endif //COREIRCLISTHELPER_H diff --git a/src/core/corenetwork.h b/src/core/corenetwork.h index 2d913179..4c956cf7 100644 --- a/src/core/corenetwork.h +++ b/src/core/corenetwork.h @@ -31,7 +31,7 @@ class CoreNetwork : public Network { public: CoreNetwork(const NetworkId &networkid, CoreSession *session); - virtual const QMetaObject *syncMetaObject() const { return &Network::staticMetaObject; } + inline virtual const QMetaObject *syncMetaObject() const { return &Network::staticMetaObject; } inline CoreSession *coreSession() const { return _coreSession; } diff --git a/src/core/coresession.cpp b/src/core/coresession.cpp index f868379b..f394b5e7 100644 --- a/src/core/coresession.cpp +++ b/src/core/coresession.cpp @@ -29,6 +29,7 @@ #include "buffersyncer.h" #include "corebacklogmanager.h" #include "corebufferviewmanager.h" +#include "coreirclisthelper.h" #include "storage.h" #include "corenetwork.h" @@ -46,6 +47,7 @@ CoreSession::CoreSession(UserId uid, bool restoreState, QObject *parent) _bufferSyncer(new BufferSyncer(this)), _backlogManager(new CoreBacklogManager(this)), _bufferViewManager(new CoreBufferViewManager(_signalProxy, this)), + _ircListHelper(new CoreIrcListHelper(this)), scriptEngine(new QScriptEngine(this)) { @@ -87,7 +89,10 @@ CoreSession::CoreSession(UserId uid, bool restoreState, QObject *parent) // init BacklogManager; p->synchronize(_backlogManager); - + + // init IrcListHelper; + p->synchronize(ircListHelper()); + // Restore session state if(restoreState) restoreSessionState(); diff --git a/src/core/coresession.h b/src/core/coresession.h index 913f630b..737e15c3 100644 --- a/src/core/coresession.h +++ b/src/core/coresession.h @@ -29,6 +29,7 @@ class BufferSyncer; class CoreBacklogManager; class CoreBufferViewManager; +class CoreIrcListHelper; class Identity; class NetworkConnection; class CoreNetwork; @@ -54,6 +55,8 @@ public: SignalProxy *signalProxy() const; + inline CoreIrcListHelper *ircListHelper() const { return _ircListHelper; } + void attachNetworkConnection(NetworkConnection *conn); //! Return necessary data for restoring the session after restarting the core @@ -185,6 +188,7 @@ private: BufferSyncer *_bufferSyncer; CoreBacklogManager *_backlogManager; CoreBufferViewManager *_bufferViewManager; + CoreIrcListHelper *_ircListHelper; QScriptEngine *scriptEngine; diff --git a/src/core/ircserverhandler.cpp b/src/core/ircserverhandler.cpp index 3d7596df..9bdb3c67 100644 --- a/src/core/ircserverhandler.cpp +++ b/src/core/ircserverhandler.cpp @@ -22,6 +22,7 @@ #include "util.h" #include "coresession.h" +#include "coreirclisthelper.h" #include "networkconnection.h" #include "network.h" #include "identity.h" @@ -144,7 +145,7 @@ void IrcServerHandler::defaultHandler(QString cmd, const QString &prefix, const break; } // Ignore these commands. - case 366: case 376: + case 321: case 366: case 376: break; // Everything else will be marked in red, so we can add them somewhere. @@ -722,6 +723,37 @@ void IrcServerHandler::handle320(const QString &prefix, const QList emit displayMsg(Message::Server, BufferInfo::StatusBuffer, "", tr("[Whois] %1").arg(serverDecode(params).join(" "))); } +/* RPL_LIST - " <# visible> :" */ +void IrcServerHandler::handle322(const QString &prefix, const QList ¶ms) { + Q_UNUSED(prefix) + QString channelName; + quint32 userCount = 0; + QString topic; + + int paramCount = params.count(); + switch(paramCount) { + case 3: + topic = serverDecode(params[2]); + case 2: + userCount = serverDecode(params[1]).toUInt(); + case 1: + channelName = serverDecode(params[0]); + default: + break; + } + if(!networkConnection()->coreSession()->ircListHelper()->addChannel(network()->networkId(), channelName, userCount, topic)) + emit displayMsg(Message::Server, BufferInfo::StatusBuffer, "", tr("Channel %1 has %2 users. Topic is: %3").arg(channelName).arg(userCount).arg(topic)); +} + +/* RPL_LISTEND ":End of LIST" */ +void IrcServerHandler::handle323(const QString &prefix, const QList ¶ms) { + Q_UNUSED(prefix) + Q_UNUSED(params) + + if(!networkConnection()->coreSession()->ircListHelper()->endOfChannelList(network()->networkId())) + emit displayMsg(Message::Server, BufferInfo::StatusBuffer, "", tr("End of channel list")); +} + /* RPL_CHANNELMODEIS - " " */ void IrcServerHandler::handle324(const QString &prefix, const QList ¶ms) { Q_UNUSED(prefix); diff --git a/src/core/ircserverhandler.h b/src/core/ircserverhandler.h index 953c3b48..518af932 100644 --- a/src/core/ircserverhandler.h +++ b/src/core/ircserverhandler.h @@ -64,6 +64,8 @@ public slots: void handle318(const QString &prefix, const QList ¶ms); // RPL_ENDOFWHOIS void handle319(const QString &prefix, const QList ¶ms); // RPL_WHOISCHANNELS void handle320(const QString &prefix, const QList ¶ms); // RPL_WHOISVIRT (is identified to services) + void handle322(const QString &prefix, const QList ¶ms); // RPL_LIST + void handle323(const QString &prefix, const QList ¶ms); // RPL_LISTEND void handle324(const QString &prefix, const QList ¶ms); // RPL_CHANNELMODEIS void handle329(const QString &prefix, const QList ¶ms); // RPL_??? (channel creation time) void handle331(const QString &prefix, const QList ¶ms); // RPL_NOTOPIC diff --git a/src/qtui/CMakeLists.txt b/src/qtui/CMakeLists.txt index 98e83c6c..561b46e7 100644 --- a/src/qtui/CMakeLists.txt +++ b/src/qtui/CMakeLists.txt @@ -7,6 +7,7 @@ include(${QT_USE_FILE}) set(SOURCES aboutdlg.cpp bufferwidget.cpp + channellistdlg.cpp coreconfigwizard.cpp coreconnectdlg.cpp debugconsole.cpp @@ -27,6 +28,7 @@ set(SOURCES set(MOC_HDRS aboutdlg.h bufferwidget.h + channellistdlg.h coreconfigwizard.h coreconnectdlg.h debugconsole.h @@ -60,6 +62,7 @@ set(FORMS aboutdlg.ui bufferviewwidget.ui bufferwidget.ui + channellistdlg.ui coreaccounteditdlg.ui coreconfigwizardintropage.ui coreconfigwizardadminuserpage.ui diff --git a/src/qtui/channellistdlg.cpp b/src/qtui/channellistdlg.cpp new file mode 100644 index 00000000..c232a05e --- /dev/null +++ b/src/qtui/channellistdlg.cpp @@ -0,0 +1,106 @@ +/*************************************************************************** + * Copyright (C) 2005-08 by the Quassel Project * + * 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) version 3. * + * * + * 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 "channellistdlg.h" + +#include "client.h" +#include "clientirclisthelper.h" + +#include + +ChannelListDlg::ChannelListDlg(QWidget *parent) + : QDialog(parent), + _listFinished(true), + _ircListModel(this), + _sortFilter(this) +{ + _sortFilter.setSourceModel(&_ircListModel); + _sortFilter.setFilterCaseSensitivity(Qt::CaseInsensitive); + _sortFilter.setFilterKeyColumn(-1); + + ui.setupUi(this); + ui.channelListView->setSelectionBehavior(QAbstractItemView::SelectRows); + ui.channelListView->setSelectionMode(QAbstractItemView::SingleSelection); + ui.channelListView->setAlternatingRowColors(true); + ui.channelListView->setTabKeyNavigation(false); + ui.channelListView->setModel(&_sortFilter); + ui.channelListView->setSortingEnabled(true); + ui.channelListView->verticalHeader()->hide(); + ui.channelListView->horizontalHeader()->setStretchLastSection(true); + + ui.searchChannelsButton->setAutoDefault(false); + + connect(ui.searchChannelsButton, SIGNAL(clicked()), this, SLOT(requestSearch())); + connect(ui.channelNameLineEdit, SIGNAL(returnPressed()), this, SLOT(requestSearch())); + connect(ui.filterLineEdit, SIGNAL(textChanged(QString)), &_sortFilter, SLOT(setFilterFixedString(QString))); + connect(Client::ircListHelper(), SIGNAL(channelListReceived(const NetworkId &, const QStringList &, QList)), + this, SLOT(receiveChannelList(NetworkId , QStringList, QList))); + connect(Client::ircListHelper(), SIGNAL(finishedListReported(const NetworkId &)), this, SLOT(reportFinishedList())); + connect(ui.channelListView, SIGNAL(activated(QModelIndex)), this, SLOT(joinChannel(QModelIndex))); + + enableQuery(true); + showFilterLine(false); +} + + +void ChannelListDlg::setNetwork(NetworkId netId) { + if(_netId == netId) + return; + + _netId = netId; + _ircListModel.setChannelList(); +} + +void ChannelListDlg::requestSearch() { + _listFinished = false; + enableQuery(false); + QStringList channelFilters; + channelFilters << ui.channelNameLineEdit->text().trimmed(); + Client::ircListHelper()->requestChannelList(_netId, channelFilters); +} + +void ChannelListDlg::receiveChannelList(const NetworkId &netId, const QStringList &channelFilters, const QList &channelList) { + Q_UNUSED(netId) + Q_UNUSED(channelFilters) + + showFilterLine(!channelList.isEmpty()); + _ircListModel.setChannelList(channelList); + enableQuery(_listFinished); +} + +void ChannelListDlg::showFilterLine(bool show) { + ui.line->setVisible(show); + ui.filterLabel->setVisible(show); + ui.filterLineEdit->setVisible(show); +} + +void ChannelListDlg::enableQuery(bool enable) { + ui.channelNameLineEdit->setEnabled(enable); + ui.searchChannelsButton->setEnabled(enable); +} + +void ChannelListDlg::reportFinishedList() { + _listFinished = true; +} + + +void ChannelListDlg::joinChannel(const QModelIndex &index) { + Client::instance()->userInput(BufferInfo::fakeStatusBuffer(_netId), QString("/JOIN %1").arg(index.sibling(index.row(), 0).data().toString())); +} diff --git a/src/qtui/channellistdlg.h b/src/qtui/channellistdlg.h new file mode 100644 index 00000000..84e5b7ad --- /dev/null +++ b/src/qtui/channellistdlg.h @@ -0,0 +1,58 @@ +/*************************************************************************** + * Copyright (C) 2005-08 by the Quassel Project * + * 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) version 3. * + * * + * 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. * + ***************************************************************************/ + +#ifndef CHANNELLISTDLG_H +#define CHANNELLISTDLG_H + +#include "ui_channellistdlg.h" + +#include "irclisthelper.h" +#include "irclistmodel.h" +#include "types.h" + +#include + +class ChannelListDlg : public QDialog { + Q_OBJECT + +public: + ChannelListDlg(QWidget *parent = 0); + + void setNetwork(NetworkId netId); + +protected slots: + void requestSearch(); + void receiveChannelList(const NetworkId &netId, const QStringList &channelFilters, const QList &channelList); + void reportFinishedList(); + void joinChannel(const QModelIndex &); + +private: + void showFilterLine(bool show); + void enableQuery(bool enable); + + Ui::ChannelListDlg ui; + + bool _listFinished; + NetworkId _netId; + IrcListModel _ircListModel; + QSortFilterProxyModel _sortFilter; +}; + +#endif //CHANNELLIST_H diff --git a/src/qtui/mainwin.cpp b/src/qtui/mainwin.cpp index 925c64f7..93909198 100644 --- a/src/qtui/mainwin.cpp +++ b/src/qtui/mainwin.cpp @@ -25,6 +25,7 @@ #include "bufferviewconfig.h" #include "bufferviewfilter.h" #include "bufferviewmanager.h" +#include "channellistdlg.h" #include "client.h" #include "clientbacklogmanager.h" #include "coreconnectdlg.h" @@ -36,6 +37,7 @@ #include "signalproxy.h" #include "topicwidget.h" #include "inputwidget.h" +#include "irclistmodel.h" #include "verticaldock.h" #include "uisettings.h" #include "qtuisettings.h" @@ -72,6 +74,7 @@ MainWin::MainWin(QtUi *_gui, QWidget *parent) offlineTrayIcon(":/icons/quassel-icon-offline.png"), trayIconActive(false), timer(new QTimer(this)), + channelListDlg(new ChannelListDlg(this)), settingsDlg(new SettingsDlg(this)), debugConsole(new DebugConsole(this)) { @@ -191,6 +194,8 @@ void MainWin::addBufferView(BufferViewConfig *config) { view->setFilteredModel(Client::bufferModel(), config); view->show(); + connect(&view->showChannelList, SIGNAL(triggered()), this, SLOT(showChannelList())); + Client::bufferModel()->synchronizeView(view); dock->setWidget(view); @@ -496,6 +501,16 @@ void MainWin::coreConnectionDlgFinished(int /*code*/) { //exit(1); } +void MainWin::showChannelList(NetworkId netId) { + if(!netId.isValid()) { + QAction *action = qobject_cast(sender()); + if(action) + netId = action->data().value(); + } + channelListDlg->setNetwork(netId); + channelListDlg->show(); +} + void MainWin::showSettingsDlg() { settingsDlg->show(); } diff --git a/src/qtui/mainwin.h b/src/qtui/mainwin.h index e2e703f0..3c756293 100644 --- a/src/qtui/mainwin.h +++ b/src/qtui/mainwin.h @@ -31,6 +31,7 @@ class ServerListDlg; +class ChannelListDlg; class CoreConnectDlg; class Buffer; class BufferViewConfig; @@ -75,6 +76,7 @@ class MainWin : public QMainWindow { void addBufferView(int bufferViewConfigId); void removeBufferView(int bufferViewConfigId); void receiveMessage(const Message &msg); + void showChannelList(NetworkId netId = NetworkId()); void showSettingsDlg(); void showNetworkDlg(); void showManageViewsDlg(); @@ -133,6 +135,7 @@ class MainWin : public QMainWindow { QTimer *timer; CoreConnectDlg *coreConnectDlg; + ChannelListDlg *channelListDlg; SettingsDlg *settingsDlg; DebugConsole *debugConsole; diff --git a/src/qtui/qtui.pri b/src/qtui/qtui.pri index 729a128a..7a071402 100644 --- a/src/qtui/qtui.pri +++ b/src/qtui/qtui.pri @@ -1,12 +1,12 @@ DEPMOD = client common uisupport QT_MOD = core gui network -SRCS += aboutdlg.cpp bufferwidget.cpp chatline-old.cpp chatwidget.cpp \ +SRCS += aboutdlg.cpp bufferwidget.cpp channellistdlg.cpp chatline-old.cpp chatwidget.cpp \ coreconfigwizard.cpp coreconnectdlg.cpp debugconsole.cpp inputwidget.cpp \ mainwin.cpp nicklistwidget.cpp qtui.cpp qtuisettings.cpp qtuistyle.cpp settingsdlg.cpp settingspagedlg.cpp \ titlesetter.cpp topicbutton.cpp topicwidget.cpp verticaldock.cpp jumpkeyhandler.cpp -HDRS += aboutdlg.h bufferwidget.h chatline-old.h chatwidget.h \ +HDRS += aboutdlg.h bufferwidget.h channellistdlg.h chatline-old.h chatwidget.h \ coreconfigwizard.h debugconsole.h inputwidget.h \ coreconnectdlg.h mainwin.h nicklistwidget.h qtui.h qtuisettings.h qtuistyle.h settingsdlg.h settingspagedlg.h \ titlesetter.h topicbutton.h topicwidget.h verticaldock.h jumpkeyhandler.h @@ -19,7 +19,7 @@ sputdev { HDRS -= chatline-old.h chatwidget.h } -FORMNAMES = aboutdlg.ui mainwin.ui coreaccounteditdlg.ui coreconnectdlg.ui bufferviewwidget.ui bufferwidget.ui nicklistwidget.ui settingsdlg.ui \ +FORMNAMES = aboutdlg.ui mainwin.ui channellistdlg.ui coreaccounteditdlg.ui coreconnectdlg.ui bufferviewwidget.ui bufferwidget.ui nicklistwidget.ui settingsdlg.ui \ settingspagedlg.ui topicwidget.ui debugconsole.ui inputwidget.ui \ coreconfigwizardintropage.ui coreconfigwizardadminuserpage.ui coreconfigwizardstorageselectionpage.ui coreconfigwizardsyncpage.ui diff --git a/src/qtui/ui/channellistdlg.ui b/src/qtui/ui/channellistdlg.ui new file mode 100644 index 00000000..ceef19fc --- /dev/null +++ b/src/qtui/ui/channellistdlg.ui @@ -0,0 +1,83 @@ + + ChannelListDlg + + + + 0 + 0 + 454 + 406 + + + + Channel List + + + + 2 + + + 0 + + + + + 6 + + + 6 + + + + + Search Pattern: + + + + + + + + + + Search Channels + + + + + + + + + Qt::Horizontal + + + + + + + 6 + + + 6 + + + + + Filter: + + + + + + + + + + + + + + + + diff --git a/src/uisupport/bufferview.cpp b/src/uisupport/bufferview.cpp index c11c6adf..fca441ee 100644 --- a/src/uisupport/bufferview.cpp +++ b/src/uisupport/bufferview.cpp @@ -48,6 +48,7 @@ // to be on the safe side: call QTreeView's method aswell BufferView::BufferView(QWidget *parent) : QTreeView(parent), + showChannelList(tr("Show Channel List"), this), _connectNetAction(tr("Connect"), this), _disconnectNetAction(tr("Disconnect"), this), _joinChannelAction(tr("Join Channel"), this), @@ -403,8 +404,10 @@ void BufferView::contextMenuEvent(QContextMenuEvent *event) { switch(itemType) { case NetworkModel::NetworkItemType: + showChannelList.setData(index.data(NetworkModel::NetworkIdRole)); _disconnectNetAction.setIcon(connectionStateIcon); _connectNetAction.setIcon(connectionStateIcon); + addItemToMenu(showChannelList, contextMenu, index, ActiveState); addItemToMenu(_disconnectNetAction, contextMenu, index, ActiveState); addItemToMenu(_connectNetAction, contextMenu, index, InactiveState); addSeparatorToMenu(contextMenu, index, ActiveState); @@ -461,10 +464,11 @@ void BufferView::contextMenuEvent(QContextMenuEvent *event) { bool ok; QString channelName = QInputDialog::getText(this, tr("Join Channel"), tr("Input channel name:"), QLineEdit::Normal, QString(), &ok); if(ok && !channelName.isEmpty()) { - BufferInfo bufferInfo = index.child(0,0).data(NetworkModel::BufferInfoRole).value(); - if(bufferInfo.isValid()) { - Client::instance()->userInput(bufferInfo, QString("/J %1").arg(channelName)); - } + Client::instance()->userInput(BufferInfo::fakeStatusBuffer(index.data(NetworkModel::NetworkIdRole).value()), QString("/J %1").arg(channelName)); +// BufferInfo bufferInfo = index.child(0,0).data(NetworkModel::BufferInfoRole).value(); +// if(bufferInfo.isValid()) { +// Client::instance()->userInput(bufferInfo, QString("/J %1").arg(channelName)); +// } } #endif return; diff --git a/src/uisupport/bufferview.h b/src/uisupport/bufferview.h index b47904a6..cb55e916 100644 --- a/src/uisupport/bufferview.h +++ b/src/uisupport/bufferview.h @@ -80,7 +80,7 @@ class BufferView : public QTreeView { }; public: Q_DECLARE_FLAGS(ItemActiveStates, ItemActiveState); - + QAction showChannelList; private: QPointer _config;