Bug 218784 - Server list dialog doesn't remember network order as established by DND
Summary: Server list dialog doesn't remember network order as established by DND
Status: RESOLVED FIXED
Alias: None
Product: konversation
Classification: Applications
Component: general (show other bugs)
Version: Git
Platform: Unlisted Binaries Linux
: NOR normal
Target Milestone: ---
Assignee: Konversation Developers
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-12-15 12:04 UTC by Eike Hein
Modified: 2010-05-22 19:38 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Eike Hein 2009-12-15 12:04:15 UTC
Title says it all - drag reordering some networks, quitting Konvi and restarting it doesn't recreate the order correctly.
Comment 1 Eike Hein 2010-05-22 19:38:19 UTC
commit 9f4ec69e3a434d0364ae7d5304cedbfec3b5864a
Author: Eike Hein <hein@kde.org>
Date:   Sat May 22 19:31:45 2010 +0200

    Fix server list dialog network order not being preserved across restarts.
    
    BUG:218784

diff --git a/ChangeLog b/ChangeLog
index 5fbd673..a0c1fa9 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -123,6 +123,8 @@ Changes since 1.2.3:
 * Added a "-local" parameter to the '/amsg' and '/ame' commands that
   limits their scope to the channel and query tabs associated with
   the same connection as the tab the command is issued in.
+* Fixed a bug causing the order of networks in the server list dialog
+  not to be preserved across application restarts.
 
 
 Changes from 1.2.2 to 1.2.3:
diff --git a/src/application.cpp b/src/application.cpp
index 837a901..8c60385 100644
--- a/src/application.cpp
+++ b/src/application.cpp
@@ -401,6 +401,7 @@ void Application::readOptions()
         QStringList::iterator it;
         QStringList tmp1;
         QStringList::iterator it2;
+        int index = 0;
         Konversation::ChannelList channelHistory;
         Konversation::ServerSettings server;
         Konversation::ChannelSettings channel;
@@ -410,6 +411,7 @@ void Application::readOptions()
             KConfigGroup cgServerGroup(KGlobal::config()->group(*it));
             Konversation::ServerGroupSettingsPtr serverGroup(new Konversation::ServerGroupSettings);
             serverGroup->setName(cgServerGroup.readEntry("Name"));
+            serverGroup->setSortIndex(index);
             serverGroup->setIdentityId(Preferences::identityByName(cgServerGroup.readEntry("Identity"))->id());
             serverGroup->setConnectCommands(cgServerGroup.readEntry("ConnectCommands"));
             serverGroup->setAutoConnectEnabled(cgServerGroup.readEntry("AutoConnect", false));
@@ -465,6 +467,8 @@ void Application::readOptions()
 
             serverGroups.insert(serverGroup->id(), serverGroup);
             sgKeys.append(serverGroup->id());
+
+            index++;
         }
 
         Preferences::setServerGroupHash(serverGroups);
@@ -726,11 +730,24 @@ void Application::saveOptions(bool updateGUI)
 
     // Add the new servergroups to the config
     Konversation::ServerGroupHash serverGroupHash = Preferences::serverGroupHash();
-    QHashIterator<int, Konversation::ServerGroupSettingsPtr> it(serverGroupHash);
+    QHashIterator<int, Konversation::ServerGroupSettingsPtr> hashIt(serverGroupHash);
+
+    QMap<int, Konversation::ServerGroupSettingsPtr> sortedServerGroupMap;
+
+    // Make the indices in the group headers reflect the server list dialog sorting.
+    while (hashIt.hasNext())
+    {
+        hashIt.next();
+
+        sortedServerGroupMap.insert(hashIt.value()->sortIndex(), hashIt.value());
+    }
+
+    QMapIterator<int, Konversation::ServerGroupSettingsPtr> it(sortedServerGroupMap);
+
     index = 0;
     int index2 = 0;
     int index3 = 0;
-    int width=0;
+    int width = 0;
     QList<int> keys = serverGroupHash.keys();
     for(int i=0; i<keys.count(); i++)
         if(width < keys.at(i)) width = keys.at(i);
diff --git a/src/commit.h b/src/commit.h
index 6cf9ebb..fa1da65 100644
--- a/src/commit.h
+++ b/src/commit.h
@@ -1,4 +1,4 @@
 // This COMMIT number is added to version string to be used as "patch level"
 #ifndef COMMIT
-#define COMMIT 4041
+#define COMMIT 4042
 #endif