Fixing BR #128 (Nicklist state not saved correctly) and ci of my current work.
authorMarcus Eggenberger <egs@quassel-irc.org>
Thu, 27 Mar 2008 17:06:14 +0000 (17:06 +0000)
committerMarcus Eggenberger <egs@quassel-irc.org>
Thu, 27 Mar 2008 17:06:14 +0000 (17:06 +0000)
29 files changed:
src/client/client.cpp
src/client/client.h
src/common/bufferviewconfig.cpp [new file with mode: 0644]
src/common/bufferviewconfig.h [new file with mode: 0644]
src/common/bufferviewmanager.cpp [new file with mode: 0644]
src/common/bufferviewmanager.h [new file with mode: 0644]
src/common/common.pri
src/core/core.pri
src/core/corebufferviewconfig.cpp [new file with mode: 0644]
src/core/corebufferviewconfig.h [new file with mode: 0644]
src/core/corebufferviewmanager.cpp [new file with mode: 0644]
src/core/corebufferviewmanager.h [new file with mode: 0644]
src/core/coresession.cpp
src/core/coresession.h
src/qtui/mainwin.cpp
src/qtui/mainwin.h
src/qtui/nicklistdock.cpp [new file with mode: 0644]
src/qtui/nicklistdock.h [new file with mode: 0644]
src/qtui/nicklistwidget.cpp
src/qtui/nicklistwidget.h
src/qtui/qtui.pri
src/qtui/settingsdlg.cpp
src/qtui/settingsdlg.h
src/qtui/settingspages/buffervieweditdlg.ui [new file with mode: 0644]
src/qtui/settingspages/bufferviewsettingspage.cpp [new file with mode: 0644]
src/qtui/settingspages/bufferviewsettingspage.h [new file with mode: 0644]
src/qtui/settingspages/bufferviewsettingspage.ui [new file with mode: 0644]
src/qtui/settingspages/settingspages.pri
version.inc

index 1c4b446..1f2a151 100644 (file)
@@ -23,6 +23,7 @@
 #include "bufferinfo.h"
 #include "buffersyncer.h"
 #include "clientbacklogmanager.h"
 #include "bufferinfo.h"
 #include "buffersyncer.h"
 #include "clientbacklogmanager.h"
+#include "bufferviewmanager.h"
 #include "global.h"
 #include "identity.h"
 #include "ircchannel.h"
 #include "global.h"
 #include "identity.h"
 #include "ircchannel.h"
@@ -66,6 +67,7 @@ Client::Client(QObject *parent)
     _bufferModel(0),
     _bufferSyncer(0),
     _backlogManager(new ClientBacklogManager(this)),
     _bufferModel(0),
     _bufferSyncer(0),
     _backlogManager(new ClientBacklogManager(this)),
