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/datatools/accelerators | |
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/datatools/accelerators')
-rw-r--r-- | kbabel/datatools/accelerators/Makefile.am | 19 | ||||
-rw-r--r-- | kbabel/datatools/accelerators/kbabel_accelstool.desktop | 105 | ||||
-rw-r--r-- | kbabel/datatools/accelerators/main.cc | 137 | ||||
-rw-r--r-- | kbabel/datatools/accelerators/main.h | 56 |
4 files changed, 317 insertions, 0 deletions
diff --git a/kbabel/datatools/accelerators/Makefile.am b/kbabel/datatools/accelerators/Makefile.am new file mode 100644 index 00000000..f204e78a --- /dev/null +++ b/kbabel/datatools/accelerators/Makefile.am @@ -0,0 +1,19 @@ + +INCLUDES = -I$(srcdir)/../../common -I../../common $(all_includes) +kbabel_accelstool_la_LIBADD = $(LIB_KIO) ../../common/libkbabelcommon.la + +####### Files + +kde_module_LTLIBRARIES = kbabel_accelstool.la + +kbabel_accelstool_la_SOURCES = main.cc + +kbabel_accelstool_la_LDFLAGS = $(all_libraries) -avoid-version -module -no-undefined + +noinst_HEADERS = main.h + +kbabel_accelstool_la_METASOURCES = AUTO + +service_DATA = kbabel_accelstool.desktop +servicedir = $(kde_servicesdir) + diff --git a/kbabel/datatools/accelerators/kbabel_accelstool.desktop b/kbabel/datatools/accelerators/kbabel_accelstool.desktop new file mode 100644 index 00000000..ffe5bb15 --- /dev/null +++ b/kbabel/datatools/accelerators/kbabel_accelstool.desktop @@ -0,0 +1,105 @@ +[Desktop Entry] +Name=Accelerator Validation for KBabel +Name[bg]=Валидност на ускорител - KBabel +Name[bs]=Provjera akceleratora za KBabel +Name[ca]=Validació dels acceleradors per a KBabel +Name[cs]=Validace akcelerátorů pro KBabel +Name[cy]=Dilysiad Cyflymydd i KBabel +Name[da]=Accelerator-validering for KBabel +Name[de]=Kurzbefehl-Überprüfung für KBabel +Name[el]=Έλεγχος εγκυρότητας πλήκτρων επιτάχυνσης για το KBabel +Name[es]=Validación de accesos rápidos para KBabel +Name[et]=KBabeli kiirklahvide kontrollija +Name[eu]=Bizkortzaile balidazioa KBabel-entzat +Name[fa]=اعتبارسنجی شتابده برای KBabel +Name[fi]=Pikavalintojen tarkistus KBabelissa +Name[fr]=Validation des accélérateurs clavier pour KBabel +Name[ga]=Bailíochtú na nAicearraí le haghaidh KBabel +Name[gl]=Validación de Aceleradores para KBabel +Name[hi]=के-बेबल के लिए त्वरक वेलिडेशन +Name[hu]=Gyorsbillentyű-ellenőrző a KBabelhez +Name[is]=Flýtilyklastaðfestir fyrir KBabel +Name[it]=Convalida dei tasti acceleratori per KBabel +Name[ja]=KBabel アクセラレータ検証 +Name[ka]=KBabel-ის აქსელერატორი დამმოწმებელი +Name[kk]=KBabel-дің акселераторларды тексеруі +Name[lt]= KBabel prieigos klavišų žymių patikros įrankis +Name[ms]=Pengesahan Kekunci Pintas untuk KBabel +Name[nb]=Sjekk av snarveistaster i KBabel +Name[nds]=Tastkombinatschoonprööv för KBabel +Name[ne]=केब्याबलका लागि गतिबर्धक प्रमाणीकरण +Name[nl]=Sneltoetsvalidatie voor KBabel +Name[nn]=Sjekk av snarvegstastar i KBabel +Name[pa]=ਕਬਬੇਲ ਲਈ ਪਰਵੇਸ਼ਕ ਪਰਮਾਣਕ +Name[pl]=Sprawdzanie klawiszy skrótu w KBabel +Name[pt]=Validação de Aceleradores para o KBabel +Name[pt_BR]=Validação de Acelerador para o KBabel +Name[ru]=Проверка акселераторов для KBabel +Name[sk]=Kontrola akcelerátorov pre KBabel +Name[sl]=Pospeševalni potrjevalnik za KBabel +Name[sr]=Овера тастера за брзи приступ за KBabel +Name[sr@Latn]=Overa tastera za brzi pristup za KBabel +Name[sv]=Validering av snabbtangenter för Kbabel +Name[ta]= Kபாபேலுக்கு தருமதிப்பு செல்லுபடிச் சோதனை +Name[tg]=Тафтиши акселаторҳо барои KBabel +Name[tr]=KBabel için Hızlandırma Onayı +Name[uk]=Перевірка акселератора для KBabel +Name[zh_CN]=KBabel 的快捷键检查器 +Name[zh_TW]=KBabel 的快速鍵檢查器 +ValidationString=accelerator +X-KDE-Library=kbabel_accelstool +Type=Service +Commands=validate +Comment=Check Accelerators +Comment[bg]=Проверка на ускорителите +Comment[bs]=Provjeri akceleratore +Comment[ca]=Comprova els acceleradors +Comment[cs]=Zkontrolovat akcelerátory +Comment[cy]=Gwirio Cyflymyddion +Comment[da]=Tjek acceleratorer +Comment[de]=Kurzbefehle prüfen +Comment[el]=Έλεγχος πλήκτρων επιτάχυνσης +Comment[es]=Comprobar teclas rápidas +Comment[et]=Kiirklahvide kontroll +Comment[eu]=Egiaztatu bizkortzaileak +Comment[fa]=بررسی شتابدهها +Comment[fi]=Tarkista pikavalinnat +Comment[fr]=Vérification des accélérateurs clavier +Comment[ga]=Seiceáil Aicearraí +Comment[gl]=Verificación de Aceleradores +Comment[he]=בודק מזנקים +Comment[hi]=त्वरक जांच करें +Comment[hu]=A gyorsbillentyűk ellenőrzése +Comment[is]=Athuga flýtilykla +Comment[it]=Controlla tasti acceleratori +Comment[ja]=アクセラレータを検証 +Comment[ka]=აქსელერაციის შემოწმება +Comment[kk]=Акселераторларды тексеру +Comment[lt]=Patikrinti prieigos klavišų žymes +Comment[ms]=Periksa Kekunci Pintas +Comment[nb]=Sjekk snarveistastene +Comment[nds]=Tastkombinatschonen pröven +Comment[ne]=गतिबर्धक जाँच गर्नुहोस् +Comment[nl]=Sneltoetsen controleren +Comment[nn]=Sjekk snarvegstastar +Comment[pa]=ਪਰਵੇਸ਼ਕ ਜਾਂਚ +Comment[pl]=Sprawdzenie klawiszy skrótu +Comment[pt]=Verificação de Aceleradores +Comment[pt_BR]=Verifica Aceleradores +Comment[ru]=Проверка акселераторов +Comment[sk]=Kontrola akcelerátorov +Comment[sl]=Preveri pospeševalnike +Comment[sr]=Провери тастере за брзи приступ +Comment[sr@Latn]=Proveri tastere za brzi pristup +Comment[sv]=Kontrollera snabbtangenter +Comment[ta]=தருமதிப்பு சரிபார்ப்பு +Comment[tg]=Тафтиши акселаторҳо +Comment[tr]=Hızlandırıcıları Denetle +Comment[uk]=Перевірити акселератори +Comment[zh_CN]=检查快捷键 +Comment[zh_TW]=檢查快速鍵 +Shortcuts=Ctrl+H +ServiceTypes=KBabelValidator,KDataTool +DataType=CatalogItem +DataMimeTypes=application/x-kbabel-catalogitem +ReadOnly=true diff --git a/kbabel/datatools/accelerators/main.cc b/kbabel/datatools/accelerators/main.cc new file mode 100644 index 00000000..4d94354e --- /dev/null +++ b/kbabel/datatools/accelerators/main.cc @@ -0,0 +1,137 @@ +/* This file is part of KBabel + based Copyright (C) 1998, 1999 Torben Weis <weis@kde.org> + 2002 Stanislav Visnovsky <visnovsky@kde.org> + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library 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 + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; see the file COPYING.LIB. If not, write to + the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, 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 <resources.h> +#include "catalogitem.h" +#include "catalogsettings.h" +#include "main.h" + +#include <kconfig.h> +#include <kdebug.h> +#include <kgenericfactory.h> +#include <klibloader.h> +#include <klocale.h> + +/*************************************************** + * + * Factory + * + ***************************************************/ + +K_EXPORT_COMPONENT_FACTORY( kbabel_accelstool, KGenericFactory<AcceleratorTool> ( "kbabeldatatool" ) ) + +using namespace KBabel; + +AcceleratorTool::AcceleratorTool( QObject* parent, const char* name, const QStringList & ) + : KDataTool( parent, name ), _cache_origin( 0 ) +{ + // bogus translation just for allowing the translation + i18n("what check found errors","accelerator"); +} + +bool AcceleratorTool::run( const QString& command, void* data, const QString& datatype, const QString& mimetype ) +{ + if ( command != "validate" ) + { + kdDebug(KBABEL) << "Accelerator Tool does only accept the command 'validate'" << endl; + kdDebug(KBABEL) << " The commands " << command << " is not accepted" << endl; + return FALSE; + } + + // Check wether we can accept the data + if ( datatype != "CatalogItem" ) + { + kdDebug(KBABEL) << "Accelerator Tool only accepts datatype CatalogItem" << endl; + return FALSE; + } + + if ( mimetype != "application/x-kbabel-catalogitem" ) + { + kdDebug(KBABEL) << "Accelerator Tool only accepts mimetype application/x-kbabel-catalogitem" << endl; + return FALSE; + } + + if( command == "validate" ) + { + CatalogItem* item = (CatalogItem*)(data); + + if( _cache_origin != item->project() ) + { + _context = item->project()->miscSettings().contextInfo; + _marker = item->project()->miscSettings().accelMarker; + _cache_origin = item->project(); + } + + bool hasError = false; + + if(!item->isUntranslated()) + { + // FIXME: this should care about plural forms in msgid + QString lineid=item->msgid().first(); + lineid.replace( _context, ""); + lineid.replace(QRegExp("\\n"),""); + lineid.simplifyWhiteSpace(); + QString regStr(_marker); + regStr+="[^\\s]"; + QRegExp reg(regStr); + + QStringList str = item->msgstr(true); + for( QStringList::Iterator form = str.begin() ; form != str.end(); form++ ) + { + QString linestr=(*form); + linestr.simplifyWhiteSpace(); + + int n = lineid.contains(reg); + if( _marker == '&' ) + n = n - lineid.contains(QRegExp("(&[a-z,A-Z,\\-,0-9,#]*;)|(&&(?!&+))")); + int m = linestr.contains(reg); + if( _marker == '&' ) + m = m - linestr.contains(QRegExp("(&[a-z,A-Z,\\-,0-9,#]*;)|(&&(?!&+))")); + hasError = hasError || ( n<=1 && m != n); + } + } + + if(hasError) + { + item->appendError( "Accelerator" ); + } + else + { + item->removeError( "Accelerator" ); + } + + return !hasError; + } + return FALSE; +} + +#include "main.moc" diff --git a/kbabel/datatools/accelerators/main.h b/kbabel/datatools/accelerators/main.h new file mode 100644 index 00000000..559fe112 --- /dev/null +++ b/kbabel/datatools/accelerators/main.h @@ -0,0 +1,56 @@ +/* This file is part of KBabel + based on Copyright (C) 1998, 1999 Torben Weis <weis@kde.org> + 2002 Stanislav Visnovsky <visnovsky@kde.org> + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library 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 + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; see the file COPYING.LIB. If not, write to + the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, 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 __main_h__ +#define __main_h__ + +#include "kbproject.h" + +#include <kdatatool.h> + +#include <qregexp.h> + +class AcceleratorTool : public KDataTool +{ + Q_OBJECT + +public: + AcceleratorTool( QObject* parent, const char* name, const QStringList & ); + virtual bool run( const QString& command, void* data, const QString& datatype, const QString& mimetype); + +private: + QRegExp _context; + QChar _marker; + KBabel::Project::Ptr _cache_origin; +}; + +#endif |