Back to index

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

#include <nftsettings.h>

Collaboration diagram for nftsettings:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 nftsettings (QString guilang, QString templateDir)
 ~nftsettings ()

Public Attributes

std::vector< nfttemplate * > templates

Private Member Functions

void read ()
void addTemplates (QString dir)
QString findTemplateXml (QString dir)

Private Attributes

QString scribusShare
QString scribusUserHome
QString userTemplateDir
QString nftHomeDir
QString lang
nftrcreaderhandler
QXmlSimpleReader * reader

Detailed Description

Definition at line 22 of file nftsettings.h.


Constructor & Destructor Documentation

nftsettings::nftsettings ( QString  guilang,
QString  templateDir 
)

Definition at line 13 of file nftsettings.cpp.

{
       lang = guilang;
       scribusShare = ScPaths::instance().templateDir();
       scribusUserHome = QDir::convertSeparators(ScPaths::getApplicationDataDir());
       userTemplateDir = templateDir;
       if (userTemplateDir.right(1) == "/")
              userTemplateDir = userTemplateDir.left(userTemplateDir.length() - 1);
       read();
}

Here is the call graph for this function:

Definition at line 92 of file nftsettings.cpp.

{
       delete reader;
       delete handler;
       for (uint i = 0; i < templates.size(); ++i)
       {
              if (templates[i] != NULL)
                     delete templates[i];
       }
}

Member Function Documentation

void nftsettings::addTemplates ( QString  dir) [private]

Definition at line 36 of file nftsettings.cpp.

{
       // Add templates from the dir itself
       QString tmplFile = findTemplateXml(dir);
       QFile* tmplxml = new QFile(QDir::convertSeparators(tmplFile));
       handler->setSourceDir(dir);
       handler->setSourceFile(tmplFile);
       if (tmplxml->exists())
       {
              QXmlInputSource* source = new QXmlInputSource(tmplxml);
              reader->parse(source);
              delete source;
       }
       delete tmplxml;
       
       
       // And from all the subdirectories. template.xml file is only searched one dir level deeper than the dir
       QDir tmpldir(dir);
       if (tmpldir.exists())
       {
              tmpldir.setFilter(QDir::Dirs);
              QStringList dirs = tmpldir.entryList();
              for (uint i = 0; i < dirs.size(); ++i)
              {
                     if ((dirs[i] != ".") && (dirs[i] != "..")) {
                            tmplFile = findTemplateXml(dir + "/" + dirs[i]);
                            QFile* tmplxml = new QFile(QDir::convertSeparators(tmplFile));
                            handler->setSourceDir(dir+"/"+dirs[i]);
                            handler->setSourceFile(tmplFile);
                            if (tmplxml->exists())
                            {
                                   QXmlInputSource* source = new QXmlInputSource(tmplxml);
                                   reader->parse(source);
                                   delete source;
                            }
                            delete tmplxml;
                     }
              }
       }
}

Here is the call graph for this function:

Here is the caller graph for this function:

QString nftsettings::findTemplateXml ( QString  dir) [private]

Definition at line 77 of file nftsettings.cpp.

{
       QString tmp = dir + "/template." + lang + ".xml";
       if (QFile(tmp).exists())
              return tmp;

       if (lang.length() > 2)
       {
              tmp = dir + "/template." + lang.left(2) + ".xml";
              if (QFile(tmp).exists())
                     return tmp;
       }
       return dir + "/template.xml";      
}

Here is the caller graph for this function:

void nftsettings::read ( ) [private]

Definition at line 24 of file nftsettings.cpp.

{
       handler = new nftrcreader(&templates,scribusUserHome);
       reader = new QXmlSimpleReader();
       reader->setContentHandler(handler);

       addTemplates(scribusShare);
       addTemplates(scribusUserHome+"/templates");
       if ((!userTemplateDir.isNull()) && (!userTemplateDir.isEmpty()))
              addTemplates(userTemplateDir);
}

Here is the call graph for this function:

Here is the caller graph for this function:


Member Data Documentation

Definition at line 29 of file nftsettings.h.

QString nftsettings::lang [private]

Definition at line 28 of file nftsettings.h.

QString nftsettings::nftHomeDir [private]

Definition at line 27 of file nftsettings.h.

QXmlSimpleReader* nftsettings::reader [private]

Definition at line 30 of file nftsettings.h.

QString nftsettings::scribusShare [private]

Definition at line 24 of file nftsettings.h.

QString nftsettings::scribusUserHome [private]

Definition at line 25 of file nftsettings.h.

Definition at line 35 of file nftsettings.h.

QString nftsettings::userTemplateDir [private]

Definition at line 26 of file nftsettings.h.


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