Implemented a channel browser (BR #176).
authorMarcus Eggenberger <egs@quassel-irc.org>
Mon, 23 Jun 2008 10:44:15 +0000 (12:44 +0200)
committerMarcus Eggenberger <egs@quassel-irc.org>
Mon, 23 Jun 2008 10:44:15 +0000 (12:44 +0200)
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

37 files changed:
src/client/CMakeLists.txt
src/client/client.cpp
src/client/client.h
src/client/client.pri
src/client/clientirclisthelper.cpp [new file with mode: 0644]
src/client/clientirclisthelper.h [new file with mode: 0644]
src/client/irclistmodel.cpp [new file with mode: 0644]
src/client/irclistmodel.h [new file with mode: 0644]
src/common/CMakeLists.txt
src/common/backlogmanager.h
src/common/bufferinfo.cpp
src/common/bufferinfo.h
src/common/common.pri
src/common/irclisthelper.h [new file with mode: 0644]
src/core/CMakeLists.txt
src/core/basichandler.cpp
src/core/basichandler.h
src/core/core.pri
src/core/corebacklogmanager.h
src/core/corebufferviewconfig.h
src/core/corebufferviewmanager.h
src/core/coreirclisthelper.cpp [new file with mode: 0644]
src/core/coreirclisthelper.h [new file with mode: 0644]
src/core/corenetwork.h
src/core/coresession.cpp
src/core/coresession.h
src/core/ircserverhandler.cpp
src/core/ircserverhandler.h
src/qtui/CMakeLists.txt
src/qtui/channellistdlg.cpp [new file with mode: 0644]
src/qtui/channellistdlg.h [new file with mode: 0644]
src/qtui/mainwin.cpp
src/qtui/mainwin.h
src/qtui/qtui.pri
src/qtui/ui/channellistdlg.ui [new file with mode: 0644]
src/uisupport/bufferview.cpp
src/uisupport/bufferview.h

index 39436cb..6877a0b 100644 (file)
@@ -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
index 6a7faa9..a6f7b4b 100644 (file)
@@ -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 &)));
 }
index 4e7eb0e..ad5740c 100644 (file)
@@ -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;
 
index dab9cf9..91b4d94 100644 (file)
@@ -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 (file)
index 0000000..65775de
--- /dev/null
@@ -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 <QStringList>
+
+#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<ChannelDescription> 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 (file)
index 0000000..194f3ef
--- /dev/null
@@ -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<IrcListHelper::ChannelDescription> &channelList);
+
+private:
+  NetworkId _netId;
+};
+
+#endif //CLIENTIRCLISTHELPER_H
diff --git a/src/client/irclistmodel.cpp b/src/client/irclistmodel.cpp
new file mode 100644 (file)
index 0000000..5da6804
--- /dev/null
@@ -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 <QStringList>
+
+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<IrcListHelper::ChannelDescription> &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 (file)
index 0000000..bb905f6
--- /dev/null
@@ -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 <QAbstractItemModel>
+
+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<IrcListHelper::ChannelDescription> &channelList = QList<IrcListHelper::ChannelDescription>());
+
+private:
+  QList<IrcListHelper::ChannelDescription> _channelList;
+};
+
+#endif //IRCLISTMODEL_H
index 3b1f2ab..f725398 100644 (file)
@@ -29,6 +29,7 @@ set(MOC_HDRS
     bufferviewmanager.h
     identity.h
     ircchannel.h
+    irclisthelper.h
     ircuser.h
     logger.h
     network.h
index 6ff6b9c..c060f9c 100644 (file)
@@ -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);
index 19e6279..c45c8aa 100644 (file)
@@ -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;
index 4eec164..9a7292c 100644 (file)
@@ -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; }
index 0942f1a..38153c8 100644 (file)
@@ -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 (file)
index 0000000..8bf7f94
--- /dev/null
@@ -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
index 2219f0a..0046153 100644 (file)
@@ -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
index a00966d..adf9fa4 100644 (file)
@@ -22,7 +22,6 @@
 #include <QMetaMethod>
 
 #include "util.h"
-#include "networkconnection.h"
 
 BasicHandler::BasicHandler(NetworkConnection *parent)
   : QObject(parent),
@@ -158,15 +157,6 @@ QList<QByteArray> 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;
index f641a30..ebac6dd 100644 (file)
@@ -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:
index 8c0f01a..1d9650f 100644 (file)
@@ -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) {
index 0272bbb..7d7e1d8 100644 (file)
@@ -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; }
 
index bb7eb95..80c2ae3 100644 (file)
@@ -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); }
index 072b455..c251002 100644 (file)
@@ -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 (file)
index 0000000..d8a317c
--- /dev/null
@@ -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<ChannelDescription>();
+
+    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<ChannelDescription>();
+    
+    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<QVariant>(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 (file)
index 0000000..84303ad
--- /dev/null
@@ -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<NetworkId, QString> _queuedQuery;
+  QHash<NetworkId, QList<ChannelDescription> > _channelLists;
+  QHash<NetworkId, QVariantList> _finishedChannelLists;
+};
+
+#endif //COREIRCLISTHELPER_H
index 2d91317..4c956cf 100644 (file)
@@ -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; }
 
index f868379..f394b5e 100644 (file)
@@ -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();
 
index 913f630..737e15c 100644 (file)
@@ -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;
 
index 3d7596d..9bdb3c6 100644 (file)
@@ -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<QByteArray>
   emit displayMsg(Message::Server, BufferInfo::StatusBuffer, "", tr("[Whois] %1").arg(serverDecode(params).join(" ")));
 }
 
