summaryrefslogtreecommitdiffstats
path: root/tools/kthesaurus/main.cc
diff options
context:
space:
mode:
authortpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2010-01-20 01:29:50 +0000
committertpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2010-01-20 01:29:50 +0000
commit8362bf63dea22bbf6736609b0f49c152f975eb63 (patch)
tree0eea3928e39e50fae91d4e68b21b1e6cbae25604 /tools/kthesaurus/main.cc
downloadkoffice-8362bf63dea22bbf6736609b0f49c152f975eb63.tar.gz
koffice-8362bf63dea22bbf6736609b0f49c152f975eb63.zip
Added old abandoned KDE3 version of koffice
git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/applications/koffice@1077364 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'tools/kthesaurus/main.cc')
-rw-r--r--tools/kthesaurus/main.cc87
1 files changed, 87 insertions, 0 deletions
diff --git a/tools/kthesaurus/main.cc b/tools/kthesaurus/main.cc
new file mode 100644
index 00000000..6b50a81b
--- /dev/null
+++ b/tools/kthesaurus/main.cc
@@ -0,0 +1,87 @@
+/***************************************************************************
+ main.cc - using the thesaurus KDataTool stand alone
+ -------------------
+ begin : 2001-12-22
+ copyright : (C) 2001 by Daniel Naber
+ $Id: main.cc 381440 2005-01-23 07:53:34Z mlaurent $
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+
+#include <qstring.h>
+
+#include <kaboutdata.h>
+#include <kapplication.h>
+#include <kcmdlineargs.h>
+#include <kdatatool.h>
+#include <kdebug.h>
+#include <kglobal.h>
+#include <klocale.h>
+#include <koffice_export.h>
+static KCmdLineOptions options[] =
+{
+ { "+[term]", I18N_NOOP("Term to search for when starting up"), 0 },
+ KCmdLineLastOption
+};
+
+extern "C" KOFFICETOOLS_EXPORT int kdemain(int argc, char **argv)
+{
+
+ KAboutData aboutData("kthesaurus", I18N_NOOP("KThesaurus"), "1.0",
+ I18N_NOOP( "KThesaurus - List synonyms" ), KAboutData::License_GPL,
+ I18N_NOOP( "(c) 2001 Daniel Naber" ) );
+
+ KCmdLineArgs::init(argc, argv, &aboutData);
+ KCmdLineArgs::addCmdLineOptions(options);
+ KApplication a; // KDataTool needs an instance
+
+ // TODO: take term from command line!
+
+ KService::Ptr service = KService::serviceByDesktopName("thesaurustool");
+ if( ! service ) {
+ kdWarning() << "Could not find Service/KDataTool 'thesaurustool'!" << endl;
+ return 1;
+ }
+
+ KDataToolInfo *info = new KDataToolInfo(service, 0);
+ KDataTool *tool = info->createTool();
+ if ( !tool ) {
+ kdWarning() << "Could not create tool 'thesaurustool'!" << endl;
+ return 2;
+ }
+
+/* TODO: get selection(), not only clipboard!
+ QClipboard *cb = QApplication::clipboard();
+ QString text = cb->text();
+ if( text.isNull() || text.length() > 50 ) {
+ // long texts are probably not supposed to be searched for
+ text = "";
+ }
+*/
+ QString text = "";
+ KCmdLineArgs *args = KCmdLineArgs::parsedArgs();
+ if ( args->count() > 0 ) {
+ text = args->arg(0);
+ }
+
+ QString command = "thesaurus_standalone"; // 'standalone' will give us different buttons
+ QString mimetype = "text/plain";
+ QString datatype = "QString";
+
+ //kdDebug() << "KThesaurus command=" << command
+ // << " dataType=" << info->dataType() << endl;
+
+ tool->run(command, &text, datatype, mimetype);
+
+ delete tool;
+
+ return 0;
+}