diff options
author | toma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2009-11-25 17:56:58 +0000 |
---|---|---|
committer | toma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2009-11-25 17:56:58 +0000 |
commit | bd9e6617827818fd043452c08c606f07b78014a0 (patch) | |
tree | 425bb4c3168f9c02f10150f235d2cb998dcc6108 /kbabel/kbabeldict/modules/poauxiliary | |
download | tdesdk-bd9e6617827818fd043452c08c606f07b78014a0.tar.gz tdesdk-bd9e6617827818fd043452c08c606f07b78014a0.zip |
Copy the KDE 3.5 branch to branches/trinity for new KDE 3.5 features.
BUG:215923
git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdesdk@1054174 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'kbabel/kbabeldict/modules/poauxiliary')
-rw-r--r-- | kbabel/kbabeldict/modules/poauxiliary/Makefile.am | 36 | ||||
-rw-r--r-- | kbabel/kbabeldict/modules/poauxiliary/pa_factory.cpp | 110 | ||||
-rw-r--r-- | kbabel/kbabeldict/modules/poauxiliary/pa_factory.h | 60 | ||||
-rw-r--r-- | kbabel/kbabeldict/modules/poauxiliary/poauxiliary.cpp | 554 | ||||
-rw-r--r-- | kbabel/kbabeldict/modules/poauxiliary/poauxiliary.desktop | 51 | ||||
-rw-r--r-- | kbabel/kbabeldict/modules/poauxiliary/poauxiliary.h | 136 | ||||
-rw-r--r-- | kbabel/kbabeldict/modules/poauxiliary/preferenceswidget.cpp | 115 | ||||
-rw-r--r-- | kbabel/kbabeldict/modules/poauxiliary/preferenceswidget.h | 77 | ||||
-rw-r--r-- | kbabel/kbabeldict/modules/poauxiliary/pwidget.ui | 133 |
9 files changed, 1272 insertions, 0 deletions
diff --git a/kbabel/kbabeldict/modules/poauxiliary/Makefile.am b/kbabel/kbabeldict/modules/poauxiliary/Makefile.am new file mode 100644 index 00000000..75509337 --- /dev/null +++ b/kbabel/kbabeldict/modules/poauxiliary/Makefile.am @@ -0,0 +1,36 @@ +## Makefile.am for poauxiliary + +# this has all of the subdirectories that make will recurse into. if +# there are none, comment this out +#SUBDIRS = + + +# this is the program that gets installed. it's name is used for all +# of the other Makefile.am variables +kde_module_LTLIBRARIES = kbabeldict_poauxiliary.la + +# set the include path for X, qt and KDE +INCLUDES = -I$(srcdir)/../.. -I../../../common -I$(srcdir)/../../../common $(all_includes) + + +kbabeldict_poauxiliary_la_SOURCES = poauxiliary.cpp preferenceswidget.cpp\ + pa_factory.cpp pwidget.ui +kbabeldict_poauxiliary_la_LIBADD = ../../libkbabeldictplugin.la ../../../common/libkbabelcommon.la $(LIB_KDEUI) $(LIB_KIO) +kbabeldict_poauxiliary_la_LDFLAGS = $(all_libraries) -module -avoid-version -no-undefined + + + +# these are the headers for your project +noinst_HEADERS = poauxiliary.h preferenceswidget.h pa_factory.h + + +# let automoc handle all of the meta source files (moc) +METASOURCES = AUTO + + +# this is where the kdelnk file will go +#datadir = $(kde_datadir)/kbabeldict/modules +#data_DATA = poauxiliary.rc + +kde_services_DATA = poauxiliary.desktop +EXTRA_DIST = $(kde_services_DATA) diff --git a/kbabel/kbabeldict/modules/poauxiliary/pa_factory.cpp b/kbabel/kbabeldict/modules/poauxiliary/pa_factory.cpp new file mode 100644 index 00000000..1448e2b0 --- /dev/null +++ b/kbabel/kbabeldict/modules/poauxiliary/pa_factory.cpp @@ -0,0 +1,110 @@ +/* **************************************************************************** + This file is part of KBabel + + Copyright (C) 2000 by Matthias Kiefer + <matthias.kiefer@gmx.de> + + 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. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + + In addition, as a special exception, the copyright holders give + permission to link the code of this program with any edition of + the Qt library by Trolltech AS, Norway (or with modified versions + of Qt that use the same license as Qt), and distribute linked + combinations including the two. You must obey the GNU General + Public License in all respects for all of the code used other than + Qt. If you modify this file, you may extend this exception to + your version of the file, but you are not obligated to do so. If + you do not wish to do so, delete this exception statement from + your version. + +**************************************************************************** */ + + +#include <klocale.h> +#include <kinstance.h> +#include <kaboutdata.h> +#include <kdebug.h> + +#include "pa_factory.h" +#include "poauxiliary.h" + + +extern "C" +{ + KDE_EXPORT void *init_kbabeldict_poauxiliary() + { + return new PaFactory; + } +} + + +KInstance *PaFactory::s_instance = 0; +KAboutData *PaFactory::s_about = 0; + + +PaFactory::PaFactory( QObject *parent, const char *name) + : KLibFactory(parent,name) +{ +} + +PaFactory::~PaFactory() +{ + if(s_instance) + { + delete s_instance; + s_instance=0; + } + + if(s_about) + { + delete s_about; + s_about=0; + } +} + + +QObject *PaFactory::createObject( QObject *parent, const char *name + , const char *classname, const QStringList &) +{ + if(QCString(classname) != "SearchEngine") + { + kdError() << "not a SearchEngine requested" << endl; + return 0; + } + + return new PoAuxiliary(parent,name); +} + + +KInstance *PaFactory::instance() +{ + if(!s_instance) + { + s_about = new KAboutData( "poauxiliary", I18N_NOOP("PO Auxiliary") + , "1.0" + , I18N_NOOP("A simple module for exact searching in a PO file") + , KAboutData::License_GPL + , "Copyright 2000, Matthias Kiefer" + ,0,0, "kiefer@kde.org"); + + s_about->addAuthor("Matthias Kiefer",0,"kiefer@kde.org"); + + s_instance = new KInstance(s_about); + } + + return s_instance; +} + +#include "pa_factory.moc" diff --git a/kbabel/kbabeldict/modules/poauxiliary/pa_factory.h b/kbabel/kbabeldict/modules/poauxiliary/pa_factory.h new file mode 100644 index 00000000..8871a538 --- /dev/null +++ b/kbabel/kbabeldict/modules/poauxiliary/pa_factory.h @@ -0,0 +1,60 @@ +/* **************************************************************************** + This file is part of KBabel + + Copyright (C) 2000 by Matthias Kiefer + <matthias.kiefer@gmx.de> + + 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. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + + In addition, as a special exception, the copyright holders give + permission to link the code of this program with any edition of + the Qt library by Trolltech AS, Norway (or with modified versions + of Qt that use the same license as Qt), and distribute linked + combinations including the two. You must obey the GNU General + Public License in all respects for all of the code used other than + Qt. If you modify this file, you may extend this exception to + your version of the file, but you are not obligated to do so. If + you do not wish to do so, delete this exception statement from + your version. + +**************************************************************************** */ + + +#ifndef PA_FACTORY_H +#define PA_FACTORY_H + +#include <klibloader.h> +class KInstance; +class KAboutData; + +class PaFactory : public KLibFactory +{ + Q_OBJECT +public: + PaFactory( QObject *parent=0, const char *name=0); + ~PaFactory(); + + virtual QObject *createObject( QObject *parent=0, const char *name=0 + , const char *classname="QObject" + , const QStringList &args = QStringList()); + + static KInstance *instance(); + +private: + static KInstance *s_instance; + static KAboutData *s_about; +}; + +#endif diff --git a/kbabel/kbabeldict/modules/poauxiliary/poauxiliary.cpp b/kbabel/kbabeldict/modules/poauxiliary/poauxiliary.cpp new file mode 100644 index 00000000..373f123d --- /dev/null +++ b/kbabel/kbabeldict/modules/poauxiliary/poauxiliary.cpp @@ -0,0 +1,554 @@ +/* **************************************************************************** + This file is part of KBabel + + Copyright (C) 2000 by Matthias Kiefer + <matthias.kiefer@gmx.de> + + 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. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + + In addition, as a special exception, the copyright holders give + permission to link the code of this program with any edition of + the Qt library by Trolltech AS, Norway (or with modified versions + of Qt that use the same license as Qt), and distribute linked + combinations including the two. You must obey the GNU General + Public License in all respects for all of the code used other than + Qt. If you modify this file, you may extend this exception to + your version of the file, but you are not obligated to do so. If + you do not wish to do so, delete this exception statement from + your version. + +**************************************************************************** */ +#include <klocale.h> +#include <kapplication.h> +#include <kcmdlineargs.h> +#include <kdebug.h> +#include <kglobal.h> +#include <kinstance.h> + +#include <qregexp.h> +#include <qtimer.h> +#include <qstylesheet.h> + +#include "poauxiliary.h" +#include "preferenceswidget.h" +#include "pa_factory.h" + +#include <resources.h> +#include <catalog.h> + +using namespace KBabel; + +PoAuxiliary::PoAuxiliary(QObject *parent, const char *name) + : SearchEngine(parent, name) +{ + catalog = new Catalog(this, "PoAuxiliary::catalog"); + prefWidget=0; + error=false; + stop=false; + active=false; + loading=false; + initialized=false; + + ignoreFuzzy=true; + + loadTimer = new QTimer(this); + connect(loadTimer,SIGNAL(timeout()),this,SLOT(loadAuxiliary())); + + msgidDict.setAutoDelete(true); +} + +PoAuxiliary::~PoAuxiliary() +{ + results.clear(); +} + +bool PoAuxiliary::isReady() const +{ + return !error; +} + + +bool PoAuxiliary::isSearching() const +{ + return active; +} + + +void PoAuxiliary::saveSettings(KConfigBase *config) +{ + if(autoUpdate && prefWidget && prefWidget->settingsChanged()) + { + applySettings(); + } + + config->writeEntry("Auxiliary", url); + config->writeEntry("IgnoreFuzzy",ignoreFuzzy); +} + +void PoAuxiliary::readSettings(KConfigBase *config) +{ + bool needLoading=false; + + QString newPath = config->readEntry("Auxiliary" + ,"../../../de/messages/@DIR1@/@PACKAGE@.po"); + if(!initialized) + { + url = newPath; + } + else if(newPath != url) + { + url = newPath; + needLoading = true; + } + + ignoreFuzzy = config->readBoolEntry("IgnoreFuzzy",true); + + if(needLoading && !loadTimer->isActive()) + { + kdDebug(KBABEL_SEARCH) << "readSettings" << endl; + loadTimer->start(100,true); + } + + restoreSettings(); +} + +PrefWidget *PoAuxiliary::preferencesWidget(QWidget *parent) +{ + prefWidget = new AuxiliaryPreferencesWidget(parent,"pocompendium_prefwidget"); + connect(prefWidget, SIGNAL(applySettings()), this, SLOT(applySettings())); + connect(prefWidget, SIGNAL(restoreSettings()) + , this, SLOT(restoreSettings())); + + restoreSettings(); + + return prefWidget; +} + +const KAboutData *PoAuxiliary::about() const +{ + return PaFactory::instance()->aboutData(); +} + + +QString PoAuxiliary::name() const +{ + return i18n("PO Auxiliary"); +} + +QString PoAuxiliary::id() const +{ + return "poauxiliary"; +} + +QString PoAuxiliary::lastError() +{ + return errorMsg; +} + +bool PoAuxiliary::startSearch(const QString& t, uint pluralForm, const SearchFilter*filter) +{ + QString text(t); + if(autoUpdate && prefWidget && prefWidget->settingsChanged()) + { + applySettings(); + } + + if(!initialized) + { + loadAuxiliary(); + } + + if(error) + return false; + + if(isSearching()) + return false; + + stop=false; + active = true; + emit started(); + + clearResults(); + + kapp->processEvents(100); + + text.replace("\n",""); + + Entry *entry = msgidDict[text]; + if(entry) + { + if( !(entry->fuzzy && ignoreFuzzy) ) + { + SearchResult *result = new SearchResult; + result->requested =QStyleSheet::convertFromPlainText(text); + result->found = QStyleSheet::convertFromPlainText(text); + result->translation = + QStyleSheet::convertFromPlainText(entry->translation); + + result->plainRequested = text; + result->plainFound=text; + result->plainTranslation=entry->translation; + result->score=100; + + if(entry->fuzzy) + { + result->translation="<qt><font color=\"red\">"+i18n("fuzzy") + +"</font><hr/>" + result->translation+"</qt>"; + } + + TranslationInfo *info = new TranslationInfo; + info->location = auxPackage; + info->translator = auxTranslator; + info->description = entry->comment; + info->filePath = auxURL; + result->descriptions.append(info); + + results.append(result); + + emit numberOfResultsChanged(1); + emit resultFound(result); + } + } + + + active = false; + stop = false; + emit finished(); + + return true; +} + + +bool PoAuxiliary::startSearchInTranslation(const QString& text) +{ + if(autoUpdate && prefWidget && prefWidget->settingsChanged()) + { + applySettings(); + } + + if(!initialized) + { + loadAuxiliary(); + } + + if(error) + return false; + + if(isSearching()) + return false; + + stop=false; + active = true; + emit started(); + + clearResults(); + + kapp->processEvents(100); + + Entry *entry = msgstrDict[text]; + if(entry) + { + if( !(entry->fuzzy && ignoreFuzzy) ) + { + SearchResult *result = new SearchResult; + result->requested =QStyleSheet::convertFromPlainText(entry->orig); + result->found = QStyleSheet::convertFromPlainText(entry->orig); + result->translation = + QStyleSheet::convertFromPlainText(text); + + result->plainRequested = entry->orig; + result->plainFound=entry->orig; + result->plainTranslation=text; + result->score=100; + + if(entry->fuzzy) + { + result->translation="<qt><font color=\"red\">"+i18n("fuzzy") + +"</font><hr/>" + result->translation+"</qt>"; + } + + TranslationInfo *info = new TranslationInfo; + info->location = auxPackage; + info->translator = auxTranslator; + info->description = entry->comment; + info->filePath = auxURL; + result->descriptions.append(info); + + results.append(result); + + emit numberOfResultsChanged(1); + emit resultFound(result); + } + } + + + active = false; + stop = false; + emit finished(); + + return true; +} + +void PoAuxiliary::stopSearch() +{ + stop=true; +} + + +void PoAuxiliary::applySettings() +{ + if(!prefWidget) + return; + + bool needLoading=false; + + if(isSearching()) + stopSearch(); + + QString newPath = prefWidget->url(); + if(!initialized) + { + url = newPath; + } + else if(newPath != url) + { + url = newPath; + needLoading=true; + } + + ignoreFuzzy = prefWidget->ignoreFuzzy(); + + if(needLoading && !loadTimer->isActive()) + { + loadTimer->start(100,true); + } +} + +void PoAuxiliary::restoreSettings() +{ + if(!prefWidget) + return; + + prefWidget->setURL(url); + prefWidget->setIgnoreFuzzy(ignoreFuzzy); +} + +void PoAuxiliary::loadAuxiliary() +{ + if(loadTimer->isActive()) + loadTimer->stop(); + + if(loading) + return; + + loading=true; + error=false; + + QString path=url; + + if(path.contains("@LANG@")) + { + path.replace("@LANG@",langCode); + } + if(path.contains("@PACKAGE@")) + { + int pos=package.findRev("/"); + if( pos<0 ) pos=0; + path.replace("@PACKAGE@",package.mid(pos)); + } + if(path.contains("@PACKAGEDIR@")) + { + QString packagedir; + int pos=package.findRev("/"); + if( pos > 0 ) packagedir=package.left(pos); + else packagedir=""; + path.replace("@PACKAGEDIR@",packagedir); + kdDebug(KBABEL_SEARCH) << "Packagedir found " << packagedir << endl; + } + QRegExp reg("@DIR[0-9]+@"); + if(path.contains(reg)) + { + int pos=reg.search(path); + int len = reg.matchedLength(); + + while(pos>=0) + { + QString num=path.mid(pos+4,len-5); + + bool ok; + int number=num.toInt(&ok); + if(ok) + { + QString dir=directory(editedFile,number); + QString s("@DIR%1@"); + path.replace(s.arg(number),dir); + + pos+=dir.length(); + } + + pos=reg.search(path); + len = reg.matchedLength(); + } + } + + KURL u; + QRegExp rel("^[a-zA-Z]+:"); + if(rel.search(path) >= 0) + { + u=path; + } + else if(path[0] != '/') // relative path + { + KURL temp(editedFile); + QString dir = temp.directory(); + kdDebug(KBABEL_SEARCH) << dir << endl; + u.setPath(dir+"/"+path); + u.cleanPath(); + kdDebug(KBABEL_SEARCH) << u.prettyURL() << endl; + } + else + { + u.setPath(path); + } + + emit progressStarts(i18n("Loading PO auxiliary")); + connect(catalog, SIGNAL(signalProgress(int)) + , this, SIGNAL(progress(int))); + + ConversionStatus stat = catalog->openURL(u); + if( stat != OK && stat != RECOVERED_PARSE_ERROR) + { + kdDebug(KBABEL_SEARCH) << "error while opening file " << u.prettyURL() << endl; + + if( !error ) + { + error = true; + errorMsg = i18n("Error while trying to open file for PO Auxiliary module:\n%1") + .arg(u.prettyURL()); + emit hasError(errorMsg); + } + } + else + { + error = false; + // build index for fast search + msgidDict.clear(); + msgstrDict.clear(); + + emit progressStarts(i18n("Building index")); + + int total = catalog->numberOfEntries(); + for(int i=0; i < total; i++) + { + if( (100*(i+1))%total < 100 ) + { + emit progress((100*(i+1))/total); + kapp->processEvents(100); + } + + Entry *e = new Entry; + // FIXME: should care about plural forms + e->orig = catalog->msgid(i).first(); + e->orig.replace("\n",""); + kdWarning() << "PoAuxialiary does not support plural forms" << endl; + e->translation = catalog->msgstr(i).first(); + e->comment = catalog->comment(i); + e->fuzzy = catalog->isFuzzy(i); + + msgidDict.insert(catalog->msgid(i,true).first(),e); + msgstrDict.insert(e->translation,e); + } + + auxPackage = catalog->packageName(); + auxURL = catalog->currentURL().url(); + auxTranslator = catalog->lastTranslator(); + } + + disconnect(catalog, SIGNAL(signalProgress(int)) + , this, SIGNAL(progress(int))); + + emit progressEnds(); + + initialized=true; + + loading=false; + + catalog->clear(); +} + + +void PoAuxiliary::setEditedFile(const QString& file) +{ + if(initialized && (url.contains("@DIR") || KURL::isRelativeURL(url)) + && file!=editedFile && !loadTimer->isActive() ) + { + initialized=false; + } + + editedFile=file; +} + + +void PoAuxiliary::setEditedPackage(const QString& pack) +{ + if(initialized && url.contains("@PACKAGE@") && pack!=package + && !loadTimer->isActive() ) + { + initialized=false; + } + + package=pack; +} + + +void PoAuxiliary::setLanguageCode(const QString& lang) +{ + if(initialized && url.contains("@LANG@") && lang!=langCode + && !loadTimer->isActive() ) + { + initialized=false; + } + + langCode=lang; +} + +bool PoAuxiliary::usesRichTextResults() +{ + return true; +} + +QString PoAuxiliary::translate(const QString& text, uint pluralForm) +{ + if(!initialized) + { + loadAuxiliary(); + } + + if(error) + { + return QString::null; + } + + Entry *entry = msgidDict[text]; + if(entry) + { + return entry->translation; + } + + return QString::null; +} + + +#include "poauxiliary.moc" diff --git a/kbabel/kbabeldict/modules/poauxiliary/poauxiliary.desktop b/kbabel/kbabeldict/modules/poauxiliary/poauxiliary.desktop new file mode 100644 index 00000000..5629930e --- /dev/null +++ b/kbabel/kbabeldict/modules/poauxiliary/poauxiliary.desktop @@ -0,0 +1,51 @@ +[Desktop Entry] +Type=Service +Name=Auxiliary PO Module for KBabelDict +Name[bg]=Помощен PO модул за KBabelDict +Name[bs]=Pomoćni PO modul za KBabelDict +Name[ca]=Mòdul PO auxiliar per a KBabelDict +Name[cs]=Doplňkový PO modul pro KBabelDict +Name[cy]=Modiwl PO Ategol i KBabelDict +Name[da]=Auxiliary PO-module for KBabelDict +Name[de]=PO-Hilfsdatei-Modul für KBabelDict +Name[el]=Άρθρωμα βοηθητικού PO για το KBabelDict +Name[es]=Módulo PO auxiliar para KBabelDict +Name[et]=KBabelDicti PO liitlasfaili moodul +Name[eu]=PO modulu laguntzailea KBabelDict-entzat +Name[fa]=پیمانۀ کمکی PO برای KBabelDict +Name[fi]=KBabelDict-ohjelman PO-apumoduuli +Name[fr]=Module de PO auxiliaire pour KBabelDict +Name[gl]=Módulo de PO auxiliar para KBabelDict +Name[hi]=के-बेबल-डिक्श के लिए ऑक्जिलरी पीओ मॉड्यूल +Name[hu]=Kiegészítő PO modul a KBabelDicthez +Name[is]=Viðbótar PO eining fyrir KBabel orðabókina +Name[it]=Modulo ausiliario PO per KBabelDict +Name[ja]=KBabelDict 補助 PO モジュール +Name[ka]=დამხმარე PO მოდული KBabelDict-სთვის +Name[kk]=KBabelDict-тың қосымша PO модулі +Name[lt]=KBabelDict papildomo PO žodyno modulis +Name[ms]=Modul Auksillari PO untuk KBabelDict +Name[nb]=Hjelpeordlistemodul for KBabelDict +Name[nds]=PO-Hülpdateimoduul för KBabelDict +Name[ne]=KBabelDict का लागि सहायक पीओ मोड्युल +Name[nl]=Alternatieve PO-module voor KBabelDict +Name[nn]=Jamføringsmodul for KBabelDict +Name[pa]=ਕੇਬਬੇਲ-ਸ਼ਬਦਕੋਸ਼ ਲਈ ਸਹਾਇਕ PO ਸਹਾਇਕ +Name[pl]=Moduł pomocniczego pliku PO dla KBabelDict +Name[pt]=Módulo de PO Auxiliar para o KBabelDict +Name[pt_BR]=Módulo Auxiliar PO para o KBabelDict +Name[ru]=Вспомогательный модуль PO для KBabelDict +Name[sk]=Iný PO súbore pre KBabelDict +Name[sl]=Dodatni modul PO za KBabelDict +Name[sr]=Помоћни PO модул за KBabelDict +Name[sr@Latn]=Pomoćni PO modul za KBabelDict +Name[sv]=Hjälp-PO modul för Kbabeldict +Name[ta]=Kபாபேலுக்கான இரண்டாம் PO கூறு +Name[tg]=Модули ёрирасони PO барои KBabelDict +Name[tr]=KBabelDict için Yardımcı PO Modülü +Name[uk]=Модуль допоміжного словника PO для KBabelDict +Name[zh_CN]=KBabelDict 的 PO 辅助词典模块 +Name[zh_TW]=KBabelDict 輔助 PO 模組 +X-KDE-Library=kbabeldict_poauxiliary +ServiceTypes=KBabelDictModule +Applications=kbabel diff --git a/kbabel/kbabeldict/modules/poauxiliary/poauxiliary.h b/kbabel/kbabeldict/modules/poauxiliary/poauxiliary.h new file mode 100644 index 00000000..27fecba6 --- /dev/null +++ b/kbabel/kbabeldict/modules/poauxiliary/poauxiliary.h @@ -0,0 +1,136 @@ +/* **************************************************************************** + This file is part of KBabel + + Copyright (C) 2000 by Matthias Kiefer + <matthias.kiefer@gmx.de> + + 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. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + + In addition, as a special exception, the copyright holders give + permission to link the code of this program with any edition of + the Qt library by Trolltech AS, Norway (or with modified versions + of Qt that use the same license as Qt), and distribute linked + combinations including the two. You must obey the GNU General + Public License in all respects for all of the code used other than + Qt. If you modify this file, you may extend this exception to + your version of the file, but you are not obligated to do so. If + you do not wish to do so, delete this exception statement from + your version. + +**************************************************************************** */ + +#ifndef POAUXILIARY_H +#define POAUXILIARY_H + +#include "searchengine.h" + +#include <qguardedptr.h> +#include <qdict.h> +class QTimer; + +namespace KBabel +{ + class Catalog; +} + +class AuxiliaryPreferencesWidget; + +class PoAuxiliary : public SearchEngine +{ + Q_OBJECT + +public: + PoAuxiliary(QObject *parent=0, const char *name=0); + virtual ~PoAuxiliary(); + + virtual bool isReady() const; + + virtual QString translate(const QString& text, uint pluralForm); + + virtual bool isSearching() const; + + virtual void saveSettings(KConfigBase *config); + virtual void readSettings(KConfigBase *config); + + virtual PrefWidget *preferencesWidget(QWidget *parent); + + virtual const KAboutData *about() const; + + virtual QString name() const; + + virtual QString id() const; + + virtual QString lastError(); + + virtual bool usesRichTextResults(); + +public slots: + virtual bool startSearch(const QString& text, unsigned int pluralForm + , const SearchFilter*filter); + virtual bool startSearchInTranslation(const QString& text); + + virtual void stopSearch(); + + virtual void setEditedFile(const QString&); + virtual void setEditedPackage(const QString&); + virtual void setLanguageCode(const QString&); + + +protected slots: + /** reads the current settings from the preferences dialog */ + void applySettings(); + + /** sets the current settings in the preferences dialog */ + void restoreSettings(); + + void loadAuxiliary(); + +private: + QGuardedPtr<AuxiliaryPreferencesWidget> prefWidget; + KBabel::Catalog *catalog; + QString auxPackage; + QString auxTranslator; + QString auxURL; + + QString url; + bool ignoreFuzzy; + + QString editedFile; + QString package; + QString langCode; + + bool error; + QString errorMsg; + + bool stop; + bool active; + bool loading; + bool initialized; + + QTimer *loadTimer; + + struct Entry + { + QString orig; + QString translation; + QString comment; + bool fuzzy; + }; + + QDict<Entry> msgidDict; + QDict<Entry> msgstrDict; +}; + +#endif diff --git a/kbabel/kbabeldict/modules/poauxiliary/preferenceswidget.cpp b/kbabel/kbabeldict/modules/poauxiliary/preferenceswidget.cpp new file mode 100644 index 00000000..e8d48032 --- /dev/null +++ b/kbabel/kbabeldict/modules/poauxiliary/preferenceswidget.cpp @@ -0,0 +1,115 @@ +/* **************************************************************************** + This file is part of KBabel + + Copyright (C) 2000 by Matthias Kiefer + <matthias.kiefer@gmx.de> + + 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. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + + In addition, as a special exception, the copyright holders give + permission to link the code of this program with any edition of + the Qt library by Trolltech AS, Norway (or with modified versions + of Qt that use the same license as Qt), and distribute linked + combinations including the two. You must obey the GNU General + Public License in all respects for all of the code used other than + Qt. If you modify this file, you may extend this exception to + your version of the file, but you are not obligated to do so. If + you do not wish to do so, delete this exception statement from + your version. + +**************************************************************************** */ +#include <qcheckbox.h> +#include <qlabel.h> +#include <qlayout.h> + +#include <kfiledialog.h> +#include <qpushbutton.h> +#include <klineedit.h> +#include <klocale.h> +#include <kurlrequester.h> + +#include "preferenceswidget.h" +#include "pwidget.h" + +AuxiliaryPreferencesWidget::AuxiliaryPreferencesWidget(QWidget *parent, const char* name) + : PrefWidget(parent,name) + , changed(false) +{ + QVBoxLayout *layout = new QVBoxLayout(this); + + prefWidget = new PWidget(this); + layout->addWidget(prefWidget); + + + connect(prefWidget->urlInput->lineEdit(),SIGNAL(textChanged(const QString&)) + , this, SLOT(setChanged())); +} + +AuxiliaryPreferencesWidget::~AuxiliaryPreferencesWidget() +{ +} + + +void AuxiliaryPreferencesWidget::apply() +{ + emit applySettings(); +} + +void AuxiliaryPreferencesWidget::cancel() +{ + emit restoreSettings(); +} + +void AuxiliaryPreferencesWidget::standard() +{ + prefWidget->urlInput->setURL("@PACKAGE@.po"); + changed=true; +} + +void AuxiliaryPreferencesWidget::setURL(const QString url) +{ + prefWidget->urlInput->setURL(url); + changed=false; +} + +QString AuxiliaryPreferencesWidget::url() +{ + changed = false; + return prefWidget->urlInput->url(); +} + +bool AuxiliaryPreferencesWidget::ignoreFuzzy() +{ + changed=false; + return prefWidget->fuzzyBtn->isChecked(); +} + +void AuxiliaryPreferencesWidget::setIgnoreFuzzy(bool flag) +{ + prefWidget->fuzzyBtn->setChecked(flag); +} + +bool AuxiliaryPreferencesWidget::settingsChanged() const +{ + return changed; +} + +void AuxiliaryPreferencesWidget::setChanged() +{ + changed=true; +} + + +#include "preferenceswidget.moc" diff --git a/kbabel/kbabeldict/modules/poauxiliary/preferenceswidget.h b/kbabel/kbabeldict/modules/poauxiliary/preferenceswidget.h new file mode 100644 index 00000000..45488158 --- /dev/null +++ b/kbabel/kbabeldict/modules/poauxiliary/preferenceswidget.h @@ -0,0 +1,77 @@ +/* **************************************************************************** + This file is part of KBabel + + Copyright (C) 2000 by Matthias Kiefer + <matthias.kiefer@gmx.de> + + 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. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + + In addition, as a special exception, the copyright holders give + permission to link the code of this program with any edition of + the Qt library by Trolltech AS, Norway (or with modified versions + of Qt that use the same license as Qt), and distribute linked + combinations including the two. You must obey the GNU General + Public License in all respects for all of the code used other than + Qt. If you modify this file, you may extend this exception to + your version of the file, but you are not obligated to do so. If + you do not wish to do so, delete this exception statement from + your version. + +**************************************************************************** */ + + +#ifndef PREFERENCESWIDGET_H +#define PREFERENCESWIDGET_H + +#include "searchengine.h" + +class PWidget; + +class AuxiliaryPreferencesWidget : public PrefWidget +{ + Q_OBJECT + +public: + AuxiliaryPreferencesWidget(QWidget *parent=0, const char* name=0); + virtual ~AuxiliaryPreferencesWidget(); + + virtual void apply(); + virtual void cancel(); + virtual void standard(); + + void setURL(const QString url); + QString url(); + + void setIgnoreFuzzy(bool); + bool ignoreFuzzy(); + + bool settingsChanged() const; + +signals: + void restoreSettings(); + void applySettings(); + +public: + PWidget *prefWidget; + +protected slots: + void setChanged(); + +private: + bool changed; + +}; + +#endif diff --git a/kbabel/kbabeldict/modules/poauxiliary/pwidget.ui b/kbabel/kbabeldict/modules/poauxiliary/pwidget.ui new file mode 100644 index 00000000..8179caed --- /dev/null +++ b/kbabel/kbabeldict/modules/poauxiliary/pwidget.ui @@ -0,0 +1,133 @@ +<!DOCTYPE UI><UI> +<class>PWidget</class> +<widget> + <class>QWidget</class> + <property stdset="1"> + <name>name</name> + <cstring>PWidget</cstring> + </property> + <property stdset="1"> + <name>geometry</name> + <rect> + <x>0</x> + <y>0</y> + <width>335</width> + <height>306</height> + </rect> + </property> + <property stdset="1"> + <name>caption</name> + <string></string> + </property> + <vbox> + <property stdset="1"> + <name>margin</name> + <number>11</number> + </property> + <property stdset="1"> + <name>spacing</name> + <number>6</number> + </property> + <widget> + <class>QLabel</class> + <property stdset="1"> + <name>name</name> + <cstring>TextLabel1</cstring> + </property> + <property stdset="1"> + <name>text</name> + <string>&Path to auxiliary file:</string> + </property> + <property> + <name>buddy</name> + <cstring>urlInput</cstring> + </property> + </widget> + <widget> + <class>KURLRequester</class> + <property stdset="1"> + <name>name</name> + <cstring>urlInput</cstring> + </property> + </widget> + <widget> + <class>QCheckBox</class> + <property stdset="1"> + <name>name</name> + <cstring>fuzzyBtn</cstring> + </property> + <property stdset="1"> + <name>text</name> + <string>&Ignore fuzzy entries</string> + </property> + </widget> + <widget> + <class>QLabel</class> + <property stdset="1"> + <name>name</name> + <cstring>TextLabel1_2</cstring> + </property> + <property stdset="1"> + <name>text</name> + <string><qt><p> +The following variables will be replaced in the path if available: +<ul> +<li><b>@PACKAGE@</b>: the name of the currently translated application or package</li> +<li><b>@LANG@</b>: the language code</li> +<li><b>@DIR<em>n</em>@</b>: where n is a positive integer. This expands to the nth folder counted from the filename</li> +</ul></p></qt></string> + </property> + </widget> + <spacer> + <property> + <name>name</name> + <cstring>Spacer1</cstring> + </property> + <property stdset="1"> + <name>orientation</name> + <enum>Vertical</enum> + </property> + <property stdset="1"> + <name>sizeType</name> + <enum>Expanding</enum> + </property> + <property> + <name>sizeHint</name> + <size> + <width>20</width> + <height>20</height> + </size> + </property> + <property> + <name>sizeHint</name> + <size> + <width>20</width> + <height>20</height> + </size> + </property> + </spacer> + </vbox> +</widget> +<customwidgets> + <customwidget> + <class>KURLRequester</class> + <header location="global">kurlrequester.h</header> + <sizehint> + <width>-1</width> + <height>-1</height> + </sizehint> + <container>0</container> + <sizepolicy> + <hordata>5</hordata> + <verdata>5</verdata> + </sizepolicy> + <pixmap>image0</pixmap> + </customwidget> +</customwidgets> +<images> + <image> + <name>image0</name> + <data format="XPM.GZ" length="646">789c6dd2c10ac2300c00d07bbf2234b7229d1be245fc04c5a3201e4615f430059d0711ff5ddb2e6bb236ec90eed134cb5a19d8ef36602af5ecdbfeeac05dda0798d3abebde87e3faa374d3807fa0d633a52d38d8de6f679fe33fc776e196f53cd010188256a3600a292882096246517815ca99884606e18044a3a40d91824820924265a7923a2e8bcd05f33db1173e002913175f2a6be6d3294871a2d95fa00e8a94ee017b69d339d90df1e77c57ea072ede6758</data> + </image> +</images> +</UI> |