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

List:       kde-commits
Subject:    koffice/tools
From:       Fredy Yanardi <fyanardi () gmail ! com>
Date:       2007-07-11 6:32:09
Message-ID: 1184135529.014194.30413.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 686368 by fyanardi:

re-enable kthesaurus
CCMAIL: mecirt@gmail.com


 M  +1 -1      CMakeLists.txt  
 M  +2 -6      kthesaurus/CMakeLists.txt  
 M  +20 -24    kthesaurus/main.cc  


--- trunk/koffice/tools/CMakeLists.txt #686367:686368
@@ -1,7 +1,7 @@
 add_subdirectory( converter )
 add_subdirectory( thumbnail )
 add_subdirectory( thesaurus )
-#add_subdirectory( kthesaurus )
+add_subdirectory( kthesaurus )
 add_subdirectory( strigi-analyzer )
 add_subdirectory( quickprint )
 
--- trunk/koffice/tools/kthesaurus/CMakeLists.txt #686367:686368
@@ -1,8 +1,5 @@
+include_directories( ${KDE4_INCLUDES} ${KOTEXT_INCLUDES} ${KOMAIN_INCLUDES})
 
-
-include_directories( ${KDE4_INCLUDES} )
-
-
 ########### next target ###############
 
 set(kthesaurus_KDEINIT_SRCS main.cc )
@@ -10,7 +7,7 @@
 
 kde4_add_kdeinit_executable( kthesaurus ${kthesaurus_KDEINIT_SRCS})
 
-target_link_libraries(kdeinit_kthesaurus  ${KDE4_KIO_LIBS} )
+target_link_libraries(kdeinit_kthesaurus  kotext)
 
 install(TARGETS kdeinit_kthesaurus  DESTINATION ${LIB_INSTALL_DIR})
 
@@ -21,4 +18,3 @@
 
 install( FILES  KThesaurus.desktop  DESTINATION ${XDG_APPS_DIR})
 
-
--- trunk/koffice/tools/kthesaurus/main.cc #686367:686368
@@ -17,20 +17,23 @@
  ***************************************************************************/
 
 #include <QString>
+#include <QTextDocument>
 
 #include <kaboutdata.h>
 #include <kapplication.h>
 #include <kcmdlineargs.h>
-#include <kdatatool.h>
 #include <kdebug.h>
 #include <kglobal.h>
 #include <klocale.h>
 #include <kdemacros.h>
 #include <kcomponentdata.h>
 
+#include <KoTextEditingPlugin.h>
+#include <KoTextEditingRegistry.h>
+#include <KoTextEditingFactory.h>
+
 extern "C" KDE_EXPORT int kdemain(int argc, char **argv)
 {
-
 	KAboutData aboutData("kthesaurus", 0, ki18n("KThesaurus"), "1.0",
 		ki18n( "KThesaurus - List synonyms" ), KAboutData::License_GPL,
 		ki18n( "(c) 2001 Daniel Naber" ) );
@@ -40,23 +43,21 @@
 	KCmdLineOptions options;
 	options.add("+[term]", ki18n("Term to search for when starting up"));
 	KCmdLineArgs::addCmdLineOptions(options);
-	KApplication a; // KDataTool needs an instance
+	KApplication a;
 
-	// TODO: take term from command line!
+    KoTextEditingPlugin *thesaurus;
 
-	KService::Ptr service = KService::serviceByDesktopName("thesaurustool");
-	if( ! service ) {
-		kWarning() << "Could not find Service/KDataTool 'thesaurustool'!" << endl;
-		return 1;
-	}
+    foreach(QString key, KoTextEditingRegistry::instance()->keys()) {
+        KoTextEditingFactory *factory =  KoTextEditingRegistry::instance()->value(key);
+        Q_ASSERT(factory);
+        if (factory->id() == "thesaurustool") {
+            kDebug() << "Thesaurus plugin found, creating..." << endl;
+            thesaurus = factory->create();
+        }
+    }
 
-	KDataToolInfo *info = new KDataToolInfo(service, KComponentData());
-	KDataTool *tool = info->createTool();
-	if ( !tool ) {
-		kWarning() << "Could not create tool 'thesaurustool'!" << endl;
-                delete info;
-		return 2;
-	}
+    if (!thesaurus) // No thesaurus plugin found
+        return 1;
 
 /* TODO: get selection(), not only clipboard!
 	QClipboard *cb = QApplication::clipboard();
@@ -72,16 +73,11 @@
 		text = args->arg(0);
 	}
 
-	QString command = "thesaurus_standalone";	// 'standalone' will give us different buttons
-	QString mimetype = "text/plain";
-	QString datatype = "QString";
+    // pas -1 to startPosition and endPosition to set as standalone and will give us different buttons
+    thesaurus->checkSection(new QTextDocument(text), -1, -1);
 
 	//kDebug() << "KThesaurus command=" << command
 	//		<< " dataType=" << info->dataType() << endl;
 
-	tool->run(command, &text, datatype, mimetype);
-
-	delete tool;
-
-	return 0;
+	return a.exec();
 }
[prev in list] [next in list] [prev in thread] [next in thread] 

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