Since we're going for one grand unified model to store all the stuff
authorMarcus Eggenberger <egs@quassel-irc.org>
Tue, 1 Jan 2008 16:58:42 +0000 (16:58 +0000)
committerMarcus Eggenberger <egs@quassel-irc.org>
Tue, 1 Jan 2008 16:58:42 +0000 (16:58 +0000)
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

23 files changed:
build/targets/core.pri
build/targets/monolithic.pri
build/targets/qtclient.pri
src/client/buffertreemodel.cpp
src/client/buffertreemodel.h
src/client/client.cpp
src/client/client.h
src/client/treemodel.cpp
src/client/treemodel.h
src/core/core.pri
src/core/coresession.cpp
src/core/coresession.h
src/core/ircserverhandler.cpp
src/core/sqlitestorage.h
src/core/storage.h
src/qtui/debugconsole.cpp [new file with mode: 0644]
src/qtui/debugconsole.h [new file with mode: 0644]
src/qtui/mainwin.cpp
src/qtui/mainwin.h
src/qtui/qtui.pri
src/qtui/ui/debugconsole.ui [new file with mode: 0644]
src/qtui/ui/mainwin.ui
src/uisupport/bufferviewfilter.cpp

index 464e839..78d0811 100644 (file)
@@ -5,4 +5,4 @@ MODULES = core common
 DEFINES = BUILD_CORE
 
 QT -= gui
-QT += network sql
+QT += network sql script
index 4d8ba4d..de74d3d 100644 (file)
@@ -4,4 +4,4 @@ TARGET  = quassel
 MODULES = core qtui uisupport client common
 DEFINES = BUILD_MONO
 
-QT += network sql
+QT += network sql script
index 5307916..451337b 100644 (file)
@@ -4,4 +4,4 @@ TARGET  = quasselclient
 MODULES = qtui uisupport client common
 DEFINES = BUILD_QTUI
 
-QT += network
+QT += network script
index e0039c8..865c4a4 100644 (file)
@@ -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<QString>() << "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<BufferTreeItem *>(child(i));
+    bufferItem = qobject_cast<BufferItem *>(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<BufferTreeItem *>(child(i));
+    bufferItem = qobject_cast<BufferItem *>(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)));
 }
 
