[Bug 61152] sort by user doesn't work in the right way

Rob Kaper <[email protected]>
Newsgroups gmane.comp.kde.devel.atlantik
Message-ID <[email protected]>
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.
     
http://bugs.kde.org/show_bug.cgi?id=61152     
[email protected] changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|                            |FIXED



------- Additional Comments From [email protected]  2003-07-13 01:16 -------
Subject: KDE_3_1_BRANCH: kdegames/atlantik

CVS commit by kaper: 

backport to kde 3.1 branch, fix #61152: sort by user doesn't work in the
right way

CCMAIL: [email protected]


  M +1 -0      ChangeLog   1.121.4.19
  M +19 -0     client/monopigator.cpp   1.9.8.5
  M +8 -0      client/monopigator.h   1.8.8.5
  M +2 -3      client/selectserver_widget.cpp   1.18.6.5


--- kdegames/atlantik/ChangeLog  #1.121.4.18:1.121.4.19
@@ -12,4 +12,5 @@
 - make use of trade revisions (monopd >= 0.8.2 recommended)
 - don't tell game has started when it has not
+- sort user column in server list by number, not alphabetically
 
 0.5.2

--- kdegames/atlantik/client/monopigator.cpp  #1.9.8.4:1.9.8.5
@@ -103,2 +103,21 @@ void Monopigator::processData(const QByt
         }
 }
+
+MonopigatorEntry::MonopigatorEntry(QListView *parent, QString host, QString version, QString users, QString port) : QListViewItem(parent, host, version, users, port)
+{
+}
+
+int MonopigatorEntry::compare(QListViewItem *i, int col, bool ascending) const
+{
+        if (col == 2)
+        {
+                int myVal = text(col).toInt(), iVal = i->text(col).toInt();
+                if (myVal == iVal)
+                        return 0;
+                else if (myVal > iVal)
+                        return 1;
+                else
+                        return -1;
+        }
+        return key( col, ascending ).compare( i->key( col, ascending) );
+}

--- kdegames/atlantik/client/monopigator.h  #1.8.8.4:1.8.8.5
@@ -20,4 +20,5 @@
 #include <qobject.h>
 #include <qbuffer.h>
+#include <qlistview.h>
 #include <qtimer.h>
 
@@ -50,4 +51,11 @@ private:
         QTimer *m_timer;
         KIO::Job *m_job;
+};
+
+class MonopigatorEntry : public QListViewItem
+{
+public:
+        MonopigatorEntry(QListView *parent, QString host, QString version, QString users, QString port);
+        int compare(QListViewItem *i, int col, bool ascending) const;
 };
 

--- kdegames/atlantik/client/selectserver_widget.cpp  #1.18.6.4:1.18.6.5
@@ -115,5 +115,5 @@ void SelectServer::checkLocalServer()
 void SelectServer::slotMonopigatorAdd(QString host, QString port, QString version, int users)
 {
-        QListViewItem *item = new QListViewItem(m_serverList, host, version, (users == -1) ? i18n("unknown") : QString::number(users), port);
+        MonopigatorEntry *item = new MonopigatorEntry(m_serverList, host, version, (users == -1) ? i18n("unknown") : QString::number(users), port);
         item->setPixmap(0, BarIcon("atlantik", KIcon::SizeSmall));
         validateConnectButton();
@@ -124,7 +124,6 @@ void SelectServer::slotLocalConnected()
         m_localServerAvailable = true;
 
-        QListViewItem *item = new QListViewItem(m_serverList, "localhost", i18n("unknown"), i18n("unknown"), QString::number(1234));
+        MonopigatorEntry *item = new MonopigatorEntry(m_serverList, "localhost", i18n("unknown"), i18n("unknown"), QString::number(1234));
         item->setPixmap(0, BarIcon("atlantik", KIcon::SizeSmall));
-
         validateConnectButton();
 }
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.