recreating some indexes that were lost in an upgrade
authorMarcus Eggenberger <egs@quassel-irc.org>
Mon, 29 Dec 2008 16:17:45 +0000 (17:17 +0100)
committerMarcus Eggenberger <egs@quassel-irc.org>
Mon, 29 Dec 2008 16:17:45 +0000 (17:17 +0100)
88 files changed:
src/client/client.cpp
src/client/client.h
src/client/networkmodel.cpp
src/client/networkmodel.h
src/common/buffersyncer.cpp
src/common/buffersyncer.h
src/core/CMakeLists.txt
src/core/SQL/SQLite/13/delete_backlog_by_uid.sql [moved from src/core/SQL/SQLite/12/delete_backlog_by_uid.sql with 100% similarity]
src/core/SQL/SQLite/13/delete_backlog_for_buffer.sql [moved from src/core/SQL/SQLite/12/delete_backlog_for_buffer.sql with 100% similarity]
src/core/SQL/SQLite/13/delete_backlog_for_network.sql [moved from src/core/SQL/SQLite/12/delete_backlog_for_network.sql with 100% similarity]
src/core/SQL/SQLite/13/delete_buffer_for_bufferid.sql [moved from src/core/SQL/SQLite/12/delete_buffer_for_bufferid.sql with 100% similarity]
src/core/SQL/SQLite/13/delete_buffers_by_uid.sql [moved from src/core/SQL/SQLite/12/delete_buffers_by_uid.sql with 100% similarity]
src/core/SQL/SQLite/13/delete_buffers_for_network.sql [moved from src/core/SQL/SQLite/12/delete_buffers_for_network.sql with 100% similarity]
src/core/SQL/SQLite/13/delete_identity.sql [moved from src/core/SQL/SQLite/12/delete_identity.sql with 100% similarity]
src/core/SQL/SQLite/13/delete_ircservers_for_network.sql [moved from src/core/SQL/SQLite/12/delete_ircservers_for_network.sql with 100% similarity]
src/core/SQL/SQLite/13/delete_network.sql [moved from src/core/SQL/SQLite/12/delete_network.sql with 100% similarity]
src/core/SQL/SQLite/13/delete_networks_by_uid.sql [moved from src/core/SQL/SQLite/12/delete_networks_by_uid.sql with 100% similarity]
src/core/SQL/SQLite/13/delete_nicks.sql [moved from src/core/SQL/SQLite/12/delete_nicks.sql with 100% similarity]
src/core/SQL/SQLite/13/delete_quasseluser.sql [moved from src/core/SQL/SQLite/12/delete_quasseluser.sql with 100% similarity]
src/core/SQL/SQLite/13/insert_buffer.sql [moved from src/core/SQL/SQLite/12/insert_buffer.sql with 100% similarity]
src/core/SQL/SQLite/13/insert_identity.sql [moved from src/core/SQL/SQLite/12/insert_identity.sql with 100% similarity]
src/core/SQL/SQLite/13/insert_message.sql [moved from src/core/SQL/SQLite/12/insert_message.sql with 100% similarity]
src/core/SQL/SQLite/13/insert_network.sql [moved from src/core/SQL/SQLite/12/insert_network.sql with 100% similarity]
src/core/SQL/SQLite/13/insert_nick.sql [moved from src/core/SQL/SQLite/12/insert_nick.sql with 100% similarity]
src/core/SQL/SQLite/13/insert_quasseluser.sql [moved from src/core/SQL/SQLite/12/insert_quasseluser.sql with 100% similarity]
src/core/SQL/SQLite/13/insert_sender.sql [moved from src/core/SQL/SQLite/12/insert_sender.sql with 100% similarity]
src/core/SQL/SQLite/13/insert_server.sql [moved from src/core/SQL/SQLite/12/insert_server.sql with 100% similarity]
src/core/SQL/SQLite/13/insert_user_setting.sql [moved from src/core/SQL/SQLite/12/insert_user_setting.sql with 100% similarity]
src/core/SQL/SQLite/13/select_authuser.sql [moved from src/core/SQL/SQLite/12/select_authuser.sql with 100% similarity]
src/core/SQL/SQLite/13/select_bufferByName.sql [moved from src/core/SQL/SQLite/12/select_bufferByName.sql with 100% similarity]
src/core/SQL/SQLite/13/select_bufferExists.sql [moved from src/core/SQL/SQLite/12/select_bufferExists.sql with 100% similarity]
src/core/SQL/SQLite/13/select_buffer_by_id.sql [moved from src/core/SQL/SQLite/12/select_buffer_by_id.sql with 100% similarity]
src/core/SQL/SQLite/13/select_buffer_lastseen_messages.sql [moved from src/core/SQL/SQLite/12/select_buffer_lastseen_messages.sql with 100% similarity]
src/core/SQL/SQLite/13/select_buffers.sql [moved from src/core/SQL/SQLite/12/select_buffers.sql with 100% similarity]
src/core/SQL/SQLite/13/select_buffers_for_network.sql [moved from src/core/SQL/SQLite/12/select_buffers_for_network.sql with 100% similarity]
src/core/SQL/SQLite/13/select_checkidentity.sql [moved from src/core/SQL/SQLite/12/select_checkidentity.sql with 100% similarity]
src/core/SQL/SQLite/13/select_connected_networks.sql [moved from src/core/SQL/SQLite/12/select_connected_networks.sql with 100% similarity]
src/core/SQL/SQLite/13/select_identities.sql [moved from src/core/SQL/SQLite/12/select_identities.sql with 100% similarity]
src/core/SQL/SQLite/13/select_internaluser.sql [moved from src/core/SQL/SQLite/12/select_internaluser.sql with 100% similarity]
src/core/SQL/SQLite/13/select_messages.sql [moved from src/core/SQL/SQLite/12/select_messages.sql with 100% similarity]
src/core/SQL/SQLite/13/select_messagesAll.sql [moved from src/core/SQL/SQLite/12/select_messagesAll.sql with 100% similarity]
src/core/SQL/SQLite/13/select_messagesAllNew.sql [moved from src/core/SQL/SQLite/12/select_messagesAllNew.sql with 100% similarity]
src/core/SQL/SQLite/13/select_messagesNew.sql [moved from src/core/SQL/SQLite/12/select_messagesNew.sql with 100% similarity]
src/core/SQL/SQLite/13/select_networkExists.sql [moved from src/core/SQL/SQLite/12/select_networkExists.sql with 100% similarity]
src/core/SQL/SQLite/13/select_networks_for_user.sql [moved from src/core/SQL/SQLite/12/select_networks_for_user.sql with 100% similarity]
src/core/SQL/SQLite/13/select_nicks.sql [moved from src/core/SQL/SQLite/12/select_nicks.sql with 100% similarity]
src/core/SQL/SQLite/13/select_persistent_channels.sql [moved from src/core/SQL/SQLite/12/select_persistent_channels.sql with 100% similarity]
src/core/SQL/SQLite/13/select_servers_for_network.sql [moved from src/core/SQL/SQLite/12/select_servers_for_network.sql with 100% similarity]
src/core/SQL/SQLite/13/select_user_setting.sql [moved from src/core/SQL/SQLite/12/select_user_setting.sql with 100% similarity]
src/core/SQL/SQLite/13/select_userid.sql [moved from src/core/SQL/SQLite/12/select_userid.sql with 100% similarity]
src/core/SQL/SQLite/13/setup_000_quasseluser.sql [moved from src/core/SQL/SQLite/12/setup_000_quasseluser.sql with 100% similarity]
src/core/SQL/SQLite/13/setup_010_sender.sql [moved from src/core/SQL/SQLite/12/setup_010_sender.sql with 100% similarity]
src/core/SQL/SQLite/13/setup_020_network.sql [moved from src/core/SQL/SQLite/12/setup_020_network.sql with 100% similarity]
src/core/SQL/SQLite/13/setup_030_buffer.sql [moved from src/core/SQL/SQLite/12/setup_030_buffer.sql with 100% similarity]
src/core/SQL/SQLite/13/setup_040_buffer_idx.sql [moved from src/core/SQL/SQLite/12/setup_040_buffer_idx.sql with 100% similarity]
src/core/SQL/SQLite/13/setup_050_buffer_cname_idx.sql [moved from src/core/SQL/SQLite/12/setup_050_buffer_cname_idx.sql with 100% similarity]
src/core/SQL/SQLite/13/setup_060_backlog.sql [moved from src/core/SQL/SQLite/12/setup_060_backlog.sql with 100% similarity]
src/core/SQL/SQLite/13/setup_070_coreinfo.sql [moved from src/core/SQL/SQLite/12/setup_070_coreinfo.sql with 100% similarity]
src/core/SQL/SQLite/13/setup_080_ircservers.sql [moved from src/core/SQL/SQLite/12/setup_080_ircservers.sql with 100% similarity]
src/core/SQL/SQLite/13/setup_090_backlog_idx.sql [moved from src/core/SQL/SQLite/12/setup_090_create_backlog_idx.sql with 100% similarity]
src/core/SQL/SQLite/13/setup_100_backlog_idx2.sql [moved from src/core/SQL/SQLite/12/setup_100_create_backlog_idx2.sql with 100% similarity]
src/core/SQL/SQLite/13/setup_110_buffer_user_idx.sql [moved from src/core/SQL/SQLite/12/setup_110_create_buffer_idx.sql with 100% similarity]
src/core/SQL/SQLite/13/setup_120_user_setting.sql [moved from src/core/SQL/SQLite/12/setup_120_create_user_setting.sql with 100% similarity]
src/core/SQL/SQLite/13/setup_130_identity.sql [moved from src/core/SQL/SQLite/12/setup_130_identity.sql with 100% similarity]
src/core/SQL/SQLite/13/setup_140_identity_nick.sql [moved from src/core/SQL/SQLite/12/setup_140_identity_nick.sql with 100% similarity]
src/core/SQL/SQLite/13/setup_999_version.sql [moved from src/core/SQL/SQLite/12/setup_999_version.sql with 100% similarity]
src/core/SQL/SQLite/13/update_buffer_lastseen.sql [moved from src/core/SQL/SQLite/12/update_buffer_lastseen.sql with 100% similarity]
src/core/SQL/SQLite/13/update_buffer_name.sql [moved from src/core/SQL/SQLite/12/update_buffer_name.sql with 100% similarity]
src/core/SQL/SQLite/13/update_buffer_persistent_channel.sql [moved from src/core/SQL/SQLite/12/update_buffer_persistent_channel.sql with 100% similarity]
src/core/SQL/SQLite/13/update_buffer_set_channel_key.sql [moved from src/core/SQL/SQLite/12/update_buffer_set_channel_key.sql with 100% similarity]
src/core/SQL/SQLite/13/update_identity.sql [moved from src/core/SQL/SQLite/12/update_identity.sql with 100% similarity]
src/core/SQL/SQLite/13/update_network.sql [moved from src/core/SQL/SQLite/12/update_network.sql with 100% similarity]
src/core/SQL/SQLite/13/update_network_connected.sql [moved from src/core/SQL/SQLite/12/update_network_connected.sql with 100% similarity]
src/core/SQL/SQLite/13/update_user_setting.sql [moved from src/core/SQL/SQLite/12/update_user_setting.sql with 100% similarity]
src/core/SQL/SQLite/13/update_username.sql [moved from src/core/SQL/SQLite/12/update_username.sql with 100% similarity]
src/core/SQL/SQLite/13/update_userpassword.sql [moved from src/core/SQL/SQLite/12/update_userpassword.sql with 100% similarity]
src/core/SQL/SQLite/13/upgrade_000_create_buffer_user_idx.sql [new file with mode: 0644]
src/core/SQL/SQLite/13/upgrade_010_create_buffer_cname_idx.sql [new file with mode: 0644]
src/core/SQL/SQLite/13/upgrade_020_create_buffer_cname_idx.sql [new file with mode: 0644]
src/core/SQL/SQLite/13/upgrade_999_version.sql [new file with mode: 0644]
src/core/core.h
src/core/coresession.cpp
src/core/coresession.h
src/core/sql.qrc
src/core/sqlitestorage.cpp
src/core/sqlitestorage.h
src/core/storage.h
src/qtui/inputwidget.cpp