+/* RPL_LIST -  "<channel> <# visible> :<topic>" */
+void IrcServerHandler::handle322(const QString &prefix, const QList<QByteArray> &params) {
+  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<QByteArray> &params) {
+  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 - "<channel> <mode> <mode params>" */
 void IrcServerHandler::handle324(const QString &prefix, const QList<QByteArray> &params) {
   Q_UNUSED(prefix);
index 953c3b4..518af93 100644 (file)
@@ -64,6 +64,8 @@ public slots:
   void handle318(const QString &prefix, const QList<QByteArray> &params);   // RPL_ENDOFWHOIS
   void handle319(const QString &prefix, const QList<QByteArray> &params);   // RPL_WHOISCHANNELS
   void handle320(const QString &prefix, const QList<QByteArray> &params);   // RPL_WHOISVIRT (is identified to services)
+  void handle322(const QString &prefix, const QList<QByteArray> &params);   // RPL_LIST
+  void handle323(const QString &prefix, const QList<QByteArray> &params);   // RPL_LISTEND
   void handle324(const QString &prefix, const QList<QByteArray> &params);   // RPL_CHANNELMODEIS
   void handle329(const QString &prefix, const QList<QByteArray> &params);   // RPL_??? (channel creation time)
   void handle331(const QString &prefix, const QList<QByteArray> &params);   // RPL_NOTOPIC
index 98e83c6..561b46e 100644 (file)
@@ -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 (file)
index 0000000..c232a05
--- /dev/null
@@ -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 <QHeaderView>
+
+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<IrcListHelper::ChannelDescription>)),
+         this, SLOT(receiveChannelList(NetworkId , QStringList, QList<IrcListHelper::ChannelDescription>)));
+  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<IrcListHelper::ChannelDescription> &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 (file)
index 0000000..84e5b7a
--- /dev/null
@@ -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 <QSortFilterProxyModel>
+
+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<IrcListHelper::ChannelDescription> &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
index 925c64f..9390919 100644 (file)
@@ -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<QAction *>(sender());
+    if(action)
+      netId = action->data().value<NetworkId>();
+  }
+  channelListDlg->setNetwork(netId);
+  channelListDlg->show();
+}
+
 void MainWin::showSettingsDlg() {
   settingsDlg->show();
 }
index e2e703f..3c75629 100644 (file)
@@ -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;
 
index 729a128..7a07140 100644 (file)
@@ -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 (file)
index 0000000..ceef19f
--- /dev/null
@@ -0,0 +1,83 @@
+<ui version="4.0" >
+ <class>ChannelListDlg</class>
+ <widget class="QDialog" name="ChannelListDlg" >
+  <property name="geometry" >
+   <rect>
+    <x>0</x>
+    <y>0</y>
+    <width>454</width>
+    <height>406</height>
+   </rect>
+  </property>
+  <property name="windowTitle" >
+   <string>Channel List</string>
+  </property>
+  <layout class="QVBoxLayout" name="verticalLayout" >
+   <property name="spacing" >
+    <number>2</number>
+   </property>
+   <property name="margin" >
+    <number>0</number>
+   </property>
+   <item>
+    <layout class="QHBoxLayout" name="horizontalLayout" >
+     <property name="spacing" >
+      <number>6</number>
+     </property>
+     <property name="leftMargin" >
+      <number>6</number>
+     </property>
+     <item>
+      <widget class="QLabel" name="label" >
+       <property name="text" >
+        <string>Search Pattern:</string>
+       </property>
+      </widget>
+     </item>
+     <item>
+      <widget class="QLineEdit" name="channelNameLineEdit" />
+     </item>
+     <item>
+      <widget class="QPushButton" name="searchChannelsButton" >
+       <property name="text" >
+        <string>Search Channels</string>
+       </property>
+      </widget>
+     </item>
+    </layout>
+   </item>
+   <item>
+    <widget class="Line" name="line" >
+     <property name="orientation" >
+      <enum>Qt::Horizontal</enum>
+     </property>
+    </widget>
+   </item>
+   <item>
+    <layout class="QHBoxLayout" name="horizontalLayout_2" >
+     <property name="spacing" >
+      <number>6</number>
+     </property>
+     <property name="leftMargin" >
+      <number>6</number>
+     </property>
+     <item>
+      <widget class="QLabel" name="filterLabel" >
+       <property name="text" >
+        <string>Filter:</string>
+       </property>
+      </widget>
+     </item>
+     <item>
+      <widget class="QLineEdit" name="filterLineEdit" />
+     </item>
+    </layout>
+   </item>
+   <item>
+    <widget class="QTableView" name="channelListView" />
+   </item>
+  </layout>
+ </widget>
+ <resources/>
+ <connections/>
+</ui>
index c11c6ad..fca441e 100644 (file)
@@ -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<BufferInfo>();
-      if(bufferInfo.isValid()) {
-        Client::instance()->userInput(bufferInfo, QString("/J %1").arg(channelName));
-      }
+      Client::instance()->userInput(BufferInfo::fakeStatusBuffer(index.data(NetworkModel::NetworkIdRole).value<NetworkId>()), QString("/J %1").arg(channelName));
+//       BufferInfo bufferInfo = index.child(0,0).data(NetworkModel::BufferInfoRole).value<BufferInfo>();
+//       if(bufferInfo.isValid()) {
+//         Client::instance()->userInput(bufferInfo, QString("/J %1").arg(channelName));
+//       }
     }
 #endif
     return;
index b47904a..cb55e91 100644 (file)
@@ -80,7 +80,7 @@ class BufferView : public QTreeView {
     };
   public:
     Q_DECLARE_FLAGS(ItemActiveStates, ItemActiveState);
-
+    QAction showChannelList;
   private:
     QPointer<BufferViewConfig> _config;