You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
88 lines
2.9 KiB
88 lines
2.9 KiB
15 years ago
|
/***************************************************************************
|
||
4 years ago
|
main.cpp - using the thesaurus KDataTool stand alone
|
||
15 years ago
|
-------------------
|
||
|
begin : 2001-12-22
|
||
|
copyright : (C) 2001 by Daniel Naber
|
||
|
email : daniel.naber@t-online.de
|
||
4 years ago
|
$Id: main.cpp 381440 2005-01-23 07:53:34Z mlaurent $
|
||
15 years ago
|
***************************************************************************/
|
||
|
|
||
|
/***************************************************************************
|
||
|
* *
|
||
|
* 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. *
|
||
|
* *
|
||
|
***************************************************************************/
|
||
|
|
||
14 years ago
|
#include <tqstring.h>
|
||
15 years ago
|
|
||
12 years ago
|
#include <tdeaboutdata.h>
|
||
|
#include <tdeapplication.h>
|
||
|
#include <tdecmdlineargs.h>
|
||
15 years ago
|
#include <kdatatool.h>
|
||
|
#include <kdebug.h>
|
||
12 years ago
|
#include <tdeglobal.h>
|
||
|
#include <tdelocale.h>
|
||
15 years ago
|
#include <koffice_export.h>
|
||
12 years ago
|
static TDECmdLineOptions options[] =
|
||
15 years ago
|
{
|
||
|
{ "+[term]", I18N_NOOP("Term to search for when starting up"), 0 },
|
||
12 years ago
|
TDECmdLineLastOption
|
||
15 years ago
|
};
|
||
|
|
||
|
extern "C" KOFFICETOOLS_EXPORT int kdemain(int argc, char **argv)
|
||
|
{
|
||
|
|
||
12 years ago
|
TDEAboutData aboutData("kthesaurus", I18N_NOOP("KThesaurus"), "1.0",
|
||
|
I18N_NOOP( "KThesaurus - List synonyms" ), TDEAboutData::License_GPL,
|
||
15 years ago
|
I18N_NOOP( "(c) 2001 Daniel Naber" ) );
|
||
|
|
||
12 years ago
|
TDECmdLineArgs::init(argc, argv, &aboutData);
|
||
|
TDECmdLineArgs::addCmdLineOptions(options);
|
||
12 years ago
|
TDEApplication a; // KDataTool needs an instance
|
||
15 years ago
|
|
||
|
// 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!
|
||
13 years ago
|
TQClipboard *cb = TQApplication::clipboard();
|
||
14 years ago
|
TQString text = cb->text();
|
||
15 years ago
|
if( text.isNull() || text.length() > 50 ) {
|
||
|
// long texts are probably not supposed to be searched for
|
||
|
text = "";
|
||
|
}
|
||
|
*/
|
||
14 years ago
|
TQString text = "";
|
||
12 years ago
|
TDECmdLineArgs *args = TDECmdLineArgs::parsedArgs();
|
||
15 years ago
|
if ( args->count() > 0 ) {
|
||
|
text = args->arg(0);
|
||
|
}
|
||
|
|
||
14 years ago
|
TQString command = "thesaurus_standalone"; // 'standalone' will give us different buttons
|
||
|
TQString mimetype = "text/plain";
|
||
|
TQString datatype = TQSTRING_OBJECT_NAME_STRING;
|
||
15 years ago
|
|
||
|
//kdDebug() << "KThesaurus command=" << command
|
||
|
// << " dataType=" << info->dataType() << endl;
|
||
|
|
||
|
tool->run(command, &text, datatype, mimetype);
|
||
|
|
||
|
delete tool;
|
||
|
|
||
|
return 0;
|
||
|
}
|