now found a usable design.
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
#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<QVariant> NickTreeModel::defaultHeader() {
- QList<QVariant> data;
- data << tr("Nick");
- return data;
-}
#define _NICKTREEMODEL_H_
#include "ircuser.h"
-#include "treemodel.h"
+//#include "treemodel.h"
+#include <QAbstractItemModel>
+
+/*
//! 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;
+ //virtual QVariant data(int column, int row) const;
private:
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<QVariant> defaultHeader();
+ NickModel(IrcChannel *);
+ virtual ~NickModel();
private:
+
};
class TreeItem : public QObject {
Q_OBJECT
Q_PROPERTY(uint id READ id)
-
+
public:
TreeItem(const QList<QVariant> &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<QVariant> itemData;
-
+
private:
QList<TreeItem *> _childItems;
QHash<uint, TreeItem *> _childHash; // uint to be compatible to qHash functions
*****************************************/
class TreeModel : public QAbstractItemModel {
Q_OBJECT
-
+
public:
TreeModel(const QList<QVariant> &, 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;
#include "ircchannel.h"
#include "networkinfo.h"
+//#include "nicktreemodel.h"
#include "signalproxy.h"
#include "ircuser.h"
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
if(isKnownUser(ircuser)) {
_userModes[ircuser] = modes;
emit userModesSet(ircuser->nick(), modes);
+ emit userModesSet(ircuser, modes);
}
}
if(!_userModes[ircuser].contains(mode)) {
_userModes[ircuser] += mode;
emit userModeAdded(ircuser->nick(), mode);
+ emit userModeAdded(ircuser, 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);
}
}
_userModes.remove(ircUser);
}
+void IrcChannel::ircUserNickSet(QString nick) {
+ IrcUser *ircUser = qobject_cast<IrcUser *>(sender());
+ Q_ASSERT(ircUser);
+ emit ircUserNickSet(ircUser, nick);
+}
+
void IrcChannel::setInitialized() {
_initialized = true;
emit initDone();
#include <QStringList>
#include <QVariantMap>
-class SignalProxy;
-class NetworkInfo;
class IrcUser;
+class NetworkInfo;
+class SignalProxy;
class IrcChannel : public QObject {
Q_OBJECT
QString userMode(IrcUser *ircuser) const;
QString userMode(const QString &nick) const;
-
-public slots:
+public slots:
void setTopic(const QString &topic);
void join(IrcUser *ircuser);
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<IrcUser *, QString> _userModes;
+ QHash<IrcUser *, QString> _userModes;
NetworkInfo *networkInfo;
};
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)
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();
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);
// init seters
void initSetChannels(const QStringList channels);
-
+
void setInitialized();
signals:
_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++) {
mode = networkInfo()->prefixToMode(nick[0]);
nick = nick.mid(1);
}
-
+
IrcUser *ircuser = networkInfo()->newIrcUser(nick);
ircuser->joinChannel(channelname);