From 7795adca52f35204f8c354da6fcc5d8e8ee35531 Mon Sep 17 00:00:00 2001 From: Manuel Nickschas Date: Fri, 23 Nov 2007 02:58:22 +0000 Subject: [PATCH] Various stuff, cosmetic fixes, fiddling with IrcUsers and NetworkInfos in Buffers. --- Quassel.kdevelop.filelist | 2 ++ src/client/buffer.cpp | 19 ++++++++++++++++- src/client/buffer.h | 10 +++++++++ src/client/buffertreemodel.h | 24 ++++++++++----------- src/client/client.cpp | 15 +++++++++++-- src/client/client.h | 15 +++++++------ src/client/nicktreemodel.cpp | 8 ++++++- src/client/nicktreemodel.h | 30 ++++++++++++++++++++++++++ src/common/ircchannel.cpp | 4 ++++ src/common/ircchannel.h | 17 ++++++++------- src/common/networkinfo.cpp | 4 ++-- src/common/networkinfo.h | 2 +- src/qtopia/ui/nicklistwidget.ui | 9 +++++++- src/uisupport/nickview.cpp | 33 ++++++++++++++++++++++++++++ src/uisupport/nickview.h | 38 +++++++++++++++++++++++++++++++++ src/uisupport/uisupport.pri | 4 ++-- 16 files changed, 197 insertions(+), 37 deletions(-) create mode 100644 src/uisupport/nickview.cpp create mode 100644 src/uisupport/nickview.h diff --git a/Quassel.kdevelop.filelist b/Quassel.kdevelop.filelist index e59c1c41..ac277a18 100644 --- a/Quassel.kdevelop.filelist +++ b/Quassel.kdevelop.filelist @@ -201,6 +201,8 @@ src/uisupport/bufferview.cpp src/uisupport/bufferview.h src/uisupport/bufferviewfilter.cpp src/uisupport/bufferviewfilter.h +src/uisupport/nickview.cpp +src/uisupport/nickview.h src/uisupport/uistyle.cpp src/uisupport/uistyle.h src/uisupport/uisupport.pri diff --git a/src/client/buffer.cpp b/src/client/buffer.cpp index 48d8a707..304d9ecb 100644 --- a/src/client/buffer.cpp +++ b/src/client/buffer.cpp @@ -22,13 +22,15 @@ #include "buffer.h" #include "client.h" +#include "ircchannel.h" #include "util.h" Buffer::Buffer(BufferInfo bufferid, QObject *parent) : QObject(parent), _bufferInfo(bufferid), - _active(false) + _active(false), + _ircChannel(0) { if(bufferid.buffer().isEmpty()) _type = StatusType; @@ -147,6 +149,21 @@ void Buffer::processUserInput(QString msg) { emit userInput(_bufferInfo, msg); } +IrcChannel *Buffer::ircChannel() const { + return _ircChannel; +} + +void Buffer::setIrcChannel(IrcChannel *ircchan) { + if(_ircChannel) { + disconnect(_ircChannel, 0, this, 0); + // TODO: remove model etc + } + _ircChannel = ircchan; + if(_ircChannel) { + connect(_ircChannel, SIGNAL(destroyed()), this, SLOT(setIrcChannel())); + } +} + // no longer needed // back reference: // void Buffer::setTopic(QString t) { diff --git a/src/client/buffer.h b/src/client/buffer.h index e862d5af..fcf28050 100644 --- a/src/client/buffer.h +++ b/src/client/buffer.h @@ -22,6 +22,7 @@ #define _BUFFER_H_ class AbstractUiMsg; +class IrcChannel; struct BufferState; @@ -73,6 +74,13 @@ public: QString topic() const; QString ownNick() const; + //! Returns a pointer to the associated IrcChannel object for the buffer. + /** A buffer has an IrcChannel object only if it is a channel buffer + * (i.e. bufferType() == ChannelType), and if it is active at the moment. + * \returns A pointer to the associated IrcChannel object, if the buffer is a channel and online; 0 else. + */ + IrcChannel *ircChannel() const; + signals: void userInput(const BufferInfo &, QString); void nickListChanged(QVariantMap nicks); @@ -89,6 +97,7 @@ public slots: void appendMsg(const Message &); void prependMsg(const Message &); bool layoutMsg(); + void setIrcChannel(IrcChannel *chan = 0); // no longer needed // void setTopic(QString); @@ -106,6 +115,7 @@ private: bool _active; Type _type; BufferState *state; + IrcChannel *_ircChannel; QList layoutQueue; QList layoutedMsgs; diff --git a/src/client/buffertreemodel.h b/src/client/buffertreemodel.h index e194c27b..7737dd36 100644 --- a/src/client/buffertreemodel.h +++ b/src/client/buffertreemodel.h @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2005-07 by The Quassel Team * + * Copyright (C) 2005-07 by the Quassel IRC Team * * devel@quassel-irc.org * * * * This program is free software; you can redistribute it and/or modify * @@ -42,20 +42,20 @@ class QAbstractItemView; *****************************************/ class BufferTreeItem : public TreeItem { Q_OBJECT - + public: BufferTreeItem(Buffer *, TreeItem *parent = 0); virtual uint id() const; QVariant data(int column, int role) const; - + Buffer *buffer() const { return buf; } void setActivity(const Buffer::ActivityLevel &); - + private: QString text(int column) const; QColor foreground(int column) const; - + Buffer *buf; Buffer::ActivityLevel activity; }; @@ -65,13 +65,13 @@ private: *****************************************/ class NetworkTreeItem : public TreeItem { Q_OBJECT - + public: NetworkTreeItem(const uint &netid, const QString &, TreeItem *parent = 0); virtual QVariant data(int column, int row) const; virtual uint id() const; - + private: uint _networkId; QString net; @@ -82,7 +82,7 @@ private: *****************************************/ class BufferTreeModel : public TreeModel { Q_OBJECT - + public: enum myRoles { BufferTypeRole = Qt::UserRole, @@ -90,7 +90,7 @@ public: BufferUidRole, NetworkIdRole }; - + BufferTreeModel(QObject *parent = 0); static QList defaultHeader(); @@ -103,7 +103,7 @@ public: static bool mimeContainsBufferList(const QMimeData *mimeData); static QList< QPair > mimeDataToBufferList(const QMimeData *mimeData); - + virtual QStringList mimeTypes() const; virtual QMimeData *mimeData(const QModelIndexList &) const; virtual bool dropMimeData(const QMimeData *, Qt::DropAction, int, int, const QModelIndex &); @@ -114,12 +114,12 @@ public slots: void setCurrentIndex(const QModelIndex &index, QItemSelectionModel::SelectionFlags command); void selectBuffer(Buffer *buffer); void bufferActivity(Buffer::ActivityLevel, Buffer *buffer); - + signals: void bufferSelected(Buffer *); void invalidateFilter(); void selectionChanged(const QModelIndex &); - + private: bool isBufferIndex(const QModelIndex &) const; Buffer *getBufferByIndex(const QModelIndex &) const; diff --git a/src/client/client.cpp b/src/client/client.cpp index 899991f7..bfce15d1 100644 --- a/src/client/client.cpp +++ b/src/client/client.cpp @@ -139,6 +139,7 @@ Client::Client(QObject *parent) } Client::~Client() { + } void Client::init() { @@ -281,7 +282,7 @@ void Client::coreSocketDisconnected() { net->deleteLater(); } Q_ASSERT(_networkInfo.isEmpty()); - + coreConnectionInfo.clear(); sessionData.clear(); layoutQueue.clear(); @@ -448,6 +449,7 @@ void Client::networkConnected(uint netid) { connect(netinfo, SIGNAL(ircUserInitDone()), this, SLOT(updateCoreConnectionProgress())); connect(netinfo, SIGNAL(ircChannelInitDone()), this, SLOT(updateCoreConnectionProgress())); } + connect(netinfo, SIGNAL(ircChannelAdded(QString)), this, SLOT(ircChannelAdded(QString))); connect(netinfo, SIGNAL(destroyed()), this, SLOT(networkInfoDestroyed())); _networkInfo[netid] = netinfo; } @@ -460,7 +462,7 @@ void Client::networkDisconnected(uint networkid) { //buffer->displayMsg(Message(bufferid, Message::Server, tr("Server disconnected."))); FIXME buffer->setActive(false); } - + Q_ASSERT(networkInfo(networkid)); if(!networkInfo(networkid)->initialized()) { qDebug() << "Network" << networkid << "disconnected while not yet initialized!"; @@ -468,6 +470,15 @@ void Client::networkDisconnected(uint networkid) { } } +void Client::ircChannelAdded(QString chanName) { + NetworkInfo *netInfo = qobject_cast(sender()); + Q_ASSERT(netInfo); + Buffer *buf = buffer(bufferInfo(netInfo->networkName(), chanName)); + Q_ASSERT(buf); + buf->setIrcChannel(netInfo->ircChannel(chanName)); + +} + void Client::updateBufferInfo(BufferInfo id) { buffer(id)->updateBufferInfo(id); } diff --git a/src/client/client.h b/src/client/client.h index 2f3d907b..66ea75f8 100644 --- a/src/client/client.h +++ b/src/client/client.h @@ -51,7 +51,7 @@ public: static QList networkInfos(); static NetworkInfo *networkInfo(uint networkid); - + static QList allBufferInfos(); static QList buffers(); static Buffer *buffer(uint bufferUid); @@ -68,7 +68,7 @@ public: static void fakeInput(uint bufferUid, QString message); static void fakeInput(BufferInfo bufferInfo, QString message); - + static void storeSessionData(const QString &key, const QVariant &data); static QVariant retrieveSessionData(const QString &key, const QVariant &def = QVariant()); static QStringList sessionDataKeys(); @@ -89,7 +89,7 @@ signals: void coreConnectionError(QString errorMsg); void coreConnectionMsg(const QString &msg); void coreConnectionProgress(uint part, uint total); - + void showConfigWizard(const QVariantMap &coredata); void connected(); @@ -104,7 +104,7 @@ public slots: //void connectToLocalCore(); void connectToCore(const QVariantMap &); void disconnectFromCore(); - + void setCoreConfiguration(const QVariantMap &settings); private slots: @@ -132,16 +132,17 @@ private slots: private slots: void bufferDestroyed(); void networkInfoDestroyed(); + void ircChannelAdded(QString); private: Client(QObject *parent = 0); virtual ~Client(); void init(); - + void syncToCore(const QVariant &coreState); static QPointer instanceptr; - + QPointer socket; QPointer _signalProxy; QPointer mainUi; @@ -151,7 +152,7 @@ private: quint32 blockSize; bool connectedToCore; - + QVariantMap coreConnectionInfo; QHash _buffers; QHash _networkInfo; diff --git a/src/client/nicktreemodel.cpp b/src/client/nicktreemodel.cpp index 25b6de84..1fcb4113 100644 --- a/src/client/nicktreemodel.cpp +++ b/src/client/nicktreemodel.cpp @@ -21,7 +21,7 @@ #include "nicktreemodel.h" -NickTreeModel::NickTreeModel(QObject *parent) : TreeModel(QList(), parent) { +NickTreeModel::NickTreeModel(QObject *parent) : TreeModel(defaultHeader(), parent) { //QStringList list; list << "test1" << "test2"; //setStringList(list); @@ -31,3 +31,9 @@ NickTreeModel::~NickTreeModel() { } + +QList NickTreeModel::defaultHeader() { + QList data; + data << tr("Nick"); + return data; +} diff --git a/src/client/nicktreemodel.h b/src/client/nicktreemodel.h index 5c57674e..3006d12b 100644 --- a/src/client/nicktreemodel.h +++ b/src/client/nicktreemodel.h @@ -21,8 +21,36 @@ #ifndef _NICKTREEMODEL_H_ #define _NICKTREEMODEL_H_ +#include "ircuser.h" #include "treemodel.h" +//! Represents a single IrcUser within a NickTreeModel. +class NickTreeItem : public TreeItem { + Q_OBJECT + + public: + NickTreeItem(IrcUser *ircuser, TreeItem *parent = 0); + + virtual QVariant data(int column, int row) const; + + private: + +}; + +//! Represents a group of nicks, such as Ops, Voiced etc. +class NickTreeGroupItem : public TreeItem { + Q_OBJECT + + public: + NickTreeGroupItem(const QString &title, TreeItem *parent = 0); + + virtual QVariant data(int column, int row) const; + + private: + +}; + +//! Represents the IrcUsers in a given IrcChannel. class NickTreeModel : public TreeModel { Q_OBJECT @@ -30,6 +58,8 @@ class NickTreeModel : public TreeModel { NickTreeModel(QObject *parent = 0); virtual ~NickTreeModel(); + static QList defaultHeader(); + private: }; diff --git a/src/common/ircchannel.cpp b/src/common/ircchannel.cpp index 28d6c6ed..906f4f0a 100644 --- a/src/common/ircchannel.cpp +++ b/src/common/ircchannel.cpp @@ -40,6 +40,10 @@ IrcChannel::IrcChannel(const QString &channelname, NetworkInfo *networkinfo) setObjectName(QString::number(networkInfo->networkId()) + "/" + channelname); } +IrcChannel::~IrcChannel() { + +} + // ==================== // PUBLIC: // ==================== diff --git a/src/common/ircchannel.h b/src/common/ircchannel.h index e60634a8..9cdf52a4 100644 --- a/src/common/ircchannel.h +++ b/src/common/ircchannel.h @@ -32,12 +32,13 @@ class IrcUser; class IrcChannel : public QObject { Q_OBJECT - + Q_PROPERTY(QString name READ name STORED false) Q_PROPERTY(QString topic READ topic WRITE setTopic STORED false) public: IrcChannel(const QString &channelname, NetworkInfo *networkInfo); + ~IrcChannel(); bool isKnownUser(IrcUser *ircuser) const; bool isValidChannelUserMode(const QString &mode) const; @@ -46,9 +47,9 @@ public: QString name() const; QString topic() const; - + QList ircUsers() const; - + QString userMode(IrcUser *ircuser) const; QString userMode(const QString &nick) const; @@ -64,10 +65,10 @@ public slots: void setUserModes(IrcUser *ircuser, const QString &modes); void setUserModes(const QString &nick, const QString &modes); - + void addUserMode(IrcUser *ircuser, const QString &mode); void addUserMode(const QString &nick, const QString &mode); - + void removeUserMode(IrcUser *ircuser, const QString &mode); void removeUserMode(const QString &nick, const QString &mode); @@ -76,7 +77,7 @@ public slots: // init seters void initSetUserModes(const QVariantMap &usermodes); - + void setInitialized(); signals: @@ -87,7 +88,7 @@ signals: void ircUserJoined(IrcUser *ircuser); void ircUserParted(IrcUser *ircuser); - + void initDone(); private slots: @@ -99,7 +100,7 @@ private: QString _topic; QHash _userModes; - + NetworkInfo *networkInfo; }; diff --git a/src/common/networkinfo.cpp b/src/common/networkinfo.cpp index 1a051f0e..75a45c0e 100644 --- a/src/common/networkinfo.cpp +++ b/src/common/networkinfo.cpp @@ -45,13 +45,13 @@ NetworkInfo::NetworkInfo(const uint &networkid, QObject *parent) } // I think this is unnecessary since IrcUsers have us as their daddy :) -// NetworkInfo::~NetworkInfo() { +//NetworkInfo::~NetworkInfo() { // QHashIterator ircuser(_ircUsers); // while (ircuser.hasNext()) { // ircuser.next(); // delete ircuser.value(); // } -// } +//} uint NetworkInfo::networkId() const { return _networkId; diff --git a/src/common/networkinfo.h b/src/common/networkinfo.h index 8be0d98d..776c7b77 100644 --- a/src/common/networkinfo.h +++ b/src/common/networkinfo.h @@ -42,7 +42,7 @@ class NetworkInfo : public QObject { public: NetworkInfo(const uint &networkid, QObject *parent = 0); - // virtual ~NetworkInfo(); + //virtual ~NetworkInfo(); uint networkId() const; bool initialized() const; diff --git a/src/qtopia/ui/nicklistwidget.ui b/src/qtopia/ui/nicklistwidget.ui index 05e18a68..889ddaee 100644 --- a/src/qtopia/ui/nicklistwidget.ui +++ b/src/qtopia/ui/nicklistwidget.ui @@ -26,10 +26,17 @@ 1 - + + + + NickView + QTreeView +
nickview.h
+
+
diff --git a/src/uisupport/nickview.cpp b/src/uisupport/nickview.cpp new file mode 100644 index 00000000..7d9545cd --- /dev/null +++ b/src/uisupport/nickview.cpp @@ -0,0 +1,33 @@ +/*************************************************************************** + * Copyright (C) 2005-07 by the Quassel IRC Team * + * devel@quassel-irc.org * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ + +#include "nickview.h" + +NickView::NickView(QWidget *parent) : QTreeView(parent) { + + + +} + +NickView::~NickView() { + + +} + diff --git a/src/uisupport/nickview.h b/src/uisupport/nickview.h new file mode 100644 index 00000000..33effda4 --- /dev/null +++ b/src/uisupport/nickview.h @@ -0,0 +1,38 @@ +/*************************************************************************** + * Copyright (C) 2005-07 by the Quassel IRC Team * + * devel@quassel-irc.org * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ + +#ifndef _NICKVIEW_H_ +#define _NICKVIEW_H_ + +#include + +class NickView : public QTreeView { + Q_OBJECT + + public: + NickView(QWidget *parent = 0); + virtual ~NickView(); + + + + +}; + +#endif diff --git a/src/uisupport/uisupport.pri b/src/uisupport/uisupport.pri index 642b98c6..910bd69d 100644 --- a/src/uisupport/uisupport.pri +++ b/src/uisupport/uisupport.pri @@ -1,8 +1,8 @@ DEPMOD = common client QT_MOD = core gui network -SRCS += bufferview.cpp bufferviewfilter.cpp uistyle.cpp -HDRS += bufferview.h bufferviewfilter.h uistyle.h +SRCS += bufferview.cpp bufferviewfilter.cpp nickview.cpp uistyle.cpp +HDRS += bufferview.h bufferviewfilter.h nickview.h uistyle.h FORMNAMES = -- 2.20.1