Back to index

scribus-ng  1.3.4.dfsg+svn20071115
Public Member Functions | Static Public Member Functions | Public Attributes | Private Member Functions | Static Private Member Functions | Private Attributes
SWConfig Class Reference

This is the Scribus Short Words configuratin specification. More...

#include <configuration.h>

List of all members.

Public Member Functions

 SWConfig ()
 Reads config from the ui cfg file.
 ~SWConfig ()
 Writes config into the ui cfg file.
QStringList getShortWords (QString lang)
 Returns all options for specified language.
void saveConfig ()
 Save cfg.

Static Public Member Functions

static QString getAvailableLanguages ()
 available configs for UI about.
static QString getLangCodeFromHyph (QString hyphenCode)
 get lang code (en, cs, pl) from Scribus hyphenator configuration structure.

Public Attributes

uint action
 Id of the UI radiobutton.

Private Member Functions

QStringList getShortWordsFromFile (QString lang, QString filename)
 getShortWords use this one.

Static Private Member Functions

static QString getAvailableLanguagesFromFile (QString filename)
 getAvailableLanguages use this one.
static QString getLangFromCode (QString code)
 returns full lang name by lang code (en -> English)

Private Attributes

PrefsContext * prefs
 Configuration structure.

Detailed Description

This is the Scribus Short Words configuratin specification.

Methods of this class read config files and PrefsManager context informations. Preferences GUI is in SWPrefsGui.

This code is based on the Scribus-Vlna plug in rewritten for international use.

Author:
Petr Vanek petr@.nosp@m.yarp.nosp@m.en.cz with contributors.

Definition at line 25 of file configuration.h.


Constructor & Destructor Documentation

Reads config from the ui cfg file.

Definition at line 35 of file configuration.cpp.

{
       prefs = PrefsManager::instance()->prefsFile->getPluginContext("short-words");
       action = prefs->getUInt("action", 0);
       //userConfig = prefs->getUInt("userConfig", 0);
       //editor = prefs->get("editor", "");
}
SWConfig::~SWConfig ( ) [inline]

Writes config into the ui cfg file.

Definition at line 33 of file configuration.h.

{};

Member Function Documentation

QString SWConfig::getAvailableLanguages ( ) [static]

available configs for UI about.

Return values:
QStringwith languages in the configuration.

Definition at line 131 of file configuration.cpp.

{
       QString allConfig = getAvailableLanguagesFromFile(RC_PATH);
       if (QFile::exists(RC_PATH_USR))
              allConfig += "<br>" + getAvailableLanguagesFromFile(RC_PATH_USR) + "";
       return  allConfig;
}

Here is the call graph for this function:

QString SWConfig::getAvailableLanguagesFromFile ( QString  filename) [static, private]

getAvailableLanguages use this one.

available config in the specified file for UI about

Parameters:
filenameconfig file
Return values:
QStringall supported languages in one string

Definition at line 99 of file configuration.cpp.

{
       QStringList langs;
       QStringList nations;
       QString aRow;

       QFile f(filename);
       if (f.open(IO_ReadOnly))
       {
              QTextStream t(&f);
              while (!t.eof())
              {
                     aRow = t.readLine();
                     if (aRow.left(1) != "#" && aRow.length() != 0 && aRow.left(1) != " " && !langs.contains(aRow.left(2)))
                     {
                            nations.append(getLangFromCode(aRow.left(2)));
                            langs.append(aRow.left(2));
                     }
              }
              f.close();
       }
       else
       {
              return QString();
       }
       if (filename == RC_PATH_USR)
              return QObject::tr("Custom (optional) configuration: ", "short words plugin") + " " + nations.join(", ");
       if (filename == RC_PATH)
              return QObject::tr("Standard configuration: ", "short words plugin") + " " + nations.join(", ");
       return nations.join(", "); // save return only
}

Here is the call graph for this function:

Here is the caller graph for this function:

QString SWConfig::getLangCodeFromHyph ( QString  hyphenCode) [static]

get lang code (en, cs, pl) from Scribus hyphenator configuration structure.

Parameters:
hyphenCodecode of the language.
Return values:
QStringfull named language.

Definition at line 139 of file configuration.cpp.

{
       hyphenCode.remove(0, 5);
       return hyphenCode.remove(2, 10);
}

Here is the caller graph for this function:

QString SWConfig::getLangFromCode ( QString  code) [static, private]

returns full lang name by lang code (en -> English)

Parameters:
codelanguage code
Return values:
QStringfull named language

Definition at line 145 of file configuration.cpp.

{
       QMap<QString,QString>::Iterator it;
       QString lang;
       LanguageManager langmgr;
       langmgr.init(false);
       return langmgr.getLangFromAbbrev(code, true);
}

Here is the caller graph for this function:

QStringList SWConfig::getShortWords ( QString  lang)

Returns all options for specified language.

Parameters:
langlanguage of the ext frame

Definition at line 86 of file configuration.cpp.

{
       //QStringList allShorts;
       if (QFile::exists(RC_PATH_USR))
              return getShortWordsFromFile(lang, RC_PATH_USR);
       return getShortWordsFromFile(lang, RC_PATH);
       /*if (userConfig && QFile::exists(RC_PATH_USR))
              return getShortWordsFromFile(lang, RC_PATH_USR);
       if (!userConfig && QFile::exists(RC_PATH_USR))
              allShorts = getShortWordsFromFile(lang, RC_PATH_USR);
       return allShorts + getShortWordsFromFile(lang, RC_PATH);*/
}

Here is the call graph for this function:

Here is the caller graph for this function:

QStringList SWConfig::getShortWordsFromFile ( QString  lang,
QString  filename 
) [private]

getShortWords use this one.

for each case from GUI select the right config file (or both).

Parameters:
langlanguage
filenameconfiguration file.
Return values:
QStringListparsed SW. Each SW in one string item.

Definition at line 50 of file configuration.cpp.

{
       // all shorts for one language
       QString shorts = "";
       // one line in cfg. file
       QString aRow;
       // cfg (doesn't) exists for the selected language indicator
       bool success = false;
       // path to the cfg. file
       QFile f;

       f.setName(filename);
       if (!f.exists())
       {
              qDebug("Short Words config file not found");
              return QStringList();
       }
       if (f.open(IO_ReadOnly))
       {
              QTextStream t(&f);
              while (!t.eof())
              {
                     aRow = t.readLine();
                     if (aRow.left(2) == lang)
                     {
                            success = true;
                            shorts += aRow.remove(0, 3);
                     }
              }
              f.close();
       }
       if (success)
              return QStringList::split(",", shorts);
       return QStringList();
}

Here is the caller graph for this function:

Save cfg.

Definition at line 43 of file configuration.cpp.

{
       prefs->set("action", action);
       //prefs->set("userConfig", userConfig);
       //prefs->set("editor", editor);
}

Here is the caller graph for this function:


Member Data Documentation

Id of the UI radiobutton.

Definition at line 33 of file configuration.h.

PrefsContext* SWConfig::prefs [private]

Configuration structure.

Definition at line 55 of file configuration.h.


The documentation for this class was generated from the following files: