[Konversation-devel] [Bug 96707] Notification state not saved
Peter Simonsson
peter.simonsson at gmail.com
Thu Jul 1 16:02:34 CEST 2010
https://bugs.kde.org/show_bug.cgi?id=96707
--- Comment #2 from Peter Simonsson <peter simonsson gmail com> 2010-07-01 16:02:31 ---
commit b796f53c72bb039e41cb310ada630c77851a6894
Author: Peter Simonsson <peter.simonsson at gmail.com>
Date: Sat Apr 2 23:31:45 2005 +0000
Remember if the notifications are disabled for this tab or not
BUG:96707
svn path=/trunk/kdeextragear-2/konversation/; revision=402752
diff --git a/konversation/inputfilter.cpp b/konversation/inputfilter.cpp
index 80fc9d3..11532c6 100644
--- a/konversation/inputfilter.cpp
+++ b/konversation/inputfilter.cpp
@@ -424,8 +424,8 @@ void InputFilter::parseClientCommand(const QString &prefix,
const QString &comma
// Did we join the channel, or was it someone else?
if(server->isNickname(sourceNick))
{
- QString key;
/*
+ QString key;
// TODO: Try to remember channel keys for autojoins and manual
joins, so
// we can get %k to work
@@ -436,7 +436,7 @@ void InputFilter::parseClientCommand(const QString &prefix,
const QString &comma
}
*/
// Join the channel
- server->joinChannel(channelName,sourceHostmask,key);
+ server->joinChannel(channelName, sourceHostmask);
// Request modes for the channel
server->queue("MODE "+channelName);
} else {
diff --git a/konversation/konversationapplication.cpp
b/konversation/konversationapplication.cpp
index 455aa3e..21a5b5f 100644
--- a/konversation/konversationapplication.cpp
+++ b/konversation/konversationapplication.cpp
@@ -697,6 +697,7 @@ void KonversationApplication::readOptions()
serverGroup->setIdentityId(preferences.getIdentityByName(config->readEntry("Identity"))->id());
serverGroup->setConnectCommands(config->readEntry("ConnectCommands"));
serverGroup->setAutoConnectEnabled(config->readBoolEntry("AutoConnect"));
+
serverGroup->setNotificationsEnabled(config->readBoolEntry("EnableNotifications",
true));
tmp1 = config->readListEntry("ServerList");
for(it2 = tmp1.begin(); it2 != tmp1.end(); ++it2) {
@@ -731,6 +732,7 @@ void KonversationApplication::readOptions()
if(!config->readEntry("Name").isEmpty()) {
channel.setName(config->readEntry("Name"));
channel.setPassword(config->readEntry("Password"));
+
channel.setNotificationsEnabled(config->readBoolEntry("EnableNotifications",
true));
channelHistory.append(channel);
}
}
@@ -1169,6 +1171,7 @@ void KonversationApplication::saveOptions(bool updateGUI)
config->setGroup(groupName);
config->writeEntry("Name", (*it3).name());
config->writeEntry("Password", (*it3).password());
+ config->writeEntry("EnableNotifications", (*it3).enableNotifications());
index3++;
}
@@ -1181,6 +1184,7 @@ void KonversationApplication::saveOptions(bool updateGUI)
config->writeEntry("ConnectCommands", (*it)->connectCommands());
config->writeEntry("AutoConnect", (*it)->autoConnectEnabled());
config->writeEntry("ChannelHistory", channelHistory);
+ config->writeEntry("EnableNotifications", (*it)->enableNotifications());
index++;
}
diff --git a/konversation/server.cpp b/konversation/server.cpp
index b2a946a..c4cbb7f 100644
--- a/konversation/server.cpp
+++ b/konversation/server.cpp
@@ -178,6 +178,7 @@ void Server::init(KonversationMainWindow* mainWindow, const
QString& nick, const
setName(QString("server_" + m_serverGroup->name()).ascii());
setMainWindow(mainWindow);
statusView = getMainWindow()->addStatusView(this);
+ statusView->setNotificationsEnabled(m_serverGroup->enableNotifications());
setNickname(nick);
obtainNickInfo(getNickname());
@@ -1450,14 +1451,15 @@ void Server::closeQuery(const QString &name)
void Server::closeChannel(const QString& name)
{
- kdDebug() << "Server::closeChannel(" << name << ")" << endl;
- Channel* channelToClose=getChannelByName(name);
- if(channelToClose)
- {
- Konversation::OutputFilterResult result =
outputFilter->parse(getNickname(),
- KonversationApplication::preferences.getCommandChar() + "PART", name);
- queue(result.toServer);
- }
+ kdDebug() << "Server::closeChannel(" << name << ")" << endl;
+ Channel* channelToClose = getChannelByName(name);
+
+ if(channelToClose)
+ {
+ Konversation::OutputFilterResult result =
outputFilter->parse(getNickname(),
+ KonversationApplication::preferences.getCommandChar() + "PART", name);
+ queue(result.toServer);
+ }
}
void Server::requestChannelList()
@@ -1794,7 +1796,7 @@ void Server::sendJoinCommand(const QString& name, const
QString& password)
queue(result.toServer);
}
-void Server::joinChannel(const QString &name, const QString &hostmask, const
QString &/*key*/)
+void Server::joinChannel(const QString& name, const QString& hostmask)
{
// (re-)join channel, open a new panel if needed
Channel* channel = getChannelByName(name);
@@ -1804,10 +1806,11 @@ void Server::joinChannel(const QString &name, const
QString &hostmask, const QSt
Q_ASSERT(channel);
channel->setIdentity(getIdentity());
channel->setNickname(getNickname());
- //channel->setKey(key);
+ Konversation::ChannelSettings channelSettings =
m_serverGroup->channelByNameFromHistory(name);
+ channel->setNotificationsEnabled(channelSettings.enableNotifications());
channelList.append(channel);
- m_serverGroup->appendChannelHistory(Konversation::ChannelSettings(name));
+ m_serverGroup->appendChannelHistory(channelSettings);
connect(channel,SIGNAL (sendFile()),this,SLOT (requestDccSend()) );
connect(this,SIGNAL (serverOnline(bool)),channel,SLOT (serverOnline(bool))
);
@@ -1828,6 +1831,11 @@ void Server::removeChannel(Channel* channel)
// Update NickInfo.
removeJoinedChannel(channel->getName());
+
+ Konversation::ChannelSettings channelSettings =
m_serverGroup->channelByNameFromHistory(channel->getName());
+ channelSettings.setNotificationsEnabled(channel->notificationsEnabled());
+ m_serverGroup->appendChannelHistory(channelSettings);
+
channelList.removeRef(channel);
}
@@ -2948,7 +2956,6 @@ KABC::Addressee Server::getOfflineNickAddressee(QString&
nickname) {
return KABC::Addressee();
}
-
#include "server.moc"
// kate: space-indent on; tab-width 4; indent-width 4; mixed-indent off;
replace-tabs on;
diff --git a/konversation/server.h b/konversation/server.h
index 79367ed..49380b5 100644
--- a/konversation/server.h
+++ b/konversation/server.h
@@ -128,7 +128,7 @@ class Server : public QObject
InputFilter* getInputFilter();
Konversation::OutputFilter* getOutputFilter();
- void joinChannel(const QString& name, const QString& hostmask, const
QString& key);
+ void joinChannel(const QString& name, const QString& hostmask);
void removeChannel(Channel* channel);
void appendServerMessageToChannel(const QString& channel, const QString&
type, const QString& message);
void appendCommandMessageToChannel(const QString& channel, const QString&
command, const QString& message);
diff --git a/konversation/servergroupsettings.cpp
b/konversation/servergroupsettings.cpp
index e192821..6d7aafb 100644
--- a/konversation/servergroupsettings.cpp
+++ b/konversation/servergroupsettings.cpp
@@ -24,6 +24,7 @@ ServerGroupSettings::ServerGroupSettings()
s_availableId++;
m_autoConnect = false;
m_identityId = 0;
+ m_enableNotifications = true;
}
ServerGroupSettings::ServerGroupSettings(int id)
@@ -38,6 +39,7 @@ ServerGroupSettings::ServerGroupSettings(int id)
m_autoConnect = false;
m_identityId = 0;
+ m_enableNotifications = true;
}
ServerGroupSettings::ServerGroupSettings(const ServerGroupSettings& settings)
@@ -50,6 +52,7 @@ ServerGroupSettings::ServerGroupSettings(const
ServerGroupSettings& settings)
setChannelList(settings.channelList());
setConnectCommands(settings.connectCommands());
setAutoConnectEnabled(settings.autoConnectEnabled());
+ setNotificationsEnabled(settings.enableNotifications());
m_id = settings.id();
}
@@ -61,6 +64,7 @@ ServerGroupSettings::ServerGroupSettings(const QString& name)
s_availableId++;
m_autoConnect = false;
m_identityId = 0;
+ m_enableNotifications = true;
}
ServerGroupSettings::~ServerGroupSettings()
@@ -109,6 +113,7 @@ void ServerGroupSettings::appendChannelHistory(const
ChannelSettings& channel)
for(ChannelList::iterator it = m_channelHistory.begin(); it != endIt; ++it)
{
if(channel.name() == (*it).name()) {
(*it).setPassword(channel.password());
+ (*it).setNotificationsEnabled(channel.enableNotifications());
return;
}
}
@@ -116,6 +121,19 @@ void ServerGroupSettings::appendChannelHistory(const
ChannelSettings& channel)
m_channelHistory.append(channel);
}
+ChannelSettings ServerGroupSettings::channelByNameFromHistory(const QString&
channelName)
+{
+ ChannelList::iterator endIt = m_channelHistory.end();
+
+ for(ChannelList::iterator it = m_channelHistory.begin(); it != endIt; ++it)
{
+ if(channelName == (*it).name()) {
+ return (*it);
+ }
+ }
+
+ return ChannelSettings(channelName);
+}
+
//
// ChannelSettings
//
@@ -124,24 +142,35 @@ ChannelSettings::ChannelSettings()
{
setName("");
setPassword("");
+ setNotificationsEnabled(true);
}
ChannelSettings::ChannelSettings(const ChannelSettings& settings)
{
setName(settings.name());
setPassword(settings.password());
+ setNotificationsEnabled(settings.enableNotifications());
}
ChannelSettings::ChannelSettings(const QString& name)
{
setName(name);
setPassword("");
+ setNotificationsEnabled(true);
}
ChannelSettings::ChannelSettings(const QString& name, const QString& password)
{
setName(name);
setPassword(password);
+ setNotificationsEnabled(true);
+}
+
+ChannelSettings::ChannelSettings(const QString& name, const QString& password,
bool enableNotifications)
+{
+ setName(name);
+ setPassword(password);
+ setNotificationsEnabled(enableNotifications);
}
ChannelSettings::~ChannelSettings()
diff --git a/konversation/servergroupsettings.h
b/konversation/servergroupsettings.h
index e34283d..4a89a94 100644
--- a/konversation/servergroupsettings.h
+++ b/konversation/servergroupsettings.h
@@ -69,6 +69,10 @@ class ServerGroupSettings : public KShared
void setChannelHistory(const ChannelList& list) { m_channelHistory = list;
}
void appendChannelHistory(const ChannelSettings& channel);
ChannelList channelHistory() const { return m_channelHistory; }
+ ChannelSettings channelByNameFromHistory(const QString& channelName);
+
+ void setNotificationsEnabled(bool enable) { m_enableNotifications =
enable; }
+ bool enableNotifications() const { return m_enableNotifications; }
private:
QString m_name;
@@ -81,6 +85,8 @@ class ServerGroupSettings : public KShared
QString m_group;
int m_id;
static int s_availableId;
+
+ bool m_enableNotifications;
};
class ChannelSettings
@@ -90,6 +96,7 @@ class ChannelSettings
ChannelSettings(const ChannelSettings& settings);
ChannelSettings(const QString& name);
ChannelSettings(const QString& name, const QString& password);
+ ChannelSettings(const QString& name, const QString& password, bool
enableNotifications);
~ChannelSettings();
void setName(const QString& name) { m_name = name; }
@@ -98,9 +105,14 @@ class ChannelSettings
void setPassword(const QString& password) { m_password = password; }
QString password() const { return m_password; }
+ void setNotificationsEnabled(bool enable) { m_enableNotifications =
enable; }
+ bool enableNotifications() const { return m_enableNotifications; }
+
private:
QString m_name;
QString m_password;
+
+ bool m_enableNotifications;
};
}
diff --git a/konversation/statuspanel.cpp b/konversation/statuspanel.cpp
index 952d0e5..0828e61 100644
--- a/konversation/statuspanel.cpp
+++ b/konversation/statuspanel.cpp
@@ -89,6 +89,7 @@ StatusPanel::StatusPanel(QWidget* parent) :
ChatWindow(parent)
StatusPanel::~StatusPanel()
{
+
m_server->serverGroupSettings()->setNotificationsEnabled(notificationsEnabled());
}
void StatusPanel::setNickname(const QString& newNickname)
--
Configure bugmail: https://bugs.kde.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.
More information about the Konversation-devel
mailing list