diff options
Diffstat (limited to 'lib/kofficecore/KoTemplates.cpp')
-rw-r--r-- | lib/kofficecore/KoTemplates.cpp | 130 |
1 files changed, 65 insertions, 65 deletions
diff --git a/lib/kofficecore/KoTemplates.cpp b/lib/kofficecore/KoTemplates.cpp index 7fbf3a99..178c6271 100644 --- a/lib/kofficecore/KoTemplates.cpp +++ b/lib/kofficecore/KoTemplates.cpp @@ -19,9 +19,9 @@ #include <KoTemplates.h> -#include <qdir.h> -#include <qimage.h> -#include <qprinter.h> +#include <tqdir.h> +#include <tqimage.h> +#include <tqprinter.h> #include <kdesktopfile.h> #include <ksimpleconfig.h> @@ -37,31 +37,31 @@ #include <stdlib.h> -KoTemplate::KoTemplate(const QString &name, const QString &description, const QString &file, - const QString &picture, const QString &fileName, const QString &_measureSystem, +KoTemplate::KoTemplate(const TQString &name, const TQString &description, const TQString &file, + const TQString &picture, const TQString &fileName, const TQString &_measureSystem, bool hidden, bool touched) : m_name(name), m_descr(description), m_file(file), m_picture(picture), m_fileName(fileName), m_hidden(hidden), m_touched(touched), m_cached(false), m_measureSystem(_measureSystem) { } -const QPixmap &KoTemplate::loadPicture( KInstance* instance ) { +const TQPixmap &KoTemplate::loadPicture( KInstance* instance ) { if(m_cached) return m_pixmap; m_cached=true; if ( m_picture[ 0 ] == '/' ) { - // ### TODO: use the class KoPicture instead of QImage to support non-image pictures - QImage img( m_picture ); + // ### TODO: use the class KoPicture instead of TQImage to support non-image pictures + TQImage img( m_picture ); if (img.isNull()) { kdWarning() << "Couldn't find icon " << m_picture << endl; - m_pixmap=QPixmap(); + m_pixmap=TQPixmap(); return m_pixmap; } const int maxHeightWidth = 128; // ### TODO: some people would surely like to have 128x128 if (img.width() > maxHeightWidth || img.height() > maxHeightWidth) { - img = img.smoothScale( maxHeightWidth, maxHeightWidth, QImage::ScaleMax ); + img = img.smoothScale( maxHeightWidth, maxHeightWidth, TQ_ScaleMax ); } m_pixmap.convertFromImage(img); return m_pixmap; @@ -72,7 +72,7 @@ const QPixmap &KoTemplate::loadPicture( KInstance* instance ) { } -KoTemplateGroup::KoTemplateGroup(const QString &name, const QString &dir, +KoTemplateGroup::KoTemplateGroup(const TQString &name, const TQString &dir, int _sortingWeight, bool touched) : m_name(name), m_touched(touched), m_sortingWeight(_sortingWeight) { @@ -82,7 +82,7 @@ KoTemplateGroup::KoTemplateGroup(const QString &name, const QString &dir, bool KoTemplateGroup::isHidden() const { - QPtrListIterator<KoTemplate> it(m_templates); + TQPtrListIterator<KoTemplate> it(m_templates); bool hidden=true; while(it.current()!=0L && hidden) { hidden=it.current()->isHidden(); @@ -93,7 +93,7 @@ bool KoTemplateGroup::isHidden() const { void KoTemplateGroup::setHidden(bool hidden) const { - QPtrListIterator<KoTemplate> it(m_templates); + TQPtrListIterator<KoTemplate> it(m_templates); for( ; it.current()!=0L; ++it) it.current()->setHidden(hidden); m_touched=true; @@ -101,7 +101,7 @@ void KoTemplateGroup::setHidden(bool hidden) const { bool KoTemplateGroup::add(KoTemplate *t, bool force, bool touch) { - KoTemplate *myTemplate=find(t->name()); + KoTemplate *myTemplate=tqfind(t->name()); if(myTemplate==0L) { m_templates.append(t); m_touched=touch; @@ -109,9 +109,9 @@ bool KoTemplateGroup::add(KoTemplate *t, bool force, bool touch) { } else if(myTemplate && force) { //kdDebug() << "removing :" << myTemplate->fileName() << endl; - QFile::remove( myTemplate->fileName() ); - QFile::remove( myTemplate->picture() ); - QFile::remove( myTemplate->file() ); + TQFile::remove( myTemplate->fileName() ); + TQFile::remove( myTemplate->picture() ); + TQFile::remove( myTemplate->file() ); m_templates.removeRef(myTemplate); m_templates.append(t); m_touched=touch; @@ -120,16 +120,16 @@ bool KoTemplateGroup::add(KoTemplate *t, bool force, bool touch) { return false; } -KoTemplate *KoTemplateGroup::find(const QString &name) const { +KoTemplate *KoTemplateGroup::tqfind(const TQString &name) const { - QPtrListIterator<KoTemplate> it(m_templates); + TQPtrListIterator<KoTemplate> it(m_templates); while(it.current() && it.current()->name()!=name) ++it; return it.current(); } -KoTemplateTree::KoTemplateTree(const QCString &templateType, +KoTemplateTree::KoTemplateTree(const TQCString &templateType, KInstance *instance, bool readTree) : m_templateType(templateType), m_instance(instance), m_defaultGroup(0L), m_defaultTemplate(0L) { @@ -146,7 +146,7 @@ void KoTemplateTree::readTemplateTree() { } void KoTemplateTree::writeTemplateTree() { - QString localDir=m_instance->dirs()->saveLocation(m_templateType); + TQString localDir=m_instance->dirs()->saveLocation(m_templateType); for(KoTemplateGroup *group=m_groups.first(); group!=0L; group=m_groups.next()) { //kdDebug() << "---------------------------------" << endl; @@ -183,8 +183,8 @@ void KoTemplateTree::writeTemplateTree() { if(t->isHidden() && t->touched() ) { //kdDebug() << "+++ delete local template ##############" << endl; writeTemplate(t, group, localDir); - QFile::remove(t->file()); - QFile::remove(t->picture()); + TQFile::remove(t->file()); + TQFile::remove(t->picture()); } } } @@ -192,16 +192,16 @@ void KoTemplateTree::writeTemplateTree() { void KoTemplateTree::add(KoTemplateGroup *g) { - KoTemplateGroup *group=find(g->name()); + KoTemplateGroup *group=tqfind(g->name()); if(group==0L) m_groups.append(g); else group->addDir(g->dirs().first()); // "...there can be only one..." (Queen) } -KoTemplateGroup *KoTemplateTree::find(const QString &name) const { +KoTemplateGroup *KoTemplateTree::tqfind(const TQString &name) const { - QPtrListIterator<KoTemplateGroup> it(m_groups); + TQPtrListIterator<KoTemplateGroup> it(m_groups); while(it.current() && it.current()->name()!=name) ++it; return it.current(); @@ -209,21 +209,21 @@ KoTemplateGroup *KoTemplateTree::find(const QString &name) const { void KoTemplateTree::readGroups() { - QStringList dirs = m_instance->dirs()->resourceDirs(m_templateType); - for(QStringList::ConstIterator it=dirs.begin(); it!=dirs.end(); ++it) { + TQStringList dirs = m_instance->dirs()->resourceDirs(m_templateType); + for(TQStringList::ConstIterator it=dirs.begin(); it!=dirs.end(); ++it) { //kdDebug() << "dir: " << *it << endl; - QDir dir(*it); + TQDir dir(*it); // avoid the annoying warning if(!dir.exists()) continue; - dir.setFilter(QDir::Dirs); - QStringList templateDirs=dir.entryList(); - for(QStringList::ConstIterator tdirIt=templateDirs.begin(); tdirIt!=templateDirs.end(); ++tdirIt) { + dir.setFilter(TQDir::Dirs); + TQStringList templateDirs=dir.entryList(); + for(TQStringList::ConstIterator tdirIt=templateDirs.begin(); tdirIt!=templateDirs.end(); ++tdirIt) { if(*tdirIt=="." || *tdirIt=="..") // we don't want to check those dirs :) continue; - QDir templateDir(*it+*tdirIt); - QString name=*tdirIt; - QString defaultTab; + TQDir templateDir(*it+*tdirIt); + TQString name=*tdirIt; + TQString defaultTab; int sortingWeight = 1000; if(templateDir.exists(".directory")) { KSimpleConfig config(templateDir.absPath()+"/.directory", true); @@ -233,7 +233,7 @@ void KoTemplateTree::readGroups() { sortingWeight=config.readNumEntry("X-KDE-SortingWeight", 1000); //kdDebug() << "name: " << name <<endl; } - KoTemplateGroup *g=new KoTemplateGroup(name, *it+*tdirIt+QChar('/'), sortingWeight); + KoTemplateGroup *g=new KoTemplateGroup(name, *it+*tdirIt+TQChar('/'), sortingWeight); add(g); if(defaultTab=="true") m_defaultGroup=g; @@ -242,32 +242,32 @@ void KoTemplateTree::readGroups() { } void KoTemplateTree::readTemplates() { - QString dontShow = "imperial"; + TQString dontShow = "imperial"; - if(KGlobal::locale()->pageSize() == QPrinter::Letter) { + if(KGlobal::locale()->pageSize() == TQPrinter::Letter) { dontShow = "metric"; } - QPtrListIterator<KoTemplateGroup> groupIt(m_groups); + TQPtrListIterator<KoTemplateGroup> groupIt(m_groups); for( ; groupIt.current()!=0L; ++groupIt) { - QStringList dirs=groupIt.current()->dirs(); - for(QStringList::ConstIterator it=dirs.begin(); it!=dirs.end(); ++it) { - QDir d(*it); + TQStringList dirs=groupIt.current()->dirs(); + for(TQStringList::ConstIterator it=dirs.begin(); it!=dirs.end(); ++it) { + TQDir d(*it); if( !d.exists() ) continue; - QStringList files=d.entryList( QDir::Files | QDir::Readable, QDir::Name ); + TQStringList files=d.entryList( TQDir::Files | TQDir::Readable, TQDir::Name ); for(unsigned int i=0; i<files.count(); ++i) { - QString filePath = *it + files[i]; + TQString filePath = *it + files[i]; //kdDebug() << "filePath: " << filePath << endl; - QString icon; - QString text; - QString description; - QString hidden_str; - QString fileName; + TQString icon; + TQString text; + TQString description; + TQString hidden_str; + TQString fileName; bool hidden=false; bool defaultTemplate = false; - QString templatePath; - QString measureSystem; + TQString templatePath; + TQString measureSystem; // If a desktop file, then read the name from it. // Otherwise (or if no name in it?) use file name if (KDesktopFile::isDesktopFile(filePath)) { @@ -280,7 +280,7 @@ void KoTemplateTree::readTemplates() { //kdDebug() << "name: " << text << endl; icon=config.readEntry("Icon"); if(icon[0]!='/' && // allow absolute paths for icons - QFile::exists(*it+icon)) // allow icons from icontheme + TQFile::exists(*it+icon)) // allow icons from icontheme icon=*it+icon; //kdDebug() << "icon2: " << icon << endl; hidden=config.readBoolEntry("X-KDE-Hidden", false); @@ -312,7 +312,7 @@ void KoTemplateTree::readTemplates() { else { // Found a PNG file - the template must be here in the same dir. icon = filePath; - QFileInfo fi(filePath); + TQFileInfo fi(filePath); text = fi.baseName(); templatePath = filePath; // Note that we store the .png file as the template ! // That's the way it's always been done. Then the app replaces the extension... @@ -330,26 +330,26 @@ void KoTemplateTree::readTemplates() { } void KoTemplateTree::writeTemplate(KoTemplate *t, KoTemplateGroup *group, - const QString &localDir) { - QString fileName; + const TQString &localDir) { + TQString fileName; if ( t->isHidden() ) { fileName = t->fileName(); // try to remove the file - if ( QFile::remove(fileName) || !QFile::exists(fileName) ) + if ( TQFile::remove(fileName) || !TQFile::exists(fileName) ) { - QFile::remove( t->name() ); - QFile::remove( t->picture() ); + TQFile::remove( t->name() ); + TQFile::remove( t->picture() ); return; } } // be sure that the template's file name is unique so we don't overwrite an other - QString const path = localDir + group->name() + '/'; - QString const name = KoTemplates::stripWhiteSpace( t->name() ); + TQString const path = localDir + group->name() + '/'; + TQString const name = KoTemplates::stripWhiteSpace( t->name() ); fileName = path + name + ".desktop"; - if ( t->isHidden() && QFile::exists(fileName) ) + if ( t->isHidden() && TQFile::exists(fileName) ) return; - QString fill; + TQString fill; while ( KIO::NetAccess::exists( fileName, true, 0 ) ) { fill += '_'; @@ -366,11 +366,11 @@ void KoTemplateTree::writeTemplate(KoTemplate *t, KoTemplateGroup *group, } namespace KoTemplates { -QString stripWhiteSpace(const QString &string) { +TQString stripWhiteSpace(const TQString &string) { - QString ret; + TQString ret; for(unsigned int i=0; i<string.length(); ++i) { - QChar tmp(string[i]); + TQChar tmp(string[i]); if(!tmp.isSpace()) ret+=tmp; } |