-QList<QVariant >BufferTreeModel::defaultHeader() {
+QList<QVariant >NetworkModel::defaultHeader() {
   QList<QVariant> 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<BufferTreeItem *>(index.internalPointer());
+Buffer *NetworkModel::getBufferByIndex(const QModelIndex &index) const {
+  BufferItem *item = static_cast<BufferItem *>(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<NetworkTreeItem *>(rootItem->childById(networkId));
+NetworkItem *NetworkModel::network(uint networkId) {
+  return qobject_cast<NetworkItem *>(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<BufferTreeItem *>(bufferIdx.internalPointer());
+    return static_cast<BufferItem *>(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<uint, uint> > BufferTreeModel::mimeDataToBufferList(const QMimeData *mimeData) {
+QList< QPair<uint, uint> > NetworkModel::mimeDataToBufferList(const QMimeData *mimeData) {
   QList< QPair<uint, uint> > bufferList;
 
   if(!mimeContainsBufferList(mimeData))
@@ -367,7 +395,7 @@ QList< QPair<uint, uint> > 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!
index f2e118e..56fcc91 100644 (file)
@@ -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 <QtCore>
 
@@ -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<QVariant> 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> _selectionModelSynchronizer;
   QPointer<ModelPropertyMapper> _propertyMapper;
   Buffer *currentBuffer;
 };
 
-#endif
+#endif // NETWORKMODEL_H
index e78fc17..f42e2a4 100644 (file)
@@ -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<uint, Buffer *>::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()));
index d13001a..cae4f9f 100644 (file)
@@ -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<QIODevice> socket;
   QPointer<SignalProxy> _signalProxy;
   QPointer<AbstractUi> mainUi;
-  QPointer<BufferTreeModel> _bufferModel;
+  QPointer<NetworkModel> _networkModel;
 
   ClientMode clientMode;
 
index a2d1183..19a6854 100644 (file)
@@ -33,8 +33,15 @@ AbstractTreeItem::AbstractTreeItem(AbstractTreeItem *parent)
 }
 
 AbstractTreeItem::~AbstractTreeItem() {
+  AbstractTreeItem *child;
   foreach(int key, _childItems.keys()) {
-    qDeleteAll(_childItems[key]);
+    QList<AbstractTreeItem *>::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<int, QList<AbstractTreeItem*> >::const_iterator iter = _parentItem->_childItems.constBegin();
-  int pos;
   while(iter != _parentItem->_childItems.constEnd()) {
-    pos = iter.value().indexOf(const_cast<AbstractTreeItem *>(this));
-    if(pos != -1)
+    if(iter.value().contains(const_cast<AbstractTreeItem *>(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<int, QList<AbstractTreeItem*> >::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<AbstractTreeItem*>(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<AbstractTreeItem *>(parent.internalPointer())->child(parent.column(), parent.row()))
+//       return child->columnCount();
+//     else
+//       return static_cast<AbstractTreeItem*>(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<AbstractTreeItem *>(sender()), child);
+}
+
+void TreeModel::childDestroyed(int row) {
+  QModelIndex parent = indexByItem(static_cast<AbstractTreeItem *>(sender()));
+  beginRemoveRows(parent, row, row);
+  endRemoveRows();
+}
 
 bool TreeModel::removeRow(int row, const QModelIndex &parent) {
   if(row > rowCount(parent))
index 0d23405..351438a 100644 (file)
@@ -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);
index 13e537d..4f020b9 100644 (file)
@@ -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 
index e807289..426bcdc 100644 (file)
 
 #include "util.h"
 
+#include <QtScript>
 
 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());
+}
+  
index ce64b09..33b09d7 100644 (file)
@@ -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
index ceb6498..9df7447 100644 (file)
@@ -209,9 +209,9 @@ void IrcServerHandler::handleKick(QString prefix, QList<QByteArray> params) {
 }
 
 void IrcServerHandler::handleMode(QString prefix, QList<QByteArray> 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();
index 40c23a6..0ab4682 100644 (file)
@@ -34,6 +34,7 @@ class SqliteStorage : public Storage {
     SqliteStorage();
     virtual ~SqliteStorage();
 
+  public slots:
     /* General */
 
     static bool isAvailable();
index 66d4b20..c049dc1 100644 (file)
@@ -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 (file)
index 0000000..c6be7bd
--- /dev/null
@@ -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 (file)
index 0000000..f443d64
--- /dev/null
@@ -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
index 0d4453d..91cc9d3 100644 (file)
@@ -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<uint>());
@@ -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()) {
index 6263919..0559b4e 100644 (file)
@@ -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;
 };
 
index c5aaab9..44df280 100644 (file)
@@ -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 (file)
index 0000000..0abb856
--- /dev/null
@@ -0,0 +1,105 @@
+<ui version="4.0" >
+ <class>DebugConsole</class>
+ <widget class="QDialog" name="DebugConsole" >
+  <property name="geometry" >
+   <rect>
+    <x>0</x>
+    <y>0</y>
+    <width>490</width>
+    <height>435</height>
+   </rect>
+  </property>
+  <property name="windowTitle" >
+   <string>Debug Console</string>
+  </property>
+  <layout class="QVBoxLayout" >
+   <property name="spacing" >
+    <number>2</number>
+   </property>
+   <property name="leftMargin" >
+    <number>3</number>
+   </property>
+   <property name="topMargin" >
+    <number>3</number>
+   </property>
+   <property name="rightMargin" >
+    <number>3</number>
+   </property>
+   <property name="bottomMargin" >
+    <number>3</number>
+   </property>
+   <item>
+    <layout class="QHBoxLayout" >
+     <property name="spacing" >
+      <number>10</number>
+     </property>
+     <item>
+      <spacer>
+       <property name="orientation" >
+        <enum>Qt::Horizontal</enum>
+       </property>
+       <property name="sizeHint" >
+        <size>
+         <width>40</width>
+         <height>20</height>
+        </size>
+       </property>
+      </spacer>
+     </item>
+     <item>
+      <widget class="QRadioButton" name="selectLocal" >
+       <property name="text" >
+        <string>local</string>
+       </property>
+       <property name="checked" >
+        <bool>false</bool>
+       </property>
+      </widget>
+     </item>
+     <item>
+      <widget class="QRadioButton" name="selectCore" >
+       <property name="text" >
+        <string>core</string>
+       </property>
+       <property name="checked" >
+        <bool>true</bool>
+       </property>
+      </widget>
+     </item>
+     <item>
+      <spacer>
+       <property name="orientation" >
+        <enum>Qt::Horizontal</enum>
+       </property>
+       <property name="sizeHint" >
+        <size>
+         <width>40</width>
+         <height>20</height>
+        </size>
+       </property>
+      </spacer>
+     </item>
+    </layout>
+   </item>
+   <item>
+    <widget class="QTextEdit" name="scriptEdit" />
+   </item>
+   <item>
+    <widget class="QPushButton" name="evalButton" >
+     <property name="text" >
+      <string>Evaluate!</string>
+     </property>
+    </widget>
+   </item>
+   <item>
+    <widget class="QLabel" name="resultLabel" >
+     <property name="text" >
+      <string/>
+     </property>
+    </widget>
+   </item>
+  </layout>
+ </widget>
+ <resources/>
+ <connections/>
+</ui>
index e96cbb6..4a92932 100644 (file)
@@ -46,7 +46,7 @@
      <x>0</x>
      <y>0</y>
      <width>800</width>
-     <height>28</height>
+     <height>22</height>
     </rect>
    </property>
    <widget class="QMenu" name="menuConnection" >
@@ -96,6 +96,7 @@
     <property name="title" >
      <string>Debug</string>
     </property>
+    <addaction name="actionDebug_Console" />
    </widget>
    <widget class="QMenu" name="menuCore" >
     <property name="title" >
    <addaction name="menuViews" />
    <addaction name="menuCore" />
    <addaction name="menuSettings" />
-   <addaction name="menuHelp" />
    <addaction name="menuDebug" />
+   <addaction name="menuHelp" />
   </widget>
   <widget class="QStatusBar" name="statusbar" />
   <action name="actionNetworkList" >
     <string>Connect to Core...</string>
    </property>
   </action>
+  <action name="actionDebug_Console" >
+   <property name="text" >
+    <string>Debug &amp;Console</string>
+   </property>
+  </action>
  </widget>
  <customwidgets>
   <customwidget>
index 4f9f767..9f0d4a1 100644 (file)
@@ -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<uint, uint> > bufferList = BufferTreeModel::mimeDataToBufferList(data);
+  QList< QPair<uint, uint> > 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;