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
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; }
}
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());
: BufferItem(bufferInfo, parent),
_ircUser(0)
{
- setFlags(flags() | Qt::ItemIsDropEnabled);
+ setFlags(flags() | Qt::ItemIsDropEnabled | Qt::ItemIsEditable);
const Network *net = Client::network(bufferInfo.networkId());
if(!net)
}
}
+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);
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;
}
}
-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);
+// }
public:
explicit BufferSyncer(QObject *parent);
+ inline virtual const QMetaObject *syncMetaObject() const { return &staticMetaObject; }
MsgId lastSeenMsg(BufferId buffer) const;
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
corealiasmanager.cpp
coreapplication.cpp
corebacklogmanager.cpp
+ corebuffersyncer.cpp
corebufferviewconfig.cpp
corebufferviewmanager.cpp
corecoreinfo.cpp
corealiasmanager.h
coreapplication.h
corebacklogmanager.h
+ corebuffersyncer.h
corebufferviewconfig.h
corebufferviewmanager.h
corecoreinfo.h
--- /dev/null
+CREATE INDEX buffer_user_idx ON buffer(userid)
--- /dev/null
+CREATE UNIQUE INDEX buffer_cname_idx
+ ON buffer(userid, networkid, buffercname)
--- /dev/null
+CREATE UNIQUE INDEX buffer_idx
+ ON buffer(userid, networkid, buffername)
--- /dev/null
+UPDATE coreinfo
+SET value = 13
+WHERE key = 'schemaversion'
//! 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
#include "coresession.h"
#include "userinputhandler.h"
#include "signalproxy.h"
-#include "buffersyncer.h"
+#include "corebuffersyncer.h"
#include "corebacklogmanager.h"
#include "corebufferviewmanager.h"
#include "coreirclisthelper.h"
_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)),
_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);
}
}
-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() {
#include "corealiasmanager.h"
#include "message.h"
-class BufferSyncer;
class CoreBacklogManager;
+class CoreBufferSyncer;
class CoreBufferViewManager;
class CoreIrcListHelper;
class Identity;
*/
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);
void networkCreated(NetworkId);
void networkRemoved(NetworkId);
- void bufferRemoved(BufferId);
- void bufferRenamed(BufferId, QString);
private slots:
void removeClient(QIODevice *dev);
// QHash<NetworkId, CoreNetwork *> _networksToRemove;
QHash<IdentityId, CoreIdentity *> _identities;
- BufferSyncer *_bufferSyncer;
+ CoreBufferSyncer *_bufferSyncer;
CoreBacklogManager *_backlogManager;
CoreBufferViewManager *_bufferViewManager;
CoreIrcListHelper *_ircListHelper;
<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>
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) {
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);
*/
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
#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),
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);
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());
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);
}