-rw-r--r-- | library/global.cpp | 55 |
1 files changed, 49 insertions, 6 deletions
diff --git a/library/global.cpp b/library/global.cpp index fd7579a..dd15eb7 100644 --- a/library/global.cpp +++ b/library/global.cpp @@ -8,24 +8,25 @@ ** Foundation and appearing in the file LICENSE.GPL included in the ** packaging of this file. ** ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. ** ** See http://www.trolltech.com/gpl/ for GPL licensing information. ** ** Contact info@trolltech.com if any conditions of this licensing are ** not clear to you. ** **********************************************************************/ +#define QTOPIA_INTERNAL_LANGLIST #include <qpe/qpedebug.h> #include <qpe/global.h> #include <qpe/qdawg.h> #include <qpe/qpeapplication.h> #include <qpe/resource.h> #include <qpe/storage.h> #include <qpe/applnk.h> #if defined(Q_WS_QWS) && !defined(QT_NO_COP) #include "qpe/qcopenvelope_qws.h" #endif #include <qfile.h> @@ -161,30 +162,36 @@ Global::Global() words for the current locale. \sa addedDawg() */ const QDawg& Global::fixedDawg() { if ( !fixed_dawg ) { if ( !docDirCreated ) createDocDir(); fixed_dawg = new QDawg; QString dawgfilename = dictDir() + "/dawg"; - QString lang = getenv( "LANG" ); - QString dawgfilename_lang = dawgfilename + "." + lang; - QString words_lang = dictDir() + "/words." + lang; - if ( QFile::exists(dawgfilename_lang) || - QFile::exists(words_lang) ) - dawgfilename = dawgfilename_lang; + QString words_lang; + QStringList langs = Global::languageList(); + for (QStringList::ConstIterator it = langs.begin(); it!=langs.end(); ++it) { + QString lang = *it; + words_lang = dictDir() + "/words." + lang; + QString dawgfilename_lang = dawgfilename + "." + lang; + if ( QFile::exists(dawgfilename_lang) || + QFile::exists(words_lang) ) { + dawgfilename = dawgfilename_lang; + break; + } + } QFile dawgfile(dawgfilename); if ( !dawgfile.exists() ) { QString fn = dictDir() + "/words"; if ( QFile::exists(words_lang) ) fn = words_lang; QFile in(fn); if ( in.open(IO_ReadOnly) ) { fixed_dawg->createFromWords(&in); dawgfile.open(IO_WriteOnly); fixed_dawg->write(&dawgfile); dawgfile.close(); @@ -630,15 +637,51 @@ void Global::findDocuments(DocLnkSet* folder, const QString &mimefilter) StorageInfo storage; const QList<FileSystem> &fs = storage.fileSystems(); QListIterator<FileSystem> it ( fs ); for ( ; it.current(); ++it ) { if ( (*it)->isRemovable() ) { QString path = (*it)->path(); DocLnkSet ide( path, mimefilter ); folder->appendFrom(ide); } } } +QStringList Global::languageList() +{ + QString lang = getenv("LANG"); + QStringList langs; + langs.append(lang); + int i = lang.find("."); + if ( i > 0 ) + lang = lang.left( i ); + i = lang.find( "_" ); + if ( i > 0 ) + langs.append(lang.left(i)); + return langs; +} + +QStringList Global::helpPath() +{ + QStringList path; + QStringList langs = Global::languageList(); + for (QStringList::ConstIterator it = langs.fromLast(); it!=langs.end(); --it) { + QString lang = *it; + if ( !lang.isEmpty() ) + path += QPEApplication::qpeDir() + "/help/" + lang + "/html"; + } + path += QPEApplication::qpeDir() + "/pics"; + path += QPEApplication::qpeDir() + "/help/en/html"; + path += QPEApplication::qpeDir() + "/docs"; + QString dir = QDir::current().canonicalPath(); + if ( dir == "/" ) + dir += "/docs"; + else { + path += dir + "/../pics"; + dir += "/../docs"; + path += dir; + } + return path; +} #include "global.moc" |