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

List:       kde-commits
Subject:    KDE/kdebase/workspace/plasma/generic/dataengines/dict
From:       Marco Martin <notmart () gmail ! com>
Date:       2011-01-05 20:41:50
Message-ID: 20110105204150.67BD5AC8B0 () svn ! kde ! org
[Download RAW message or body]

SVN commit 1212121 by mart:

FEATURE:optional parameters for the query, that can be in the form:
server:dictionary:term
server and dictionary are optional, so it's retrocompatible


 M  +27 -5     dictengine.cpp  
 M  +1 -0      dictengine.h  


--- trunk/KDE/kdebase/workspace/plasma/generic/dataengines/dict/dictengine.cpp #1212120:1212121
@@ -179,22 +179,44 @@
     m_tcpSocket = 0;
 }
 
-bool DictEngine::sourceRequestEvent(const QString &word)
+bool DictEngine::sourceRequestEvent(const QString &query)
 {
-    // FIXME: this is COMPLETELY broken .. it can only look up one word at a time!
+    // FIXME: this is COMPLETELY broken .. it can only look up one query at a time!
     //        a DataContainer subclass that does the look up should probably be made
-    if (m_currentWord == word) {
+    if (m_currentQuery == query) {
         return false;
     }
 
     if (m_tcpSocket) {
-        m_tcpSocket->abort(); //stop if lookup is in progress and new word is requested
+        m_tcpSocket->abort(); //stop if lookup is in progress and new query is requested
         m_tcpSocket->deleteLater();
         m_tcpSocket = 0;
     }
 
-    m_currentWord = word;
+    QStringList queryParts = query.split(':', QString::SkipEmptyParts);
+    if (queryParts.isEmpty()) {
+        return false;
+    }
 
+    m_currentWord = queryParts.last();
+    m_currentQuery = query;
+
+    //asked for a dictionary?
+    if (queryParts.count() > 1) {
+        setDict(queryParts[queryParts.count()-2]);
+    //default to wordnet
+    } else {
+        setDict("wn");
+    }
+
+    //asked for a server?
+    if (queryParts.count() > 2) {
+        setServer(queryParts[queryParts.count()-3]);
+    //default to wordnet
+    } else {
+        setServer("dict.org");
+    }
+
     if (m_currentWord.simplified().isEmpty()) {
         setData(m_currentWord, m_dictName, QString());
     } else {
--- trunk/KDE/kdebase/workspace/plasma/generic/dataengines/dict/dictengine.h #1212120:1212121
@@ -50,6 +50,7 @@
         QHash<QString, QString> m_dictNameToDictCode;
         KTcpSocket *m_tcpSocket;
         QString m_currentWord;
+        QString m_currentQuery;
         QString m_dictName;
         QString m_serverName;
 
[prev in list] [next in list] [prev in thread] [next in thread] 

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