• Skip to content
  • Skip to link menu
KDE 4.0 API Reference
  • KDE API Reference
  • kdeedu
  • Sitemap
  • Contact Us
 

klettres

langutils.cpp

Go to the documentation of this file.
00001 /*
00002     Copyright 2007 Pino Toscano <pino@kde.org>
00003     Copyright 2007 Anne-Marie Mahfouf <annma@kde.org>
00004 
00005     This program is free software; you can redistribute it and/or
00006     modify it under the terms of the GNU General Public
00007     License as published by the Free Software Foundation; either
00008     version 2 of the License, or (at your option) any later version.
00009 
00010     This program is distributed in the hope that it will be useful,
00011     but WITHOUT ANY WARRANTY; without even the implied warranty of
00012     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013     GNU General Public License for more details.
00014 
00015     You should have received a copy of the GNU General Public License
00016     along with this program; if not, write to the Free Software
00017     Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
00018  */
00019 
00020 //project headers
00021 #include "langutils.h"
00022 #include "prefs.h"
00023 
00024 #include <QDir>
00025 
00026 #include <KDebug>
00027 #include <KGlobal>
00028 #include <KStandardDirs>
00029 
00030 bool LangUtils::hasSpecialChars(const QString& lang)
00031 {
00032     if (lang== "cs"
00033         || lang== "da"
00034         || lang== "sk"
00035         || lang== "es"
00036         || lang== "de"
00037         || lang== "nds")
00038         return true;
00039     return false;
00040 }
00041 
00042 QStringList LangUtils::getLanguages()
00043 {
00044     QStringList m_languages;
00045     m_languages.clear();
00046     //the program scans in klettres/data/ to see what languages data is found
00047     QStringList mdirs = KGlobal::dirs()->findDirs("data", "klettres/");
00048     //if (mdirs.isEmpty()) return NULL;
00049     for (QStringList::Iterator it =mdirs.begin(); it !=mdirs.end(); ++it ) {
00050         QDir dir(*it);
00051         m_languages += dir.entryList(QDir::Dirs, QDir::Name);
00052         m_languages.removeAll(".");
00053         m_languages.removeAll("..");
00054     }
00055     m_languages.removeAll("pics");
00056     m_languages.removeAll("data");
00057     m_languages.removeAll("icons");
00058     m_languages.sort();
00059     
00060     //Prefs::setLanguages(m_languages);
00061     //Prefs::self()->writeConfig();
00062     //find duplicated entries in KDEDIR and KDEHOME
00063     QStringList temp_languages;
00064     for (int i=0;  i<m_languages.count(); i++)  {
00065         if (m_languages.count(m_languages[i])>1)  {
00066             temp_languages.append(m_languages[i]);
00067             m_languages.removeAll(m_languages[i]);
00068         }
00069         for (int i=0;  i<temp_languages.count(); i++)  {
00070             if (i%2==0)
00071             m_languages.append(temp_languages[i]);//append 1 of the 2 instances found
00072         }
00073         temp_languages.clear();
00074     }
00075     //TODO TEST in FRENCH
00076     m_languages.sort();
00077     kDebug() <<m_languages;
00078     return m_languages;
00079 }
00080 
00081 void LangUtils::writeLangConfig()
00082 {
00083     //write the present languages in config so they cannot be downloaded
00084     KConfigGroup config(KGlobal::config(), "KNewStuffStatus");
00085     QStringList m_languages = getLanguages();
00086     for (int i=0;  i<m_languages.count(); i++)  {
00087         QString tmp = m_languages[i];
00088         if (!config.readEntry(tmp, QString()).isEmpty())
00089             config.writeEntry(tmp, QDate::currentDate().toString());
00090     }
00091     config.sync();
00092 }
00093 
00094 

klettres

Skip menu "klettres"
  • Main Page
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Class Members

kdeedu

Skip menu "kdeedu"
  • kalzium
  • kanagram
  • kig
  • klettres
  • kstars
  • libkdeedu
  •   keduvocdocument
  •   docs
  •   src
  • parley
Generated for kdeedu by doxygen 1.5.4
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal