From 788fd0058595c815dc42597e9956c02aea45261f Mon Sep 17 00:00:00 2001 From: Marcus Eggenberger Date: Tue, 1 Jan 2008 16:58:42 +0000 Subject: [PATCH] Since we're going for one grand unified model to store all the stuff from the networks and no longer only the buffer informations the BufferTreeModel is now known as NetworkModel Introduced a simple Debugconsole, that allows direct Data manipulation using Qt Script. Currently it works only with the core and the storage backend is the only registered QObject --- build/targets/core.pri | 2 +- build/targets/monolithic.pri | 2 +- build/targets/qtclient.pri | 2 +- src/client/buffertreemodel.cpp | 184 +++++++++++++++++------------ src/client/buffertreemodel.h | 59 ++++++--- src/client/client.cpp | 18 +-- src/client/client.h | 6 +- src/client/treemodel.cpp | 74 ++++++++++-- src/client/treemodel.h | 4 + src/core/core.pri | 2 +- src/core/coresession.cpp | 19 ++- src/core/coresession.h | 10 ++ src/core/ircserverhandler.cpp | 6 +- src/core/sqlitestorage.h | 1 + src/core/storage.h | 1 + src/qtui/debugconsole.cpp | 46 ++++++++ src/qtui/debugconsole.h | 46 ++++++++ src/qtui/mainwin.cpp | 20 +++- src/qtui/mainwin.h | 4 + src/qtui/qtui.pri | 6 +- src/qtui/ui/debugconsole.ui | 105 ++++++++++++++++ src/qtui/ui/mainwin.ui | 10 +- src/uisupport/bufferviewfilter.cpp | 20 ++-- 23 files changed, 499 insertions(+), 148 deletions(-) create mode 100644 src/qtui/debugconsole.cpp create mode 100644 src/qtui/debugconsole.h create mode 100644 src/qtui/ui/debugconsole.ui diff --git a/build/targets/core.pri b/build/targets/core.pri index 464e8392..78d0811f 100644 --- a/build/targets/core.pri +++ b/build/targets/core.pri @@ -5,4 +5,4 @@ MODULES = core common DEFINES = BUILD_CORE QT -= gui -QT += network sql +QT += network sql script diff --git a/build/targets/monolithic.pri b/build/targets/monolithic.pri index 4d8ba4d4..de74d3d5 100644 --- a/build/targets/monolithic.pri +++ b/build/targets/monolithic.pri @@ -4,4 +4,4 @@ TARGET = quassel MODULES = core qtui uisupport client common DEFINES = BUILD_MONO -QT += network sql +QT += network sql script diff --git a/build/targets/qtclient.pri b/build/targets/qtclient.pri index 53079164..451337b4 100644 --- a/build/targets/qtclient.pri +++ b/build/targets/qtclient.pri @@ -4,4 +4,4 @@ TARGET = quasselclient MODULES = qtui uisupport client common DEFINES = BUILD_QTUI -QT += network +QT += network script diff --git a/src/client/buffertreemodel.cpp b/src/client/buffertreemodel.cpp index e0039c8f..865c4a45 100644 --- a/src/client/buffertreemodel.cpp +++ b/src/client/buffertreemodel.cpp @@ -35,7 +35,7 @@ /***************************************** * Fancy Buffer Items *****************************************/ -BufferTreeItem::BufferTreeItem(Buffer *buffer, AbstractTreeItem *parent) +BufferItem::BufferItem(Buffer *buffer, AbstractTreeItem *parent) : PropertyMapItem(QStringList() << "bufferName" << "topic" << "nickCount", parent), buf(buffer), activity(Buffer::NoActivity) @@ -46,15 +46,15 @@ BufferTreeItem::BufferTreeItem(Buffer *buffer, AbstractTreeItem *parent) setFlags(flags); } -quint64 BufferTreeItem::id() const { +quint64 BufferItem::id() const { return buf->bufferInfo().uid(); } -void BufferTreeItem::setActivity(const Buffer::ActivityLevel &level) { +void BufferItem::setActivity(const Buffer::ActivityLevel &level) { activity = level; } -QColor BufferTreeItem::foreground(int column) const { +QColor BufferItem::foreground(int column) const { Q_UNUSED(column) // for the time beeing we ignore the column :) if(activity & Buffer::Highlight) { @@ -71,15 +71,17 @@ QColor BufferTreeItem::foreground(int column) const { } } -QVariant BufferTreeItem::data(int column, int role) const { +QVariant BufferItem::data(int column, int role) const { switch(role) { - case BufferTreeModel::BufferUidRole: + case NetworkModel::ItemTypeRole: + return NetworkModel::BufferItemType; + case NetworkModel::BufferUidRole: return buf->bufferInfo().uid(); - case BufferTreeModel::NetworkIdRole: + case NetworkModel::NetworkIdRole: return buf->bufferInfo().networkId(); - case BufferTreeModel::BufferTypeRole: + case NetworkModel::BufferTypeRole: return int(buf->bufferType()); - case BufferTreeModel::BufferActiveRole: + case NetworkModel::BufferActiveRole: return buf->isActive(); case Qt::ForegroundRole: return foreground(column); @@ -88,7 +90,7 @@ QVariant BufferTreeItem::data(int column, int role) const { } } -void BufferTreeItem::attachIrcChannel(IrcChannel *ircChannel) { +void BufferItem::attachIrcChannel(IrcChannel *ircChannel) { if(!ircChannel) return; @@ -102,35 +104,35 @@ void BufferTreeItem::attachIrcChannel(IrcChannel *ircChannel) { this, SLOT(part(IrcUser *))); } -QString BufferTreeItem::bufferName() const { +QString BufferItem::bufferName() const { return buf->name(); } -QString BufferTreeItem::topic() const { +QString BufferItem::topic() const { if(_ircChannel) return _ircChannel->topic(); else return QString(); } -int BufferTreeItem::nickCount() const { +int BufferItem::nickCount() const { if(_ircChannel) return _ircChannel->ircUsers().count(); else return 0; } -void BufferTreeItem::setTopic(const QString &topic) { +void BufferItem::setTopic(const QString &topic) { Q_UNUSED(topic); emit dataChanged(1); } -void BufferTreeItem::join(IrcUser *ircUser) { - Q_UNUSED(ircUser); - emit dataChanged(2); +void BufferItem::join(IrcUser *ircUser) { +// emit newChild(new IrcUserItem(ircUser, this)); +// emit dataChanged(2); } -void BufferTreeItem::part(IrcUser *ircUser) { +void BufferItem::part(IrcUser *ircUser) { Q_UNUSED(ircUser); emit dataChanged(2); } @@ -138,7 +140,7 @@ void BufferTreeItem::part(IrcUser *ircUser) { /***************************************** * Network Items *****************************************/ -NetworkTreeItem::NetworkTreeItem(const uint &netid, const QString &network, AbstractTreeItem *parent) +NetworkItem::NetworkItem(const uint &netid, const QString &network, AbstractTreeItem *parent) : PropertyMapItem(QList() << "networkName" << "currentServer" << "nickCount", parent), _networkId(netid), _networkName(network) @@ -146,40 +148,40 @@ NetworkTreeItem::NetworkTreeItem(const uint &netid, const QString &network, Abst setFlags(Qt::ItemIsEnabled); } -QVariant NetworkTreeItem::data(int column, int role) const { +QVariant NetworkItem::data(int column, int role) const { switch(role) { - case BufferTreeModel::NetworkIdRole: + case NetworkModel::NetworkIdRole: return _networkId; - case BufferTreeModel::ItemTypeRole: - return BufferTreeModel::NetworkItem; + case NetworkModel::ItemTypeRole: + return NetworkModel::NetworkItemType; default: return PropertyMapItem::data(column, role); } } -quint64 NetworkTreeItem::id() const { +quint64 NetworkItem::id() const { return _networkId; } -QString NetworkTreeItem::networkName() const { +QString NetworkItem::networkName() const { if(_networkInfo) return _networkInfo->networkName(); else return _networkName; } -QString NetworkTreeItem::currentServer() const { +QString NetworkItem::currentServer() const { if(_networkInfo) return _networkInfo->currentServer(); else return QString(); } -int NetworkTreeItem::nickCount() const { - BufferTreeItem *bufferItem; +int NetworkItem::nickCount() const { + BufferItem *bufferItem; int count = 0; for(int i = 0; i < childCount(); i++) { - bufferItem = qobject_cast(child(i)); + bufferItem = qobject_cast(child(i)); if(!bufferItem) continue; count += bufferItem->nickCount(); @@ -187,7 +189,7 @@ int NetworkTreeItem::nickCount() const { return count; } -void NetworkTreeItem::attachNetworkInfo(NetworkInfo *networkInfo) { +void NetworkItem::attachNetworkInfo(NetworkInfo *networkInfo) { if(!networkInfo) return; @@ -202,16 +204,16 @@ void NetworkTreeItem::attachNetworkInfo(NetworkInfo *networkInfo) { // FIXME: connect this and that... } -void NetworkTreeItem::attachIrcChannel(const QString &channelName) { +void NetworkItem::attachIrcChannel(const QString &channelName) { IrcChannel *ircChannel = _networkInfo->ircChannel(channelName); if(!ircChannel) { - qWarning() << "NetworkTreeItem::attachIrcChannel(): unkown Channel" << channelName; + qWarning() << "NetworkItem::attachIrcChannel(): unkown Channel" << channelName; return; } - BufferTreeItem *bufferItem; + BufferItem *bufferItem; for(int i = 0; i < childCount(); i++) { - bufferItem = qobject_cast(child(i)); + bufferItem = qobject_cast(child(i)); if(bufferItem->bufferName() == ircChannel->name()) { bufferItem->attachIrcChannel(ircChannel); break; @@ -219,21 +221,48 @@ void NetworkTreeItem::attachIrcChannel(const QString &channelName) { } } -void NetworkTreeItem::setNetworkName(const QString &networkName) { +void NetworkItem::setNetworkName(const QString &networkName) { Q_UNUSED(networkName); emit dataChanged(0); } -void NetworkTreeItem::setCurrentServer(const QString &serverName) { +void NetworkItem::setCurrentServer(const QString &serverName) { Q_UNUSED(serverName); emit dataChanged(1); } /***************************************** - * BufferTreeModel +* Irc User Items +*****************************************/ +IrcUserItem::IrcUserItem(IrcUser *ircUser, AbstractTreeItem *parent) + : PropertyMapItem(QStringList() << "nickName", parent), + _ircUser(ircUser) +{ + connect(ircUser, SIGNAL(destroyed()), + this, SLOT(ircUserDestroyed())); + + connect(ircUser, SIGNAL(nickSet(QString)), + this, SLOT(setNick(QString))); +} + +QString IrcUserItem::nickName() { + return _ircUser->nick(); +} + +void IrcUserItem::setNick(QString newNick) { + Q_UNUSED(newNick); + emit dataChanged(0); +} +void IrcUserItem::ircUserDestroyed() { + deleteLater(); +} + + +/***************************************** + * NetworkModel *****************************************/ -BufferTreeModel::BufferTreeModel(QObject *parent) - : TreeModel(BufferTreeModel::defaultHeader(), parent), +NetworkModel::NetworkModel(QObject *parent) + : TreeModel(NetworkModel::defaultHeader(), parent), _selectionModelSynchronizer(new SelectionModelSynchronizer(this)), _propertyMapper(new ModelPropertyMapper(this)) { @@ -248,17 +277,17 @@ BufferTreeModel::BufferTreeModel(QObject *parent) this, SLOT(setCurrentIndex(QModelIndex, QItemSelectionModel::SelectionFlags))); } -QListBufferTreeModel::defaultHeader() { +QListNetworkModel::defaultHeader() { QList data; data << tr("Buffer") << tr("Topic") << tr("Nick Count"); return data; } -void BufferTreeModel::synchronizeSelectionModel(MappedSelectionModel *selectionModel) { +void NetworkModel::synchronizeSelectionModel(MappedSelectionModel *selectionModel) { selectionModelSynchronizer()->addSelectionModel(selectionModel); } -void BufferTreeModel::synchronizeView(QAbstractItemView *view) { +void NetworkModel::synchronizeView(QAbstractItemView *view) { MappedSelectionModel *mappedSelectionModel = new MappedSelectionModel(view->model()); selectionModelSynchronizer()->addSelectionModel(mappedSelectionModel); Q_ASSERT(mappedSelectionModel); @@ -266,17 +295,16 @@ void BufferTreeModel::synchronizeView(QAbstractItemView *view) { view->setSelectionModel(mappedSelectionModel); } -void BufferTreeModel::mapProperty(int column, int role, QObject *target, const QByteArray &property) { +void NetworkModel::mapProperty(int column, int role, QObject *target, const QByteArray &property) { propertyMapper()->addMapping(column, role, target, property); } -bool BufferTreeModel::isBufferIndex(const QModelIndex &index) const { - // not so purdy... - return parent(index) != QModelIndex(); +bool NetworkModel::isBufferIndex(const QModelIndex &index) const { + return index.data(NetworkModel::ItemTypeRole) == NetworkModel::BufferItemType; } -Buffer *BufferTreeModel::getBufferByIndex(const QModelIndex &index) const { - BufferTreeItem *item = static_cast(index.internalPointer()); +Buffer *NetworkModel::getBufferByIndex(const QModelIndex &index) const { + BufferItem *item = static_cast(index.internalPointer()); // FIXME get rid of this Q_ASSERT(item->buffer() == Client::instance()->buffer(item->id())); return item->buffer(); @@ -284,19 +312,19 @@ Buffer *BufferTreeModel::getBufferByIndex(const QModelIndex &index) const { // experimental stuff :) -QModelIndex BufferTreeModel::networkIndex(uint networkId) { +QModelIndex NetworkModel::networkIndex(uint networkId) { return indexById(networkId); } -NetworkTreeItem *BufferTreeModel::network(uint networkId) { - return qobject_cast(rootItem->childById(networkId)); +NetworkItem *NetworkModel::network(uint networkId) { + return qobject_cast(rootItem->childById(networkId)); } -NetworkTreeItem *BufferTreeModel::newNetwork(uint networkId, const QString &networkName) { - NetworkTreeItem *networkItem = network(networkId); +NetworkItem *NetworkModel::newNetwork(uint networkId, const QString &networkName) { + NetworkItem *networkItem = network(networkId); if(networkItem == 0) { - networkItem = new NetworkTreeItem(networkId, networkName, rootItem); + networkItem = new NetworkItem(networkId, networkName, rootItem); appendChild(rootItem, networkItem); } @@ -304,7 +332,7 @@ NetworkTreeItem *BufferTreeModel::newNetwork(uint networkId, const QString &netw return networkItem; } -QModelIndex BufferTreeModel::bufferIndex(BufferInfo bufferInfo) { +QModelIndex NetworkModel::bufferIndex(BufferInfo bufferInfo) { QModelIndex networkIdx = networkIndex(bufferInfo.networkId()); if(!networkIdx.isValid()) return QModelIndex(); @@ -312,22 +340,22 @@ QModelIndex BufferTreeModel::bufferIndex(BufferInfo bufferInfo) { return indexById(bufferInfo.uid(), networkIdx); } -BufferTreeItem *BufferTreeModel::buffer(BufferInfo bufferInfo) { +BufferItem *NetworkModel::buffer(BufferInfo bufferInfo) { QModelIndex bufferIdx = bufferIndex(bufferInfo); if(bufferIdx.isValid()) - return static_cast(bufferIdx.internalPointer()); + return static_cast(bufferIdx.internalPointer()); else return 0; } -BufferTreeItem *BufferTreeModel::newBuffer(BufferInfo bufferInfo) { - BufferTreeItem *bufferItem = buffer(bufferInfo); +BufferItem *NetworkModel::newBuffer(BufferInfo bufferInfo) { + BufferItem *bufferItem = buffer(bufferInfo); if(bufferItem == 0) { - NetworkTreeItem *networkItem = newNetwork(bufferInfo.networkId(), bufferInfo.network()); + NetworkItem *networkItem = newNetwork(bufferInfo.networkId(), bufferInfo.network()); // FIXME: get rid of the buffer pointer Buffer *buffer = Client::instance()->buffer(bufferInfo.uid()); - bufferItem = new BufferTreeItem(buffer, networkItem); + bufferItem = new BufferItem(buffer, networkItem); appendChild(networkItem, bufferItem); } @@ -335,7 +363,7 @@ BufferTreeItem *BufferTreeModel::newBuffer(BufferInfo bufferInfo) { return bufferItem; } -QStringList BufferTreeModel::mimeTypes() const { +QStringList NetworkModel::mimeTypes() const { // mimetypes we accept for drops QStringList types; // comma separated list of colon separated pairs of networkid and bufferid @@ -344,11 +372,11 @@ QStringList BufferTreeModel::mimeTypes() const { return types; } -bool BufferTreeModel::mimeContainsBufferList(const QMimeData *mimeData) { +bool NetworkModel::mimeContainsBufferList(const QMimeData *mimeData) { return mimeData->hasFormat("application/Quassel/BufferItemList"); } -QList< QPair > BufferTreeModel::mimeDataToBufferList(const QMimeData *mimeData) { +QList< QPair > NetworkModel::mimeDataToBufferList(const QMimeData *mimeData) { QList< QPair > bufferList; if(!mimeContainsBufferList(mimeData)) @@ -367,7 +395,7 @@ QList< QPair > BufferTreeModel::mimeDataToBufferList(const QMimeData } -QMimeData *BufferTreeModel::mimeData(const QModelIndexList &indexes) const { +QMimeData *NetworkModel::mimeData(const QModelIndexList &indexes) const { QMimeData *mimeData = new QMimeData(); QStringList bufferlist; @@ -385,7 +413,7 @@ QMimeData *BufferTreeModel::mimeData(const QModelIndexList &indexes) const { return mimeData; } -bool BufferTreeModel::dropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent) { +bool NetworkModel::dropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent) { Q_UNUSED(action) Q_UNUSED(row) Q_UNUSED(column) @@ -394,7 +422,7 @@ bool BufferTreeModel::dropMimeData(const QMimeData *data, Qt::DropAction action, return false; // target must be a query - Buffer::Type targetType = (Buffer::Type)parent.data(BufferTreeModel::BufferTypeRole).toInt(); + Buffer::Type targetType = (Buffer::Type)parent.data(NetworkModel::BufferTypeRole).toInt(); if(targetType != Buffer::QueryType) return false; @@ -426,23 +454,23 @@ bool BufferTreeModel::dropMimeData(const QMimeData *data, Qt::DropAction action, return true; } -void BufferTreeModel::attachNetworkInfo(NetworkInfo *networkInfo) { - NetworkTreeItem *networkItem = network(networkInfo->networkId()); +void NetworkModel::attachNetworkInfo(NetworkInfo *networkInfo) { + NetworkItem *networkItem = network(networkInfo->networkId()); if(!networkItem) { - qWarning() << "BufferTreeModel::attachNetworkInfo(): network is unknown!"; + qWarning() << "NetworkModel::attachNetworkInfo(): network is unknown!"; return; } networkItem->attachNetworkInfo(networkInfo); } -void BufferTreeModel::bufferUpdated(Buffer *buffer) { - BufferTreeItem *bufferItem = newBuffer(buffer->bufferInfo()); +void NetworkModel::bufferUpdated(Buffer *buffer) { + BufferItem *bufferItem = newBuffer(buffer->bufferInfo()); QModelIndex itemindex = indexByItem(bufferItem); emit dataChanged(itemindex, itemindex); } // This Slot indicates that the user has selected a different buffer in the gui -void BufferTreeModel::setCurrentIndex(const QModelIndex &index, QItemSelectionModel::SelectionFlags command) { +void NetworkModel::setCurrentIndex(const QModelIndex &index, QItemSelectionModel::SelectionFlags command) { Q_UNUSED(command) Buffer *newCurrentBuffer; if(isBufferIndex(index) && currentBuffer != (newCurrentBuffer = getBufferByIndex(index))) { @@ -453,10 +481,10 @@ void BufferTreeModel::setCurrentIndex(const QModelIndex &index, QItemSelectionMo } } -void BufferTreeModel::bufferActivity(Buffer::ActivityLevel level, Buffer *buf) { - BufferTreeItem *bufferItem = buffer(buf->bufferInfo()); +void NetworkModel::bufferActivity(Buffer::ActivityLevel level, Buffer *buf) { + BufferItem *bufferItem = buffer(buf->bufferInfo()); if(!bufferItem) { - qWarning() << "BufferTreeModel::bufferActivity(): received Activity Info for uknown Buffer"; + qWarning() << "NetworkModel::bufferActivity(): received Activity Info for uknown Buffer"; return; } @@ -467,10 +495,10 @@ void BufferTreeModel::bufferActivity(Buffer::ActivityLevel level, Buffer *buf) { bufferUpdated(buf); } -void BufferTreeModel::selectBuffer(Buffer *buffer) { +void NetworkModel::selectBuffer(Buffer *buffer) { QModelIndex index = bufferIndex(buffer->bufferInfo()); if(!index.isValid()) { - qWarning() << "BufferTreeModel::selectBuffer(): unknown Buffer has been selected."; + qWarning() << "NetworkModel::selectBuffer(): unknown Buffer has been selected."; return; } // SUPER UGLY! diff --git a/src/client/buffertreemodel.h b/src/client/buffertreemodel.h index f2e118e1..56fcc918 100644 --- a/src/client/buffertreemodel.h +++ b/src/client/buffertreemodel.h @@ -18,8 +18,8 @@ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * ***************************************************************************/ -#ifndef _BUFFERTREEMODEL_H_ -#define _BUFFERTREEMODEL_H_ +#ifndef NETWORKMODEL_H +#define NETWORKMODEL_H #include @@ -43,14 +43,14 @@ class IrcUser; /***************************************** * Fancy Buffer Items *****************************************/ -class BufferTreeItem : public PropertyMapItem { +class BufferItem : public PropertyMapItem { Q_OBJECT Q_PROPERTY(QString bufferName READ bufferName) Q_PROPERTY(QString topic READ topic) Q_PROPERTY(int nickCount READ nickCount) public: - BufferTreeItem(Buffer *, AbstractTreeItem *parent = 0); + BufferItem(Buffer *, AbstractTreeItem *parent = 0); virtual quint64 id() const; virtual QVariant data(int column, int role) const; @@ -82,14 +82,14 @@ private: /***************************************** * Network Items *****************************************/ -class NetworkTreeItem : public PropertyMapItem { +class NetworkItem : public PropertyMapItem { Q_OBJECT Q_PROPERTY(QString networkName READ networkName) Q_PROPERTY(QString currentServer READ currentServer) Q_PROPERTY(int nickCount READ nickCount) public: - NetworkTreeItem(const uint &netid, const QString &, AbstractTreeItem *parent = 0); + NetworkItem(const uint &netid, const QString &, AbstractTreeItem *parent = 0); virtual QVariant data(int column, int row) const; virtual quint64 id() const; @@ -113,9 +113,30 @@ private: }; /***************************************** - * BufferTreeModel +* Irc User Items +*****************************************/ +class IrcUserItem : public PropertyMapItem { + Q_OBJECT + Q_PROPERTY(QString nickName READ nickName) + +public: + IrcUserItem(IrcUser *ircUser, AbstractTreeItem *parent); + + QString nickName(); + +private slots: + void setNick(QString newNick); + void ircUserDestroyed(); + +private: + IrcUser *_ircUser; +}; + + +/***************************************** + * NetworkModel *****************************************/ -class BufferTreeModel : public TreeModel { +class NetworkModel : public TreeModel { Q_OBJECT public: @@ -128,14 +149,14 @@ public: }; enum itemTypes { - AbstractItem, - SimpleItem, - NetworkItem, - BufferItem, - NickItem + AbstractItemType, + SimpleItemType, + NetworkItemType, + BufferItemType, + NickItemType }; - BufferTreeModel(QObject *parent = 0); + NetworkModel(QObject *parent = 0); static QList defaultHeader(); inline SelectionModelSynchronizer *selectionModelSynchronizer() { return _selectionModelSynchronizer; } @@ -169,16 +190,16 @@ private: Buffer *getBufferByIndex(const QModelIndex &) const; QModelIndex networkIndex(uint networkId); - NetworkTreeItem *network(uint networkId); - NetworkTreeItem *newNetwork(uint networkId, const QString &networkName); + NetworkItem *network(uint networkId); + NetworkItem *newNetwork(uint networkId, const QString &networkName); QModelIndex bufferIndex(BufferInfo bufferInfo); - BufferTreeItem *buffer(BufferInfo bufferInfo); - BufferTreeItem *newBuffer(BufferInfo bufferInfo); + BufferItem *buffer(BufferInfo bufferInfo); + BufferItem *newBuffer(BufferInfo bufferInfo); QPointer _selectionModelSynchronizer; QPointer _propertyMapper; Buffer *currentBuffer; }; -#endif +#endif // NETWORKMODEL_H diff --git a/src/client/client.cpp b/src/client/client.cpp index e78fc17e..f42e2a4a 100644 --- a/src/client/client.cpp +++ b/src/client/client.cpp @@ -118,8 +118,8 @@ BufferInfo Client::statusBufferInfo(QString net) { return bufferInfo(net, ""); } -BufferTreeModel *Client::bufferModel() { - return instance()->_bufferModel; +NetworkModel *Client::networkModel() { + return instance()->_networkModel; } SignalProxy *Client::signalProxy() { @@ -134,7 +134,7 @@ Client::Client(QObject *parent) socket(0), _signalProxy(new SignalProxy(SignalProxy::Client, this)), mainUi(0), - _bufferModel(0), + _networkModel(0), connectedToCore(false) { } @@ -146,14 +146,14 @@ Client::~Client() { void Client::init() { blockSize = 0; - _bufferModel = new BufferTreeModel(this); + _networkModel = new NetworkModel(this); connect(this, SIGNAL(bufferSelected(Buffer *)), - _bufferModel, SLOT(selectBuffer(Buffer *))); + _networkModel, SLOT(selectBuffer(Buffer *))); connect(this, SIGNAL(bufferUpdated(Buffer *)), - _bufferModel, SLOT(bufferUpdated(Buffer *))); + _networkModel, SLOT(bufferUpdated(Buffer *))); connect(this, SIGNAL(bufferActivity(Buffer::ActivityLevel, Buffer *)), - _bufferModel, SLOT(bufferActivity(Buffer::ActivityLevel, Buffer *))); + _networkModel, SLOT(bufferActivity(Buffer::ActivityLevel, Buffer *))); SignalProxy *p = signalProxy(); p->attachSignal(this, SIGNAL(sendSessionData(const QString &, const QVariant &)), @@ -263,7 +263,7 @@ void Client::coreSocketDisconnected() { blockSize = 0; /* Clear internal data. Hopefully nothing relies on it at this point. */ - _bufferModel->clear(); + _networkModel->clear(); QHash::iterator bufferIter = _buffers.begin(); while(bufferIter != _buffers.end()) { @@ -444,7 +444,7 @@ void Client::networkConnected(uint netid) { NetworkInfo *netinfo = new NetworkInfo(netid, this); netinfo->setProxy(signalProxy()); - bufferModel()->attachNetworkInfo(netinfo); + networkModel()->attachNetworkInfo(netinfo); if(!isConnected()) { connect(netinfo, SIGNAL(initDone()), this, SLOT(updateCoreConnectionProgress())); diff --git a/src/client/client.h b/src/client/client.h index d13001a4..cae4f9f8 100644 --- a/src/client/client.h +++ b/src/client/client.h @@ -35,7 +35,7 @@ class NetworkInfo; class AbstractUi; class AbstractUiMsg; -class BufferTreeModel; +class NetworkModel; class SignalProxy; class QTimer; @@ -59,7 +59,7 @@ public: static BufferInfo statusBufferInfo(QString net); static BufferInfo bufferInfo(QString net, QString buf); - static BufferTreeModel *bufferModel(); + static NetworkModel *networkModel(); static SignalProxy *signalProxy(); static AbstractUiMsg *layoutMsg(const Message &); @@ -146,7 +146,7 @@ private: QPointer socket; QPointer _signalProxy; QPointer mainUi; - QPointer _bufferModel; + QPointer _networkModel; ClientMode clientMode; diff --git a/src/client/treemodel.cpp b/src/client/treemodel.cpp index a2d1183b..19a68549 100644 --- a/src/client/treemodel.cpp +++ b/src/client/treemodel.cpp @@ -33,8 +33,15 @@ AbstractTreeItem::AbstractTreeItem(AbstractTreeItem *parent) } AbstractTreeItem::~AbstractTreeItem() { + AbstractTreeItem *child; foreach(int key, _childItems.keys()) { - qDeleteAll(_childItems[key]); + QList::iterator iter = _childItems[key].begin(); + while(iter != _childItems[key].end()) { + child = *iter; + iter = _childItems[key].erase(iter); + disconnect(child, 0, this, 0); + child->deleteLater(); + } } } @@ -75,6 +82,7 @@ void AbstractTreeItem::removeChild(int column, int row) { AbstractTreeItem *treeitem = _childItems[column].value(row); _childItems[column].removeAt(row); _childHash[column].remove(_childHash[column].key(treeitem)); + disconnect(treeitem, 0, this, 0); treeitem->deleteLater(); } @@ -122,10 +130,8 @@ int AbstractTreeItem::column() const { return -1; QHash >::const_iterator iter = _parentItem->_childItems.constBegin(); - int pos; while(iter != _parentItem->_childItems.constEnd()) { - pos = iter.value().indexOf(const_cast(this)); - if(pos != -1) + if(iter.value().contains(const_cast(this))) return iter.key(); iter++; } @@ -160,8 +166,26 @@ void AbstractTreeItem::childDestroyed() { qWarning() << "AbstractTreeItem::childDestroyed() received null pointer!"; return; } - _childItems[item->column()].removeAt(item->row()); - _childHash[item->column()].remove(_childHash[item->column()].key(item)); + + QHash >::const_iterator iter = _childItems.constBegin(); + int column, row = -1; + while(iter != _childItems.constEnd()) { + row = iter.value().indexOf(item); + if(row != -1) { + column = iter.key(); + break; + } + iter++; + } + + if(row == -1) { + qWarning() << "AbstractTreeItem::childDestroyed(): unknown Child died:" << item << "parent:" << this; + return; + } + + _childItems[column].removeAt(row); + _childHash[column].remove(_childHash[column].key(item)); + emit childDestroyed(row); } /***************************************** @@ -311,10 +335,23 @@ int TreeModel::rowCount(const QModelIndex &parent) const { } int TreeModel::columnCount(const QModelIndex &parent) const { - if(parent.isValid()) - return static_cast(parent.internalPointer())->columnCount(); - else - return rootItem->columnCount(); + Q_UNUSED(parent) + // since there the Qt Views don't draw more columns than the header has columns + // we can be lazy and simply return the count of header columns + // actually this gives us more freedom cause we don't have to ensure that a rows parent + // has equal or more columns than that row + +// if(parent.isValid()) { +// AbstractTreeItem *child; +// if(child = static_cast(parent.internalPointer())->child(parent.column(), parent.row())) +// return child->columnCount(); +// else +// return static_cast(parent.internalPointer())->columnCount(); +// } else { +// return rootItem->columnCount(); +// } + + return rootItem->columnCount(); } QVariant TreeModel::data(const QModelIndex &index, int role) const { @@ -355,7 +392,7 @@ void TreeModel::itemDataChanged(int column) { void TreeModel::appendChild(AbstractTreeItem *parent, AbstractTreeItem *child) { if(parent == 0 or child == 0) { - qWarning() << "TreeModel::apendChild(parent, child) parent and child have to be valid pointers!" << parent << child; + qWarning() << "TreeModel::appendChild(parent, child) parent and child have to be valid pointers!" << parent << child; return; } @@ -366,8 +403,23 @@ void TreeModel::appendChild(AbstractTreeItem *parent, AbstractTreeItem *child) { connect(child, SIGNAL(dataChanged(int)), this, SLOT(itemDataChanged(int))); + + connect(child, SIGNAL(newChild(AbstractTreeItem *)), + this, SLOT(newChild(AbstractTreeItem *))); + + connect(child, SIGNAL(childDestroyed(int)), + this, SLOT(childDestroyed(int))); } +void TreeModel::newChild(AbstractTreeItem *child) { + appendChild(static_cast(sender()), child); +} + +void TreeModel::childDestroyed(int row) { + QModelIndex parent = indexByItem(static_cast(sender())); + beginRemoveRows(parent, row, row); + endRemoveRows(); +} bool TreeModel::removeRow(int row, const QModelIndex &parent) { if(row > rowCount(parent)) diff --git a/src/client/treemodel.h b/src/client/treemodel.h index 0d23405a..351438a1 100644 --- a/src/client/treemodel.h +++ b/src/client/treemodel.h @@ -68,6 +68,8 @@ public: signals: void dataChanged(int column); + void newChild(AbstractTreeItem *); + void childDestroyed(int row); private slots: void childDestroyed(); @@ -147,6 +149,8 @@ public: private slots: void itemDataChanged(int column); + void newChild(AbstractTreeItem *child); + void childDestroyed(int row); protected: void appendChild(AbstractTreeItem *parent, AbstractTreeItem *child); diff --git a/src/core/core.pri b/src/core/core.pri index 13e537dc..4f020b9a 100644 --- a/src/core/core.pri +++ b/src/core/core.pri @@ -1,4 +1,4 @@ DEPMOD = common -QT_MOD = core network sql +QT_MOD = core network sql script SRCS = core.cpp coresession.cpp coresettings.cpp server.cpp sqlitestorage.cpp storage.cpp basichandler.cpp ircserverhandler.cpp userinputhandler.cpp ctcphandler.cpp HDRS = core.h coresession.h coresettings.h server.h sqlitestorage.h storage.h basichandler.h ircserverhandler.h userinputhandler.h ctcphandler.h diff --git a/src/core/coresession.cpp b/src/core/coresession.cpp index e8072894..426bcdc7 100644 --- a/src/core/coresession.cpp +++ b/src/core/coresession.cpp @@ -30,12 +30,14 @@ #include "util.h" +#include CoreSession::CoreSession(UserId uid, Storage *_storage, QObject *parent) : QObject(parent), user(uid), _signalProxy(new SignalProxy(SignalProxy::Server, 0, this)), - storage(_storage) + storage(_storage), + scriptEngine(new QScriptEngine(this)) { QSettings s; @@ -71,6 +73,7 @@ CoreSession::CoreSession(UserId uid, Storage *_storage, QObject *parent) if(list.count()) connectToIrc(list); */ + initScriptEngine(); } CoreSession::~CoreSession() { @@ -261,3 +264,17 @@ void CoreSession::sendBacklog(BufferInfo id, QVariant v1, QVariant v2) { } if(log.count() > 0) emit backlogData(id, log, true); } + + +void CoreSession::initScriptEngine() { + signalProxy()->attachSlot(SIGNAL(scriptRequest(QString)), this, SLOT(scriptRequest(QString))); + signalProxy()->attachSignal(this, SIGNAL(scriptResult(QString))); + + QScriptValue storage_ = scriptEngine->newQObject(storage); + scriptEngine->globalObject().setProperty("storage", storage_); +} + +void CoreSession::scriptRequest(QString script) { + emit scriptResult(scriptEngine->evaluate(script).toString()); +} + diff --git a/src/core/coresession.h b/src/core/coresession.h index ce64b090..33b09d77 100644 --- a/src/core/coresession.h +++ b/src/core/coresession.h @@ -31,6 +31,8 @@ class Server; class SignalProxy; class Storage; +class QScriptEngine; + class CoreSession : public QObject { Q_OBJECT @@ -83,13 +85,19 @@ signals: void sessionDataChanged(const QString &key); void sessionDataChanged(const QString &key, const QVariant &data); + void scriptResult(QString result); + private slots: void recvStatusMsgFromServer(QString msg); void recvMessageFromServer(Message::Type, QString target, QString text, QString sender = "", quint8 flags = Message::None); void serverConnected(uint networkid); void serverDisconnected(uint networkid); + void scriptRequest(QString script); + private: + void initScriptEngine(); + UserId user; SignalProxy *_signalProxy; @@ -98,6 +106,8 @@ private: QVariantMap sessionData; QMutex mutex; + + QScriptEngine *scriptEngine; }; #endif diff --git a/src/core/ircserverhandler.cpp b/src/core/ircserverhandler.cpp index ceb64980..9df74478 100644 --- a/src/core/ircserverhandler.cpp +++ b/src/core/ircserverhandler.cpp @@ -209,9 +209,9 @@ void IrcServerHandler::handleKick(QString prefix, QList params) { } void IrcServerHandler::handleMode(QString prefix, QList params) { - Q_UNUSED(prefix) - Q_UNUSED(params) - + if(networkInfo()->isChannelName(params[0])) { + } else { + } // if(isChannelName(params[0])) { // // TODO only channel-user modes supported by now // QString prefixes = serverSupports["PrefixModes"].toString(); diff --git a/src/core/sqlitestorage.h b/src/core/sqlitestorage.h index 40c23a6c..0ab46825 100644 --- a/src/core/sqlitestorage.h +++ b/src/core/sqlitestorage.h @@ -34,6 +34,7 @@ class SqliteStorage : public Storage { SqliteStorage(); virtual ~SqliteStorage(); + public slots: /* General */ static bool isAvailable(); diff --git a/src/core/storage.h b/src/core/storage.h index 66d4b20d..c049dc17 100644 --- a/src/core/storage.h +++ b/src/core/storage.h @@ -33,6 +33,7 @@ class Storage : public QObject { Storage() {}; virtual ~Storage() {}; + public slots: /* General */ //! Check if the storage type is available. diff --git a/src/qtui/debugconsole.cpp b/src/qtui/debugconsole.cpp new file mode 100644 index 00000000..c6be7bd2 --- /dev/null +++ b/src/qtui/debugconsole.cpp @@ -0,0 +1,46 @@ +/*************************************************************************** + * 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) 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 "debugconsole.h" +#include "client.h" +#include "signalproxy.h" + +DebugConsole::DebugConsole(QWidget *parent) + : QDialog(parent) +{ + ui.setupUi(this); + + Client::signalProxy()->attachSignal(this, SIGNAL(scriptRequest(QString))); + Client::signalProxy()->attachSlot(SIGNAL(scriptResult(QString)), this, SLOT(scriptResult(QString))); + +} + +DebugConsole::~DebugConsole() { +} + +void DebugConsole::on_evalButton_clicked() { + if(ui.selectCore->isChecked()) { + emit scriptRequest(ui.scriptEdit->toPlainText()); + } +} + +void DebugConsole::scriptResult(QString result) { + ui.resultLabel->setText(result); +} diff --git a/src/qtui/debugconsole.h b/src/qtui/debugconsole.h new file mode 100644 index 00000000..f443d64b --- /dev/null +++ b/src/qtui/debugconsole.h @@ -0,0 +1,46 @@ +/*************************************************************************** + * 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) 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 DEBUGCONSOLE_H +#define DEBUGCONSOLE_H + +#include "ui_debugconsole.h" + +class DebugConsole : public QDialog { + Q_OBJECT + +public: + DebugConsole(QWidget *parent = 0); + virtual ~DebugConsole(); + +public slots: + void scriptResult(QString result); + +signals: + void scriptRequest(QString script); + +private slots: + void on_evalButton_clicked(); + +private: + Ui::DebugConsole ui; +}; + +#endif diff --git a/src/qtui/mainwin.cpp b/src/qtui/mainwin.cpp index 0d4453d5..91cc9d30 100644 --- a/src/qtui/mainwin.cpp +++ b/src/qtui/mainwin.cpp @@ -36,6 +36,8 @@ #include "settingspages/fontssettingspage.h" +#include "debugconsole.h" + MainWin::MainWin(QtUi *_gui, QWidget *parent) : QMainWindow(parent), gui(_gui) { ui.setupUi(this); setWindowTitle("Quassel IRC"); @@ -46,7 +48,7 @@ MainWin::MainWin(QtUi *_gui, QWidget *parent) : QMainWindow(parent), gui(_gui) { statusBar()->showMessage(tr("Waiting for core...")); serverListDlg = new ServerListDlg(this); settingsDlg = new SettingsDlg(this); - + debugConsole = new DebugConsole(this); } void MainWin::init() { @@ -106,7 +108,8 @@ void MainWin::init() { setDockNestingEnabled(true); - // TESTING + // new Topic Stuff... should be probably refactored out into a separate method + setCorner(Qt::TopLeftCorner, Qt::LeftDockWidgetArea); setCorner(Qt::BottomLeftCorner, Qt::LeftDockWidgetArea); @@ -121,13 +124,15 @@ void MainWin::init() { TopicWidget *topicwidget = new TopicWidget(dock); dock->setWidget(topicwidget); - Client::bufferModel()->mapProperty(1, Qt::DisplayRole, topicwidget, "topic"); + Client::networkModel()->mapProperty(1, Qt::DisplayRole, topicwidget, "topic"); addDockWidget(Qt::TopDockWidgetArea, dock); ui.menuViews->addAction(dock->toggleViewAction()); //showSettingsDlg(); + + } MainWin::~MainWin() { @@ -153,13 +158,14 @@ void MainWin::setupMenus() { connect(ui.actionNetworkList, SIGNAL(triggered()), this, SLOT(showServerList())); connect(ui.actionEditIdentities, SIGNAL(triggered()), serverListDlg, SLOT(editIdentities())); connect(ui.actionSettingsDlg, SIGNAL(triggered()), this, SLOT(showSettingsDlg())); + connect(ui.actionDebug_Console, SIGNAL(triggered()), this, SLOT(showDebugConsole())); //ui.actionSettingsDlg->setEnabled(false); connect(ui.actionAboutQt, SIGNAL(triggered()), QApplication::instance(), SLOT(aboutQt())); } void MainWin::setupViews() { - BufferTreeModel *model = Client::bufferModel(); + NetworkModel *model = Client::networkModel(); connect(model, SIGNAL(bufferSelected(Buffer *)), this, SLOT(showBuffer(Buffer *))); addBufferView(tr("All Buffers"), model, BufferViewFilter::AllNets, QList()); @@ -180,7 +186,7 @@ void MainWin::addBufferView(const QString &viewname, QAbstractItemModel *model, //create the view and initialize it's filter BufferView *view = new BufferView(dock); view->setFilteredModel(model, mode, nets); - Client::bufferModel()->synchronizeView(view); + Client::networkModel()->synchronizeView(view); dock->setWidget(view); addDockWidget(Qt::LeftDockWidgetArea, dock); @@ -250,6 +256,10 @@ void MainWin::showSettingsDlg() { settingsDlg->show(); } +void MainWin::showDebugConsole() { + debugConsole->show(); +} + void MainWin::closeEvent(QCloseEvent *event) { //if (userReallyWantsToQuit()) { diff --git a/src/qtui/mainwin.h b/src/qtui/mainwin.h index 6263919b..0559b4e0 100644 --- a/src/qtui/mainwin.h +++ b/src/qtui/mainwin.h @@ -34,6 +34,8 @@ class QtUi; class Message; class NickListWidget; +class DebugConsole; + //!\brief The main window of Quassel's QtUi. class MainWin : public QMainWindow { Q_OBJECT @@ -58,6 +60,7 @@ class MainWin : public QMainWindow { void showServerList(); void showSettingsDlg(); + void showDebugConsole(); void showCoreConnectionDlg(bool autoConnect = false); void coreConnectionDlgFinished(int result); @@ -92,6 +95,7 @@ class MainWin : public QMainWindow { QDockWidget *nickDock; NickListWidget *nickListWidget; + DebugConsole *debugConsole; friend class QtUi; }; diff --git a/src/qtui/qtui.pri b/src/qtui/qtui.pri index c5aaab99..44df280e 100644 --- a/src/qtui/qtui.pri +++ b/src/qtui/qtui.pri @@ -4,15 +4,15 @@ QT_MOD = core gui network SRCS += bufferwidget.cpp chatline-old.cpp \ chatwidget.cpp coreconnectdlg.cpp configwizard.cpp \ guisettings.cpp identities.cpp mainwin.cpp nicklistwidget.cpp qtui.cpp qtuistyle.cpp serverlist.cpp settingsdlg.cpp \ - topicwidget.cpp + topicwidget.cpp debugconsole.cpp HDRS += bufferwidget.h chatline-old.h chatwidget.h configwizard.h \ coreconnectdlg.h guisettings.h identities.h mainwin.h nicklistwidget.h qtui.h qtuistyle.h serverlist.h settingsdlg.h \ - topicwidget.h + topicwidget.h debugconsole.h FORMNAMES = identitiesdlg.ui identitieseditdlg.ui networkeditdlg.ui mainwin.ui nickeditdlg.ui serverlistdlg.ui \ servereditdlg.ui coreconnectdlg.ui bufferviewwidget.ui bufferwidget.ui nicklistwidget.ui settingsdlg.ui \ - buffermgmtpage.ui connectionpage.ui usermgmtpage.ui topicwidget.ui + buffermgmtpage.ui connectionpage.ui usermgmtpage.ui topicwidget.ui debugconsole.ui for(ui, FORMNAMES) { FRMS += ui/$${ui} diff --git a/src/qtui/ui/debugconsole.ui b/src/qtui/ui/debugconsole.ui new file mode 100644 index 00000000..0abb8560 --- /dev/null +++ b/src/qtui/ui/debugconsole.ui @@ -0,0 +1,105 @@ + + DebugConsole + + + + 0 + 0 + 490 + 435 + + + + Debug Console + + + + 2 + + + 3 + + + 3 + + + 3 + + + 3 + + + + + 10 + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + local + + + false + + + + + + + core + + + true + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + + + + Evaluate! + + + + + + + + + + + + + + + diff --git a/src/qtui/ui/mainwin.ui b/src/qtui/ui/mainwin.ui index e96cbb66..4a92932f 100644 --- a/src/qtui/ui/mainwin.ui +++ b/src/qtui/ui/mainwin.ui @@ -46,7 +46,7 @@ 0 0 800 - 28 + 22 @@ -96,6 +96,7 @@ Debug + @@ -106,8 +107,8 @@ - + @@ -230,6 +231,11 @@ Connect to Core... + + + Debug &Console + + diff --git a/src/uisupport/bufferviewfilter.cpp b/src/uisupport/bufferviewfilter.cpp index 4f9f7675..9f0d4a1a 100644 --- a/src/uisupport/bufferviewfilter.cpp +++ b/src/uisupport/bufferviewfilter.cpp @@ -58,10 +58,10 @@ bool BufferViewFilter::dropMimeData(const QMimeData *data, Qt::DropAction action if(parent != QModelIndex()) return QSortFilterProxyModel::dropMimeData(data, action, row, column, parent); - if(!BufferTreeModel::mimeContainsBufferList(data)) + if(!NetworkModel::mimeContainsBufferList(data)) return false; - QList< QPair > bufferList = BufferTreeModel::mimeDataToBufferList(data); + QList< QPair > bufferList = NetworkModel::mimeDataToBufferList(data); uint netId, bufferId; for(int i = 0; i < bufferList.count(); i++) { @@ -90,8 +90,8 @@ void BufferViewFilter::removeBuffer(const QModelIndex &index) { return; // only child elements can be deleted bool lastBuffer = (rowCount(index.parent()) == 1); - uint netId = index.data(BufferTreeModel::NetworkIdRole).toUInt(); - uint bufferuid = index.data(BufferTreeModel::BufferUidRole).toUInt(); + uint netId = index.data(NetworkModel::NetworkIdRole).toUInt(); + uint bufferuid = index.data(NetworkModel::BufferUidRole).toUInt(); if(buffers.contains(bufferuid)) { buffers.remove(bufferuid); @@ -108,7 +108,7 @@ void BufferViewFilter::removeBuffer(const QModelIndex &index) { bool BufferViewFilter::filterAcceptBuffer(const QModelIndex &source_bufferIndex) const { - Buffer::Type bufferType = (Buffer::Type) source_bufferIndex.data(BufferTreeModel::BufferTypeRole).toInt(); + Buffer::Type bufferType = (Buffer::Type) source_bufferIndex.data(NetworkModel::BufferTypeRole).toInt(); if((mode & NoChannels) && bufferType == Buffer::ChannelType) return false; @@ -117,14 +117,14 @@ bool BufferViewFilter::filterAcceptBuffer(const QModelIndex &source_bufferIndex) if((mode & NoServers) && bufferType == Buffer::StatusType) return false; -// bool isActive = source_bufferIndex.data(BufferTreeModel::BufferActiveRole).toBool(); +// bool isActive = source_bufferIndex.data(NetworkModel::BufferActiveRole).toBool(); // if((mode & NoActive) && isActive) // return false; // if((mode & NoInactive) && !isActive) // return false; if((mode & FullCustom)) { - uint bufferuid = source_bufferIndex.data(BufferTreeModel::BufferUidRole).toUInt(); + uint bufferuid = source_bufferIndex.data(NetworkModel::BufferUidRole).toUInt(); return buffers.contains(bufferuid); } @@ -132,7 +132,7 @@ bool BufferViewFilter::filterAcceptBuffer(const QModelIndex &source_bufferIndex) } bool BufferViewFilter::filterAcceptNetwork(const QModelIndex &source_index) const { - uint net = source_index.data(BufferTreeModel::NetworkIdRole).toUInt(); + uint net = source_index.data(NetworkModel::NetworkIdRole).toUInt(); return !((mode & (SomeNets | FullCustom)) && !networks.contains(net)); } @@ -151,8 +151,8 @@ bool BufferViewFilter::filterAcceptsRow(int source_row, const QModelIndex &sourc } bool BufferViewFilter::lessThan(const QModelIndex &left, const QModelIndex &right) const { - int lefttype = left.data(BufferTreeModel::BufferTypeRole).toInt(); - int righttype = right.data(BufferTreeModel::BufferTypeRole).toInt(); + int lefttype = left.data(NetworkModel::BufferTypeRole).toInt(); + int righttype = right.data(NetworkModel::BufferTypeRole).toInt(); if(lefttype != righttype) return lefttype < righttype; -- 2.20.1