From a30b5992589c96fcb1eca1af36465a955d2cf6ff Mon Sep 17 00:00:00 2001 From: Manuel Nickschas Date: Mon, 26 Nov 2007 17:09:20 +0000 Subject: [PATCH] Some cosmetic corrections and some minor work on the nick model. Hopefully I now found a usable design. --- qtopia-build/quasseltopia.pro | 2 +- src/client/nicktreemodel.cpp | 11 ++++------- src/client/nicktreemodel.h | 19 +++++++++++-------- src/client/treemodel.h | 26 +++++++++++++------------- src/common/ircchannel.cpp | 14 ++++++++++++-- src/common/ircchannel.h | 14 +++++++++----- src/common/ircuser.h | 12 ++++++------ src/common/networkinfo.cpp | 4 ++-- src/core/ircserverhandler.cpp | 2 +- 9 files changed, 59 insertions(+), 45 deletions(-) diff --git a/qtopia-build/quasseltopia.pro b/qtopia-build/quasseltopia.pro index c47229a7..fa32432e 100644 --- a/qtopia-build/quasseltopia.pro +++ b/qtopia-build/quasseltopia.pro @@ -47,5 +47,5 @@ pkg.desc=Quassel IRC, a next-gen IRC client pkg.version=0.0.1-1 pkg.maintainer=www.quassel-irc.org pkg.license=GPL -pkg.domain=docapi,pim,profiles,window,qdl,qds +pkg.domain=docapi,pim,profiles,window,qdl,qds,doc_write diff --git a/src/client/nicktreemodel.cpp b/src/client/nicktreemodel.cpp index 1fcb4113..89e1ca70 100644 --- a/src/client/nicktreemodel.cpp +++ b/src/client/nicktreemodel.cpp @@ -20,20 +20,17 @@ #include "nicktreemodel.h" +#include "ircchannel.h" -NickTreeModel::NickTreeModel(QObject *parent) : TreeModel(defaultHeader(), parent) { + +NickModel::NickModel(IrcChannel *channel) : QAbstractItemModel(channel) { //QStringList list; list << "test1" << "test2"; //setStringList(list); } -NickTreeModel::~NickTreeModel() { +NickModel::~NickModel() { } -QList NickTreeModel::defaultHeader() { - QList data; - data << tr("Nick"); - return data; -} diff --git a/src/client/nicktreemodel.h b/src/client/nicktreemodel.h index 3006d12b..79dead36 100644 --- a/src/client/nicktreemodel.h +++ b/src/client/nicktreemodel.h @@ -22,8 +22,11 @@ #define _NICKTREEMODEL_H_ #include "ircuser.h" -#include "treemodel.h" +//#include "treemodel.h" +#include + +/* //! Represents a single IrcUser within a NickTreeModel. class NickTreeItem : public TreeItem { Q_OBJECT @@ -31,7 +34,7 @@ class NickTreeItem : public TreeItem { public: NickTreeItem(IrcUser *ircuser, TreeItem *parent = 0); - virtual QVariant data(int column, int row) const; + //virtual QVariant data(int column, int row) const; private: @@ -44,23 +47,23 @@ class NickTreeGroupItem : public TreeItem { public: NickTreeGroupItem(const QString &title, TreeItem *parent = 0); - virtual QVariant data(int column, int row) const; + //virtual QVariant data(int column, int row) const; private: }; +*/ //! Represents the IrcUsers in a given IrcChannel. -class NickTreeModel : public TreeModel { +class NickModel : public QAbstractItemModel { Q_OBJECT public: - NickTreeModel(QObject *parent = 0); - virtual ~NickTreeModel(); - - static QList defaultHeader(); + NickModel(IrcChannel *); + virtual ~NickModel(); private: + }; diff --git a/src/client/treemodel.h b/src/client/treemodel.h index c7202168..f1317be7 100644 --- a/src/client/treemodel.h +++ b/src/client/treemodel.h @@ -32,39 +32,39 @@ class TreeItem : public QObject { Q_OBJECT Q_PROPERTY(uint id READ id) - + public: TreeItem(const QList &data, TreeItem *parent = 0); TreeItem(TreeItem *parent = 0); virtual ~TreeItem(); - + void appendChild(TreeItem *child); void removeChild(int row); - + virtual uint id() const; - + TreeItem *child(int row) const; TreeItem *childById(const uint &) const; - + int childCount() const; int columnCount() const; - + virtual QVariant data(int column, int role) const; - + Qt::ItemFlags flags() const; void setFlags(Qt::ItemFlags); - + int row() const; TreeItem *parent(); private slots: void childDestroyed(); - - + + protected: QList itemData; - + private: QList _childItems; QHash _childHash; // uint to be compatible to qHash functions @@ -78,11 +78,11 @@ private: *****************************************/ class TreeModel : public QAbstractItemModel { Q_OBJECT - + public: TreeModel(const QList &, QObject *parent = 0); virtual ~TreeModel(); - + 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; diff --git a/src/common/ircchannel.cpp b/src/common/ircchannel.cpp index 906f4f0a..412ad2ad 100644 --- a/src/common/ircchannel.cpp +++ b/src/common/ircchannel.cpp @@ -21,6 +21,7 @@ #include "ircchannel.h" #include "networkinfo.h" +//#include "nicktreemodel.h" #include "signalproxy.h" #include "ircuser.h" @@ -111,6 +112,7 @@ void IrcChannel::join(IrcUser *ircuser) { if(!_userModes.contains(ircuser) && ircuser) { _userModes[ircuser] = QString(); ircuser->joinChannel(name()); + connect(ircuser, SIGNAL(nickSet(QString)), this, SLOT(ircUserNickSet(QString))); connect(ircuser, SIGNAL(destroyed()), this, SLOT(ircUserDestroyed())); // if you wonder why there is no counterpart to ircUserJoined: // the joines are propagted by the ircuser. the signal ircUserJoined is only for convenience @@ -141,6 +143,7 @@ void IrcChannel::setUserModes(IrcUser *ircuser, const QString &modes) { if(isKnownUser(ircuser)) { _userModes[ircuser] = modes; emit userModesSet(ircuser->nick(), modes); + emit userModesSet(ircuser, modes); } } @@ -156,6 +159,7 @@ void IrcChannel::addUserMode(IrcUser *ircuser, const QString &mode) { if(!_userModes[ircuser].contains(mode)) { _userModes[ircuser] += mode; emit userModeAdded(ircuser->nick(), mode); + emit userModeAdded(ircuser, mode); } } @@ -164,15 +168,15 @@ void IrcChannel::addUserMode(const QString &nick, const QString &mode) { addUserMode(networkInfo->ircUser(nick), mode); } - // REMOVE USER MODE -void IrcChannel::removeUserMode(IrcUser *ircuser, const QString &mode) { +void IrcChannel::removeUserMode(IrcUser *ircuser, const QString &mode) { qDebug() << "remove mode:" << ircuser->nick() << mode; if(!isKnownUser(ircuser) || !isValidChannelUserMode(mode)) return; if(_userModes[ircuser].contains(mode)) { _userModes[ircuser].remove(mode); emit userModeRemoved(ircuser->nick(), mode); + emit userModeRemoved(ircuser, mode); } } @@ -206,6 +210,12 @@ void IrcChannel::ircUserDestroyed() { _userModes.remove(ircUser); } +void IrcChannel::ircUserNickSet(QString nick) { + IrcUser *ircUser = qobject_cast(sender()); + Q_ASSERT(ircUser); + emit ircUserNickSet(ircUser, nick); +} + void IrcChannel::setInitialized() { _initialized = true; emit initDone(); diff --git a/src/common/ircchannel.h b/src/common/ircchannel.h index 9cdf52a4..53fc9343 100644 --- a/src/common/ircchannel.h +++ b/src/common/ircchannel.h @@ -26,9 +26,9 @@ #include #include -class SignalProxy; -class NetworkInfo; class IrcUser; +class NetworkInfo; +class SignalProxy; class IrcChannel : public QObject { Q_OBJECT @@ -53,8 +53,7 @@ public: QString userMode(IrcUser *ircuser) const; QString userMode(const QString &nick) const; - -public slots: +public slots: void setTopic(const QString &topic); void join(IrcUser *ircuser); @@ -83,23 +82,28 @@ public slots: signals: void topicSet(QString topic); void userModesSet(QString nick, QString modes); + void userModesSet(IrcUser *ircuser, QString modes); void userModeAdded(QString nick, QString mode); + void userModeAdded(IrcUser *ircuser, QString mode); void userModeRemoved(QString nick, QString mode); + void userModeRemoved(IrcUser *ircuser, QString mode); void ircUserJoined(IrcUser *ircuser); void ircUserParted(IrcUser *ircuser); + void ircUserNickSet(IrcUser *ircuser, QString nick); void initDone(); private slots: void ircUserDestroyed(); + void ircUserNickSet(QString nick); private: bool _initialized; QString _name; QString _topic; - QHash _userModes; + QHash _userModes; NetworkInfo *networkInfo; }; diff --git a/src/common/ircuser.h b/src/common/ircuser.h index 1ed1c85d..a6d4f26f 100644 --- a/src/common/ircuser.h +++ b/src/common/ircuser.h @@ -32,7 +32,7 @@ class IrcChannel; class IrcUser : public QObject { Q_OBJECT - + Q_PROPERTY(QString user READ user WRITE setUser STORED false) Q_PROPERTY(QString host READ host WRITE setHost STORED false) Q_PROPERTY(QString nick READ nick WRITE setNick STORED false) @@ -40,7 +40,7 @@ class IrcUser : public QObject { Q_PROPERTY(QStringList channels READ channels STORED false) // Q_PROPERTY(QStringList usermodes READ usermodes WRITE setUsermodes) - + public: IrcUser(const QString &hostmask, NetworkInfo *networkInfo); virtual ~IrcUser(); @@ -55,13 +55,13 @@ public: QString userModes() const; QStringList channels() const; - -public slots: + +public slots: void setUser(const QString &user); void setHost(const QString &host); void setNick(const QString &nick); void updateHostmask(const QString &mask); - + void setUserModes(const QString &modes); void joinChannel(const QString &channel); @@ -72,7 +72,7 @@ public slots: // init seters void initSetChannels(const QStringList channels); - + void setInitialized(); signals: diff --git a/src/common/networkinfo.cpp b/src/common/networkinfo.cpp index 75a45c0e..5690a264 100644 --- a/src/common/networkinfo.cpp +++ b/src/common/networkinfo.cpp @@ -356,8 +356,8 @@ void NetworkInfo::determinePrefixes() { _prefixes = PREFIX.section(")", 1); _prefixModes = PREFIX.mid(1).section(")", 0, 0); } else { - QString defaultPrefixes("@%+"); - QString defaultPrefixModes("ohv"); + QString defaultPrefixes("~&@%+"); + QString defaultPrefixModes("qaohv"); // we just assume that in PREFIX are only prefix chars stored for(int i = 0; i < defaultPrefixes.size(); i++) { diff --git a/src/core/ircserverhandler.cpp b/src/core/ircserverhandler.cpp index 0fa0372f..21430500 100644 --- a/src/core/ircserverhandler.cpp +++ b/src/core/ircserverhandler.cpp @@ -378,7 +378,7 @@ void IrcServerHandler::handle353(QString prefix, QStringList params) { mode = networkInfo()->prefixToMode(nick[0]); nick = nick.mid(1); } - + IrcUser *ircuser = networkInfo()->newIrcUser(nick); ircuser->joinChannel(channelname); -- 2.20.1