[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    extragear/network/kmldonkey
From:       Aleksey Markelov <markelovai () gmail ! com>
Date:       2009-07-07 16:25:51
Message-ID: 1246983951.226044.21234.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 992756 by amarkelov:

libkmldonkey no longer depends on Qt3Support


 M  +1 -0      kmldonkey/clientlist.h  
 M  +1 -0      kmldonkey/mlconfig.h  
 M  +2 -4      kmldonkey/searchcore.cpp  
 M  +0 -2      libkmldonkey/CMakeLists.txt  
 M  +22 -32    libkmldonkey/donkeyprotocol.cpp  
 M  +7 -5      libkmldonkey/donkeyprotocol.h  
 M  +0 -1      libkmldonkey/ed2kurl.h  
 M  +4 -0      libkmldonkey/infoiface.h  
 M  +3 -4      libkmldonkey/protocoliface.h  
 M  +15 -15    libkmldonkey/roominfo.cpp  
 M  +12 -12    libkmldonkey/roominfo.h  
 M  +2 -2      libkmldonkey/searchinfo.cpp  
 M  +4 -3      libkmldonkey/searchinfo.h  
 M  +13 -14    libkmldonkey/searchquery.cpp  
 M  +3 -2      libkmldonkey/searchquery.h  
 M  +0 -1      libkmldonkey/serverinfo.h  


--- trunk/extragear/network/kmldonkey/kmldonkey/clientlist.h #992755:992756
@@ -29,6 +29,7 @@
 #include "availability.h"
 //Added by qt3to4:
 #include <QShowEvent>
+#include <Q3IntDict>
 
 class SourceItem;
 
--- trunk/extragear/network/kmldonkey/kmldonkey/mlconfig.h #992755:992756
@@ -25,6 +25,7 @@
 #define __kmldonkey_mlconfig_h__
 
 #include <q3dict.h>
+#include <Q3IntDict>
 #include <QHash>
 #include <kpagedialog.h>
 
--- trunk/extragear/network/kmldonkey/kmldonkey/searchcore.cpp #992755:992756
@@ -360,10 +360,8 @@
     if ( !label.isEmpty() )
     {
         // Get a free new searchNum
-        Q3IntDict<SearchInfo> searches = KMLDonkey::App->donkey->activeSearches();
-        do { searchNum++; }
-        while ( searches.find( searchNum ) != 0 );
-
+        do { ++searchNum; }
+        while (KMLDonkey::App->donkey->findSearchNo(searchNum) != 0);
         // Add a new searchtabresult
         m_page->addSearchResult( searchNum, query, label );
         // Let's start the search now
--- trunk/extragear/network/kmldonkey/libkmldonkey/CMakeLists.txt #992755:992756
@@ -27,8 +27,6 @@
 
 qt4_wrap_cpp(libkmldonkey_LIB_SRCS protocoliface.h)
 
-add_definitions(-DQT3_SUPPORT -DQT3_SUPPORT_WARNINGS)
-#add_definitions(-DQT3_SUPPORT)
 add_definitions(${QT_DEFINITIONS} ${KDE4_DEFINITIONS})
 
 kde4_add_library(libkmldonkey SHARED ${libkmldonkey_LIB_SRCS})
--- trunk/extragear/network/kmldonkey/libkmldonkey/donkeyprotocol.cpp #992755:992756
@@ -61,9 +61,6 @@
     connectedservers = 0;
     proto = MIN_PROTOCOL_VERSION;
     wantpoll = poll;
-    rooms.setAutoDelete(true);
-    searches.setAutoDelete(true);
-    unmappedResults.setAutoDelete(true);
     connect(m_socket, SIGNAL(readyMessage()), SLOT(processMessage()));
     connect(m_socket, SIGNAL(connectionClosed()), SLOT(socketDisconnected()));
     connect(m_socket, SIGNAL(error(QAbstractSocket::SocketError)), \
SLOT(socketError(QAbstractSocket::SocketError))); @@ -71,11 +68,7 @@
 
 DonkeyProtocol::~DonkeyProtocol()
 {
-    qDeleteAll(download);
-    qDeleteAll(downloaded);
-    qDeleteAll(shares);
-    qDeleteAll(clients);
-    qDeleteAll(networks);
+    flushState();
 }
 
 
@@ -155,17 +148,15 @@
     ptrContainerClear(networks);
     ptrContainerClear(clients);
     ptrContainerClear(shares);
-    searches.clear();
-    unmappedResults.clear();
+    ptrContainerClear(searches);
+    ptrContainerClear(unmappedResults);
     options.clear();
     friends.clear();
-    rooms.clear();
+    ptrContainerClear(rooms);
     m_sectionOptions.clear();
     m_pluginOptions.clear();
-    qDeleteAll(consoleCallbacks);
-    consoleCallbacks.clear();
-    qDeleteAll(defSearches);
-    defSearches.clear();
+    ptrContainerClear(consoleCallbacks);
+    ptrContainerClear(defSearches);
     connectedservers = 0;
     downloadstarted = false;
 }
@@ -650,8 +641,7 @@
         } break;
 
         case DefineSearches: {
-            qDeleteAll(defSearches);
-            defSearches.clear();
+            ptrContainerClear(defSearches);
             defSearch = QString();
             int i, j = msg->readInt16();
             for (i=0; i<j; i++) {
@@ -671,19 +661,19 @@
         case Result_info:
         {
             ResultInfo *si = new ResultInfo(msg, proto);
-            unmappedResults.replace(si->resultNo(), si);
+            unmappedResults.insert(si->resultNo(), si);
         } break;
 
         case Search_result:
         {
             int searchnum = msg->readInt32();
             int resultnum = msg->readInt32();
-            ResultInfo* ri = unmappedResults[resultnum];
+            ResultInfo* ri = unmappedResults.value(resultnum);
             if (!ri) return;
-            SearchInfo *si = searches[searchnum];
+            SearchInfo *si = findSearchNo(searchnum);
             if (!si) {
                 si = new SearchInfo(searchnum);
-                searches.replace(searchnum, si);
+                searches.insert(searchnum, si);
             }
             si->addResult(ri);
             emit searchUpdated(searchnum, ri);
@@ -785,12 +775,12 @@
         case Room_info:
         {
             int roomno = msg->readInt32();
-            RoomInfo* ri = rooms.find(roomno);
-            if (ri)
-                ri->update(msg, proto);
-            else {
-                ri = new RoomInfo(msg, proto, roomno);
-                rooms.replace(roomno, ri);
+            RoomInfo* ri = findRoomNo(roomno);
+            if (ri) {
+                ri->updateRoomInfo(msg, proto);
+            } else {
+                ri = new RoomInfo(roomno, msg, proto);
+                rooms.insert(roomno, ri);
             }
             emit roomUpdated(roomno);
         } break;
@@ -798,7 +788,7 @@
         case Room_message:
         {
             int roomno = msg->readInt32();
-            RoomInfo* ri = rooms.find(roomno);
+            RoomInfo* ri = findRoomNo(roomno);
             if (ri) {
                 RoomMessage* rm = new RoomMessage(msg, proto);
                 ri->addMessage(rm);
@@ -1129,10 +1119,10 @@
 
 SearchInfo* DonkeyProtocol::findSearchNo(int num)
 {
-    return searches[num];
+    return searches.value(num);
 }
 
-const Q3IntDict<SearchInfo>& DonkeyProtocol::activeSearches()
+const SearchInfoHash& DonkeyProtocol::activeSearches()
 {
     return searches;
 }
@@ -1269,7 +1259,7 @@
 
 const ResultInfo* DonkeyProtocol::findClientFile(int fileno)
 {
-    return unmappedResults[fileno];
+    return unmappedResults.value(fileno);
 }
 
 const QMap<QString, QString>& DonkeyProtocol::optionsList()
@@ -1342,7 +1332,7 @@
 
 RoomInfo* DonkeyProtocol::findRoomNo(int roomno)
 {
-    return rooms[roomno];
+    return rooms.value(roomno);
 }
 
 void DonkeyProtocol::setRoomState(int roomno, RoomInfo::RoomState state)
--- trunk/extragear/network/kmldonkey/libkmldonkey/donkeyprotocol.h #992755:992756
@@ -27,7 +27,6 @@
 #ifndef __libkmldonkey_donkeyprotocol_h__
 #define __libkmldonkey_donkeyprotocol_h__
 
-#include <q3intdict.h>
 #include <QString>
 #include <QMap>
 #include <QObject>
@@ -73,6 +72,9 @@
 typedef QHash<int, ClientInfo *> ClientInfoHash;
 typedef QHash<int, Network *> NetworkHash;
 typedef QHash<int, ServerInfo *> ServerInfoHash;
+typedef QHash<int, SearchInfo *> SearchInfoHash;
+typedef QHash<int, ResultInfo *> ResultInfoHash;
+typedef QHash<int, RoomInfo *> RoomInfoHash;
 
 //! A high level abstraction of the mldonkey GUI protocol.
 /*!
@@ -369,7 +371,7 @@
      * \return A dictionary containing SearchInfo objects representing
      *   the active searches, indexed on their searchNo() values.
      */
-    const Q3IntDict<SearchInfo>& activeSearches();
+    const SearchInfoHash& activeSearches();
 
     //! Find a downloading file by its file number.
     /*!
@@ -857,9 +859,9 @@
     NetworkHash networks;
     ClientInfoHash clients;
     ShareInfoHash shares;
-    Q3IntDict<RoomInfo> rooms;
-    Q3IntDict<SearchInfo> searches;
-    Q3IntDict<ResultInfo> unmappedResults;
+    RoomInfoHash rooms;
+    SearchInfoHash searches;
+    ResultInfoHash unmappedResults;
     QList<DonkeyOption> m_sectionOptions;
     QList<DonkeyOption> m_pluginOptions;
     QMap<QString,QString> options;
--- trunk/extragear/network/kmldonkey/libkmldonkey/ed2kurl.h #992755:992756
@@ -24,7 +24,6 @@
 #define __libkmldonkey_ed2kurl_h__
 
 #include <QString>
-#include <q3cstring.h>
 #include <kmldonkey_export.h>
 
 #include "donkeytypes.h"
--- trunk/extragear/network/kmldonkey/libkmldonkey/infoiface.h #992755:992756
@@ -26,7 +26,9 @@
 
 #include <QObject>
 #include <QVariant>
+#if 0
 #include <q3intdict.h>
+#endif
 
 class InfoInterface
 {
@@ -66,7 +68,9 @@
 */
 };
 
+#if 0
 typedef Q3IntDict<InfoInterface*> InfoDict;
 typedef QMap<QString, InfoDict> InfoMap;
+#endif //deprecated
 
 #endif
--- trunk/extragear/network/kmldonkey/libkmldonkey/protocoliface.h #992755:992756
@@ -25,7 +25,6 @@
 #define __libkmldonkey_protocoliface_h__
 
 #include <QObject>
-#include <q3intdict.h>
 
 #include "hostiface.h"
 #include "infoiface.h"
@@ -97,7 +96,7 @@
         AuthenticationError, // Incorrect authentification (name/password).
         CommunicationError // A read error occurred when communicating with the \
core. The connection has been terminated.  };
-
+#if 0
     /**
      * Checks if a InfoDict with that key exists.
      * \param key Unique name of the InfoDict
@@ -123,7 +122,7 @@
     InfoDict getInfos(const QString& key) {
         return infomap[key];
     }
-
+#endif //deprecated?
 signals:
     /**
      * This signal is emitted if the connection to the core was established
@@ -142,7 +141,7 @@
     HostInterface* host;
 
 protected:
-    InfoMap infomap; // each protocol have to add there supported \
InfoInterface-classes into this map. +    //InfoMap infomap; // each protocol have to \
add there supported InfoInterface-classes into this map.  };
 
 #endif
--- trunk/extragear/network/kmldonkey/libkmldonkey/roominfo.cpp #992755:992756
@@ -24,17 +24,10 @@
 #include "roominfo.h"
 
 #include <kdebug.h>
-//Added by qt3to4:
-#include <Q3ValueList>
 
 RoomMessage::RoomMessage(DonkeyMessage* msg, int proto)
 {
-    update(msg, proto);
-}
-
-bool RoomMessage::update(DonkeyMessage* msg, int /*proto*/)
-{
-    //int num = msg->readInt32(); // Already handled before.
+    Q_UNUSED(proto);
     int t = msg->readInt8();
     switch (t) {
         case 0: {
@@ -54,25 +47,32 @@
         } break;
         default: {
             type = Unknown;
-            return false;
         } break;
     }
-    return true;
 }
 
+RoomMessage::~RoomMessage()
+{
+}
+
 RoomMessage::MessageType RoomMessage::messageType() { return type; }
 QString RoomMessage::messageBody() { return message; }
 int RoomMessage::messageUser() { return user; }
 
-RoomInfo::RoomInfo(DonkeyMessage* msg, int proto, int num)
+RoomInfo::RoomInfo(int num, DonkeyMessage* msg, int proto)
 {
     this->num = num;
-    update(msg, proto);
+    updateRoomInfo(msg, proto);
 }
 
-void RoomInfo::update(DonkeyMessage* msg, int /*proto*/)
+
+RoomInfo::~RoomInfo()
 {
-    //num = msg->readInt32(); // Already handled before
+    qDeleteAll(messages);
+}
+
+void RoomInfo::updateRoomInfo(DonkeyMessage* msg, int /*proto*/)
+{
     network = msg->readInt32();
     name = msg->readString();
     switch( msg->readInt8() ) {
@@ -90,5 +90,5 @@
 RoomInfo::RoomState RoomInfo::roomState() { return state; }
 int RoomInfo::roomUsers() { return users; }
 
-Q3ValueList<RoomMessage*> RoomInfo::getMessages() { return messages; }
+QList<RoomMessage*> RoomInfo::getMessages() { return messages; }
 void RoomInfo::addMessage(RoomMessage* msg) { messages.append(msg); }
--- trunk/extragear/network/kmldonkey/libkmldonkey/roominfo.h #992755:992756
@@ -25,7 +25,7 @@
 #define __libkmldonkey_roominfo_h__
 
 #include <QString>
-#include <q3valuelist.h>
+#include <QList>
 #include <kmldonkey_export.h>
 
 #include "donkeymessage.h"
@@ -33,7 +33,7 @@
 /**
  * Presents a room-message in a mlnet-room.
  */
-class KDE_EXPORT RoomMessage
+class KMLDONKEY_EXPORT RoomMessage
 {
 public:
     /**
@@ -51,10 +51,8 @@
      */
     RoomMessage(DonkeyMessage* msg, int proto);
 
-    /**
-     * Updates the RoomMessage-content.
-     */
-    bool update(DonkeyMessage* msg, int proto);
+    ///Destructor.
+    ~RoomMessage();
 
     /**
      * Returns the messagetype.
@@ -80,7 +78,7 @@
 /**
  * Presents a mlnet-room.
  */
-class KDE_EXPORT RoomInfo
+class KMLDONKEY_EXPORT RoomInfo
 {
 public:
     /**
@@ -96,12 +94,14 @@
     /**
      * Constructor.
      */
-    RoomInfo(DonkeyMessage* msg, int proto, int num);
+    RoomInfo(int num, DonkeyMessage* msg, int proto);
+    ///Destructor
+    ~RoomInfo();
 
     /**
      * Updates the RoomInfo-content.
      */
-    void update(DonkeyMessage* msg, int proto);
+    void updateRoomInfo(DonkeyMessage* msg, int proto);
 
     /**
      * Each room does have a unique number.
@@ -131,12 +131,12 @@
     /**
      * Return the room-messages.
      */
-    Q3ValueList<RoomMessage*> getMessages();
+    QList<RoomMessage *> getMessages();
 
     /**
      * Add a room-message.
      */
-    void addMessage(RoomMessage*);
+    void addMessage(RoomMessage *);
 
 private:
     int num;
@@ -144,7 +144,7 @@
     QString name;
     RoomState state;
     int users;
-    Q3ValueList<RoomMessage*> messages;
+    QList<RoomMessage *> messages;
 };
 
 #endif
--- trunk/extragear/network/kmldonkey/libkmldonkey/searchinfo.cpp #992755:992756
@@ -150,6 +150,6 @@
     network = msg->readInt32();
 }
 
-const Q3IntDict<ResultInfo>& SearchInfo::searchResults() const { return results; }
-void SearchInfo::addResult(ResultInfo* result) { results.replace(result->resultNo(), \
result); } +const ResultInfoHash& SearchInfo::searchResults() const { return results; \
} +void SearchInfo::addResult(ResultInfo* result) { \
results.insert(result->resultNo(), result); }  
--- trunk/extragear/network/kmldonkey/libkmldonkey/searchinfo.h #992755:992756
@@ -26,7 +26,6 @@
 #include <QString>
 #include <QStringList>
 #include <QVariant>
-#include <q3intdict.h>
 #include <kmldonkey_export.h>
 
 #include "donkeytypes.h"
@@ -85,6 +84,8 @@
     int32 time;
 };
 
+typedef QHash<int, ResultInfo *> ResultInfoHash;
+
 //! Representation of a search result.
 class KMLDONKEY_EXPORT SearchInfo
 {
@@ -97,12 +98,12 @@
     const QString getQuerystring();
     void setQuery(DonkeyMessage* msg);
 
-    const Q3IntDict<ResultInfo>& searchResults() const;
+    const ResultInfoHash& searchResults() const;
     void addResult(ResultInfo* result);
 
 private:
     int32 num;
-    Q3IntDict<ResultInfo> results;
+    ResultInfoHash results;
 
     SearchQuery* query;
     QString querystring;
--- trunk/extragear/network/kmldonkey/libkmldonkey/searchquery.cpp #992755:992756
@@ -25,6 +25,7 @@
 #include "donkeymessage.h"
 
 #include <QRegExp>
+#include <QStringList>
 #include <kdebug.h>
 #include "donkeytypes.h"
 
@@ -206,9 +207,14 @@
 SearchQueryList::SearchQueryList(Operation op)
     : SearchQuery(op)
 {
-    queryList.setAutoDelete(true);
 }
 
+
+SearchQueryList::~SearchQueryList()
+{
+    qDeleteAll(queryList);
+}
+
 SearchQueryList* SearchQueryList::append(SearchQuery* q)
 {
     queryList.append(q);
@@ -227,7 +233,7 @@
 
 SearchQuery* SearchQueryList::take(uint index)
 {
-    return queryList.take(index);
+    return queryList.takeAt(index);
 }
 
 const QString SearchQueryList::getQuerystring()
@@ -238,25 +244,18 @@
 
 const QString SearchQueryList::toQueryString(const QString& joinstr)
 {
-    QString qs = QString::null;
-    Q3PtrListIterator<SearchQuery> it(queryList);
-    SearchQuery* q;
-    while ((q = it.current()) != 0) {
-        ++it;
-        if(! qs.isEmpty()) qs += " " + joinstr + " ";
-        qs += "(" + q->getQuerystring() + ")";
+    QStringList qs;
+    foreach (SearchQuery *q, queryList) {
+        qs << '(' + q->getQuerystring() + ')';
     }
-    return qs;
+    return qs.join(' ' + joinstr + ' ');
 }
 
 void SearchQueryList::writeQuery(DonkeyMessage& msg)
 {
     SearchQuery::writeQuery(msg);
     msg.writeInt16((int16)queryList.count());
-    Q3PtrListIterator<SearchQuery> it(queryList);
-    SearchQuery* q;
-    while ((q = it.current()) != 0) {
-        ++it;
+    foreach (SearchQuery *q, queryList) {
         q->writeQuery(msg);
     }
 }
--- trunk/extragear/network/kmldonkey/libkmldonkey/searchquery.h #992755:992756
@@ -25,7 +25,7 @@
 #define __libkmldonkey_searchquery_h__
 
 #include <QString>
-#include <q3ptrlist.h>
+#include <QList>
 #include <kmldonkey_export.h>
 
 class DonkeyMessage;
@@ -85,6 +85,7 @@
 {
 public:
     SearchQueryList(Operation op);
+    ~SearchQueryList();
 
     //! Append a query to the list.
     /*! Queries appended to the query list are owned by the list, and will be freed \
along with it. @@ -119,7 +120,7 @@
     const QString toQueryString(const QString& joinstr);
 
 private:
-    Q3PtrList<SearchQuery> queryList;
+    QList<SearchQuery *> queryList;
 };
 
 
--- trunk/extragear/network/kmldonkey/libkmldonkey/serverinfo.h #992755:992756
@@ -27,7 +27,6 @@
 
 #include <QString>
 #include <QStringList>
-#include <q3valuelist.h>
 #include <QVariant>
 
 class DonkeyMessage;


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic