* Option Compile-Time pour definir le chemin du dossier des fichiers de traduction : QET_LANG_PATH

* Option Compile-Time pour definir le chemin du dossier des elements communs : QET_COMMON_COLLECTION_PATH
  * Option Run-Time pour definir le chemin de la collection principale : --common-elements-dir=/path/to/elements/
  * Option Compile-Time pour autoriser ou non l'utilisation de l'option Run-Time precedente : QET_ALLOW_OVERRIDE_CED_OPTION
Les options Compile-Time sont a definir dans le fichier .pro


git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/trunk@158 bfdf4180-ca20-0410-9c96-a3a8aa849046
This commit is contained in:
xavierqet
2007-10-04 20:34:29 +00:00
parent 0dfed41a75
commit 7b71cbb7ae
3 changed files with 60 additions and 11 deletions

View File

@@ -2,6 +2,8 @@
#include "qetdiagrameditor.h"
#include "qetelementeditor.h"
QString QETApp::common_elements_dir = QString();
/**
Constructeur
@param argc Nombre d'arguments passes a l'application
@@ -58,6 +60,17 @@ QETApp::QETApp(int &argc, char **argv) : QApplication(argc, argv) {
connect(this, SIGNAL(lastWindowClosed()), this, SLOT(checkRemainingWindows()));
}
// parse les arguments
foreach(QString argument, arguments()) {
#ifdef QET_ALLOW_OVERRIDE_CED_OPTION
QString ced_arg("--common-elements-dir=");
if (argument.startsWith(ced_arg)) {
QString ced_value = argument.right(argument.length() - ced_arg.length());
overrideCommonElementsDir(ced_value);
}
#endif
}
// Creation et affichage d'un editeur de schema
QStringList files;
foreach(QString argument, arguments()) {
@@ -165,7 +178,14 @@ void QETApp::newElementEditor() {
@return Le chemin du dossier des elements communs
*/
QString QETApp::commonElementsDir() {
#ifdef QET_ALLOW_OVERRIDE_CED_OPTION
if (common_elements_dir != QString()) return(common_elements_dir);
#endif
#ifdef QET_COMMON_COLLECTION_PATH
return(QET_COMMON_COLLECTION_PATH);
#else
return(QDir::current().path() + "/elements/");
#endif
}
/**
@@ -201,7 +221,7 @@ QString QETApp::configDir() {
@return Une chaine de caracteres vide en cas d'erreur ou le chemin absolu du
fichier *.elmt.
*/
QString QETApp::realPath(QString &sym_path) {
QString QETApp::realPath(const QString &sym_path) {
QString directory;
if (sym_path.startsWith("common://")) {
directory = commonElementsDir();
@@ -218,7 +238,7 @@ QString QETApp::realPath(QString &sym_path) {
@return Une chaine de caracteres vide en cas d'erreur ou le chemin
symbolique designant l'element.
*/
QString QETApp::symbolicPath(QString &real_path) {
QString QETApp::symbolicPath(const QString &real_path) {
// recupere les dossier common et custom
QString commond = commonElementsDir();
QString customd = customElementsDir();
@@ -232,11 +252,28 @@ QString QETApp::symbolicPath(QString &real_path) {
return(chemin);
}
#ifdef QET_ALLOW_OVERRIDE_CED_OPTION
/**
Redefinit le chemin du dossier des elements communs.
*/
void QETApp::overrideCommonElementsDir(const QString &new_ced) {
QFileInfo new_ced_info(new_ced);
if (new_ced_info.isDir()) {
common_elements_dir = new_ced_info.absoluteFilePath();
if (!common_elements_dir.endsWith("/")) common_elements_dir += "/";
}
}
#endif
/**
@return Le chemin du dossier contenant les fichiers de langue
*/
QString QETApp::languagesPath() {
#ifndef QET_LANG_PATH
return(QDir::current().path() + "/lang/");
#else
return(QET_LANG_PATH);
#endif
}
/**