index 295e062..9956cd2 100644 (file)
@@ -398,6 +398,12 @@ void Client::removeBuffer(BufferId id) {
   bufferSyncer()->requestRemoveBuffer(id);
 }
 
+void Client::renameBuffer(BufferId bufferId, const QString &newName) {
+  if(!bufferSyncer())
+    return;
+  bufferSyncer()->requestRenameBuffer(bufferId, newName);
+}
+
 void Client::bufferRemoved(BufferId bufferId) {
   // select a sane buffer (status buffer)
   /* we have to manually select a buffer because otherwise inconsitent changes
index 610e732..ac3663d 100644 (file)
@@ -113,6 +113,7 @@ public:
 
   static void setBufferLastSeenMsg(BufferId id, const MsgId &msgId); // this is synced to core and other clients
   static void removeBuffer(BufferId id);
+  static void renameBuffer(BufferId bufferId, const QString &newName);
 
   static void logMessage(QtMsgType type, const char *msg);
   static inline const QString &debugLog() { return instance()->_debugLogBuffer; }
index 9202036..45cb33b 100644 (file)
@@ -244,7 +244,6 @@ QVariant BufferItem::data(int column, int role) const {
 }
 
 bool BufferItem::setData(int column, const QVariant &value, int role) {
-  qDebug() << "BufferItem::setData(int column, const QVariant &value, int role):" << this << column << value << role;
   switch(role) {
   case NetworkModel::BufferActivityRole:
     setActivityLevel((BufferInfo::ActivityLevel)value.toInt());
@@ -304,7 +303,7 @@ QueryBufferItem::QueryBufferItem(const BufferInfo &bufferInfo, NetworkItem *pare
   : BufferItem(bufferInfo, parent),
     _ircUser(0)
 {
-  setFlags(flags() | Qt::ItemIsDropEnabled);
+  setFlags(flags() | Qt::ItemIsDropEnabled | Qt::ItemIsEditable);
 
   const Network *net = Client::network(bufferInfo.networkId());
   if(!net)
@@ -326,6 +325,24 @@ QVariant QueryBufferItem::data(int column, int role) const {
   }
 }
 
+bool QueryBufferItem::setData(int column, const QVariant &value, int role) {
+  switch(role) {
+  case Qt::EditRole:
+    {
+      QString newName = value.toString();
+      if(!newName.isEmpty()) {
+       Client::renameBuffer(bufferId(), newName);
+       return true;
+      } else {
+       return false;
+      }
+    }
+    break;
+  default:
+    return BufferItem::setData(column, value, role);
+  }
+}
+
 QString QueryBufferItem::toolTip(int column) const {
   // pretty much code duplication of IrcUserItem::toolTip() but inheritance won't solve this...
   Q_UNUSED(column);
index 6fd078e..e765252 100644 (file)
@@ -140,6 +140,7 @@ public:
   QueryBufferItem(const BufferInfo &bufferInfo, NetworkItem *parent);
 
   virtual QVariant data(int column, int role) const;
+  virtual bool setData(int column, const QVariant &value, int role);
   virtual inline bool isActive() const { return (bool)_ircUser; }
   virtual QString toolTip(int column) const;
 
index fe69db7..816227f 100644 (file)
@@ -64,22 +64,13 @@ void BufferSyncer::initSetLastSeenMsg(const QVariantList &list) {
   }
 }
 
-void BufferSyncer::requestSetLastSeenMsg(BufferId buffer, const MsgId &msgId) {
-  if(setLastSeenMsg(buffer, msgId))
-    emit setLastSeenMsgRequested(buffer, msgId);
-}
-
-
-void BufferSyncer::requestRemoveBuffer(BufferId buffer) {
-  emit removeBufferRequested(buffer);
-}
-
 void BufferSyncer::removeBuffer(BufferId buffer) {
-  if(_lastSeenMsg.contains(buffer))
+  if(_lastSeenMsg.contains(buffer)) {
     _lastSeenMsg.remove(buffer);
-  emit bufferRemoved(buffer);
+    emit bufferRemoved(buffer);
+  }
 }
 
-void BufferSyncer::renameBuffer(BufferId buffer, QString newName) {
-  emit bufferRenamed(buffer, newName);
-}
+// void BufferSyncer::renameBuffer(BufferId buffer, QString newName) {
+//   emit bufferRenamed(buffer, newName);
+// }
index 0ad8eaa..92ca54d 100644 (file)
@@ -29,6 +29,7 @@ class BufferSyncer : public SyncableObject {
 
 public:
   explicit BufferSyncer(QObject *parent);
+  inline virtual const QMetaObject *syncMetaObject() const { return &staticMetaObject; }
 
   MsgId lastSeenMsg(BufferId buffer) const;
 
@@ -36,24 +37,25 @@ public slots:
   QVariantList initLastSeenMsg() const;
   void initSetLastSeenMsg(const QVariantList &);
 
-  void requestSetLastSeenMsg(BufferId buffer, const MsgId &msgId);
-  void requestRemoveBuffer(BufferId buffer);
-  void removeBuffer(BufferId buffer);
-  void renameBuffer(BufferId buffer, QString newName);
+  virtual inline void requestSetLastSeenMsg(BufferId buffer, const MsgId &msgId) { emit setLastSeenMsgRequested(buffer, msgId); }
+  virtual inline void requestRemoveBuffer(BufferId buffer) { emit removeBufferRequested(buffer); }
+  virtual void removeBuffer(BufferId buffer);
+  virtual inline void requestRenameBuffer(BufferId buffer, QString newName) { emit renameBufferRequested(buffer, newName); }
+  virtual inline void renameBuffer(BufferId buffer, QString newName) { emit bufferRenamed(buffer, newName); }
 
 signals:
   void lastSeenMsgSet(BufferId buffer, const MsgId &msgId);
   void setLastSeenMsgRequested(BufferId buffer, const MsgId &msgId);
   void removeBufferRequested(BufferId buffer);
   void bufferRemoved(BufferId buffer);
+  void renameBufferRequested(BufferId buffer, QString newName);
   void bufferRenamed(BufferId buffer, QString newName);
 
-private slots:
+protected slots:
   bool setLastSeenMsg(BufferId buffer, const MsgId &msgId);
 
 private:
   QHash<BufferId, MsgId> _lastSeenMsg;
-
 };
 
 #endif
index c4cd518..9f79949 100644 (file)
@@ -13,6 +13,7 @@ set(SOURCES
     corealiasmanager.cpp
     coreapplication.cpp
     corebacklogmanager.cpp
+    corebuffersyncer.cpp
     corebufferviewconfig.cpp
     corebufferviewmanager.cpp
     corecoreinfo.cpp
@@ -37,6 +38,7 @@ set(MOC_HDRS
     corealiasmanager.h
     coreapplication.h
     corebacklogmanager.h
+    corebuffersyncer.h
     corebufferviewconfig.h
     corebufferviewmanager.h
     corecoreinfo.h
diff --git a/src/core/SQL/SQLite/13/upgrade_000_create_buffer_user_idx.sql b/src/core/SQL/SQLite/13/upgrade_000_create_buffer_user_idx.sql
new file mode 100644 (file)
index 0000000..cb55f1d
--- /dev/null
@@ -0,0 +1 @@
+CREATE INDEX buffer_user_idx ON buffer(userid)
diff --git a/src/core/SQL/SQLite/13/upgrade_010_create_buffer_cname_idx.sql b/src/core/SQL/SQLite/13/upgrade_010_create_buffer_cname_idx.sql
new file mode 100644 (file)
index 0000000..3858455
--- /dev/null
@@ -0,0 +1,2 @@
+CREATE UNIQUE INDEX buffer_cname_idx 
+       ON buffer(userid, networkid, buffercname)
diff --git a/src/core/SQL/SQLite/13/upgrade_020_create_buffer_cname_idx.sql b/src/core/SQL/SQLite/13/upgrade_020_create_buffer_cname_idx.sql
new file mode 100644 (file)
index 0000000..042ce3a
--- /dev/null
@@ -0,0 +1,2 @@
+CREATE UNIQUE INDEX buffer_idx 
+       ON buffer(userid, networkid, buffername)
diff --git a/src/core/SQL/SQLite/13/upgrade_999_version.sql b/src/core/SQL/SQLite/13/upgrade_999_version.sql
new file mode 100644 (file)
index 0000000..edb5aef
--- /dev/null
@@ -0,0 +1,3 @@
+UPDATE coreinfo
+SET value = 13
+WHERE key = 'schemaversion'
index 0c6e88d..6ddb6e8 100644 (file)
@@ -292,13 +292,12 @@ class Core : public QObject {
   //! Rename a Buffer
   /** \note This method is threadsafe.
    *  \param user      The id of the buffer owner
-   *  \param networkId The id of the network the buffer belongs to
+   *  \param bufferId  The bufferId
    *  \param newName   The new name of the buffer
-   *  \param oldName   The previous name of the buffer
-   *  \return the BufferId of the affected buffer or an invalid BufferId if not successfull
+   *  \return true if successfull
    */
-  static inline BufferId renameBuffer(const UserId &user, const NetworkId &networkId, const QString &newName, const QString &oldName) {
-    return instance()->storage->renameBuffer(user, networkId, newName, oldName);
+  static inline bool renameBuffer(const UserId &user, const BufferId &bufferId, const QString &newName) {
+    return instance()->storage->renameBuffer(user, bufferId, newName);
   }
 
   //! Update the LastSeenDate for a Buffer
index f18f926..841ae7c 100644 (file)
@@ -24,7 +24,7 @@
 #include "coresession.h"
 #include "userinputhandler.h"
 #include "signalproxy.h"
-#include "buffersyncer.h"
+#include "corebuffersyncer.h"
 #include "corebacklogmanager.h"
 #include "corebufferviewmanager.h"
 #include "coreirclisthelper.h"
@@ -44,7 +44,7 @@ CoreSession::CoreSession(UserId uid, bool restoreState, QObject *parent)
     _user(uid),
     _signalProxy(new SignalProxy(SignalProxy::Server, 0, this)),
     _aliasManager(this),
-    _bufferSyncer(new BufferSyncer(this)),
+    _bufferSyncer(new CoreBufferSyncer(this)),
     _backlogManager(new CoreBacklogManager(this)),
     _bufferViewManager(new CoreBufferViewManager(_signalProxy, this)),
     _ircListHelper(new CoreIrcListHelper(this)),
@@ -81,9 +81,6 @@ CoreSession::CoreSession(UserId uid, bool restoreState, QObject *parent)
     _bufferSyncer->requestSetLastSeenMsg(id, lastSeenHash[id]);
 
   connect(_bufferSyncer, SIGNAL(lastSeenMsgSet(BufferId, MsgId)), this, SLOT(storeBufferLastSeenMsg(BufferId, MsgId)));
-  connect(_bufferSyncer, SIGNAL(removeBufferRequested(BufferId)), this, SLOT(removeBufferRequested(BufferId)));
-  connect(this, SIGNAL(bufferRemoved(BufferId)), _bufferSyncer, SLOT(removeBuffer(BufferId)));
-  connect(this, SIGNAL(bufferRenamed(BufferId, QString)), _bufferSyncer, SLOT(renameBuffer(BufferId, QString)));
   p->synchronize(_bufferSyncer);
 
 
@@ -386,40 +383,9 @@ void CoreSession::destroyNetwork(NetworkId id) {
   }
 }
 
-void CoreSession::removeBufferRequested(BufferId bufferId) {
-  BufferInfo bufferInfo = Core::getBufferInfo(user(), bufferId);
-  if(!bufferInfo.isValid()) {
-    qWarning() << "CoreSession::removeBufferRequested(): invalid BufferId:" << bufferId << "for User:" << user();
-    return;
-  }
-
-  if(bufferInfo.type() == BufferInfo::StatusBuffer) {
-    qWarning() << "CoreSession::removeBufferRequested(): Status Buffers cannot be removed!";
-    return;
-  }
-
-  if(bufferInfo.type() == BufferInfo::ChannelBuffer) {
-    CoreNetwork *net = network(bufferInfo.networkId());
-    if(!net) {
-      qWarning() << "CoreSession::removeBufferRequested(): Received BufferInfo with unknown networkId!";
-      return;
-    }
-    IrcChannel *chan = net->ircChannel(bufferInfo.bufferName());
-    if(chan) {
-      qWarning() << "CoreSession::removeBufferRequested(): Unable to remove Buffer for joined Channel:" << bufferInfo.bufferName();
-      return;
-    }
-  }
-  if(Core::removeBuffer(user(), bufferId))
-    emit bufferRemoved(bufferId);
-}
-
-// FIXME: use a coreBufferSyncer for this
 void CoreSession::renameBuffer(const NetworkId &networkId, const QString &newName, const QString &oldName) {
-  BufferId bufferId = Core::renameBuffer(user(), networkId, newName, oldName);
-  if(bufferId.isValid()) {
-    emit bufferRenamed(bufferId, newName);
-  }
+  BufferInfo bufferInfo = Core::bufferInfo(user(), networkId, BufferInfo::QueryBuffer, oldName);
+  _bufferSyncer->renameBuffer(bufferInfo.bufferId(), newName);
 }
 
 void CoreSession::clientsConnected() {
index d781f21..e47698e 100644 (file)
@@ -28,8 +28,8 @@
 #include "corealiasmanager.h"
 #include "message.h"
 
-class BufferSyncer;
 class CoreBacklogManager;
+class CoreBufferSyncer;
 class CoreBufferViewManager;
 class CoreIrcListHelper;
 class Identity;
@@ -96,17 +96,10 @@ public slots:
    */
   void removeNetwork(NetworkId network);
 
-  //! Remove a buffer and it's backlog permanently
-  /** \param bufferId The id of the buffer to be removed.
-   *  emits bufferRemoved(bufferId) on success.
-   */
-  void removeBufferRequested(BufferId bufferId);
-
   //! Rename a Buffer for a given network
   /* \param networkId The id of the network the buffer belongs to
    * \param newName   The new name of the buffer
    * \param oldName   The old name of the buffer
-   * emits bufferRenamed(bufferId, newName) on success.
    */
   void renameBuffer(const NetworkId &networkId, const QString &newName, const QString &oldName);
 
@@ -136,8 +129,6 @@ signals:
 
   void networkCreated(NetworkId);
   void networkRemoved(NetworkId);
-  void bufferRemoved(BufferId);
-  void bufferRenamed(BufferId, QString);
 
 private slots:
   void removeClient(QIODevice *dev);
@@ -169,7 +160,7 @@ private:
   //  QHash<NetworkId, CoreNetwork *> _networksToRemove;
   QHash<IdentityId, CoreIdentity *> _identities;
 
-  BufferSyncer *_bufferSyncer;
+  CoreBufferSyncer *_bufferSyncer;
   CoreBacklogManager *_backlogManager;
   CoreBufferViewManager *_bufferViewManager;
   CoreIrcListHelper *_ircListHelper;
index e3459e1..2c2c50e 100644 (file)
     <file>./SQL/SQLite/10/upgrade_999_version.sql</file>
     <file>./SQL/SQLite/11/upgrade_000_create_user_setting.sql</file>
     <file>./SQL/SQLite/11/upgrade_999_version.sql</file>
-    <file>./SQL/SQLite/12/delete_backlog_by_uid.sql</file>
-    <file>./SQL/SQLite/12/delete_backlog_for_buffer.sql</file>
-    <file>./SQL/SQLite/12/delete_backlog_for_network.sql</file>
-    <file>./SQL/SQLite/12/delete_buffer_for_bufferid.sql</file>
-    <file>./SQL/SQLite/12/delete_buffers_by_uid.sql</file>
-    <file>./SQL/SQLite/12/delete_buffers_for_network.sql</file>
-    <file>./SQL/SQLite/12/delete_identity.sql</file>
-    <file>./SQL/SQLite/12/delete_ircservers_for_network.sql</file>
-    <file>./SQL/SQLite/12/delete_network.sql</file>
-    <file>./SQL/SQLite/12/delete_networks_by_uid.sql</file>
-    <file>./SQL/SQLite/12/delete_nicks.sql</file>
-    <file>./SQL/SQLite/12/delete_quasseluser.sql</file>
-    <file>./SQL/SQLite/12/insert_buffer.sql</file>
-    <file>./SQL/SQLite/12/insert_identity.sql</file>
-    <file>./SQL/SQLite/12/insert_message.sql</file>
-    <file>./SQL/SQLite/12/insert_network.sql</file>
-    <file>./SQL/SQLite/12/insert_nick.sql</file>
-    <file>./SQL/SQLite/12/insert_quasseluser.sql</file>
-    <file>./SQL/SQLite/12/insert_sender.sql</file>
-    <file>./SQL/SQLite/12/insert_server.sql</file>
-    <file>./SQL/SQLite/12/insert_user_setting.sql</file>
-    <file>./SQL/SQLite/12/select_authuser.sql</file>
-    <file>./SQL/SQLite/12/select_buffer_by_id.sql</file>
-    <file>./SQL/SQLite/12/select_buffer_lastseen_messages.sql</file>
-    <file>./SQL/SQLite/12/select_bufferByName.sql</file>
-    <file>./SQL/SQLite/12/select_bufferExists.sql</file>
-    <file>./SQL/SQLite/12/select_buffers.sql</file>
-    <file>./SQL/SQLite/12/select_buffers_for_network.sql</file>
-    <file>./SQL/SQLite/12/select_checkidentity.sql</file>
-    <file>./SQL/SQLite/12/select_connected_networks.sql</file>
-    <file>./SQL/SQLite/12/select_identities.sql</file>
-    <file>./SQL/SQLite/12/select_internaluser.sql</file>
-    <file>./SQL/SQLite/12/select_messages.sql</file>
-    <file>./SQL/SQLite/12/select_messagesAll.sql</file>
-    <file>./SQL/SQLite/12/select_messagesAllNew.sql</file>
-    <file>./SQL/SQLite/12/select_messagesNew.sql</file>
-    <file>./SQL/SQLite/12/select_networkExists.sql</file>
-    <file>./SQL/SQLite/12/select_networks_for_user.sql</file>
-    <file>./SQL/SQLite/12/select_nicks.sql</file>
-    <file>./SQL/SQLite/12/select_persistent_channels.sql</file>
-    <file>./SQL/SQLite/12/select_servers_for_network.sql</file>
-    <file>./SQL/SQLite/12/select_user_setting.sql</file>
-    <file>./SQL/SQLite/12/select_userid.sql</file>
-    <file>./SQL/SQLite/12/setup_000_quasseluser.sql</file>
-    <file>./SQL/SQLite/12/setup_010_sender.sql</file>
-    <file>./SQL/SQLite/12/setup_020_network.sql</file>
-    <file>./SQL/SQLite/12/setup_030_buffer.sql</file>
-    <file>./SQL/SQLite/12/setup_040_buffer_idx.sql</file>
-    <file>./SQL/SQLite/12/setup_050_buffer_cname_idx.sql</file>
-    <file>./SQL/SQLite/12/setup_060_backlog.sql</file>
-    <file>./SQL/SQLite/12/setup_070_coreinfo.sql</file>
-    <file>./SQL/SQLite/12/setup_080_ircservers.sql</file>
-    <file>./SQL/SQLite/12/setup_090_create_backlog_idx.sql</file>
-    <file>./SQL/SQLite/12/setup_100_create_backlog_idx2.sql</file>
-    <file>./SQL/SQLite/12/setup_110_create_buffer_idx.sql</file>
-    <file>./SQL/SQLite/12/setup_120_create_user_setting.sql</file>
-    <file>./SQL/SQLite/12/setup_130_identity.sql</file>
-    <file>./SQL/SQLite/12/setup_140_identity_nick.sql</file>
-    <file>./SQL/SQLite/12/setup_999_version.sql</file>
-    <file>./SQL/SQLite/12/update_buffer_lastseen.sql</file>
-    <file>./SQL/SQLite/12/update_buffer_name.sql</file>
-    <file>./SQL/SQLite/12/update_buffer_persistent_channel.sql</file>
-    <file>./SQL/SQLite/12/update_buffer_set_channel_key.sql</file>
-    <file>./SQL/SQLite/12/update_identity.sql</file>
-    <file>./SQL/SQLite/12/update_network.sql</file>
-    <file>./SQL/SQLite/12/update_network_connected.sql</file>
-    <file>./SQL/SQLite/12/update_user_setting.sql</file>
-    <file>./SQL/SQLite/12/update_username.sql</file>
-    <file>./SQL/SQLite/12/update_userpassword.sql</file>
     <file>./SQL/SQLite/12/upgrade_000_create_identity.sql</file>
     <file>./SQL/SQLite/12/upgrade_010_create_identity_nick.sql</file>
     <file>./SQL/SQLite/12/upgrade_020_rename_servertable.sql</file>
     <file>./SQL/SQLite/12/upgrade_040_copy_ircserver.sql</file>
     <file>./SQL/SQLite/12/upgrade_050_drop_ircserverold.sql</file>
     <file>./SQL/SQLite/12/upgrade_999_version.sql</file>
+    <file>./SQL/SQLite/13/delete_backlog_by_uid.sql</file>
+    <file>./SQL/SQLite/13/delete_backlog_for_buffer.sql</file>
+    <file>./SQL/SQLite/13/delete_backlog_for_network.sql</file>
+    <file>./SQL/SQLite/13/delete_buffer_for_bufferid.sql</file>
+    <file>./SQL/SQLite/13/delete_buffers_by_uid.sql</file>
+    <file>./SQL/SQLite/13/delete_buffers_for_network.sql</file>
+    <file>./SQL/SQLite/13/delete_identity.sql</file>
+    <file>./SQL/SQLite/13/delete_ircservers_for_network.sql</file>
+    <file>./SQL/SQLite/13/delete_network.sql</file>
+    <file>./SQL/SQLite/13/delete_networks_by_uid.sql</file>
+    <file>./SQL/SQLite/13/delete_nicks.sql</file>
+    <file>./SQL/SQLite/13/delete_quasseluser.sql</file>
+    <file>./SQL/SQLite/13/insert_buffer.sql</file>
+    <file>./SQL/SQLite/13/insert_identity.sql</file>
+    <file>./SQL/SQLite/13/insert_message.sql</file>
+    <file>./SQL/SQLite/13/insert_network.sql</file>
+    <file>./SQL/SQLite/13/insert_nick.sql</file>
+    <file>./SQL/SQLite/13/insert_quasseluser.sql</file>
+    <file>./SQL/SQLite/13/insert_sender.sql</file>
+    <file>./SQL/SQLite/13/insert_server.sql</file>
+    <file>./SQL/SQLite/13/insert_user_setting.sql</file>
+    <file>./SQL/SQLite/13/select_authuser.sql</file>
+    <file>./SQL/SQLite/13/select_buffer_by_id.sql</file>
+    <file>./SQL/SQLite/13/select_buffer_lastseen_messages.sql</file>
+    <file>./SQL/SQLite/13/select_bufferByName.sql</file>
+    <file>./SQL/SQLite/13/select_bufferExists.sql</file>
+    <file>./SQL/SQLite/13/select_buffers.sql</file>
+    <file>./SQL/SQLite/13/select_buffers_for_network.sql</file>
+    <file>./SQL/SQLite/13/select_checkidentity.sql</file>
+    <file>./SQL/SQLite/13/select_connected_networks.sql</file>
+    <file>./SQL/SQLite/13/select_identities.sql</file>
+    <file>./SQL/SQLite/13/select_internaluser.sql</file>
+    <file>./SQL/SQLite/13/select_messages.sql</file>
+    <file>./SQL/SQLite/13/select_messagesAll.sql</file>
+    <file>./SQL/SQLite/13/select_messagesAllNew.sql</file>
+    <file>./SQL/SQLite/13/select_messagesNew.sql</file>
+    <file>./SQL/SQLite/13/select_networkExists.sql</file>
+    <file>./SQL/SQLite/13/select_networks_for_user.sql</file>
+    <file>./SQL/SQLite/13/select_nicks.sql</file>
+    <file>./SQL/SQLite/13/select_persistent_channels.sql</file>
+    <file>./SQL/SQLite/13/select_servers_for_network.sql</file>
+    <file>./SQL/SQLite/13/select_user_setting.sql</file>
+    <file>./SQL/SQLite/13/select_userid.sql</file>
+    <file>./SQL/SQLite/13/setup_000_quasseluser.sql</file>
+    <file>./SQL/SQLite/13/setup_010_sender.sql</file>
+    <file>./SQL/SQLite/13/setup_020_network.sql</file>
+    <file>./SQL/SQLite/13/setup_030_buffer.sql</file>
+    <file>./SQL/SQLite/13/setup_040_buffer_idx.sql</file>
+    <file>./SQL/SQLite/13/setup_050_buffer_cname_idx.sql</file>
+    <file>./SQL/SQLite/13/setup_060_backlog.sql</file>
+    <file>./SQL/SQLite/13/setup_070_coreinfo.sql</file>
+    <file>./SQL/SQLite/13/setup_080_ircservers.sql</file>
+    <file>./SQL/SQLite/13/setup_090_backlog_idx.sql</file>
+    <file>./SQL/SQLite/13/setup_100_backlog_idx2.sql</file>
+    <file>./SQL/SQLite/13/setup_110_buffer_user_idx.sql</file>
+    <file>./SQL/SQLite/13/setup_120_user_setting.sql</file>
+    <file>./SQL/SQLite/13/setup_130_identity.sql</file>
+    <file>./SQL/SQLite/13/setup_140_identity_nick.sql</file>
+    <file>./SQL/SQLite/13/setup_999_version.sql</file>
+    <file>./SQL/SQLite/13/update_buffer_lastseen.sql</file>
+    <file>./SQL/SQLite/13/update_buffer_name.sql</file>
+    <file>./SQL/SQLite/13/update_buffer_persistent_channel.sql</file>
+    <file>./SQL/SQLite/13/update_buffer_set_channel_key.sql</file>
+    <file>./SQL/SQLite/13/update_identity.sql</file>
+    <file>./SQL/SQLite/13/update_network.sql</file>
+    <file>./SQL/SQLite/13/update_network_connected.sql</file>
+    <file>./SQL/SQLite/13/update_user_setting.sql</file>
+    <file>./SQL/SQLite/13/update_username.sql</file>
+    <file>./SQL/SQLite/13/update_userpassword.sql</file>
+    <file>./SQL/SQLite/13/upgrade_000_create_buffer_user_idx.sql</file>
+    <file>./SQL/SQLite/13/upgrade_010_create_buffer_cname_idx.sql</file>
+    <file>./SQL/SQLite/13/upgrade_020_create_buffer_cname_idx.sql</file>
+    <file>./SQL/SQLite/13/upgrade_999_version.sql</file>
     <file>./SQL/SQLite/2/upgrade_000_drop_buffergroup.sql</file>
     <file>./SQL/SQLite/2/upgrade_010_update_schemaversion.sql</file>
     <file>./SQL/SQLite/3/upgrade_000_update_backlog_flags.sql</file>
index 85ffe51..dea348f 100644 (file)
@@ -788,45 +788,24 @@ bool SqliteStorage::removeBuffer(const UserId &user, const BufferId &bufferId) {
   return true;
 }
 
-BufferId SqliteStorage::renameBuffer(const UserId &user, const NetworkId &networkId, const QString &newName, const QString &oldName) {
-  // check if such a buffer exists...
-  QSqlQuery existsQuery(logDb());
-  existsQuery.prepare(queryString("select_bufferByName"));
-  existsQuery.bindValue(":networkid", networkId.toInt());
-  existsQuery.bindValue(":userid", user.toInt());
-  existsQuery.bindValue(":buffercname", oldName.toLower());
-  safeExec(existsQuery);
-  if(!watchQuery(existsQuery))
-    return false;
-
-  if(!existsQuery.first())
-    return false;
-
-  const int bufferid = existsQuery.value(0).toInt();
-
-  Q_ASSERT(!existsQuery.next());
-
-  // ... and if the new name is still free.
-  existsQuery.bindValue(":networkid", networkId.toInt());
-  existsQuery.bindValue(":userid", user.toInt());
-  existsQuery.bindValue(":buffercname", newName.toLower());
-  safeExec(existsQuery);
-  if(!watchQuery(existsQuery))
+bool SqliteStorage::renameBuffer(const UserId &user, const BufferId &bufferId, const QString &newName) {
+  if(!isValidBuffer(user, bufferId))
     return false;
 
-  if(existsQuery.first())
+  QSqlQuery query(logDb());
+  query.prepare(queryString("update_buffer_name"));
+  query.bindValue(":buffername", newName);
+  query.bindValue(":buffercname", newName.toLower());
+  query.bindValue(":bufferid", bufferId.toInt());
+  safeExec(query);
+  if(query.lastError().isValid()) {
+    // unexepcted error occured (19 == constraint violation)
+    if(query.lastError().number() != 19)
+      watchQuery(query);
     return false;
+  }
 
-  QSqlQuery renameBufferQuery(logDb());
-  renameBufferQuery.prepare(queryString("update_buffer_name"));
-  renameBufferQuery.bindValue(":buffername", newName);
-  renameBufferQuery.bindValue(":buffercname", newName.toLower());
-  renameBufferQuery.bindValue(":bufferid", bufferid);
-  safeExec(renameBufferQuery);
-  if(watchQuery(existsQuery))
-    return BufferId(bufferid);
-  else
-    return BufferId();
+  return true;
 }
 
 void SqliteStorage::setBufferLastSeenMsg(UserId user, const BufferId &bufferId, const MsgId &msgId) {
index 5adae63..9b6d2c7 100644 (file)
@@ -79,7 +79,7 @@ public slots:
   virtual QList<BufferInfo> requestBuffers(UserId user);
   virtual QList<BufferId> requestBufferIdsForNetwork(UserId user, NetworkId networkId);
   virtual bool removeBuffer(const UserId &user, const BufferId &bufferId);
-  virtual BufferId renameBuffer(const UserId &user, const NetworkId &networkId, const QString &newName, const QString &oldName);
+  virtual bool renameBuffer(const UserId &user, const BufferId &bufferId, const QString &newName);
   virtual void setBufferLastSeenMsg(UserId user, const BufferId &bufferId, const MsgId &msgId);
   virtual QHash<BufferId, MsgId> bufferLastSeenMsgIds(UserId user);
 
index a80620f..a7aaae9 100644 (file)
@@ -265,14 +265,15 @@ public slots:
    */
   virtual bool removeBuffer(const UserId &user, const BufferId &bufferId) = 0;
 
+
   //! Rename a Buffer
-  /** \param user      The id of the buffer owner
-   *  \param networkId The id of the network the buffer belongs to
+  /** \note This method is threadsafe.
+   *  \param user      The id of the buffer owner
+   *  \param bufferId  The bufferId
    *  \param newName   The new name of the buffer
-   *  \param oldName   The previous name of the buffer
-   *  \return the BufferId of the affected buffer or an invalid BufferId if not successfull
+   *  \return true if successfull
    */
-  virtual BufferId renameBuffer(const UserId &user, const NetworkId &networkId, const QString &newName, const QString &oldName) = 0;
+  virtual bool renameBuffer(const UserId &user, const BufferId &bufferId, const QString &newName) = 0;
   
   //! Update the LastSeenDate for a Buffer
   /** This Method is used to make the LastSeenDate of a Buffer persistent
index f885819..9d6ab38 100644 (file)
 
 #include "inputwidget.h"
 
-#include "ircuser.h"
-#include "client.h"
-#include "networkmodel.h"
-#include "jumpkeyhandler.h"
-#include "qtuisettings.h"
-
 #include "action.h"
 #include "actioncollection.h"
+#include "client.h"
+#include "iconloader.h"
+#include "ircuser.h"
+#include "jumpkeyhandler.h"
+#include "networkmodel.h"
 #include "qtui.h"
+#include "qtuisettings.h"
 
 InputWidget::InputWidget(QWidget *parent)
   : AbstractItemView(parent),
@@ -38,6 +38,7 @@ InputWidget::InputWidget(QWidget *parent)
   connect(ui.inputEdit, SIGNAL(sendText(QString)), this, SLOT(sendText(QString)));
   connect(ui.ownNick, SIGNAL(activated(QString)), this, SLOT(changeNick(QString)));
   connect(this, SIGNAL(userInput(BufferInfo, QString)), Client::instance(), SIGNAL(sendInput(BufferInfo, QString)));
+  connect(Client::instance(), SIGNAL(disconnected()), this, SLOT(updateNickSelector()));
   setFocusProxy(ui.inputEdit);
 
   ui.ownNick->setSizeAdjustPolicy(QComboBox::AdjustToContents);
@@ -119,6 +120,7 @@ void InputWidget::setNetwork(const Network *network) {
       connect(network->me(), SIGNAL(userModesSet(QString)), this, SLOT(updateNickSelector()));
       connect(network->me(), SIGNAL(userModesAdded(QString)), this, SLOT(updateNickSelector()));
       connect(network->me(), SIGNAL(userModesRemoved(QString)), this, SLOT(updateNickSelector()));
+      connect(network->me(), SIGNAL(awaySet(bool)), this, SLOT(updateNickSelector()));
     }
   }
   setIdentity(network->identity());
@@ -161,10 +163,18 @@ void InputWidget::updateNickSelector() const {
     nickIdx = 0;
   }
 
-  if(net->me() && nickIdx < nicks.count())
-    nicks[nickIdx] = net->myNick() + QString(" (+%1)").arg(net->me()->userModes());
+  if(nicks.isEmpty())
+    return;
+
+  IrcUser *me = net->me();
+  if(me)
+    nicks[nickIdx] = net->myNick() + QString(" (+%1)").arg(me->userModes());
       
   ui.ownNick->addItems(nicks);
+
+  if(me && me->isAway())
+    ui.ownNick->setItemData(nickIdx, SmallIcon("user-away"), Qt::DecorationRole);
+
   ui.ownNick->setCurrentIndex(nickIdx);
 }