first version of core info dialog
authorMarcus Eggenberger <egs@quassel-irc.org>
Wed, 16 Jul 2008 22:07:49 +0000 (00:07 +0200)
committerMarcus Eggenberger <egs@quassel-irc.org>
Wed, 16 Jul 2008 22:07:59 +0000 (00:07 +0200)
19 files changed:
src/client/CMakeLists.txt
src/client/clientcoreinfo.h [new file with mode: 0644]
src/common/CMakeLists.txt
src/common/coreinfo.h [new file with mode: 0644]
src/common/signalproxy.h
src/core/CMakeLists.txt
src/core/core.cpp
src/core/core.h
src/core/corecoreinfo.cpp [new file with mode: 0644]
src/core/corecoreinfo.h [new file with mode: 0644]
src/core/coresession.cpp
src/core/coresession.h
src/qtui/CMakeLists.txt
src/qtui/coreinfodlg.cpp [new file with mode: 0644]
src/qtui/coreinfodlg.h [new file with mode: 0644]
src/qtui/mainwin.cpp
src/qtui/mainwin.h
src/qtui/ui/coreinfodlg.ui [new file with mode: 0644]
src/qtui/ui/mainwin.ui

index 6877a0b..5f4baeb 100644 (file)
@@ -25,6 +25,7 @@ set(MOC_HDRS
     buffermodel.h
     client.h
     clientbacklogmanager.h
+    clientcoreinfo.h
     clientirclisthelper.h
     clientsyncer.h
     irclistmodel.h
diff --git a/src/client/clientcoreinfo.h b/src/client/clientcoreinfo.h
new file mode 100644 (file)
index 0000000..7846039
--- /dev/null
@@ -0,0 +1,47 @@
+/***************************************************************************
+ *   Copyright (C) 2005-08 by the Quassel Project                          *
+ *   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 CLIENTCOREINFO_H
+#define CLIENTCOREINFO_H
+
+#include "coreinfo.h"
+
+/*
+ * Yes this name is somewhat stupid... but it fits the general naming scheme
+ * which is prefixing client specific sync objects with "Client"... ;)
+ */ 
+class ClientCoreInfo : public CoreInfo {
+  Q_OBJECT
+
+public:
+  ClientCoreInfo(QObject *parent = 0) : CoreInfo(parent) {}
+
+  inline virtual const QMetaObject *syncMetaObject() const { return &CoreInfo::staticMetaObject; }
+
+  inline QVariant &operator[](const QString &key) { return _coreData[key]; }
+
+public slots:
+  inline virtual void setCoreData(const QVariantMap &data) { _coreData = data; }
+
+private:
+  QVariantMap _coreData;
+};
+
+#endif //CLIENTCOREINFO_H
index f725398..880ccc9 100644 (file)
@@ -27,6 +27,7 @@ set(MOC_HDRS
     buffersyncer.h
     bufferviewconfig.h
     bufferviewmanager.h
+    coreinfo.h
     identity.h
     ircchannel.h
     irclisthelper.h
diff --git a/src/common/coreinfo.h b/src/common/coreinfo.h
new file mode 100644 (file)
index 0000000..e7b9244
--- /dev/null
@@ -0,0 +1,43 @@
+/***************************************************************************
+ *   Copyright (C) 2005-08 by the Quassel Project                          *
+ *   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 COREINFO_H
+#define COREINFO_H
+
+#include "syncableobject.h"
+
+/*
+ * gather various informations about the core.
+ */
+
+class CoreInfo : public SyncableObject {
+  Q_OBJECT
+
+  Q_PROPERTY(QVariantMap coreData READ coreData WRITE setCoreData STORED false)
+
+public:
+  CoreInfo(QObject *parent = 0) : SyncableObject(parent) {}
+
+public slots:
+  virtual inline QVariantMap coreData() const { return QVariantMap(); }
+  virtual inline void setCoreData(const QVariantMap &) {}
+};
+
+#endif //COREINFO_H
index 15acc88..b39e7ca 100644 (file)
@@ -160,6 +160,7 @@ private:
 
 public:
   void dumpSyncMap(SyncableObject *object);
+  inline int peerCount() const { return _peers.size(); }
   
 private:
   // Hash of used QIODevices
index c80336c..a7bbbd2 100644 (file)
@@ -13,6 +13,7 @@ set(SOURCES
     corebacklogmanager.cpp
     corebufferviewconfig.cpp
     corebufferviewmanager.cpp
+    corecoreinfo.cpp
     coreirclisthelper.cpp
     corenetwork.cpp
     coresession.cpp
@@ -33,6 +34,7 @@ set(MOC_HDRS
     corebacklogmanager.h
     corebufferviewconfig.h
     corebufferviewmanager.h
+    corecoreinfo.h
     coreirclisthelper.h
     corenetwork.h
     coresession.h
index 0f652d0..f4fadd4 100644 (file)
@@ -48,7 +48,7 @@ void Core::destroy() {
 }
 
 Core::Core() : storage(0) {
-  startTime = QDateTime::currentDateTime();  // for uptime :)
+  _startTime = QDateTime::currentDateTime();  // for uptime :)
 
   // Register storage backends here!
   registerStorageBackend(new SqliteStorage(this));
@@ -423,14 +423,14 @@ void Core::processClientMessage(QTcpSocket *socket, const QVariantMap &msg) {
     reply["CoreBuild"] = 860; // FIXME legacy
     reply["ProtocolVersion"] = Global::protocolVersion;
     // TODO: Make the core info configurable
-    int uptime = startTime.secsTo(QDateTime::currentDateTime());
+    int uptime = startTime().secsTo(QDateTime::currentDateTime());
     int updays = uptime / 86400; uptime %= 86400;
     int uphours = uptime / 3600; uptime %= 3600;
     int upmins = uptime / 60;
     reply["CoreInfo"] = tr("<b>Quassel Core Version %1</b><br>"
-                            "Built: %2<br>"
-                            "Up %3d%4h%5m (since %6)").arg(Global::quasselVersion).arg(Global::quasselBuildDate)
-                            .arg(updays).arg(uphours,2,10,QChar('0')).arg(upmins,2,10,QChar('0')).arg(startTime.toString(Qt::TextDate));
+                          "Built: %2<br>"
+                          "Up %3d%4h%5m (since %6)").arg(Global::quasselVersion).arg(Global::quasselBuildDate)
+      .arg(updays).arg(uphours,2,10,QChar('0')).arg(upmins,2,10,QChar('0')).arg(startTime().toString(Qt::TextDate));
 
 #ifndef QT_NO_OPENSSL
     SslServer *sslServer = qobject_cast<SslServer *>(&server);
index 1288ae0..e6da7ab 100644 (file)
@@ -282,6 +282,8 @@ class Core : public QObject {
      */
     static QHash<BufferId, MsgId> bufferLastSeenMsgIds(UserId user);
 
+  const QDateTime &startTime() const { return _startTime; }
+
   public slots:
     //! Make storage data persistent
     /** \note This method is threadsafe.
@@ -336,7 +338,7 @@ class Core : public QObject {
 
     QHash<QString, Storage *> _storageBackends;
 
-    QDateTime startTime;
+    QDateTime _startTime;
 
     bool configured;
 
diff --git a/src/core/corecoreinfo.cpp b/src/core/corecoreinfo.cpp
new file mode 100644 (file)
index 0000000..495de45
--- /dev/null
@@ -0,0 +1,41 @@
+/***************************************************************************
+ *   Copyright (C) 2005-08 by the Quassel Project                          *
+ *   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 "corecoreinfo.h"
+
+#include "core.h"
+#include "coresession.h"
+#include "global.h"
+#include "signalproxy.h"
+
+CoreCoreInfo::CoreCoreInfo(CoreSession *parent)
+  : CoreInfo(parent),
+    _coreSession(parent)
+{
+}
+
+QVariantMap CoreCoreInfo::coreData() const {
+  QVariantMap data;
+  data["quasselVersion"] = Global::quasselVersion;
+  data["quasselBuildDate"] = Global::quasselBuildDate;
+  data["startTime"] = Core::instance()->startTime();
+  data["sessionConnectedClients"] = _coreSession->signalProxy()->peerCount();
+  return data;
+}
diff --git a/src/core/corecoreinfo.h b/src/core/corecoreinfo.h
new file mode 100644 (file)
index 0000000..e3eecd8
--- /dev/null
@@ -0,0 +1,47 @@
+/***************************************************************************
+ *   Copyright (C) 2005-08 by the Quassel Project                          *
+ *   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 CORECOREINFO_H
+#define CORECOREINFO_H
+
+#include "coreinfo.h"
+
+class CoreSession;
+
+/*
+ * Yes this name is somewhat stupid... but it fits the general naming scheme
+ * which is prefixing core specific sync objects with "Core"... ;)
+ */ 
+class CoreCoreInfo : public CoreInfo {
+  Q_OBJECT
+
+public:
+  CoreCoreInfo(CoreSession *parent);
+
+  inline virtual const QMetaObject *syncMetaObject() const { return &CoreInfo::staticMetaObject; }
+
+public slots:
+  virtual QVariantMap coreData() const;
+
+private:
+  CoreSession *_coreSession;
+};
+
+#endif //CORECOREINFO_H
index bbb78b3..2956d88 100644 (file)
@@ -48,6 +48,7 @@ CoreSession::CoreSession(UserId uid, bool restoreState, QObject *parent)
     _backlogManager(new CoreBacklogManager(this)),
     _bufferViewManager(new CoreBufferViewManager(_signalProxy, this)),
     _ircListHelper(new CoreIrcListHelper(this)),
+    _coreInfo(this),
     scriptEngine(new QScriptEngine(this))
 {
 
@@ -93,6 +94,9 @@ CoreSession::CoreSession(UserId uid, bool restoreState, QObject *parent)
   // init IrcListHelper;
   p->synchronize(ircListHelper());
   
+  // init CoreInfo;
+  p->synchronize(&_coreInfo);
+  
   // Restore session state
   if(restoreState) restoreSessionState();
 
index 737e15c..7144fe2 100644 (file)
@@ -24,6 +24,7 @@
 #include <QString>
 #include <QVariant>
 
+#include "corecoreinfo.h"
 #include "message.h"
 
 class BufferSyncer;
@@ -189,6 +190,7 @@ private:
   CoreBacklogManager *_backlogManager;
   CoreBufferViewManager *_bufferViewManager;
   CoreIrcListHelper *_ircListHelper;
+  CoreCoreInfo _coreInfo;
 
   QScriptEngine *scriptEngine;
 
index 1bb30fe..e7525bf 100644 (file)
@@ -10,6 +10,7 @@ set(SOURCES
     channellistdlg.cpp
     coreconfigwizard.cpp
     coreconnectdlg.cpp
+    coreinfodlg.cpp
     debugconsole.cpp
     inputwidget.cpp
     jumpkeyhandler.cpp
@@ -31,6 +32,7 @@ set(MOC_HDRS
     channellistdlg.h
     coreconfigwizard.h
     coreconnectdlg.h
+    coreinfodlg.h
     debugconsole.h
     inputwidget.h
     jumpkeyhandler.h
@@ -69,6 +71,7 @@ set(FORMS
     coreconfigwizardstorageselectionpage.ui
     coreconfigwizardsyncpage.ui
     coreconnectdlg.ui
+    coreinfodlg.ui
     debugconsole.ui
     inputwidget.ui
     mainwin.ui
diff --git a/src/qtui/coreinfodlg.cpp b/src/qtui/coreinfodlg.cpp
new file mode 100644 (file)
index 0000000..29e6048
--- /dev/null
@@ -0,0 +1,40 @@
+/***************************************************************************
+ *   Copyright (C) 2005-08 by the Quassel Project                          *
+ *   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 "coreinfodlg.h"
+
+#include "client.h"
+#include "signalproxy.h"
+
+CoreInfoDlg::CoreInfoDlg(QWidget *parent)
+  : QDialog(parent),
+    _coreInfo(this)
+{
+  ui.setupUi(this);
+  connect(&_coreInfo, SIGNAL(initDone()), this, SLOT(coreInfoAvailable()));
+  Client::signalProxy()->synchronize(&_coreInfo);
+}
+
+void CoreInfoDlg::coreInfoAvailable() {
+  ui.labelCoreVersion->setText(_coreInfo["quasselVersion"].toString());
+  ui.labelUptime->setText(_coreInfo["startTime"].toString());
+  ui.labelClientCount->setNum(_coreInfo["sessionConnectedClients"].toInt());
+  // data["quasselBuildDate"] = Global::quasselBuildDate;
+}
diff --git a/src/qtui/coreinfodlg.h b/src/qtui/coreinfodlg.h
new file mode 100644 (file)
index 0000000..f9698aa
--- /dev/null
@@ -0,0 +1,43 @@
+/***************************************************************************
+ *   Copyright (C) 2005-08 by the Quassel Project                          *
+ *   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 COREINFODLG_H
+#define COREINFODLG_H
+
+#include "ui_coreinfodlg.h"
+#include <QDialog>
+
+#include "clientcoreinfo.h";
+
+class CoreInfoDlg : public QDialog {
+  Q_OBJECT
+
+public:
+  CoreInfoDlg(QWidget *parent = 0);
+
+public slots:
+  void coreInfoAvailable();
+
+private:
+  Ui::CoreInfoDlg ui;
+  ClientCoreInfo _coreInfo;
+};
+
+#endif //COREINFODLG_H
index bf806b7..e3dece2 100644 (file)
@@ -28,6 +28,7 @@
 #include "channellistdlg.h"
 #include "client.h"
 #include "clientbacklogmanager.h"
+#include "coreinfodlg.h"
 #include "coreconnectdlg.h"
 #include "networkmodel.h"
 #include "buffermodel.h"
@@ -162,6 +163,7 @@ MainWin::~MainWin() {
 void MainWin::setupMenus() {
   connect(ui.actionConnectCore, SIGNAL(triggered()), this, SLOT(showCoreConnectionDlg()));
   connect(ui.actionDisconnectCore, SIGNAL(triggered()), Client::instance(), SLOT(disconnectFromCore()));
+  connect(ui.actionCoreInfo, SIGNAL(triggered()), this, SLOT(showCoreInfoDlg()));
   connect(ui.actionQuit, SIGNAL(triggered()), QCoreApplication::instance(), SLOT(quit()));
   connect(ui.actionSettingsDlg, SIGNAL(triggered()), this, SLOT(showSettingsDlg()));
   // connect(ui.actionDebug_Console, SIGNAL(triggered()), this, SLOT(showDebugConsole()));
@@ -494,6 +496,11 @@ void MainWin::showChannelList(NetworkId netId) {
   channelListDlg->show();
 }
 
+void MainWin::showCoreInfoDlg() {
+  CoreInfoDlg dlg(this);
+  dlg.exec();
+}
+
 void MainWin::showSettingsDlg() {
   settingsDlg->show();
 }
index 721cc3e..1c5521e 100644 (file)
@@ -77,6 +77,7 @@ class MainWin : public QMainWindow {
     void removeBufferView(int bufferViewConfigId);
     void receiveMessage(const Message &msg);
     void showChannelList(NetworkId netId = NetworkId());
+    void showCoreInfoDlg();
     void showSettingsDlg();
     void on_actionEditNetworks_triggered();
     void on_actionManageViews_triggered();
diff --git a/src/qtui/ui/coreinfodlg.ui b/src/qtui/ui/coreinfodlg.ui
new file mode 100644 (file)
index 0000000..45fa14d
--- /dev/null
@@ -0,0 +1,79 @@
+<ui version="4.0" >
+ <class>CoreInfoDlg</class>
+ <widget class="QDialog" name="CoreInfoDlg" >
+  <property name="geometry" >
+   <rect>
+    <x>0</x>
+    <y>0</y>
+    <width>284</width>
+    <height>137</height>
+   </rect>
+  </property>
+  <property name="windowTitle" >
+   <string>Core Information</string>
+  </property>
+  <layout class="QVBoxLayout" name="verticalLayout" >
+   <item>
+    <layout class="QGridLayout" name="gridLayout" >
+     <item row="0" column="0" >
+      <widget class="QLabel" name="label_2" >
+       <property name="text" >
+        <string>Version:</string>
+       </property>
+      </widget>
+     </item>
+     <item row="0" column="1" >
+      <widget class="QLabel" name="labelCoreVersion" >
+       <property name="text" >
+        <string>&lt;core version></string>
+       </property>
+      </widget>
+     </item>
+     <item row="1" column="0" >
+      <widget class="QLabel" name="label_4" >
+       <property name="text" >
+        <string>Uptime:</string>
+       </property>
+      </widget>
+     </item>
+     <item row="2" column="0" >
+      <widget class="QLabel" name="label_3" >
+       <property name="text" >
+        <string>Connected Clients:</string>
+       </property>
+      </widget>
+     </item>
+     <item row="2" column="1" >
+      <widget class="QLabel" name="labelClientCount" >
+       <property name="text" >
+        <string>&lt;connected clients></string>
+       </property>
+      </widget>
+     </item>
+     <item row="1" column="1" >
+      <widget class="QLabel" name="labelUptime" >
+       <property name="text" >
+        <string>&lt;core uptime></string>
+       </property>
+      </widget>
+     </item>
+    </layout>
+   </item>
+   <item>
+    <spacer name="verticalSpacer" >
+     <property name="orientation" >
+      <enum>Qt::Vertical</enum>
+     </property>
+     <property name="sizeHint" stdset="0" >
+      <size>
+       <width>20</width>
+       <height>28</height>
+      </size>
+     </property>
+    </spacer>
+   </item>
+  </layout>
+ </widget>
+ <resources/>
+ <connections/>
+</ui>
index 6fd7abd..9b77edf 100644 (file)
@@ -58,6 +58,7 @@
     </widget>
     <addaction name="actionConnectCore" />
     <addaction name="actionDisconnectCore" />
+    <addaction name="actionCoreInfo" />
     <addaction name="separator" />
     <addaction name="menuNetworks" />
     <addaction name="actionJoinChannel" />
     <string>Edit &amp;Networks...</string>
    </property>
   </action>
+  <action name="actionCoreInfo" >
+   <property name="icon" >
+    <iconset resource="../../icons/icons.qrc" >
+     <normaloff>:/16x16/actions/oxygen/16x16/actions/help-about.png</normaloff>:/16x16/actions/oxygen/16x16/actions/help-about.png</iconset>
+   </property>
+   <property name="text" >
+    <string>Core Info</string>
+   </property>
+  </action>
  </widget>
  <customwidgets>
   <customwidget>