Summary: | Cannot edit server if its "Network" label is blank | ||
---|---|---|---|
Product: | [Applications] konversation | Reporter: | Bill Kendrick <bill> |
Component: | general | Assignee: | Peter Simonsson <peter.simonsson> |
Status: | RESOLVED FIXED | ||
Severity: | normal | CC: | kde-bugs |
Priority: | NOR | ||
Version: | unspecified | ||
Target Milestone: | --- | ||
Platform: | unspecified | ||
OS: | Linux | ||
Latest Commit: | Version Fixed In: |
Description
Bill Kendrick
2005-02-07 07:08:46 UTC
CVS commit by psn: * Start using KSharedPtr for ServerGroupSettings * Make networks with no name editable BUG:98744 M +1 -1 editnotifydialog.cpp 1.8 M +1 -1 identitydialog.cpp 1.15 M +29 -29 konversationapplication.cpp 1.238 M +11 -11 preferences.cpp 1.189 M +2 -2 preferences.h 1.148 M +33 -32 server.cpp 1.450 M +1 -1 server.h 1.197 M +18 -18 servergroupdialog.cpp 1.14 M +2 -2 servergroupdialog.h 1.7 M +6 -4 servergroupsettings.h 1.6 M +16 -20 serverlistdialog.cpp 1.22 M +4 -3 serverlistdialog.h 1.9 *** Bug 103773 has been marked as a duplicate of this bug. *** commit 2d72e0a1791a172f854b1eb81f6c7b6b4c11eb21 Author: Peter Simonsson <peter.simonsson@gmail.com> Date: Thu Mar 31 17:55:25 2005 +0000 * Start using KSharedPtr for ServerGroupSettings * Make networks with no name editable BUG:98744 svn path=/trunk/kdeextragear-2/konversation/; revision=402197 diff --git a/konversation/editnotifydialog.cpp b/konversation/editnotifydialog.cpp index f0db662..eef20ad 100644 --- a/konversation/editnotifydialog.cpp +++ b/konversation/editnotifydialog.cpp @@ -66,7 +66,7 @@ EditNotifyDialog::EditNotifyDialog(QWidget* parent, for(Konversation::ServerGroupList::iterator it = serverNetworks.begin(); it != serverNetworks.end(); ++it) { - QString name = (*it).name(); + QString name = (*it)->name(); if (!networkNames.contains(name)) { networkNames.append(name); diff --git a/konversation/identitydialog.cpp b/konversation/identitydialog.cpp index 192946a..9174b1b 100644 --- a/konversation/identitydialog.cpp +++ b/konversation/identitydialog.cpp @@ -461,7 +461,7 @@ void IdentityDialog::deleteIdentity() bool found = false; while((it != serverGroups.end()) && !found) { - if((*it).identityId() == m_currentIdentity->id()) { + if((*it)->identityId() == m_currentIdentity->id()) { found = true; } diff --git a/konversation/konversationapplication.cpp b/konversation/konversationapplication.cpp index 28e2482..ef60982 100644 --- a/konversation/konversationapplication.cpp +++ b/konversation/konversationapplication.cpp @@ -136,8 +136,8 @@ int KonversationApplication::newInstance() Konversation::ServerGroupList serverGroups = preferences.serverGroupList(); for(Konversation::ServerGroupList::iterator it = serverGroups.begin(); it != serverGroups.end(); ++it) { - if((*it).autoConnectEnabled()) { - connectToServer((*it).id()); + if((*it)->autoConnectEnabled()) { + connectToServer((*it)->id()); } } @@ -283,8 +283,8 @@ void KonversationApplication::insertRememberLine() void KonversationApplication::connectToServer(int id) { - Konversation::ServerGroupSettings serverGroup = preferences.serverGroupById(id); - IdentityPtr identity = serverGroup.identity(); + Konversation::ServerGroupSettingsPtr serverGroup = preferences.serverGroupById(id); + IdentityPtr identity = serverGroup->identity(); if(!identity) { return; @@ -323,7 +323,7 @@ void KonversationApplication::connectToServer(int id) mainWindow->show(); // Check if a server window with same name and port is already open - Server* newServer = new Server(mainWindow,id); + Server* newServer = new Server(mainWindow, id); connect(mainWindow,SIGNAL (startNotifyTimer(int)),newServer,SLOT (startNotifyTimer(int)) ); connect(mainWindow,SIGNAL (quitServer()),newServer,SLOT (quitServer()) ); @@ -643,18 +643,18 @@ void KonversationApplication::readOptions() { QString serverStr = config->readEntry(QString("Server%1").arg(index++)); - Konversation::ServerGroupSettings serverGroup; + Konversation::ServerGroupSettingsPtr serverGroup = new Konversation::ServerGroupSettings; QStringList tmp = QStringList::split(',', serverStr, true); - serverGroup.setName(tmp[1]); - serverGroup.setGroup(tmp[0]); + serverGroup->setName(tmp[1]); + serverGroup->setGroup(tmp[0]); Konversation::ServerSettings server; server.setServer(tmp[1]); server.setPort(tmp[2].toInt()); server.setPassword(tmp[3]); - serverGroup.addServer(server); - serverGroup.setIdentityId(preferences.getIdentityByName(tmp[7])->id()); - serverGroup.setAutoConnectEnabled(tmp[6].toInt()); - serverGroup.setConnectCommands(tmp[8]); + serverGroup->addServer(server); + serverGroup->setIdentityId(preferences.getIdentityByName(tmp[7])->id()); + serverGroup->setAutoConnectEnabled(tmp[6].toInt()); + serverGroup->setConnectCommands(tmp[8]); if(!tmp[4].isEmpty()) { QStringList tmp2 = QStringList::split(" ", tmp[4], false); @@ -667,7 +667,7 @@ void KonversationApplication::readOptions() channel.setPassword(tmp3[i]); } - serverGroup.addChannel(channel); + serverGroup->addChannel(channel); } } @@ -687,12 +687,12 @@ void KonversationApplication::readOptions() for(it = groups.begin(); it != groups.end(); ++it) { config->setGroup((*it)); - Konversation::ServerGroupSettings serverGroup; - serverGroup.setName(config->readEntry("Name")); - serverGroup.setGroup(config->readEntry("Group")); - serverGroup.setIdentityId(preferences.getIdentityByName(config->readEntry("Identity"))->id()); - serverGroup.setConnectCommands(config->readEntry("ConnectCommands")); - serverGroup.setAutoConnectEnabled(config->readBoolEntry("AutoConnect")); + Konversation::ServerGroupSettingsPtr serverGroup = new Konversation::ServerGroupSettings; + serverGroup->setName(config->readEntry("Name")); + serverGroup->setGroup(config->readEntry("Group")); + serverGroup->setIdentityId(preferences.getIdentityByName(config->readEntry("Identity"))->id()); + serverGroup->setConnectCommands(config->readEntry("ConnectCommands")); + serverGroup->setAutoConnectEnabled(config->readBoolEntry("AutoConnect")); tmp1 = config->readListEntry("ServerList"); tmp2 = config->readListEntry("AutoJoinChannels"); @@ -703,7 +703,7 @@ void KonversationApplication::readOptions() server.setPort(config->readNumEntry("Port")); server.setPassword(config->readEntry("Password")); server.setSSLEnabled(config->readBoolEntry("SSLEnabled")); - serverGroup.addServer(server); + serverGroup->addServer(server); } @@ -714,7 +714,7 @@ void KonversationApplication::readOptions() if(!config->readEntry("Name").isEmpty()) { channel.setName(config->readEntry("Name")); channel.setPassword(config->readEntry("Password")); - serverGroup.addChannel(channel); + serverGroup->addChannel(channel); } } @@ -756,7 +756,7 @@ void KonversationApplication::readOptions() for(Konversation::ServerGroupList::iterator it = serverGroups.begin(); it != serverGroups.end(); ++it) { - QString name = (*it).name(); + QString name = (*it)->name(); if (!groupNames.contains(name)) { groupNames.append(name); @@ -1113,7 +1113,7 @@ void KonversationApplication::saveOptions(bool updateGUI) QStringList channels; for(it = serverGroupList.begin(); it != serverGroupList.end(); ++it) { - serverlist = (*it).serverList(); + serverlist = (*it)->serverList(); servers.clear(); for(it2 = serverlist.begin(); it2 != serverlist.end(); ++it2) { @@ -1127,7 +1127,7 @@ void KonversationApplication::saveOptions(bool updateGUI) index2++; } - channelList = (*it).channelList(); + channelList = (*it)->channelList(); channels.clear(); for(it3 = channelList.begin(); it3 != channelList.end(); ++it3) { @@ -1140,13 +1140,13 @@ void KonversationApplication::saveOptions(bool updateGUI) } config->setGroup(QString("ServerGroup %1").arg(index)); - config->writeEntry("Name", (*it).name()); - config->writeEntry("Group", (*it).group()); - config->writeEntry("Identity", (*it).identity()->getName()); + config->writeEntry("Name", (*it)->name()); + config->writeEntry("Group", (*it)->group()); + config->writeEntry("Identity", (*it)->identity()->getName()); config->writeEntry("ServerList", servers); config->writeEntry("AutoJoinChannels", channels); - config->writeEntry("ConnectCommands", (*it).connectCommands()); - config->writeEntry("AutoConnect", (*it).autoConnectEnabled()); + config->writeEntry("ConnectCommands", (*it)->connectCommands()); + config->writeEntry("AutoConnect", (*it)->autoConnectEnabled()); index++; } diff --git a/konversation/preferences.cpp b/konversation/preferences.cpp index 917b889..00d121c 100644 --- a/konversation/preferences.cpp +++ b/konversation/preferences.cpp @@ -61,15 +61,15 @@ Preferences::Preferences() setNickCompleteSuffixStart(": "); setNickCompleteSuffixMiddle(" "); - Konversation::ServerGroupSettings serverGroup; - serverGroup.setName("Freenode"); + Konversation::ServerGroupSettingsPtr serverGroup = new Konversation::ServerGroupSettings; + serverGroup->setName("Freenode"); Konversation::ServerSettings server; server.setServer("irc.freenode.org"); - serverGroup.addServer(server); - serverGroup.setIdentityId(identity->id()); + serverGroup->addServer(server); + serverGroup->setIdentityId(identity->id()); Konversation::ChannelSettings channel; channel.setName("#kde"); - serverGroup.addChannel(channel); + serverGroup->addChannel(channel); m_serverGroupList.append(serverGroup); buttonList.append("Op,/OP %u%n"); @@ -267,26 +267,26 @@ void Preferences::setServerGroupList(const Konversation::ServerGroupList& list) m_serverGroupList = list; } -void Preferences::addServerGroup(const Konversation::ServerGroupSettings& serverGroup) +void Preferences::addServerGroup(Konversation::ServerGroupSettingsPtr serverGroup) { m_serverGroupList.append(serverGroup); } -const Konversation::ServerGroupSettings Preferences::serverGroupById(int id) +const Konversation::ServerGroupSettingsPtr Preferences::serverGroupById(int id) { if(!m_serverGroupList.count()) { - return Konversation::ServerGroupSettings(); + return 0; } Konversation::ServerGroupList::iterator it; for(it = m_serverGroupList.begin(); it != m_serverGroupList.end(); ++it) { - if((*it).id() == id) { + if((*it)->id() == id) { return (*it); } } - return Konversation::ServerGroupSettings(); + return 0; } void Preferences::removeServerGroup(int id) @@ -298,7 +298,7 @@ void Preferences::removeServerGroup(int id) Konversation::ServerGroupList::iterator it; for(it = m_serverGroupList.begin(); it != m_serverGroupList.end(); ++it) { - if((*it).id() == id) { + if((*it)->id() == id) { m_serverGroupList.remove(it); return; } diff --git a/konversation/preferences.h b/konversation/preferences.h index 222c496..2c63505 100644 --- a/konversation/preferences.h +++ b/konversation/preferences.h @@ -69,8 +69,8 @@ class Preferences : public QObject const Konversation::ServerGroupList serverGroupList(); void setServerGroupList(const Konversation::ServerGroupList& list); - void addServerGroup(const Konversation::ServerGroupSettings& serverGroup); - const Konversation::ServerGroupSettings serverGroupById(int id); + void addServerGroup(Konversation::ServerGroupSettingsPtr serverGroup); + const Konversation::ServerGroupSettingsPtr serverGroupById(int id); void removeServerGroup(int id); const bool getAutoReconnect(); diff --git a/konversation/server.cpp b/konversation/server.cpp index 323a29d..2cda2e2 100644 --- a/konversation/server.cpp +++ b/konversation/server.cpp @@ -74,15 +74,16 @@ Server::Server(KonversationMainWindow* mainWindow,const QString& hostName,const const QString& channel,const QString& _nick, QString password,const bool& useSSL) { QString nick( _nick ); - m_serverGroup.setName(hostName); - m_serverGroup.setIdentityId(KonversationApplication::preferences.getIdentityByName("Default")->id()); + m_serverGroup = new Konversation::ServerGroupSettings; + m_serverGroup->setName(hostName); + m_serverGroup->setIdentityId(KonversationApplication::preferences.getIdentityByName("Default")->id()); Konversation::ServerSettings serverSettings; serverSettings.setServer(hostName); serverSettings.setPort(port.toInt()); serverSettings.setPassword(password); serverSettings.setSSLEnabled(useSSL); - m_serverGroup.addServer(serverSettings); + m_serverGroup->addServer(serverSettings); if(nick.isEmpty()) // Happens when we are invoked from an irc:/ url nick = getIdentity()->getNickname(0); @@ -170,7 +171,7 @@ Server::~Server() void Server::init(KonversationMainWindow* mainWindow, const QString& nick, const QString& channel) { - setName(QString("server_" + m_serverGroup.name()).ascii()); + setName(QString("server_" + m_serverGroup->name()).ascii()); m_currentServerIndex = 0; m_tryReconnect=true; @@ -218,7 +219,7 @@ void Server::init(KonversationMainWindow* mainWindow, const QString& nick, const // For /msg query completion completeQueryPosition=0; - Konversation::ChannelList tmpList = m_serverGroup.channelList(); + Konversation::ChannelList tmpList = m_serverGroup->channelList(); if(!channel.isEmpty()) tmpList.push_front(channel); @@ -245,9 +246,9 @@ void Server::init(KonversationMainWindow* mainWindow, const QString& nick, const setAutoJoin(false); } - if(!m_serverGroup.connectCommands().isEmpty()) + if(!m_serverGroup->connectCommands().isEmpty()) { - connectCommands = QStringList::split(";", m_serverGroup.connectCommands()); + connectCommands = QStringList::split(";", m_serverGroup->connectCommands()); } if(!getIdentity()->getShellCommand().isEmpty()) { @@ -373,10 +374,10 @@ void Server::connectSignals() } -QString Server::getServerName() const { return m_serverGroup.serverByIndex(m_currentServerIndex).server(); } -int Server::getPort() const { return m_serverGroup.serverByIndex(m_currentServerIndex).port(); } +QString Server::getServerName() const { return m_serverGroup->serverByIndex(m_currentServerIndex).server(); } +int Server::getPort() const { return m_serverGroup->serverByIndex(m_currentServerIndex).port(); } -QString Server::getServerGroup() const { return m_serverGroup.name(); } +QString Server::getServerGroup() const { return m_serverGroup->name(); } int Server::getLag() const { return currentLag; } @@ -439,7 +440,7 @@ void Server::connectToIRCServer() tryNickNumber = 0; // connect() will do a async lookup too - if(!m_serverGroup.serverByIndex(m_currentServerIndex).SSLEnabled()) { + if(!m_serverGroup->serverByIndex(m_currentServerIndex).SSLEnabled()) { m_socket = new KNetwork::KBufferedSocket(QString::null, QString::null, 0L, "serverSocket"); connect(m_socket,SIGNAL (connected(const KResolverEntry&)),this,SLOT (ircServerConnectionSuccess())); } else { @@ -455,14 +456,14 @@ void Server::connectToIRCServer() connect(m_socket,SIGNAL (readyWrite()),this,SLOT (send()) ); connect(m_socket,SIGNAL (closed()),this,SLOT(closed())); - m_socket->connect(m_serverGroup.serverByIndex(m_currentServerIndex).server(), - QString::number(m_serverGroup.serverByIndex(m_currentServerIndex).port())); + m_socket->connect(m_serverGroup->serverByIndex(m_currentServerIndex).server(), + QString::number(m_serverGroup->serverByIndex(m_currentServerIndex).port())); // set up the connection details setPrefixes("ov","@+"); statusView->appendServerMessage(i18n("Info"),i18n("Looking for server %1:%2...") - .arg(m_serverGroup.serverByIndex(m_currentServerIndex).server()) - .arg(m_serverGroup.serverByIndex(m_currentServerIndex).port())); + .arg(m_serverGroup->serverByIndex(m_currentServerIndex).server()) + .arg(m_serverGroup->serverByIndex(m_currentServerIndex).port())); // Flash taskbar KWin::demandAttention(KonversationApplication::instance()->getMainWindow()->winId()); // reset InputFilter (auto request info, /WHO request info) @@ -564,11 +565,11 @@ void Server::mangleNicknameWithModes(QString& nickname,bool& isAdmin,bool& isOwn void Server::lookupFinished() { // error during lookup - if(m_serverGroup.serverByIndex(m_currentServerIndex).SSLEnabled() && m_socket->status()) + if(m_serverGroup->serverByIndex(m_currentServerIndex).SSLEnabled() && m_socket->status()) { // inform user about the error statusView->appendServerMessage(i18n("Error"),i18n("Server %1 not found. %2") - .arg(m_serverGroup.serverByIndex(m_currentServerIndex).server()) + .arg(m_serverGroup->serverByIndex(m_currentServerIndex).server()) .arg(m_socket->errorString(m_socket->error()))); m_socket->resetStatus(); @@ -593,8 +594,8 @@ void Server::ircServerConnectionSuccess() " 8 * :" + // 8 = +i; 4 = +w getIdentity()->getRealName(); - if(!m_serverGroup.serverByIndex(m_currentServerIndex).password().isEmpty()) { - queueAt(0, "PASS " + m_serverGroup.serverByIndex(m_currentServerIndex).password()); + if(!m_serverGroup->serverByIndex(m_currentServerIndex).password().isEmpty()) { + queueAt(0, "PASS " + m_serverGroup->serverByIndex(m_currentServerIndex).password()); } queueAt(1,"NICK "+getNickname()); @@ -659,7 +660,7 @@ void Server::broken(int state) if(reconnectCounter >= 10 || !m_tryReconnect) { QString error = i18n("Connection to Server %1 failed. %2") - .arg(m_serverGroup.serverByIndex(m_currentServerIndex).server()) + .arg(m_serverGroup->serverByIndex(m_currentServerIndex).server()) .arg(KNetwork::KSocketBase::errorString((KNetwork::KSocketBase::SocketError)state)); statusView->appendServerMessage(i18n("Error"),error); @@ -668,10 +669,10 @@ void Server::broken(int state) reconnectCounter = 0; rejoinChannels = false; - if(m_currentServerIndex < (m_serverGroup.serverList().count() - 1)) { + if(m_currentServerIndex < (m_serverGroup->serverList().count() - 1)) { m_currentServerIndex++; error = i18n("Trying server %1 instead.") - .arg(m_serverGroup.serverByIndex(m_currentServerIndex).server()); + .arg(m_serverGroup->serverByIndex(m_currentServerIndex).server()); statusView->appendServerMessage(i18n("Error"),error ); // Uncomment below if you want the server error message to be in the current window. @@ -684,7 +685,7 @@ void Server::broken(int state) else { QString error = i18n("Connection to Server %1 lost. %2. Trying to reconnect.") - .arg(m_serverGroup.serverByIndex(m_currentServerIndex).server()) + .arg(m_serverGroup->serverByIndex(m_currentServerIndex).server()) .arg(KNetwork::KSocketBase::errorString((KNetwork::KSocketBase::SocketError)state)); statusView->appendServerMessage(i18n("Error"), error); @@ -704,7 +705,7 @@ void Server::broken(int state) else { QString error = i18n("Connection to Server %1 failed.") - .arg(m_serverGroup.serverByIndex(m_currentServerIndex).server()); + .arg(m_serverGroup->serverByIndex(m_currentServerIndex).server()); statusView->appendServerMessage(i18n("Error"),error); // Uncomment below if you want the server error message to be in the current window. @@ -717,8 +718,8 @@ void Server::broken(int state) void Server::sslError(QString reason) { QString error = i18n("Could not connect to %1:%2 using SSL encryption. Maybe the server does not support SSL, or perhaps you have the wrong port? %3") - .arg(m_serverGroup.serverByIndex(m_currentServerIndex).server()) - .arg(m_serverGroup.serverByIndex(m_currentServerIndex).port()) + .arg(m_serverGroup->serverByIndex(m_currentServerIndex).server()) + .arg(m_serverGroup->serverByIndex(m_currentServerIndex).port()) .arg(reason); statusView->appendServerMessage(i18n("SSL Connection Error"),error); m_tryReconnect=false; @@ -968,7 +969,7 @@ void Server::lockSending() void Server::incoming() { - if(m_serverGroup.serverByIndex(m_currentServerIndex).SSLEnabled()) + if(m_serverGroup->serverByIndex(m_currentServerIndex).SSLEnabled()) emit sslConnected(this); // We read all available bytes here because readyRead() signal will be emitted when there is new data @@ -981,7 +982,7 @@ void Server::incoming() // Read at max "max_bytes" bytes into "buffer" len = m_socket->readBlock(buffer.data(),max_bytes); - if( len <=0 && m_serverGroup.serverByIndex(m_currentServerIndex).SSLEnabled() ) + if( len <=0 && m_serverGroup->serverByIndex(m_currentServerIndex).SSLEnabled() ) return; if( len <= 0 ) // Zero means buffer is empty which shouldn't happen because readyRead signal is emitted @@ -2783,8 +2784,8 @@ QString Server::parseWildcards(const QString& toParse, if(!channelKey.isEmpty()) out.append(channelKey); } else if (toExpand == 'K') { - if(!m_serverGroup.serverByIndex(m_currentServerIndex).password().isEmpty()) - out.append(m_serverGroup.serverByIndex(m_currentServerIndex).password()); + if(!m_serverGroup->serverByIndex(m_currentServerIndex).password().isEmpty()) + out.append(m_serverGroup->serverByIndex(m_currentServerIndex).password()); } else if (toExpand == 'n') { out.append("\n"); } else if (toExpand == 'p') { @@ -2985,14 +2986,14 @@ void Server::autoRejoinChannels() queue(joinString); } -IdentityPtr Server::getIdentity() const { return m_serverGroup.identity(); } +IdentityPtr Server::getIdentity() const { return m_serverGroup->identity(); } void Server::setMainWindow(KonversationMainWindow* newMainWindow) { mainWindow=newMainWindow; } KonversationMainWindow* Server::getMainWindow() const { return mainWindow; } bool Server::getUseSSL() const { - return m_serverGroup.serverByIndex(m_currentServerIndex).SSLEnabled(); + return m_serverGroup->serverByIndex(m_currentServerIndex).SSLEnabled(); } QString Server::getSSLInfo() const diff --git a/konversation/server.h b/konversation/server.h index 6984cc0..8bb902e 100644 --- a/konversation/server.h +++ b/konversation/server.h @@ -636,7 +636,7 @@ class Server : public QObject /// List of nicks in Queries. NickInfoMap m_queryNicks; - Konversation::ServerGroupSettings m_serverGroup; + Konversation::ServerGroupSettingsPtr m_serverGroup; unsigned int m_currentServerIndex; QString m_allowedChannelModes; diff --git a/konversation/servergroupdialog.cpp b/konversation/servergroupdialog.cpp index 3ad17e0..39c8873 100644 --- a/konversation/servergroupdialog.cpp +++ b/konversation/servergroupdialog.cpp @@ -167,15 +167,15 @@ ServerGroupDialog::~ServerGroupDialog() { } -void ServerGroupDialog::setServerGroupSettings(const ServerGroupSettings& settings) +void ServerGroupDialog::setServerGroupSettings(ServerGroupSettingsPtr settings) { - m_id = settings.id(); - m_nameEdit->setText(settings.name()); - m_groupCBox->setCurrentText(settings.group()); - m_identityCBox->setCurrentText(settings.identity()->getName()); - m_commandEdit->setText(settings.connectCommands()); - m_autoConnectCBox->setChecked(settings.autoConnectEnabled()); - m_serverList = settings.serverList(); + m_id = settings->id(); + m_nameEdit->setText(settings->name()); + m_groupCBox->setCurrentText(settings->group()); + m_identityCBox->setCurrentText(settings->identity()->getName()); + m_commandEdit->setText(settings->connectCommands()); + m_autoConnectCBox->setChecked(settings->autoConnectEnabled()); + m_serverList = settings->serverList(); ServerList::iterator it; m_serverLBox->clear(); @@ -183,7 +183,7 @@ void ServerGroupDialog::setServerGroupSettings(const ServerGroupSettings& settin m_serverLBox->insertItem((*it).server()); } - m_channelList = settings.channelList(); + m_channelList = settings->channelList(); ChannelList::iterator it2; for(it2 = m_channelList.begin(); it2 != m_channelList.end(); ++it2) { @@ -191,17 +191,17 @@ void ServerGroupDialog::setServerGroupSettings(const ServerGroupSettings& settin } } -ServerGroupSettings ServerGroupDialog::serverGroupSettings() +ServerGroupSettingsPtr ServerGroupDialog::serverGroupSettings() { - ServerGroupSettings settings(m_id); - settings.setName(m_nameEdit->text()); - settings.setGroup(m_groupCBox->currentText()); + ServerGroupSettingsPtr settings = new ServerGroupSettings(m_id); + settings->setName(m_nameEdit->text()); + settings->setGroup(m_groupCBox->currentText()); QValueList<IdentityPtr> identities = KonversationApplication::preferences.getIdentityList(); - settings.setIdentityId(identities[m_identityCBox->currentItem()]->id()); - settings.setConnectCommands(m_commandEdit->text()); - settings.setAutoConnectEnabled(m_autoConnectCBox->isChecked()); - settings.setServerList(m_serverList); - settings.setChannelList(m_channelList); + settings->setIdentityId(identities[m_identityCBox->currentItem()]->id()); + settings->setConnectCommands(m_commandEdit->text()); + settings->setAutoConnectEnabled(m_autoConnectCBox->isChecked()); + settings->setServerList(m_serverList); + settings->setChannelList(m_channelList); return settings; } diff --git a/konversation/servergroupdialog.h b/konversation/servergroupdialog.h index 3bed7ec..2959dfd 100644 --- a/konversation/servergroupdialog.h +++ b/konversation/servergroupdialog.h @@ -31,8 +31,8 @@ class ServerGroupDialog : public KDialogBase ServerGroupDialog(const QString& title, QWidget* parent = 0, const char* name = 0); ~ServerGroupDialog(); - void setServerGroupSettings(const ServerGroupSettings& settings); - ServerGroupSettings serverGroupSettings(); + void setServerGroupSettings(ServerGroupSettingsPtr settings); + ServerGroupSettingsPtr serverGroupSettings(); void setAvailableGroups(const QStringList& groups); diff --git a/konversation/servergroupsettings.h b/konversation/servergroupsettings.h index c777178..95c8f3e 100644 --- a/konversation/servergroupsettings.h +++ b/konversation/servergroupsettings.h @@ -15,19 +15,21 @@ #include <qvaluelist.h> #include <qstringlist.h> +#include <ksharedptr.h> + #include "serversettings.h" #include "identity.h" namespace Konversation { -class ChannelSettings; class ServerGroupSettings; - -typedef QValueList<ServerGroupSettings> ServerGroupList; +class ChannelSettings; +typedef KSharedPtr<ServerGroupSettings> ServerGroupSettingsPtr; +typedef QValueList<ServerGroupSettingsPtr> ServerGroupList; typedef QValueList<ServerSettings> ServerList; typedef QValueList<ChannelSettings> ChannelList; -class ServerGroupSettings +class ServerGroupSettings : public KShared { public: ServerGroupSettings(); diff --git a/konversation/serverlistdialog.cpp b/konversation/serverlistdialog.cpp index 0706288..95ec590 100644 --- a/konversation/serverlistdialog.cpp +++ b/konversation/serverlistdialog.cpp @@ -294,9 +294,9 @@ namespace Konversation { if(item) { - Konversation::ServerGroupSettings serverGroup = m_preferences->serverGroupById(item->serverId()); + Konversation::ServerGroupSettingsPtr serverGroup = m_preferences->serverGroupById(item->serverId()); - if(!serverGroup.name().isEmpty()) { + if(serverGroup) { ServerGroupDialog dlg(i18n("Edit Network"), this); QStringList groups = createGroupList(); dlg.setAvailableGroups(groups); @@ -313,13 +313,9 @@ namespace Konversation { delete branch; } - ServerGroupSettings serverGroup = dlg.serverGroupSettings(); - m_preferences->removeServerGroup(serverGroup.id()); - addServerGroup(serverGroup); + *serverGroup = *(dlg.serverGroupSettings()); // TODO [SERVER] Make this work! - if(dlg.identitiesNeedsUpdate()) { - updateServerGroupList(); - } + updateServerGroupList(); } } } @@ -364,7 +360,7 @@ namespace Konversation { m_editButton->setEnabled(enable); } - void ServerListDialog::addServerGroup(const ServerGroupSettings& serverGroup) + void ServerListDialog::addServerGroup(ServerGroupSettingsPtr serverGroup) { m_preferences->addServerGroup(serverGroup); QListViewItem* item = addListItem(serverGroup); @@ -400,10 +396,10 @@ namespace Konversation { } } - QListViewItem* ServerListDialog::addListItem(const ServerGroupSettings& serverGroup) + QListViewItem* ServerListDialog::addListItem(ServerGroupSettingsPtr serverGroup) { - QListViewItem* branch = findBranch(serverGroup.group()); - Konversation::ChannelList tmpList = serverGroup.channelList(); + QListViewItem* branch = findBranch(serverGroup->group()); + Konversation::ChannelList tmpList = serverGroup->channelList(); Konversation::ChannelList::iterator it; Konversation::ChannelList::iterator begin = tmpList.begin(); QString channels; @@ -419,17 +415,17 @@ namespace Konversation { QListViewItem* item = 0; if(branch) { - item = new ServerListItem(branch, serverGroup.id(), - serverGroup.name(), - serverGroup.identity()->getName(), + item = new ServerListItem(branch, serverGroup->id(), + serverGroup->name(), + serverGroup->identity()->getName(), channels, - serverGroup.autoConnectEnabled()); + serverGroup->autoConnectEnabled()); } else { - item = new ServerListItem(m_serverList, serverGroup.id(), - serverGroup.name(), - serverGroup.identity()->getName(), + item = new ServerListItem(m_serverList, serverGroup->id(), + serverGroup->name(), + serverGroup->identity()->getName(), channels, - serverGroup.autoConnectEnabled()); + serverGroup->autoConnectEnabled()); } return item; diff --git a/konversation/serverlistdialog.h b/konversation/serverlistdialog.h index afaf2c7..c545709 100644 --- a/konversation/serverlistdialog.h +++ b/konversation/serverlistdialog.h @@ -15,12 +15,13 @@ #include <kdialogbase.h> #include <klistview.h> +#include "servergroupsettings.h" + class Preferences; class QPushButton; class QStringList; namespace Konversation { - class ServerGroupSettings; class ServerListItem : public KListViewItem { @@ -71,9 +72,9 @@ namespace Konversation { protected: QListViewItem* findBranch(QString name, bool generate = true); QStringList createGroupList(); - QListViewItem* addListItem(const ServerGroupSettings& serverGroup); /// Adds a list item to the list view + QListViewItem* addListItem(ServerGroupSettingsPtr serverGroup); /// Adds a list item to the list view - void addServerGroup(const ServerGroupSettings& serverGroup); + void addServerGroup(ServerGroupSettingsPtr serverGroup); private: KListView* m_serverList; |