From: Marcus Eggenberger Date: Mon, 29 Dec 2008 16:17:45 +0000 (+0100) Subject: recreating some indexes that were lost in an upgrade X-Git-Tag: 0.4.0~313 X-Git-Url: https://git.quassel-irc.org/?a=commitdiff_plain;h=7897b8623a42967511e31c68d5c102033a1dcdb9;p=quassel.git recreating some indexes that were lost in an upgrade --- diff --git a/src/client/client.cpp b/src/client/client.cpp index 295e062e..9956cd2b 100644 --- a/src/client/client.cpp +++ b/src/client/client.cpp @@ -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 diff --git a/src/client/client.h b/src/client/client.h index 610e732f..ac3663dd 100644 --- a/src/client/client.h +++ b/src/client/client.h @@ -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; } diff --git a/src/client/networkmodel.cpp b/src/client/networkmodel.cpp index 92020360..45cb33bb 100644 --- a/src/client/networkmodel.cpp +++ b/src/client/networkmodel.cpp @@ -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); diff --git a/src/client/networkmodel.h b/src/client/networkmodel.h index 6fd078e2..e765252b 100644 --- a/src/client/networkmodel.h +++ b/src/client/networkmodel.h @@ -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; diff --git a/src/common/buffersyncer.cpp b/src/common/buffersyncer.cpp index fe69db71..816227fa 100644 --- a/src/common/buffersyncer.cpp +++ b/src/common/buffersyncer.cpp @@ -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); +// } diff --git a/src/common/buffersyncer.h b/src/common/buffersyncer.h index 0ad8eaa0..92ca54d5 100644 --- a/src/common/buffersyncer.h +++ b/src/common/buffersyncer.h @@ -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 _lastSeenMsg; - }; #endif diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt index c4cd518c..9f799493 100644 --- a/src/core/CMakeLists.txt +++ b/src/core/CMakeLists.txt @@ -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/12/delete_backlog_by_uid.sql b/src/core/SQL/SQLite/13/delete_backlog_by_uid.sql similarity index 100% rename from src/core/SQL/SQLite/12/delete_backlog_by_uid.sql rename to src/core/SQL/SQLite/13/delete_backlog_by_uid.sql diff --git a/src/core/SQL/SQLite/12/delete_backlog_for_buffer.sql b/src/core/SQL/SQLite/13/delete_backlog_for_buffer.sql similarity index 100% rename from src/core/SQL/SQLite/12/delete_backlog_for_buffer.sql rename to src/core/SQL/SQLite/13/delete_backlog_for_buffer.sql diff --git a/src/core/SQL/SQLite/12/delete_backlog_for_network.sql b/src/core/SQL/SQLite/13/delete_backlog_for_network.sql similarity index 100% rename from src/core/SQL/SQLite/12/delete_backlog_for_network.sql rename to src/core/SQL/SQLite/13/delete_backlog_for_network.sql diff --git a/src/core/SQL/SQLite/12/delete_buffer_for_bufferid.sql b/src/core/SQL/SQLite/13/delete_buffer_for_bufferid.sql similarity index 100% rename from src/core/SQL/SQLite/12/delete_buffer_for_bufferid.sql rename to src/core/SQL/SQLite/13/delete_buffer_for_bufferid.sql diff --git a/src/core/SQL/SQLite/12/delete_buffers_by_uid.sql b/src/core/SQL/SQLite/13/delete_buffers_by_uid.sql similarity index 100% rename from src/core/SQL/SQLite/12/delete_buffers_by_uid.sql rename to src/core/SQL/SQLite/13/delete_buffers_by_uid.sql diff --git a/src/core/SQL/SQLite/12/delete_buffers_for_network.sql b/src/core/SQL/SQLite/13/delete_buffers_for_network.sql similarity index 100% rename from src/core/SQL/SQLite/12/delete_buffers_for_network.sql rename to src/core/SQL/SQLite/13/delete_buffers_for_network.sql diff --git a/src/core/SQL/SQLite/12/delete_identity.sql b/src/core/SQL/SQLite/13/delete_identity.sql similarity index 100% rename from src/core/SQL/SQLite/12/delete_identity.sql rename to src/core/SQL/SQLite/13/delete_identity.sql diff --git a/src/core/SQL/SQLite/12/delete_ircservers_for_network.sql b/src/core/SQL/SQLite/13/delete_ircservers_for_network.sql similarity index 100% rename from src/core/SQL/SQLite/12/delete_ircservers_for_network.sql rename to src/core/SQL/SQLite/13/delete_ircservers_for_network.sql diff --git a/src/core/SQL/SQLite/12/delete_network.sql b/src/core/SQL/SQLite/13/delete_network.sql similarity index 100% rename from src/core/SQL/SQLite/12/delete_network.sql rename to src/core/SQL/SQLite/13/delete_network.sql diff --git a/src/core/SQL/SQLite/12/delete_networks_by_uid.sql b/src/core/SQL/SQLite/13/delete_networks_by_uid.sql similarity index 100% rename from src/core/SQL/SQLite/12/delete_networks_by_uid.sql rename to src/core/SQL/SQLite/13/delete_networks_by_uid.sql diff --git a/src/core/SQL/SQLite/12/delete_nicks.sql b/src/core/SQL/SQLite/13/delete_nicks.sql similarity index 100% rename from src/core/SQL/SQLite/12/delete_nicks.sql rename to src/core/SQL/SQLite/13/delete_nicks.sql diff --git a/src/core/SQL/SQLite/12/delete_quasseluser.sql b/src/core/SQL/SQLite/13/delete_quasseluser.sql similarity index 100% rename from src/core/SQL/SQLite/12/delete_quasseluser.sql rename to src/core/SQL/SQLite/13/delete_quasseluser.sql diff --git a/src/core/SQL/SQLite/12/insert_buffer.sql b/src/core/SQL/SQLite/13/insert_buffer.sql similarity index 100% rename from src/core/SQL/SQLite/12/insert_buffer.sql rename to src/core/SQL/SQLite/13/insert_buffer.sql diff --git a/src/core/SQL/SQLite/12/insert_identity.sql b/src/core/SQL/SQLite/13/insert_identity.sql similarity index 100% rename from src/core/SQL/SQLite/12/insert_identity.sql rename to src/core/SQL/SQLite/13/insert_identity.sql diff --git a/src/core/SQL/SQLite/12/insert_message.sql b/src/core/SQL/SQLite/13/insert_message.sql similarity index 100% rename from src/core/SQL/SQLite/12/insert_message.sql rename to src/core/SQL/SQLite/13/insert_message.sql diff --git a/src/core/SQL/SQLite/12/insert_network.sql b/src/core/SQL/SQLite/13/insert_network.sql similarity index 100% rename from src/core/SQL/SQLite/12/insert_network.sql rename to src/core/SQL/SQLite/13/insert_network.sql diff --git a/src/core/SQL/SQLite/12/insert_nick.sql b/src/core/SQL/SQLite/13/insert_nick.sql similarity index 100% rename from src/core/SQL/SQLite/12/insert_nick.sql rename to src/core/SQL/SQLite/13/insert_nick.sql diff --git a/src/core/SQL/SQLite/12/insert_quasseluser.sql b/src/core/SQL/SQLite/13/insert_quasseluser.sql similarity index 100% rename from src/core/SQL/SQLite/12/insert_quasseluser.sql rename to src/core/SQL/SQLite/13/insert_quasseluser.sql diff --git a/src/core/SQL/SQLite/12/insert_sender.sql b/src/core/SQL/SQLite/13/insert_sender.sql similarity index 100% rename from src/core/SQL/SQLite/12/insert_sender.sql rename to src/core/SQL/SQLite/13/insert_sender.sql diff --git a/src/core/SQL/SQLite/12/insert_server.sql b/src/core/SQL/SQLite/13/insert_server.sql similarity index 100% rename from src/core/SQL/SQLite/12/insert_server.sql rename to src/core/SQL/SQLite/13/insert_server.sql diff --git a/src/core/SQL/SQLite/12/insert_user_setting.sql b/src/core/SQL/SQLite/13/insert_user_setting.sql similarity index 100% rename from src/core/SQL/SQLite/12/insert_user_setting.sql rename to src/core/SQL/SQLite/13/insert_user_setting.sql diff --git a/src/core/SQL/SQLite/12/select_authuser.sql b/src/core/SQL/SQLite/13/select_authuser.sql similarity index 100% rename from src/core/SQL/SQLite/12/select_authuser.sql rename to src/core/SQL/SQLite/13/select_authuser.sql diff --git a/src/core/SQL/SQLite/12/select_bufferByName.sql b/src/core/SQL/SQLite/13/select_bufferByName.sql similarity index 100% rename from src/core/SQL/SQLite/12/select_bufferByName.sql rename to src/core/SQL/SQLite/13/select_bufferByName.sql diff --git a/src/core/SQL/SQLite/12/select_bufferExists.sql b/src/core/SQL/SQLite/13/select_bufferExists.sql similarity index 100% rename from src/core/SQL/SQLite/12/select_bufferExists.sql rename to src/core/SQL/SQLite/13/select_bufferExists.sql diff --git a/src/core/SQL/SQLite/12/select_buffer_by_id.sql b/src/core/SQL/SQLite/13/select_buffer_by_id.sql similarity index 100% rename from src/core/SQL/SQLite/12/select_buffer_by_id.sql rename to src/core/SQL/SQLite/13/select_buffer_by_id.sql diff --git a/src/core/SQL/SQLite/12/select_buffer_lastseen_messages.sql b/src/core/SQL/SQLite/13/select_buffer_lastseen_messages.sql similarity index 100% rename from src/core/SQL/SQLite/12/select_buffer_lastseen_messages.sql rename to src/core/SQL/SQLite/13/select_buffer_lastseen_messages.sql diff --git a/src/core/SQL/SQLite/12/select_buffers.sql b/src/core/SQL/SQLite/13/select_buffers.sql similarity index 100% rename from src/core/SQL/SQLite/12/select_buffers.sql rename to src/core/SQL/SQLite/13/select_buffers.sql diff --git a/src/core/SQL/SQLite/12/select_buffers_for_network.sql b/src/core/SQL/SQLite/13/select_buffers_for_network.sql similarity index 100% rename from src/core/SQL/SQLite/12/select_buffers_for_network.sql rename to src/core/SQL/SQLite/13/select_buffers_for_network.sql diff --git a/src/core/SQL/SQLite/12/select_checkidentity.sql b/src/core/SQL/SQLite/13/select_checkidentity.sql similarity index 100% rename from src/core/SQL/SQLite/12/select_checkidentity.sql rename to src/core/SQL/SQLite/13/select_checkidentity.sql diff --git a/src/core/SQL/SQLite/12/select_connected_networks.sql b/src/core/SQL/SQLite/13/select_connected_networks.sql similarity index 100% rename from src/core/SQL/SQLite/12/select_connected_networks.sql rename to src/core/SQL/SQLite/13/select_connected_networks.sql diff --git a/src/core/SQL/SQLite/12/select_identities.sql b/src/core/SQL/SQLite/13/select_identities.sql similarity index 100% rename from src/core/SQL/SQLite/12/select_identities.sql rename to src/core/SQL/SQLite/13/select_identities.sql diff --git a/src/core/SQL/SQLite/12/select_internaluser.sql b/src/core/SQL/SQLite/13/select_internaluser.sql similarity index 100% rename from src/core/SQL/SQLite/12/select_internaluser.sql rename to src/core/SQL/SQLite/13/select_internaluser.sql diff --git a/src/core/SQL/SQLite/12/select_messages.sql b/src/core/SQL/SQLite/13/select_messages.sql similarity index 100% rename from src/core/SQL/SQLite/12/select_messages.sql rename to src/core/SQL/SQLite/13/select_messages.sql diff --git a/src/core/SQL/SQLite/12/select_messagesAll.sql b/src/core/SQL/SQLite/13/select_messagesAll.sql similarity index 100% rename from src/core/SQL/SQLite/12/select_messagesAll.sql rename to src/core/SQL/SQLite/13/select_messagesAll.sql diff --git a/src/core/SQL/SQLite/12/select_messagesAllNew.sql b/src/core/SQL/SQLite/13/select_messagesAllNew.sql similarity index 100% rename from src/core/SQL/SQLite/12/select_messagesAllNew.sql rename to src/core/SQL/SQLite/13/select_messagesAllNew.sql diff --git a/src/core/SQL/SQLite/12/select_messagesNew.sql b/src/core/SQL/SQLite/13/select_messagesNew.sql similarity index 100% rename from src/core/SQL/SQLite/12/select_messagesNew.sql rename to src/core/SQL/SQLite/13/select_messagesNew.sql diff --git a/src/core/SQL/SQLite/12/select_networkExists.sql b/src/core/SQL/SQLite/13/select_networkExists.sql similarity index 100% rename from src/core/SQL/SQLite/12/select_networkExists.sql rename to src/core/SQL/SQLite/13/select_networkExists.sql diff --git a/src/core/SQL/SQLite/12/select_networks_for_user.sql b/src/core/SQL/SQLite/13/select_networks_for_user.sql similarity index 100% rename from src/core/SQL/SQLite/12/select_networks_for_user.sql rename to src/core/SQL/SQLite/13/select_networks_for_user.sql diff --git a/src/core/SQL/SQLite/12/select_nicks.sql b/src/core/SQL/SQLite/13/select_nicks.sql similarity index 100% rename from src/core/SQL/SQLite/12/select_nicks.sql rename to src/core/SQL/SQLite/13/select_nicks.sql diff --git a/src/core/SQL/SQLite/12/select_persistent_channels.sql b/src/core/SQL/SQLite/13/select_persistent_channels.sql similarity index 100% rename from src/core/SQL/SQLite/12/select_persistent_channels.sql rename to src/core/SQL/SQLite/13/select_persistent_channels.sql diff --git a/src/core/SQL/SQLite/12/select_servers_for_network.sql b/src/core/SQL/SQLite/13/select_servers_for_network.sql similarity index 100% rename from src/core/SQL/SQLite/12/select_servers_for_network.sql rename to src/core/SQL/SQLite/13/select_servers_for_network.sql diff --git a/src/core/SQL/SQLite/12/select_user_setting.sql b/src/core/SQL/SQLite/13/select_user_setting.sql similarity index 100% rename from src/core/SQL/SQLite/12/select_user_setting.sql rename to src/core/SQL/SQLite/13/select_user_setting.sql diff --git a/src/core/SQL/SQLite/12/select_userid.sql b/src/core/SQL/SQLite/13/select_userid.sql similarity index 100% rename from src/core/SQL/SQLite/12/select_userid.sql rename to src/core/SQL/SQLite/13/select_userid.sql diff --git a/src/core/SQL/SQLite/12/setup_000_quasseluser.sql b/src/core/SQL/SQLite/13/setup_000_quasseluser.sql similarity index 100% rename from src/core/SQL/SQLite/12/setup_000_quasseluser.sql rename to src/core/SQL/SQLite/13/setup_000_quasseluser.sql diff --git a/src/core/SQL/SQLite/12/setup_010_sender.sql b/src/core/SQL/SQLite/13/setup_010_sender.sql similarity index 100% rename from src/core/SQL/SQLite/12/setup_010_sender.sql rename to src/core/SQL/SQLite/13/setup_010_sender.sql diff --git a/src/core/SQL/SQLite/12/setup_020_network.sql b/src/core/SQL/SQLite/13/setup_020_network.sql similarity index 100% rename from src/core/SQL/SQLite/12/setup_020_network.sql rename to src/core/SQL/SQLite/13/setup_020_network.sql diff --git a/src/core/SQL/SQLite/12/setup_030_buffer.sql b/src/core/SQL/SQLite/13/setup_030_buffer.sql similarity index 100% rename from src/core/SQL/SQLite/12/setup_030_buffer.sql rename to src/core/SQL/SQLite/13/setup_030_buffer.sql diff --git a/src/core/SQL/SQLite/12/setup_040_buffer_idx.sql b/src/core/SQL/SQLite/13/setup_040_buffer_idx.sql similarity index 100% rename from src/core/SQL/SQLite/12/setup_040_buffer_idx.sql rename to src/core/SQL/SQLite/13/setup_040_buffer_idx.sql diff --git a/src/core/SQL/SQLite/12/setup_050_buffer_cname_idx.sql b/src/core/SQL/SQLite/13/setup_050_buffer_cname_idx.sql similarity index 100% rename from src/core/SQL/SQLite/12/setup_050_buffer_cname_idx.sql rename to src/core/SQL/SQLite/13/setup_050_buffer_cname_idx.sql diff --git a/src/core/SQL/SQLite/12/setup_060_backlog.sql b/src/core/SQL/SQLite/13/setup_060_backlog.sql similarity index 100% rename from src/core/SQL/SQLite/12/setup_060_backlog.sql rename to src/core/SQL/SQLite/13/setup_060_backlog.sql diff --git a/src/core/SQL/SQLite/12/setup_070_coreinfo.sql b/src/core/SQL/SQLite/13/setup_070_coreinfo.sql similarity index 100% rename from src/core/SQL/SQLite/12/setup_070_coreinfo.sql rename to src/core/SQL/SQLite/13/setup_070_coreinfo.sql diff --git a/src/core/SQL/SQLite/12/setup_080_ircservers.sql b/src/core/SQL/SQLite/13/setup_080_ircservers.sql similarity index 100% rename from src/core/SQL/SQLite/12/setup_080_ircservers.sql rename to src/core/SQL/SQLite/13/setup_080_ircservers.sql diff --git a/src/core/SQL/SQLite/12/setup_090_create_backlog_idx.sql b/src/core/SQL/SQLite/13/setup_090_backlog_idx.sql similarity index 100% rename from src/core/SQL/SQLite/12/setup_090_create_backlog_idx.sql rename to src/core/SQL/SQLite/13/setup_090_backlog_idx.sql diff --git a/src/core/SQL/SQLite/12/setup_100_create_backlog_idx2.sql b/src/core/SQL/SQLite/13/setup_100_backlog_idx2.sql similarity index 100% rename from src/core/SQL/SQLite/12/setup_100_create_backlog_idx2.sql rename to src/core/SQL/SQLite/13/setup_100_backlog_idx2.sql diff --git a/src/core/SQL/SQLite/12/setup_110_create_buffer_idx.sql b/src/core/SQL/SQLite/13/setup_110_buffer_user_idx.sql similarity index 100% rename from src/core/SQL/SQLite/12/setup_110_create_buffer_idx.sql rename to src/core/SQL/SQLite/13/setup_110_buffer_user_idx.sql diff --git a/src/core/SQL/SQLite/12/setup_120_create_user_setting.sql b/src/core/SQL/SQLite/13/setup_120_user_setting.sql similarity index 100% rename from src/core/SQL/SQLite/12/setup_120_create_user_setting.sql rename to src/core/SQL/SQLite/13/setup_120_user_setting.sql diff --git a/src/core/SQL/SQLite/12/setup_130_identity.sql b/src/core/SQL/SQLite/13/setup_130_identity.sql similarity index 100% rename from src/core/SQL/SQLite/12/setup_130_identity.sql rename to src/core/SQL/SQLite/13/setup_130_identity.sql diff --git a/src/core/SQL/SQLite/12/setup_140_identity_nick.sql b/src/core/SQL/SQLite/13/setup_140_identity_nick.sql similarity index 100% rename from src/core/SQL/SQLite/12/setup_140_identity_nick.sql rename to src/core/SQL/SQLite/13/setup_140_identity_nick.sql diff --git a/src/core/SQL/SQLite/12/setup_999_version.sql b/src/core/SQL/SQLite/13/setup_999_version.sql similarity index 100% rename from src/core/SQL/SQLite/12/setup_999_version.sql rename to src/core/SQL/SQLite/13/setup_999_version.sql diff --git a/src/core/SQL/SQLite/12/update_buffer_lastseen.sql b/src/core/SQL/SQLite/13/update_buffer_lastseen.sql similarity index 100% rename from src/core/SQL/SQLite/12/update_buffer_lastseen.sql rename to src/core/SQL/SQLite/13/update_buffer_lastseen.sql diff --git a/src/core/SQL/SQLite/12/update_buffer_name.sql b/src/core/SQL/SQLite/13/update_buffer_name.sql similarity index 100% rename from src/core/SQL/SQLite/12/update_buffer_name.sql rename to src/core/SQL/SQLite/13/update_buffer_name.sql diff --git a/src/core/SQL/SQLite/12/update_buffer_persistent_channel.sql b/src/core/SQL/SQLite/13/update_buffer_persistent_channel.sql similarity index 100% rename from src/core/SQL/SQLite/12/update_buffer_persistent_channel.sql rename to src/core/SQL/SQLite/13/update_buffer_persistent_channel.sql diff --git a/src/core/SQL/SQLite/12/update_buffer_set_channel_key.sql b/src/core/SQL/SQLite/13/update_buffer_set_channel_key.sql similarity index 100% rename from src/core/SQL/SQLite/12/update_buffer_set_channel_key.sql rename to src/core/SQL/SQLite/13/update_buffer_set_channel_key.sql diff --git a/src/core/SQL/SQLite/12/update_identity.sql b/src/core/SQL/SQLite/13/update_identity.sql similarity index 100% rename from src/core/SQL/SQLite/12/update_identity.sql rename to src/core/SQL/SQLite/13/update_identity.sql diff --git a/src/core/SQL/SQLite/12/update_network.sql b/src/core/SQL/SQLite/13/update_network.sql similarity index 100% rename from src/core/SQL/SQLite/12/update_network.sql rename to src/core/SQL/SQLite/13/update_network.sql diff --git a/src/core/SQL/SQLite/12/update_network_connected.sql b/src/core/SQL/SQLite/13/update_network_connected.sql similarity index 100% rename from src/core/SQL/SQLite/12/update_network_connected.sql rename to src/core/SQL/SQLite/13/update_network_connected.sql diff --git a/src/core/SQL/SQLite/12/update_user_setting.sql b/src/core/SQL/SQLite/13/update_user_setting.sql similarity index 100% rename from src/core/SQL/SQLite/12/update_user_setting.sql rename to src/core/SQL/SQLite/13/update_user_setting.sql diff --git a/src/core/SQL/SQLite/12/update_username.sql b/src/core/SQL/SQLite/13/update_username.sql similarity index 100% rename from src/core/SQL/SQLite/12/update_username.sql rename to src/core/SQL/SQLite/13/update_username.sql diff --git a/src/core/SQL/SQLite/12/update_userpassword.sql b/src/core/SQL/SQLite/13/update_userpassword.sql similarity index 100% rename from src/core/SQL/SQLite/12/update_userpassword.sql rename to src/core/SQL/SQLite/13/update_userpassword.sql 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 index 00000000..cb55f1da --- /dev/null +++ b/src/core/SQL/SQLite/13/upgrade_000_create_buffer_user_idx.sql @@ -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 index 00000000..3858455e --- /dev/null +++ b/src/core/SQL/SQLite/13/upgrade_010_create_buffer_cname_idx.sql @@ -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 index 00000000..042ce3a3 --- /dev/null +++ b/src/core/SQL/SQLite/13/upgrade_020_create_buffer_cname_idx.sql @@ -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 index 00000000..edb5aef0 --- /dev/null +++ b/src/core/SQL/SQLite/13/upgrade_999_version.sql @@ -0,0 +1,3 @@ +UPDATE coreinfo +SET value = 13 +WHERE key = 'schemaversion' diff --git a/src/core/core.h b/src/core/core.h index 0c6e88dc..6ddb6e86 100644 --- a/src/core/core.h +++ b/src/core/core.h @@ -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 diff --git a/src/core/coresession.cpp b/src/core/coresession.cpp index f18f9269..841ae7c1 100644 --- a/src/core/coresession.cpp +++ b/src/core/coresession.cpp @@ -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() { diff --git a/src/core/coresession.h b/src/core/coresession.h index d781f211..e47698e0 100644 --- a/src/core/coresession.h +++ b/src/core/coresession.h @@ -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 _networksToRemove; QHash _identities; - BufferSyncer *_bufferSyncer; + CoreBufferSyncer *_bufferSyncer; CoreBacklogManager *_backlogManager; CoreBufferViewManager *_bufferViewManager; CoreIrcListHelper *_ircListHelper; diff --git a/src/core/sql.qrc b/src/core/sql.qrc index e3459e14..2c2c50e7 100644 --- a/src/core/sql.qrc +++ b/src/core/sql.qrc @@ -11,75 +11,6 @@ ./SQL/SQLite/10/upgrade_999_version.sql ./SQL/SQLite/11/upgrade_000_create_user_setting.sql ./SQL/SQLite/11/upgrade_999_version.sql - ./SQL/SQLite/12/delete_backlog_by_uid.sql - ./SQL/SQLite/12/delete_backlog_for_buffer.sql - ./SQL/SQLite/12/delete_backlog_for_network.sql - ./SQL/SQLite/12/delete_buffer_for_bufferid.sql - ./SQL/SQLite/12/delete_buffers_by_uid.sql - ./SQL/SQLite/12/delete_buffers_for_network.sql - ./SQL/SQLite/12/delete_identity.sql - ./SQL/SQLite/12/delete_ircservers_for_network.sql - ./SQL/SQLite/12/delete_network.sql - ./SQL/SQLite/12/delete_networks_by_uid.sql - ./SQL/SQLite/12/delete_nicks.sql - ./SQL/SQLite/12/delete_quasseluser.sql - ./SQL/SQLite/12/insert_buffer.sql - ./SQL/SQLite/12/insert_identity.sql - ./SQL/SQLite/12/insert_message.sql - ./SQL/SQLite/12/insert_network.sql - ./SQL/SQLite/12/insert_nick.sql - ./SQL/SQLite/12/insert_quasseluser.sql - ./SQL/SQLite/12/insert_sender.sql - ./SQL/SQLite/12/insert_server.sql - ./SQL/SQLite/12/insert_user_setting.sql - ./SQL/SQLite/12/select_authuser.sql - ./SQL/SQLite/12/select_buffer_by_id.sql - ./SQL/SQLite/12/select_buffer_lastseen_messages.sql - ./SQL/SQLite/12/select_bufferByName.sql - ./SQL/SQLite/12/select_bufferExists.sql - ./SQL/SQLite/12/select_buffers.sql - ./SQL/SQLite/12/select_buffers_for_network.sql - ./SQL/SQLite/12/select_checkidentity.sql - ./SQL/SQLite/12/select_connected_networks.sql - ./SQL/SQLite/12/select_identities.sql - ./SQL/SQLite/12/select_internaluser.sql - ./SQL/SQLite/12/select_messages.sql - ./SQL/SQLite/12/select_messagesAll.sql - ./SQL/SQLite/12/select_messagesAllNew.sql - ./SQL/SQLite/12/select_messagesNew.sql - ./SQL/SQLite/12/select_networkExists.sql - ./SQL/SQLite/12/select_networks_for_user.sql - ./SQL/SQLite/12/select_nicks.sql - ./SQL/SQLite/12/select_persistent_channels.sql - ./SQL/SQLite/12/select_servers_for_network.sql - ./SQL/SQLite/12/select_user_setting.sql - ./SQL/SQLite/12/select_userid.sql - ./SQL/SQLite/12/setup_000_quasseluser.sql - ./SQL/SQLite/12/setup_010_sender.sql - ./SQL/SQLite/12/setup_020_network.sql - ./SQL/SQLite/12/setup_030_buffer.sql - ./SQL/SQLite/12/setup_040_buffer_idx.sql - ./SQL/SQLite/12/setup_050_buffer_cname_idx.sql - ./SQL/SQLite/12/setup_060_backlog.sql - ./SQL/SQLite/12/setup_070_coreinfo.sql - ./SQL/SQLite/12/setup_080_ircservers.sql - ./SQL/SQLite/12/setup_090_create_backlog_idx.sql - ./SQL/SQLite/12/setup_100_create_backlog_idx2.sql - ./SQL/SQLite/12/setup_110_create_buffer_idx.sql - ./SQL/SQLite/12/setup_120_create_user_setting.sql - ./SQL/SQLite/12/setup_130_identity.sql - ./SQL/SQLite/12/setup_140_identity_nick.sql - ./SQL/SQLite/12/setup_999_version.sql - ./SQL/SQLite/12/update_buffer_lastseen.sql - ./SQL/SQLite/12/update_buffer_name.sql - ./SQL/SQLite/12/update_buffer_persistent_channel.sql - ./SQL/SQLite/12/update_buffer_set_channel_key.sql - ./SQL/SQLite/12/update_identity.sql - ./SQL/SQLite/12/update_network.sql - ./SQL/SQLite/12/update_network_connected.sql - ./SQL/SQLite/12/update_user_setting.sql - ./SQL/SQLite/12/update_username.sql - ./SQL/SQLite/12/update_userpassword.sql ./SQL/SQLite/12/upgrade_000_create_identity.sql ./SQL/SQLite/12/upgrade_010_create_identity_nick.sql ./SQL/SQLite/12/upgrade_020_rename_servertable.sql @@ -87,6 +18,79 @@ ./SQL/SQLite/12/upgrade_040_copy_ircserver.sql ./SQL/SQLite/12/upgrade_050_drop_ircserverold.sql ./SQL/SQLite/12/upgrade_999_version.sql + ./SQL/SQLite/13/delete_backlog_by_uid.sql + ./SQL/SQLite/13/delete_backlog_for_buffer.sql + ./SQL/SQLite/13/delete_backlog_for_network.sql + ./SQL/SQLite/13/delete_buffer_for_bufferid.sql + ./SQL/SQLite/13/delete_buffers_by_uid.sql + ./SQL/SQLite/13/delete_buffers_for_network.sql + ./SQL/SQLite/13/delete_identity.sql + ./SQL/SQLite/13/delete_ircservers_for_network.sql + ./SQL/SQLite/13/delete_network.sql + ./SQL/SQLite/13/delete_networks_by_uid.sql + ./SQL/SQLite/13/delete_nicks.sql + ./SQL/SQLite/13/delete_quasseluser.sql + ./SQL/SQLite/13/insert_buffer.sql + ./SQL/SQLite/13/insert_identity.sql + ./SQL/SQLite/13/insert_message.sql + ./SQL/SQLite/13/insert_network.sql + ./SQL/SQLite/13/insert_nick.sql + ./SQL/SQLite/13/insert_quasseluser.sql + ./SQL/SQLite/13/insert_sender.sql + ./SQL/SQLite/13/insert_server.sql + ./SQL/SQLite/13/insert_user_setting.sql + ./SQL/SQLite/13/select_authuser.sql + ./SQL/SQLite/13/select_buffer_by_id.sql + ./SQL/SQLite/13/select_buffer_lastseen_messages.sql + ./SQL/SQLite/13/select_bufferByName.sql + ./SQL/SQLite/13/select_bufferExists.sql + ./SQL/SQLite/13/select_buffers.sql + ./SQL/SQLite/13/select_buffers_for_network.sql + ./SQL/SQLite/13/select_checkidentity.sql + ./SQL/SQLite/13/select_connected_networks.sql + ./SQL/SQLite/13/select_identities.sql + ./SQL/SQLite/13/select_internaluser.sql + ./SQL/SQLite/13/select_messages.sql + ./SQL/SQLite/13/select_messagesAll.sql + ./SQL/SQLite/13/select_messagesAllNew.sql + ./SQL/SQLite/13/select_messagesNew.sql + ./SQL/SQLite/13/select_networkExists.sql + ./SQL/SQLite/13/select_networks_for_user.sql + ./SQL/SQLite/13/select_nicks.sql + ./SQL/SQLite/13/select_persistent_channels.sql + ./SQL/SQLite/13/select_servers_for_network.sql + ./SQL/SQLite/13/select_user_setting.sql + ./SQL/SQLite/13/select_userid.sql + ./SQL/SQLite/13/setup_000_quasseluser.sql + ./SQL/SQLite/13/setup_010_sender.sql + ./SQL/SQLite/13/setup_020_network.sql + ./SQL/SQLite/13/setup_030_buffer.sql + ./SQL/SQLite/13/setup_040_buffer_idx.sql + ./SQL/SQLite/13/setup_050_buffer_cname_idx.sql + ./SQL/SQLite/13/setup_060_backlog.sql + ./SQL/SQLite/13/setup_070_coreinfo.sql + ./SQL/SQLite/13/setup_080_ircservers.sql + ./SQL/SQLite/13/setup_090_backlog_idx.sql + ./SQL/SQLite/13/setup_100_backlog_idx2.sql + ./SQL/SQLite/13/setup_110_buffer_user_idx.sql + ./SQL/SQLite/13/setup_120_user_setting.sql + ./SQL/SQLite/13/setup_130_identity.sql + ./SQL/SQLite/13/setup_140_identity_nick.sql + ./SQL/SQLite/13/setup_999_version.sql + ./SQL/SQLite/13/update_buffer_lastseen.sql + ./SQL/SQLite/13/update_buffer_name.sql + ./SQL/SQLite/13/update_buffer_persistent_channel.sql + ./SQL/SQLite/13/update_buffer_set_channel_key.sql + ./SQL/SQLite/13/update_identity.sql + ./SQL/SQLite/13/update_network.sql + ./SQL/SQLite/13/update_network_connected.sql + ./SQL/SQLite/13/update_user_setting.sql + ./SQL/SQLite/13/update_username.sql + ./SQL/SQLite/13/update_userpassword.sql + ./SQL/SQLite/13/upgrade_000_create_buffer_user_idx.sql + ./SQL/SQLite/13/upgrade_010_create_buffer_cname_idx.sql + ./SQL/SQLite/13/upgrade_020_create_buffer_cname_idx.sql + ./SQL/SQLite/13/upgrade_999_version.sql ./SQL/SQLite/2/upgrade_000_drop_buffergroup.sql ./SQL/SQLite/2/upgrade_010_update_schemaversion.sql ./SQL/SQLite/3/upgrade_000_update_backlog_flags.sql diff --git a/src/core/sqlitestorage.cpp b/src/core/sqlitestorage.cpp index 85ffe515..dea348fb 100644 --- a/src/core/sqlitestorage.cpp +++ b/src/core/sqlitestorage.cpp @@ -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) { diff --git a/src/core/sqlitestorage.h b/src/core/sqlitestorage.h index 5adae63f..9b6d2c7c 100644 --- a/src/core/sqlitestorage.h +++ b/src/core/sqlitestorage.h @@ -79,7 +79,7 @@ public slots: virtual QList requestBuffers(UserId user); virtual QList 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 bufferLastSeenMsgIds(UserId user); diff --git a/src/core/storage.h b/src/core/storage.h index a80620fa..a7aaae91 100644 --- a/src/core/storage.h +++ b/src/core/storage.h @@ -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 diff --git a/src/qtui/inputwidget.cpp b/src/qtui/inputwidget.cpp index f885819d..9d6ab388 100644 --- a/src/qtui/inputwidget.cpp +++ b/src/qtui/inputwidget.cpp @@ -20,15 +20,15 @@ #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); }