+    _bufferViewManager(0),
     _connectedToCore(false),
     _syncedToCore(false)
 {
     _connectedToCore(false),
     _syncedToCore(false)
 {
@@ -307,6 +309,9 @@ void Client::setSyncedToCore() {
 
   // attach backlog manager
   signalProxy()->synchronize(backlogManager());
 
   // attach backlog manager
   signalProxy()->synchronize(backlogManager());
+
+  // create a new BufferViewManager
+  _bufferViewManager = new BufferViewManager(signalProxy(), this);
   
   _syncedToCore = true;
   emit connected();
   
   _syncedToCore = true;
   emit connected();
@@ -332,6 +337,12 @@ void Client::disconnectFromCore() {
     _bufferSyncer->deleteLater();
     _bufferSyncer = 0;
   }
     _bufferSyncer->deleteLater();
     _bufferSyncer = 0;
   }
+
+  if(_bufferViewManager) {
+    _bufferViewManager->deleteLater();
+    _bufferViewManager = 0;
+  }
+  
   _networkModel->clear();
 
   QHash<BufferId, Buffer *>::iterator bufferIter =  _buffers.begin();
   _networkModel->clear();
 
   QHash<BufferId, Buffer *>::iterator bufferIter =  _buffers.begin();
index fad53ac..509b447 100644 (file)
@@ -41,6 +41,7 @@ class NetworkModel;
 class BufferModel;
 class BufferSyncer;
 class ClientBacklogManager;
 class BufferModel;
 class BufferSyncer;
 class ClientBacklogManager;
+class BufferViewManager;
 class IrcUser;
 class IrcChannel;
 class SignalProxy;
 class IrcUser;
 class IrcChannel;
 class SignalProxy;
@@ -96,7 +97,8 @@ public:
   static inline SignalProxy *signalProxy() { return instance()->_signalProxy; }
 
   static inline ClientBacklogManager *backlogManager() { return instance()->_backlogManager; }
   static inline SignalProxy *signalProxy() { return instance()->_signalProxy; }
 
   static inline ClientBacklogManager *backlogManager() { return instance()->_backlogManager; }
-
+  static inline BufferViewManager *bufferViewManager() { return instance()->_bufferViewManager; }
+  
   static AccountId currentCoreAccount();
 
   static AbstractUiMsg *layoutMsg(const Message &);
   static AccountId currentCoreAccount();
 
   static AbstractUiMsg *layoutMsg(const Message &);
@@ -209,6 +211,7 @@ private:
   BufferModel * _bufferModel;
   BufferSyncer * _bufferSyncer;
   ClientBacklogManager *_backlogManager;
   BufferModel * _bufferModel;
   BufferSyncer * _bufferSyncer;
   ClientBacklogManager *_backlogManager;
+  BufferViewManager *_bufferViewManager;
 
   ClientMode clientMode;
 
 
   ClientMode clientMode;
 
diff --git a/src/common/bufferviewconfig.cpp b/src/common/bufferviewconfig.cpp
new file mode 100644 (file)
index 0000000..7a893b3
--- /dev/null
@@ -0,0 +1,60 @@
+/***************************************************************************
+ *   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 "bufferviewconfig.h"
+
+BufferViewConfig::BufferViewConfig(int bufferViewId, QObject *parent)
+  : SyncableObject(parent),
+    _bufferViewId(bufferViewId)
+{
+  setObjectName(QString::number(bufferViewId));
+}
+
+void BufferViewConfig::setBufferViewName(const QString &bufferViewName) {
+  if(_bufferViewName == bufferViewName)
+    return;
+
+  _bufferViewName = bufferViewName;
+  emit bufferViewNameSet(bufferViewName);
+}
+
+void BufferViewConfig::setNetworkId(const NetworkId &networkId) {
+  if(_networkId == networkId)
+    return;
+
+  _networkId = networkId;
+  emit networkIdSet(networkId);
+}
+
+void BufferViewConfig::setAddNewBuffersAutomatically(bool addNewBuffersAutomatically) {
+  if(_addNewBuffersAutomatically == addNewBuffersAutomatically)
+    return;
+
+  _addNewBuffersAutomatically = addNewBuffersAutomatically;
+  emit addNewBuffersAutomaticallySet(addNewBuffersAutomatically);
+}
+
+void BufferViewConfig::setSortAlphabetically(bool sortAlphabetically) {
+  if(_sortAlphabetically == sortAlphabetically)
+    return;
+
+  _sortAlphabetically = sortAlphabetically;
+  emit sortAlphabeticallySet(sortAlphabetically);
+}
diff --git a/src/common/bufferviewconfig.h b/src/common/bufferviewconfig.h
new file mode 100644 (file)
index 0000000..d728df5
--- /dev/null
@@ -0,0 +1,71 @@
+/***************************************************************************
+ *   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 BUFFERVIEWCONFIG_H
+#define BUFFERVIEWCONFIG_H
+
+#include "syncableobject.h"
+
+#include "types.h"
+
+class BufferViewConfig : public SyncableObject {
+  Q_OBJECT
+  Q_PROPERTY(QString bufferViewName READ bufferViewName WRITE setBufferViewName)
+  Q_PROPERTY(NetworkId networkId READ networkId WRITE setNetworkId)
+  Q_PROPERTY(bool addNewBuffersAutomatically READ addNewBuffersAutomatically WRITE setAddNewBuffersAutomatically)
+  Q_PROPERTY(bool sortAlphabetically READ sortAlphabetically WRITE setSortAlphabetically)
+
+public:
+  BufferViewConfig(int bufferViewId, QObject *parent = 0);
+
+public slots:
+  inline int bufferViewId() const { return _bufferViewId; }
+
+  inline const QString &bufferViewName() const { return _bufferViewName; }
+  void setBufferViewName(const QString &bufferViewName);
+
+  inline const NetworkId &networkId() const { return _networkId; }
+  void setNetworkId(const NetworkId &networkId);
+
+  inline bool addNewBuffersAutomatically() const { return _addNewBuffersAutomatically; }
+  void setAddNewBuffersAutomatically(bool addNewBuffersAutomatically);
+
+  inline bool sortAlphabetically() const { return _sortAlphabetically; }
+  void setSortAlphabetically(bool sortAlphabetically);
+
+  virtual inline void requestSetBufferViewName(const QString &bufferViewName) { emit setBufferViewNameRequested(bufferViewName); }
+
+signals:
+  void bufferViewNameSet(const QString &bufferViewName);
+  void networkIdSet(const NetworkId &networkId);
+  void addNewBuffersAutomaticallySet(bool addNewBuffersAutomatically);
+  void sortAlphabeticallySet(bool sortAlphabetically);  
+
+  void setBufferViewNameRequested(const QString &bufferViewName);
+
+private:
+  int _bufferViewId;
+  QString _bufferViewName;
+  NetworkId _networkId;
+  bool _addNewBuffersAutomatically;
+  bool _sortAlphabetically;
+};
+
+#endif // BUFFERVIEWCONFIG_H
diff --git a/src/common/bufferviewmanager.cpp b/src/common/bufferviewmanager.cpp
new file mode 100644 (file)
index 0000000..7ab9831
--- /dev/null
@@ -0,0 +1,74 @@
+/***************************************************************************
+ *   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 "bufferviewmanager.h"
+
+#include "bufferviewconfig.h"
+#include "signalproxy.h"
+
+BufferViewManager::BufferViewManager(SignalProxy *proxy, QObject *parent)
+  : SyncableObject(parent),
+    _proxy(proxy)
+{
+  _proxy->synchronize(this);
+}
+
+BufferViewConfig *BufferViewManager::bufferViewConfig(int bufferViewId) const {
+  if(_bufferViewConfigs.contains(bufferViewId))
+    return _bufferViewConfigs[bufferViewId];
+  else
+    return 0;
+}
+
+void BufferViewManager::addBufferViewConfig(BufferViewConfig *config) {
+  if(_bufferViewConfigs.contains(config->bufferViewId()))
+     return;
+
+  _proxy->synchronize(config);
+  _bufferViewConfigs[config->bufferViewId()] = config;
+  emit bufferViewConfigAdded(config->bufferViewId());
+}
+
+void BufferViewManager::addBufferViewConfig(int bufferViewConfigId) {
+  if(_bufferViewConfigs.contains(bufferViewConfigId))
+     return;
+  
+  addBufferViewConfig(new BufferViewConfig(bufferViewConfigId, this));
+}
+
+QVariantList BufferViewManager::initBufferViewIds() const {
+  QVariantList bufferViewIds;
+  BufferViewConfigHash::const_iterator iter = _bufferViewConfigs.constBegin();
+  BufferViewConfigHash::const_iterator iterEnd = _bufferViewConfigs.constEnd();
+  while(iter != iterEnd) {
+    bufferViewIds << (*iter)->bufferViewId();
+    iter++;
+  }
+  return bufferViewIds;
+}
+
+void BufferViewManager::initSetBufferViewIds(const QVariantList bufferViewIds) {
+  QVariantList::const_iterator iter = bufferViewIds.constBegin();
+  QVariantList::const_iterator iterEnd = bufferViewIds.constEnd();
+  while(iter != iterEnd) {
+    newBufferViewConfig((*iter).value<int>());
+    iter++;
+  }
+}
diff --git a/src/common/bufferviewmanager.h b/src/common/bufferviewmanager.h
new file mode 100644 (file)
index 0000000..143b400
--- /dev/null
@@ -0,0 +1,64 @@
+/***************************************************************************
+ *   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 BUFFERVIEWMANAGER_H
+#define BUFFERVIEWMANAGER_H
+
+#include "syncableobject.h"
+
+#include <QList>
+#include <QHash>
+
+class BufferViewConfig;
+class SignalProxy;
+
+class BufferViewManager : public SyncableObject {
+  Q_OBJECT
+
+public:
+  BufferViewManager(SignalProxy *proxy, QObject *parent = 0);
+
+  inline QList<BufferViewConfig *> bufferViewConfigs() const { return _bufferViewConfigs.values(); }
+  BufferViewConfig *bufferViewConfig(int bufferViewId) const;
+
+public slots:
+  void addBufferViewConfig(BufferViewConfig *config);
+  void addBufferViewConfig(int bufferViewConfigId);
+  inline void newBufferViewConfig(int bufferViewConfigId)  { addBufferViewConfig(bufferViewConfigId); }
+
+  QVariantList initBufferViewIds() const;
+  void initSetBufferViewIds(const QVariantList bufferViewIds);
+
+  virtual inline void requestCreateBufferView(const QString &bufferViewName) { emit createBufferViewRequested(bufferViewName); }
+
+signals:
+  void bufferViewConfigAdded(int bufferViewConfigId);
+  void createBufferViewRequested(const QString &bufferViewName);
+
+protected:
+  typedef QHash<int, BufferViewConfig *> BufferViewConfigHash;
+  inline const BufferViewConfigHash &bufferViewConfigHash() { return _bufferViewConfigs; }
+
+private:
+  BufferViewConfigHash _bufferViewConfigs;
+  SignalProxy *_proxy;
+};
+
+#endif // BUFFERVIEWMANAGER_H
index 3a9dcce..7326b76 100644 (file)
@@ -1,6 +1,8 @@
 DEPMOD =
 QT_MOD = network
 DEPMOD =
 QT_MOD = network
-SRCS += backlogmanager.cpp bufferinfo.cpp buffersyncer.cpp global.cpp identity.cpp logger.cpp message.cpp settings.cpp signalproxy.cpp syncableobject.cpp \
+SRCS += backlogmanager.cpp bufferinfo.cpp buffersyncer.cpp bufferviewconfig.cpp bufferviewmanager.cpp global.cpp identity.cpp \
+        logger.cpp message.cpp settings.cpp signalproxy.cpp syncableobject.cpp \
         util.cpp network.cpp ircuser.cpp ircchannel.cpp
         util.cpp network.cpp ircuser.cpp ircchannel.cpp
-HDRS += backlogmanager.h bufferinfo.h buffersyncer.h global.h identity.h logger.h message.h settings.h signalproxy.h syncableobject.h \
+HDRS += backlogmanager.h bufferinfo.h buffersyncer.h bufferviewconfig.h bufferviewmanager.h global.h identity.h \
+        logger.h message.h settings.h signalproxy.h syncableobject.h \
         util.h network.h ircuser.h ircchannel.h types.h
         util.h network.h ircuser.h ircchannel.h types.h
index 9782316..722c530 100644 (file)
@@ -1,6 +1,6 @@
 DEPMOD = common
 QT_MOD = core network sql script
 DEPMOD = common
 QT_MOD = core network sql script
-SRCS = core.cpp corebacklogmanager.cpp coresession.cpp coresettings.cpp networkconnection.cpp sqlitestorage.cpp abstractsqlstorage.cpp storage.cpp basichandler.cpp \
+SRCS = core.cpp corebacklogmanager.cpp corebufferviewconfig.cpp corebufferviewmanager.cpp coresession.cpp coresettings.cpp networkconnection.cpp sqlitestorage.cpp abstractsqlstorage.cpp storage.cpp basichandler.cpp \
        ircserverhandler.cpp userinputhandler.cpp ctcphandler.cpp coreusersettings.cpp sessionthread.cpp
        ircserverhandler.cpp userinputhandler.cpp ctcphandler.cpp coreusersettings.cpp sessionthread.cpp
-HDRS = core.h corebacklogmanager.h coresession.h coresettings.h networkconnection.h sqlitestorage.h abstractsqlstorage.h storage.h basichandler.h \
+HDRS = core.h corebacklogmanager.h corebufferviewconfig.h corebufferviewmanager.h coresession.h coresettings.h networkconnection.h sqlitestorage.h abstractsqlstorage.h storage.h basichandler.h \
        ircserverhandler.h userinputhandler.h ctcphandler.h coreusersettings.h sessionthread.h
        ircserverhandler.h userinputhandler.h ctcphandler.h coreusersettings.h sessionthread.h
diff --git a/src/core/corebufferviewconfig.cpp b/src/core/corebufferviewconfig.cpp
new file mode 100644 (file)
index 0000000..49686c1
--- /dev/null
@@ -0,0 +1,31 @@
+/***************************************************************************
+ *   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 "corebufferviewconfig.h"
+
+CoreBufferViewConfig::CoreBufferViewConfig(int bufferViewId, QObject *parent)
+  : BufferViewConfig(bufferViewId, parent)
+{
+}
+
+void CoreBufferViewConfig::requestSetBufferViewName(const QString &bufferViewName) {
+  qDebug() << "requestSetBufferViewName" << bufferViewName;
+  setBufferViewName(bufferViewName);
+}
diff --git a/src/core/corebufferviewconfig.h b/src/core/corebufferviewconfig.h
new file mode 100644 (file)
index 0000000..06f15cf
--- /dev/null
@@ -0,0 +1,38 @@
+/***************************************************************************
+ *   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 "bufferviewconfig.h"
+
+#ifndef COREBUFFERVIEWCONFIG_H
+#define COREBUFFERVIEWCONFIG_H
+
+class CoreBufferViewConfig : public BufferViewConfig {
+  Q_OBJECT
+
+public:
+  CoreBufferViewConfig(int bufferViewId, QObject *parent = 0);
+
+  virtual const QMetaObject *syncMetaObject() const { return &BufferViewConfig::staticMetaObject; }
+
+public slots:
+  virtual void requestSetBufferViewName(const QString &bufferViewName);
+};
+
+#endif // COREBUFFERVIEWCONFIG_H
diff --git a/src/core/corebufferviewmanager.cpp b/src/core/corebufferviewmanager.cpp
new file mode 100644 (file)
index 0000000..a23a775
--- /dev/null
@@ -0,0 +1,57 @@
+/***************************************************************************
+ *   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 "corebufferviewmanager.h"
+
+#include "corebufferviewconfig.h"
+
+CoreBufferViewManager::CoreBufferViewManager(SignalProxy *proxy, QObject *parent)
+  : BufferViewManager(proxy, parent)
+{
+  return;
+  // fill in some demo views
+  CoreBufferViewConfig *config = 0;
+  for(int i = 0; i < 10; i++) {
+    config = new CoreBufferViewConfig(i);
+    config->setBufferViewName(QString("asdf%1").arg(i));
+    addBufferViewConfig(config);
+  }
+}
+
+void CoreBufferViewManager::requestCreateBufferView(const QString &bufferViewName) {
+  // FIXME retreive new Id from database or whereever this stuff will be stored
+  int maxId = -1;
+  BufferViewConfigHash::const_iterator iter = bufferViewConfigHash().constBegin();
+  BufferViewConfigHash::const_iterator iterEnd = bufferViewConfigHash().constEnd();
+  while(iter != iterEnd) {
+    if((*iter)->bufferViewName() == bufferViewName)
+      return;
+    
+    if((*iter)->bufferViewId() > maxId)
+      maxId = (*iter)->bufferViewId();
+    
+    iter++;
+  }
+  maxId++;
+
+  CoreBufferViewConfig *config = new CoreBufferViewConfig(maxId);
+  config->setBufferViewName(bufferViewName);
+  addBufferViewConfig(config);
+}
diff --git a/src/core/corebufferviewmanager.h b/src/core/corebufferviewmanager.h
new file mode 100644 (file)
index 0000000..235c9dc
--- /dev/null
@@ -0,0 +1,38 @@
+/***************************************************************************
+ *   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 COREBUFFERVIEWMANAGER_H
+#define COREBUFFERVIEWMANAGER_H
+
+#include "bufferviewmanager.h"
+
+class CoreBufferViewManager : public BufferViewManager {
+  Q_OBJECT
+
+public:
+  CoreBufferViewManager(SignalProxy *proxy, QObject *parent = 0);
+
+  virtual const QMetaObject *syncMetaObject() const { return &BufferViewManager::staticMetaObject; }
+
+public slots:
+  virtual void requestCreateBufferView(const QString &bufferViewName);
+};
+
+#endif // COREBUFFERVIEWMANAGER_H
index c93324b..d71144f 100644 (file)
@@ -27,6 +27,7 @@
 #include "signalproxy.h"
 #include "buffersyncer.h"
 #include "corebacklogmanager.h"
 #include "signalproxy.h"
 #include "buffersyncer.h"
 #include "corebacklogmanager.h"
+#include "corebufferviewmanager.h"
 #include "storage.h"
 
 #include "network.h"
 #include "storage.h"
 
 #include "network.h"
@@ -43,6 +44,7 @@ CoreSession::CoreSession(UserId uid, bool restoreState, QObject *parent)
     _signalProxy(new SignalProxy(SignalProxy::Server, 0, this)),
     _bufferSyncer(new BufferSyncer(this)),
     _backlogManager(new CoreBacklogManager(this)),
     _signalProxy(new SignalProxy(SignalProxy::Server, 0, this)),
     _bufferSyncer(new BufferSyncer(this)),
     _backlogManager(new CoreBacklogManager(this)),
+    _bufferViewManager(new CoreBufferViewManager(_signalProxy, this)),
     scriptEngine(new QScriptEngine(this))
 {
 
     scriptEngine(new QScriptEngine(this))
 {
 
index 9965f0d..88fefaf 100644 (file)
@@ -28,6 +28,7 @@
 
 class BufferSyncer;
 class CoreBacklogManager;
 
 class BufferSyncer;
 class CoreBacklogManager;
+class CoreBufferViewManager;
 class Identity;
 class NetworkConnection;
 class Network;
 class Identity;
 class NetworkConnection;
 class Network;
@@ -181,6 +182,7 @@ private:
 
   BufferSyncer *_bufferSyncer;
   CoreBacklogManager *_backlogManager;
 
   BufferSyncer *_bufferSyncer;
   CoreBacklogManager *_backlogManager;
+  CoreBufferViewManager *_bufferViewManager;
 
   QScriptEngine *scriptEngine;
 
 
   QScriptEngine *scriptEngine;
 
index f5afc10..846ccc1 100644 (file)
@@ -30,6 +30,7 @@
 #include "networkmodel.h"
 #include "buffermodel.h"
 #include "nicklistwidget.h"
 #include "networkmodel.h"
 #include "buffermodel.h"
 #include "nicklistwidget.h"
+#include "nicklistdock.h"
 #include "settingsdlg.h"
 #include "settingspagedlg.h"
 #include "signalproxy.h"
 #include "settingsdlg.h"
 #include "settingspagedlg.h"
 #include "signalproxy.h"
@@ -43,6 +44,7 @@
 #include "selectionmodelsynchronizer.h"
 #include "mappedselectionmodel.h"
 
 #include "selectionmodelsynchronizer.h"
 #include "mappedselectionmodel.h"
 
+#include "settingspages/bufferviewsettingspage.h"
 #include "settingspages/colorsettingspage.h"
 #include "settingspages/fontssettingspage.h"
 #include "settingspages/generalsettingspage.h"
 #include "settingspages/colorsettingspage.h"
 #include "settingspages/fontssettingspage.h"
 #include "settingspages/generalsettingspage.h"
@@ -193,22 +195,21 @@ void MainWin::setupSettingsDlg() {
   //Category: General
   settingsDlg->registerSettingsPage(new IdentitiesSettingsPage(settingsDlg));
   settingsDlg->registerSettingsPage(new NetworksSettingsPage(settingsDlg));
   //Category: General
   settingsDlg->registerSettingsPage(new IdentitiesSettingsPage(settingsDlg));
   settingsDlg->registerSettingsPage(new NetworksSettingsPage(settingsDlg));
+  // settingsDlg->registerSettingsPage(new BufferViewSettingsPage(settingsDlg));
 }
 
 void MainWin::setupNickWidget() {
   // create nick dock
 }
 
 void MainWin::setupNickWidget() {
   // create nick dock
-  nickDock = new QDockWidget(tr("Nicks"), this);
+  NickListDock *nickDock = new NickListDock(tr("Nicks"), this);
   nickDock->setObjectName("NickDock");
   nickDock->setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea);
 
   nickListWidget = new NickListWidget(nickDock);
   nickDock->setWidget(nickListWidget);
 
   nickDock->setObjectName("NickDock");
   nickDock->setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea);
 
   nickListWidget = new NickListWidget(nickDock);
   nickDock->setWidget(nickListWidget);
 
-  nickListWidget->setShowDockAction(nickDock->toggleViewAction());
-  connect(nickDock->toggleViewAction(), SIGNAL(toggled(bool)), nickListWidget, SLOT(changedVisibility(bool)));
   addDockWidget(Qt::RightDockWidgetArea, nickDock);
   addDockWidget(Qt::RightDockWidgetArea, nickDock);
-
-  ui.menuViews->addAction(nickListWidget->showNickListAction());
+  ui.menuViews->addAction(nickDock->toggleViewAction());
+  connect(nickDock->toggleViewAction(), SIGNAL(triggered(bool)), nickListWidget, SLOT(showWidget(bool)));
 
   // attach the NickListWidget to the BufferModel and the default selection
   nickListWidget->setModel(Client::bufferModel());
 
   // attach the NickListWidget to the BufferModel and the default selection
   nickListWidget->setModel(Client::bufferModel());
index 32bf286..0f5e299 100644 (file)
@@ -123,7 +123,6 @@ class MainWin : public QMainWindow {
     QString currentProfile;
 
     QList<QDockWidget *> netViews;
     QString currentProfile;
 
     QList<QDockWidget *> netViews;
-    QDockWidget *nickDock;
     NickListWidget *nickListWidget;
 
     QAction *actionEditNetworks;
     NickListWidget *nickListWidget;
 
     QAction *actionEditNetworks;
diff --git a/src/qtui/nicklistdock.cpp b/src/qtui/nicklistdock.cpp
new file mode 100644 (file)
index 0000000..dc24d52
--- /dev/null
@@ -0,0 +1,57 @@
+/***************************************************************************
+ *   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 "nicklistdock.h"
+#include "qtuisettings.h"
+
+#include <QAction>
+#include <QDebug>
+#include <QEvent>
+#include <QAbstractButton>
+
+NickListDock::NickListDock(const QString &title, QWidget *parent)
+  : QDockWidget(title, parent)
+{
+  QAction *toggleView = toggleViewAction();
+  disconnect(toggleView, SIGNAL(triggered(bool)), this, 0);
+
+  foreach(QAbstractButton *button, findChildren<QAbstractButton *>()) {
+    if(disconnect(button, SIGNAL(clicked()), this, SLOT(close())))
+      connect(button, SIGNAL(clicked()), toggleView, SLOT(trigger()));
+  }
+
+  installEventFilter(this);
+
+  toggleView->setChecked(QtUiSettings().value("ShowNickList", QVariant(true)).toBool());
+}
+
+NickListDock::~NickListDock() {
+  QtUiSettings().setValue("ShowNickList", toggleViewAction()->isChecked());
+}
+
+bool NickListDock::eventFilter(QObject *watched, QEvent *event) {
+  Q_UNUSED(watched)
+  if(event->type() != QEvent::Hide && event->type() != QEvent::Show)
+    return false;
+
+  emit visibilityChanged(event->type() == QEvent::Show);
+
+  return true;
+}
diff --git a/src/qtui/nicklistdock.h b/src/qtui/nicklistdock.h
new file mode 100644 (file)
index 0000000..ca610ee
--- /dev/null
@@ -0,0 +1,36 @@
+/***************************************************************************
+ *   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 NICKLISTDOCK_H
+#define NICKLISTDOCK_H
+
+#include <QDockWidget>
+
+class NickListDock : public QDockWidget {
+  Q_OBJECT
+
+public:
+  NickListDock(const QString &title, QWidget *parent = 0);
+  ~NickListDock();
+  
+  virtual bool eventFilter(QObject *watched, QEvent *event);
+};
+
+#endif //NICKLISTDOCK_H
index 68a6757..d6916f9 100644 (file)
 #include "nickviewfilter.h"
 #include "qtuisettings.h"
 
 #include "nickviewfilter.h"
 #include "qtuisettings.h"
 
+#include <QDockWidget>
+
 NickListWidget::NickListWidget(QWidget *parent)
 NickListWidget::NickListWidget(QWidget *parent)
-  : AbstractItemView(parent),
-    _showNickListAction(new QAction(tr("Nicks"), this)),
-    _showDockAction(0)
+  : AbstractItemView(parent)
 {
 {
-  _showNickListAction->setCheckable(true);
-  QtUiSettings s;
-  _showNickListAction->setChecked(s.value("ShowNickListAction", QVariant(true)).toBool());
   ui.setupUi(this);
   ui.setupUi(this);
-  connect(_showNickListAction, SIGNAL(toggled(bool)), this, SLOT(showWidget(bool)));
-}
-
-NickListWidget::~NickListWidget() {
-  QtUiSettings s;
-  s.setValue("ShowNickListAction", showNickListAction()->isChecked());
-}
-
-void NickListWidget::setShowDockAction(QAction *action) {
-  _showDockAction = action;
 }
 
 }
 
-QAction *NickListWidget::showDockAction() const {
-  return _showDockAction;
-}
-
-QAction *NickListWidget::showNickListAction() const {
-  return _showNickListAction;
+QDockWidget *NickListWidget::dock() const {
+  QDockWidget *dock = qobject_cast<QDockWidget *>(parent());
+  if(dock)
+    return dock;
+  else
+    return 0;
 }
 
 void NickListWidget::showWidget(bool visible) {
 }
 
 void NickListWidget::showWidget(bool visible) {
@@ -62,21 +49,15 @@ void NickListWidget::showWidget(bool visible) {
     return;
 
   QModelIndex currentIndex = selectionModel()->currentIndex();
     return;
 
   QModelIndex currentIndex = selectionModel()->currentIndex();
-  if(currentIndex.data(NetworkModel::BufferTypeRole) == BufferInfo::ChannelBuffer && showDockAction()) {
-    if(visible  != showDockAction()->isChecked()) {
-      // show or hide
-      showDockAction()->trigger();
-    }
-  }
-}
-
-void NickListWidget::changedVisibility(bool visible) {
-  if(!selectionModel())
-    return;
-
-  QModelIndex currentIndex = selectionModel()->currentIndex();
-  if(currentIndex.data(NetworkModel::BufferTypeRole) == BufferInfo::ChannelBuffer && !visible) {
-    showNickListAction()->setChecked(false);
+  if(currentIndex.data(NetworkModel::BufferTypeRole) == BufferInfo::ChannelBuffer) {
+    QDockWidget *dock_ = dock();
+    if(!dock_)
+      return;
+
+    if(visible)
+      dock_->show();
+    else
+      dock_->close();
   }
 }
 
   }
 }
 
@@ -85,19 +66,19 @@ void NickListWidget::currentChanged(const QModelIndex &current, const QModelInde
   BufferId newBufferId = current.data(NetworkModel::BufferIdRole).value<BufferId>();
   BufferId oldBufferId = previous.data(NetworkModel::BufferIdRole).value<BufferId>();
 
   BufferId newBufferId = current.data(NetworkModel::BufferIdRole).value<BufferId>();
   BufferId oldBufferId = previous.data(NetworkModel::BufferIdRole).value<BufferId>();
 
+
   if(bufferType != BufferInfo::ChannelBuffer) {
     ui.stackedWidget->setCurrentWidget(ui.emptyPage);
   if(bufferType != BufferInfo::ChannelBuffer) {
     ui.stackedWidget->setCurrentWidget(ui.emptyPage);
-    if(showDockAction() && showDockAction()->isChecked()) {
-      // hide
-      showDockAction()->trigger();
+    QDockWidget *dock_ = dock();
+    if(dock_) {
+      dock_->close();
     }
     return;
   } else {
     }
     return;
   } else {
-    if(showNickListAction()->isChecked())
-      if(showDockAction()&& !showDockAction()->isChecked()) {
-        // show
-        showDockAction()->trigger();
-      }
+    QDockWidget *dock_ = dock();
+    if(dock_ && dock_->toggleViewAction()->isChecked()) {
+      dock_->show();
+    }
   }
 
   if(newBufferId == oldBufferId)
   }
 
   if(newBufferId == oldBufferId)
index 3a6dfe6..9525803 100644 (file)
 
 class Buffer;
 class NickView;
 
 class Buffer;
 class NickView;
+class QDockWidget;
 
 class NickListWidget : public AbstractItemView {
   Q_OBJECT
 
 public:
   NickListWidget(QWidget *parent = 0);
 
 class NickListWidget : public AbstractItemView {
   Q_OBJECT
 
 public:
   NickListWidget(QWidget *parent = 0);
-  ~NickListWidget();
-  void setShowDockAction(QAction *action);
-  QAction *showDockAction() const;
-  QAction *showNickListAction() const;
 
 public slots:
 
 public slots:
-  void changedVisibility(bool visible);
   void showWidget(bool visible);
 
 protected:
   void showWidget(bool visible);
 
 protected:
@@ -60,8 +56,8 @@ private slots:
 private:
   Ui::NickListWidget ui;
   QHash<BufferId, NickView *> nickViews;
 private:
   Ui::NickListWidget ui;
   QHash<BufferId, NickView *> nickViews;
-  QAction *_showNickListAction;
-  QPointer<QAction> _showDockAction;
+
+  QDockWidget *dock() const;
 };
 
 #endif
 };
 
 #endif
index e410de4..693e385 100644 (file)
@@ -3,12 +3,12 @@ QT_MOD = core gui network
 
 SRCS += aboutdlg.cpp bufferwidget.cpp chatitem.cpp chatline.cpp chatline-old.cpp chatscene.cpp chatview.cpp chatwidget.cpp \
         coreconfigwizard.cpp coreconnectdlg.cpp configwizard.cpp debugconsole.cpp inputwidget.cpp \
 
 SRCS += aboutdlg.cpp bufferwidget.cpp chatitem.cpp chatline.cpp chatline-old.cpp chatscene.cpp chatview.cpp chatwidget.cpp \
         coreconfigwizard.cpp coreconnectdlg.cpp configwizard.cpp debugconsole.cpp inputwidget.cpp \
-        mainwin.cpp nicklistwidget.cpp qtui.cpp qtuisettings.cpp qtuistyle.cpp settingsdlg.cpp settingspagedlg.cpp \
+        mainwin.cpp nicklistdock.cpp nicklistwidget.cpp qtui.cpp qtuisettings.cpp qtuistyle.cpp settingsdlg.cpp settingspagedlg.cpp \
         topicbutton.cpp topicwidget.cpp verticaldock.cpp jumpkeyhandler.cpp
 
 HDRS += aboutdlg.h bufferwidget.h chatitem.h chatline.h chatline-old.h chatscene.h chatview.h chatwidget.h \
         coreconfigwizard.h configwizard.h debugconsole.h inputwidget.h \
         topicbutton.cpp topicwidget.cpp verticaldock.cpp jumpkeyhandler.cpp
 
 HDRS += aboutdlg.h bufferwidget.h chatitem.h chatline.h chatline-old.h chatscene.h chatview.h chatwidget.h \
         coreconfigwizard.h configwizard.h debugconsole.h inputwidget.h \
-        coreconnectdlg.h mainwin.h nicklistwidget.h qtui.h qtuisettings.h qtuistyle.h settingsdlg.h settingspagedlg.h \
+        coreconnectdlg.h mainwin.h nicklistdock.h nicklistwidget.h qtui.h qtuisettings.h qtuistyle.h settingsdlg.h settingspagedlg.h \
         topicbutton.h topicwidget.h verticaldock.h jumpkeyhandler.h
 
 FORMNAMES = aboutdlg.ui mainwin.ui coreaccounteditdlg.ui coreconnectdlg.ui bufferviewwidget.ui bufferwidget.ui nicklistwidget.ui settingsdlg.ui \
         topicbutton.h topicwidget.h verticaldock.h jumpkeyhandler.h
 
 FORMNAMES = aboutdlg.ui mainwin.ui coreaccounteditdlg.ui coreconnectdlg.ui bufferviewwidget.ui bufferwidget.ui nicklistwidget.ui settingsdlg.ui \
index a249c79..0b372f6 100644 (file)
@@ -65,7 +65,7 @@ void SettingsDlg::registerSettingsPage(SettingsPage *sp) {
   QTreeWidgetItem *item = new QTreeWidgetItem(cat, QStringList(sp->title()));
   treeItems[sp] = item;
   pages[QString("%1$%2").arg(sp->category(), sp->title())] = sp;
   QTreeWidgetItem *item = new QTreeWidgetItem(cat, QStringList(sp->title()));
   treeItems[sp] = item;
   pages[QString("%1$%2").arg(sp->category(), sp->title())] = sp;
-  sp->load();
+  pageIsLoaded[sp] = false;
   // TESTING
   // selectPage(sp->category(), sp->title());
 }
   // TESTING
   // selectPage(sp->category(), sp->title());
 }
@@ -78,6 +78,10 @@ void SettingsDlg::selectPage(const QString &cat, const QString &title) {
     ui.settingsTree->setCurrentItem(0);
     return;
   }
     ui.settingsTree->setCurrentItem(0);
     return;
   }
+  if(!pageIsLoaded[sp]) {
+    sp->load();
+    pageIsLoaded[sp] = true;
+  }
   if(sp != currentPage() && currentPage() != 0 && currentPage()->hasChanged()) {
     int ret = QMessageBox::warning(this, tr("Save changes"),
                                   tr("There are unsaved changes on the current configuration page. Would you like to apply your changes now?"),
   if(sp != currentPage() && currentPage() != 0 && currentPage()->hasChanged()) {
     int ret = QMessageBox::warning(this, tr("Save changes"),
                                   tr("There are unsaved changes on the current configuration page. Would you like to apply your changes now?"),
index cefc780..3cfda43 100644 (file)
@@ -55,6 +55,7 @@ class SettingsDlg : public QDialog {
     SettingsPage *_currentPage;
     QHash<QString, SettingsPage *> pages;
     QHash<SettingsPage *, QTreeWidgetItem *> treeItems;
     SettingsPage *_currentPage;
     QHash<QString, SettingsPage *> pages;
     QHash<SettingsPage *, QTreeWidgetItem *> treeItems;
+    QHash<SettingsPage *, bool> pageIsLoaded;
 
     //QSize recommendedSize;
 };
 
     //QSize recommendedSize;
 };
diff --git a/src/qtui/settingspages/buffervieweditdlg.ui b/src/qtui/settingspages/buffervieweditdlg.ui
new file mode 100644 (file)
index 0000000..3237df8
--- /dev/null
@@ -0,0 +1,90 @@
+<ui version="4.0" >
+ <class>BufferViewEditDlg</class>
+ <widget class="QDialog" name="BufferViewEditDlg" >
+  <property name="geometry" >
+   <rect>
+    <x>0</x>
+    <y>0</y>
+    <width>282</width>
+    <height>131</height>
+   </rect>
+  </property>
+  <property name="windowTitle" >
+   <string>Dialog</string>
+  </property>
+  <layout class="QVBoxLayout" >
+   <item>
+    <layout class="QVBoxLayout" >
+     <item>
+      <widget class="QLabel" name="label" >
+       <property name="text" >
+        <string>Please enter a name for the buffer view:</string>
+       </property>
+      </widget>
+     </item>
+     <item>
+      <widget class="QLineEdit" name="bufferViewEdit" />
+     </item>
+     <item>
+      <spacer>
+       <property name="orientation" >
+        <enum>Qt::Vertical</enum>
+       </property>
+       <property name="sizeHint" >
+        <size>
+         <width>20</width>
+         <height>40</height>
+        </size>
+       </property>
+      </spacer>
+     </item>
+     <item>
+      <widget class="QDialogButtonBox" name="buttonBox" >
+       <property name="orientation" >
+        <enum>Qt::Horizontal</enum>
+       </property>
+       <property name="standardButtons" >
+        <set>QDialogButtonBox::Cancel|QDialogButtonBox::NoButton|QDialogButtonBox::Ok</set>
+       </property>
+      </widget>
+     </item>
+    </layout>
+   </item>
+  </layout>
+ </widget>
+ <resources/>
+ <connections>
+  <connection>
+   <sender>buttonBox</sender>
+   <signal>accepted()</signal>
+   <receiver>BufferViewEditDlg</receiver>
+   <slot>accept()</slot>
+   <hints>
+    <hint type="sourcelabel" >
+     <x>248</x>
+     <y>254</y>
+    </hint>
+    <hint type="destinationlabel" >
+     <x>157</x>
+     <y>274</y>
+    </hint>
+   </hints>
+  </connection>
+  <connection>
+   <sender>buttonBox</sender>
+   <signal>rejected()</signal>
+   <receiver>BufferViewEditDlg</receiver>
+   <slot>reject()</slot>
+   <hints>
+    <hint type="sourcelabel" >
+     <x>316</x>
+     <y>260</y>
+    </hint>
+    <hint type="destinationlabel" >
+     <x>286</x>
+     <y>274</y>
+    </hint>
+   </hints>
+  </connection>
+ </connections>
+</ui>
diff --git a/src/qtui/settingspages/bufferviewsettingspage.cpp b/src/qtui/settingspages/bufferviewsettingspage.cpp
new file mode 100644 (file)
index 0000000..861bdb6
--- /dev/null
@@ -0,0 +1,179 @@
+/***************************************************************************
+ *   Copyright (C) 2005-08 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 "bufferviewsettingspage.h"
+
+#include "client.h"
+#include "bufferviewmanager.h"
+#include "bufferviewconfig.h"
+
+BufferViewSettingsPage::BufferViewSettingsPage(QWidget *parent)
+  : SettingsPage(tr("General"), tr("Buffer Views"), parent)
+{
+  ui.setupUi(this);
+  reset();
+  setEnabled(Client::isConnected());  // need a core connection!
+  connect(Client::instance(), SIGNAL(coreConnectionStateChanged(bool)), this, SLOT(coreConnectionStateChanged(bool)));
+}
+
+void BufferViewSettingsPage::reset() {
+  // currentId = 0;
+  ui.bufferViewList->clear();
+  _viewToListPos.clear();
+  _listPosToView.clear();
+}
+
+void BufferViewSettingsPage::load() {
+  reset();
+
+  if(!Client::bufferViewManager())
+    return;
+
+  const QList<BufferViewConfig *> bufferViewConfigs = Client::bufferViewManager()->bufferViewConfigs();
+  foreach(BufferViewConfig *bufferViewConfig, bufferViewConfigs) {
+    addBufferView(bufferViewConfig);
+  }
+}
+
+void BufferViewSettingsPage::save() {
+}
+
+void BufferViewSettingsPage::coreConnectionStateChanged(bool state) {
+  setEnabled(state);
+  if(state) {
+    load();
+    connect(Client::bufferViewManager(), SIGNAL(bufferViewConfigAdded(int)), this, SLOT(addBufferView(int)));
+  } else {
+    reset();
+  }
+}
+
+void BufferViewSettingsPage::addBufferView(BufferViewConfig *config) {
+  _viewToListPos[config->bufferViewId()] = ui.bufferViewList->count();
+  _listPosToView[ui.bufferViewList->count()] = config->bufferViewId();
+  ui.bufferViewList->addItem(config->bufferViewName());
+  connect(config, SIGNAL(updatedRemotely()), this, SLOT(updateBufferView()));
+}
+
+void BufferViewSettingsPage::addBufferView(int bufferViewId) {
+  Q_ASSERT(Client::bufferViewManager());
+  addBufferView(Client::bufferViewManager()->bufferViewConfig(bufferViewId));
+}
+
+void BufferViewSettingsPage::newBufferView(const QString &bufferViewName) {
+  // id's of newly created bufferviews are negative (-1, -2... -n)
+  int fakeId = -1 * (_newBufferViews.count() + 1);
+  addBufferView(new BufferViewConfig(fakeId));
+}
+      
+int BufferViewSettingsPage::listPos(BufferViewConfig *config) {
+  if(_viewToListPos.contains(config->bufferViewId()))
+    return _viewToListPos[config->bufferViewId()];
+  else
+    return -1;
+}
+
+int BufferViewSettingsPage::bufferViewId(int listPos) {
+  if(_listPosToView.contains(listPos))
+    return _listPosToView[listPos];
+  else
+    return -1;
+}
+
+void BufferViewSettingsPage::updateBufferView() {
+  BufferViewConfig *config = qobject_cast<BufferViewConfig *>(sender());
+  if(!config)
+    return;
+
+  int itemPos = listPos(config);
+  if(itemPos == -1) {
+    qWarning() << "BufferViewSettingsPage::updateBufferView(): view is unknown:" << config->bufferViewId();
+    return;
+  }
+  ui.bufferViewList->item(itemPos)->setText(config->bufferViewName());
+}
+
+void BufferViewSettingsPage::on_addBufferView_clicked() {
+  if(!Client::bufferViewManager())
+    return;
+  
+  QStringList existing;
+  foreach(BufferViewConfig *bufferConfig, Client::bufferViewManager()->bufferViewConfigs()) {
+    existing << bufferConfig->bufferViewName();
+  }
+
+  BufferViewEditDlg dlg(QString(), existing, this);
+  if(dlg.exec() == QDialog::Accepted) {
+    newBufferView(dlg.bufferViewName());
+  }
+}
+
+void BufferViewSettingsPage::on_renameBufferView_clicked() {
+  if(ui.bufferViewList->selectedItems().isEmpty())
+    return;
+
+  if(!Client::bufferViewManager())
+    return;
+  
+  BufferViewConfig *config = Client::bufferViewManager()->bufferViewConfig(bufferViewId(ui.bufferViewList->currentRow()));
+  if(!config)
+    return;
+
+  QStringList existing;
+  foreach(BufferViewConfig *bufferConfig, Client::bufferViewManager()->bufferViewConfigs()) {
+    existing << bufferConfig->bufferViewName();
+  }
+
+  BufferViewEditDlg dlg(config->bufferViewName(), existing, this);
+  if(dlg.exec() != QDialog::Accepted)
+    return;
+  
+  BufferViewConfig *changedConfig;
+  if(!_changedBufferViews.contains(config)) {
+    _changedBufferViews[config] = new BufferViewConfig(-1);
+    _changedBufferViews[config]->fromVariantMap(config->toVariantMap());
+  }
+  
+  changedConfig = _changedBufferViews[config];
+  changedConfig->setBufferViewName(dlg.bufferViewName());
+  changed();
+}
+
+
+/**************************************************************************
+ * BufferViewEditDlg
+ *************************************************************************/
+BufferViewEditDlg::BufferViewEditDlg(const QString &old, const QStringList &exist, QWidget *parent) : QDialog(parent), existing(exist) {
+  ui.setupUi(this);
+
+  if(old.isEmpty()) {
+    // new buffer
+    setWindowTitle(tr("Add Buffer View"));
+    on_bufferViewEdit_textChanged(""); // disable ok button
+  } else {
+    ui.bufferViewEdit->setText(old);
+  }
+}
+
+
+void BufferViewEditDlg::on_bufferViewEdit_textChanged(const QString &text) {
+  ui.buttonBox->button(QDialogButtonBox::Ok)->setDisabled(text.isEmpty() || existing.contains(text));
+}
+
diff --git a/src/qtui/settingspages/bufferviewsettingspage.h b/src/qtui/settingspages/bufferviewsettingspage.h
new file mode 100644 (file)
index 0000000..a3f32c1
--- /dev/null
@@ -0,0 +1,92 @@
+/***************************************************************************
+ *   Copyright (C) 2005-08 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 BUFFERVIEWSETTINGSPAGE_H
+#define BUFFERVIEWSETTINGSPAGE_H
+
+#include "settingspage.h"
+#include "ui_bufferviewsettingspage.h"
+#include "ui_buffervieweditdlg.h"
+
+class BufferViewConfig;
+
+class BufferViewSettingsPage : public SettingsPage {
+  Q_OBJECT
+
+public:
+  BufferViewSettingsPage(QWidget *parent = 0);
+
+public slots:
+  void save();
+  void load();
+  void reset();
+
+private slots:
+  void coreConnectionStateChanged(bool state);
+
+  void addBufferView(BufferViewConfig *config);
+  void addBufferView(int bufferViewId);
+  void newBufferView(const QString &bufferViewName);
+  void updateBufferView();
+
+  void on_addBufferView_clicked();
+  void on_renameBufferView_clicked();
+  
+private:
+  Ui::BufferViewSettingsPage ui;
+
+  // mappings for bufferViewId to position in the list and vice versa
+  QHash<int, int> _viewToListPos;
+  QHash<int, int> _listPosToView;
+
+  // list of bufferviews to create
+  QList<BufferViewConfig *> _newBufferViews;
+
+  // Hash of pointers to cloned bufferViewConfigs holding the changes
+  QHash<BufferViewConfig *, BufferViewConfig *> _changedBufferViews;
+
+  int listPos(BufferViewConfig *config);
+  int bufferViewId(int listPos);
+};
+
+
+/**************************************************************************
+ * BufferViewEditDlg
+ *************************************************************************/
+class BufferViewEditDlg : public QDialog {
+  Q_OBJECT
+
+public:
+  BufferViewEditDlg(const QString &old, const QStringList &existing = QStringList(), QWidget *parent = 0);
+
+  inline QString bufferViewName() const { return ui.bufferViewEdit->text(); }
+
+private slots:
+  void on_bufferViewEdit_textChanged(const QString &);
+  
+private:
+  Ui::BufferViewEditDlg ui;
+
+  QStringList existing;
+};
+
+
+
+#endif // BUFFERVIEWSETTINGSPAGE_H
diff --git a/src/qtui/settingspages/bufferviewsettingspage.ui b/src/qtui/settingspages/bufferviewsettingspage.ui
new file mode 100644 (file)
index 0000000..161ecaa
--- /dev/null
@@ -0,0 +1,163 @@
+<ui version="4.0" >
+ <class>BufferViewSettingsPage</class>
+ <widget class="QWidget" name="BufferViewSettingsPage" >
+  <property name="geometry" >
+   <rect>
+    <x>0</x>
+    <y>0</y>
+    <width>507</width>
+    <height>485</height>
+   </rect>
+  </property>
+  <property name="windowTitle" >
+   <string>Form</string>
+  </property>
+  <layout class="QHBoxLayout" >
+   <item>
+    <layout class="QVBoxLayout" >
+     <item>
+      <widget class="QListWidget" name="bufferViewList" />
+     </item>
+     <item>
+      <widget class="QPushButton" name="renameBufferView" >
+       <property name="sizePolicy" >
+        <sizepolicy vsizetype="Fixed" hsizetype="Preferred" >
+         <horstretch>0</horstretch>
+         <verstretch>0</verstretch>
+        </sizepolicy>
+       </property>
+       <property name="text" >
+        <string>Re&amp;name...</string>
+       </property>
+       <property name="icon" >
+        <iconset resource="../../icons/icons.qrc" >:/16x16/actions/oxygen/16x16/actions/edit-rename.png</iconset>
+       </property>
+      </widget>
+     </item>
+     <item>
+      <widget class="QPushButton" name="addBufferView" >
+       <property name="sizePolicy" >
+        <sizepolicy vsizetype="Fixed" hsizetype="Preferred" >
+         <horstretch>0</horstretch>
+         <verstretch>0</verstretch>
+        </sizepolicy>
+       </property>
+       <property name="text" >
+        <string>&amp;Add...</string>
+       </property>
+       <property name="icon" >
+        <iconset resource="../../icons/icons.qrc" >:/16x16/actions/oxygen/16x16/actions/list-add.png</iconset>
+       </property>
+       <property name="iconSize" >
+        <size>
+         <width>16</width>
+         <height>16</height>
+        </size>
+       </property>
+      </widget>
+     </item>
+     <item>
+      <widget class="QPushButton" name="deleteBufferView" >
+       <property name="sizePolicy" >
+        <sizepolicy vsizetype="Fixed" hsizetype="Preferred" >
+         <horstretch>0</horstretch>
+         <verstretch>0</verstretch>
+        </sizepolicy>
+       </property>
+       <property name="text" >
+        <string>De&amp;lete</string>
+       </property>
+       <property name="icon" >
+        <iconset resource="../../icons/icons.qrc" >:/16x16/actions/oxygen/16x16/actions/edit-delete.png</iconset>
+       </property>
+      </widget>
+     </item>
+    </layout>
+   </item>
+   <item>
+    <widget class="QGroupBox" name="groupBox" >
+     <property name="title" >
+      <string>Buffer View  Settings</string>
+     </property>
+     <layout class="QVBoxLayout" >
+      <item>
+       <layout class="QHBoxLayout" >
+        <item>
+         <widget class="QLabel" name="label" >
+          <property name="text" >
+           <string>Show only Buffers from:</string>
+          </property>
+         </widget>
+        </item>
+        <item>
+         <widget class="QComboBox" name="comboBox" />
+        </item>
+       </layout>
+      </item>
+      <item>
+       <widget class="QGroupBox" name="groupBox_2" >
+        <property name="title" >
+         <string>Restrict Buffers to:</string>
+        </property>
+        <layout class="QVBoxLayout" >
+         <item>
+          <widget class="QCheckBox" name="checkBox" >
+           <property name="text" >
+            <string>Status Buffers</string>
+           </property>
+          </widget>
+         </item>
+         <item>
+          <widget class="QCheckBox" name="checkBox_2" >
+           <property name="text" >
+            <string>Channel Buffers</string>
+           </property>
+          </widget>
+         </item>
+         <item>
+          <widget class="QCheckBox" name="checkBox_3" >
+           <property name="text" >
+            <string>Query Buffers</string>
+           </property>
+          </widget>
+         </item>
+        </layout>
+       </widget>
+      </item>
+      <item>
+       <widget class="QCheckBox" name="checkBox_4" >
+        <property name="text" >
+         <string>Add new Buffers automatically</string>
+        </property>
+       </widget>
+      </item>
+      <item>
+       <widget class="QCheckBox" name="checkBox_5" >
+        <property name="text" >
+         <string>Sort Buffers alphabetically</string>
+        </property>
+       </widget>
+      </item>
+      <item>
+       <spacer>
+        <property name="orientation" >
+         <enum>Qt::Vertical</enum>
+        </property>
+        <property name="sizeHint" >
+         <size>
+          <width>20</width>
+          <height>40</height>
+         </size>
+        </property>
+       </spacer>
+      </item>
+     </layout>
+    </widget>
+   </item>
+  </layout>
+ </widget>
+ <resources>
+  <include location="../../icons/icons.qrc" />
+ </resources>
+ <connections/>
+</ui>
index 82256f9..6d7d510 100644 (file)
@@ -1,8 +1,8 @@
 # Putting $FOO in SETTINGSPAGES automatically includes
 # $FOOsettingspage.cpp, $FOOsettingspage.h and $FOOsettingspage.ui
 # Putting $FOO in SETTINGSPAGES automatically includes
 # $FOOsettingspage.cpp, $FOOsettingspage.h and $FOOsettingspage.ui
-SETTINGSPAGES = color fonts general identities networks 
+SETTINGSPAGES = color fonts general identities networks bufferview
 
 # Specify additional files (e.g. for subdialogs) here!
 SP_SRCS =
 SP_HDRS =
 
 # Specify additional files (e.g. for subdialogs) here!
 SP_SRCS =
 SP_HDRS =
-SP_FRMS = createidentitydlg.ui saveidentitiesdlg.ui networkeditdlg.ui nickeditdlg.ui servereditdlg.ui
+SP_FRMS = buffervieweditdlg.ui createidentitydlg.ui saveidentitiesdlg.ui networkeditdlg.ui nickeditdlg.ui servereditdlg.ui
index 60d47a7..7b90fb7 100644 (file)
@@ -4,8 +4,8 @@
 { using namespace Global;
 
   quasselVersion = "0.2.0-alpha4-pre";
 { using namespace Global;
 
   quasselVersion = "0.2.0-alpha4-pre";
-  quasselDate = "2008-03-25";
-  quasselBuild = 659;
+  quasselDate = "2008-03-27";
+  quasselBuild = 660;
 
   //! Minimum client build number the core needs
   clientBuildNeeded = 642;
 
   //! Minimum client build number the core needs
   clientBuildNeeded = 642;