diff options
Diffstat (limited to 'src/configuration.cpp')
-rw-r--r-- | src/configuration.cpp | 136 |
1 files changed, 68 insertions, 68 deletions
diff --git a/src/configuration.cpp b/src/configuration.cpp index 6df8c11..99b4ff9 100644 --- a/src/configuration.cpp +++ b/src/configuration.cpp @@ -19,10 +19,10 @@ ***************************************************************************/ #include "configuration.h" -#include <qfile.h> -#include <qwidgetstack.h> -#include <qobjectlist.h> -#include <qdir.h> +#include <ntqfile.h> +#include <ntqwidgetstack.h> +#include <ntqobjectlist.h> +#include <ntqdir.h> #include <kstandarddirs.h> #include <kshell.h> @@ -31,18 +31,18 @@ #include "menulistviewitem.h" Config::Config() - :mTintColor(Qt::black),mOpacity(0.2f),mScheme("none"),mMenuButtonSize(32),mNavButtonSize(32),mMenuRadius(132),doc(NULL) + :mTintColor(TQt::black),mOpacity(0.2f),mScheme("none"),mMenuButtonSize(32),mNavButtonSize(32),mMenuRadius(132),doc(NULL) { mConfigPath = locate("data", "kommando/kommandorc"); kdDebug() << "kommandorc located: " << mConfigPath << endl; - if (mConfigPath.isNull() || !QFile::exists(mConfigPath)){ //test for new config file + if (mConfigPath.isNull() || !TQFile::exists(mConfigPath)){ //test for new config file kdDebug() << "There is no kommandorc in kdedirs" << endl; mConfigPath = locateLocal("data", "kommando/kommandorc"); - if(QFile::exists(KShell::homeDir("")+"/.kommandorc")){ //tries old config file + if(TQFile::exists(KShell::homeDir("")+"/.kommandorc")){ //tries old config file kdDebug() << "There is a kommandorc in homedir, moving it to " << mConfigPath << endl; - QDir dir; + TQDir dir; if (!dir.rename(KShell::homeDir("")+"/.kommandorc", mConfigPath)) { kdWarning() << "Moving ~/.kommandorc failed, creating a default one" << endl; createDefaultConfigFile(); @@ -69,22 +69,22 @@ void Config::createDefaultConfigFile() bool Config::readConfigFile( ) { - QFile file(mConfigPath); + TQFile file(mConfigPath); if(!file.open(IO_ReadOnly)){ return false; } if(doc){ delete doc; } - doc = new QDomDocument(); + doc = new TQDomDocument(); doc->setContent( &file ); file.close(); if(doc){ - QDomNode topLevelNode = doc->documentElement().firstChild(); + TQDomNode topLevelNode = doc->documentElement().firstChild(); while(!topLevelNode.isNull()){ if(topLevelNode.isElement()){ - QDomElement elem = topLevelNode.toElement(); + TQDomElement elem = topLevelNode.toElement(); if(elem.tagName()=="access"){ setShortcut(elem.text()); } else if(elem.tagName()=="tintcolor"){ @@ -114,11 +114,11 @@ bool Config::writeConfigFile( ) } mConfigPath = locateLocal("data", "kommando/kommandorc"); - QFile file(mConfigPath); + TQFile file(mConfigPath); if(!file.open(IO_WriteOnly)){ return false; } - QTextStream str(&file); + TQTextStream str(&file); str << *doc; file.close(); return true; @@ -129,8 +129,8 @@ void Config::fromConfigDlg(KommandoViewList& listViews ) if(doc){ delete doc; } - doc = new QDomDocument(); - QDomElement root=doc->createElement("root"); + doc = new TQDomDocument(); + TQDomElement root=doc->createElement("root"); doc->appendChild(root); newNode("access",root,Shortcut(),"method","shortcut"); @@ -143,8 +143,8 @@ void Config::fromConfigDlg(KommandoViewList& listViews ) for(KommandoView* it = listViews.first(); it != 0; it = listViews.next()){ if(it->childCount() > 0){ - QDomElement node = newMenu(root,it->appName()); - QListViewItem* temp = it->firstChild(); + TQDomElement node = newMenu(root,it->appName()); + TQListViewItem* temp = it->firstChild(); while(temp){ menuItemToXML(node,static_cast<MenuListViewItem*>(temp)); temp=temp->nextSibling(); @@ -154,12 +154,12 @@ void Config::fromConfigDlg(KommandoViewList& listViews ) } } -//ARGHHH!! I need this function because QListView::lastItem returns not only top level items but also children of top level items +//ARGHHH!! I need this function because TQListView::lastItem returns not only top level items but also children of top level items //It took me hours of my precious lifetime to figure that out!! _Terribly_ annoying -.- -QListViewItem* lastChild(QListView* view) +TQListViewItem* lastChild(TQListView* view) { - QListViewItem* temp=view->firstChild(); - QListViewItem* item=NULL; + TQListViewItem* temp=view->firstChild(); + TQListViewItem* item=NULL; while(temp!=NULL){ item=temp; temp=temp->nextSibling(); @@ -167,15 +167,15 @@ QListViewItem* lastChild(QListView* view) return item; } -void Config::toListView(KommandoViewList& listViews, QWidgetStack* listViewParent)//QListView* listView ) +void Config::toListView(KommandoViewList& listViews, TQWidgetStack* listViewParent)//TQListView* listView ) { if(doc){ - QDomNode topLevelNode = doc->documentElement().firstChild(); - const QObjectList *children = listViewParent->children(); + TQDomNode topLevelNode = doc->documentElement().firstChild(); + const TQObjectList *children = listViewParent->children(); if (children != 0) { - QObjectListIterator it(*children); + TQObjectListIterator it(*children); for (; *it != 0; ++it) - listViewParent->removeWidget(static_cast<QWidget*>(*it)); + listViewParent->removeWidget(static_cast<TQWidget*>(*it)); } while(!topLevelNode.isNull()){ @@ -184,10 +184,10 @@ void Config::toListView(KommandoViewList& listViews, QWidgetStack* listViewParen { KommandoView* view = new KommandoView(listViewParent,topLevelNode.toElement().attribute("appname")); listViewParent->addWidget(view); - QDomNode menuNode = topLevelNode.firstChild(); + TQDomNode menuNode = topLevelNode.firstChild(); while(!menuNode.isNull()){ if(menuNode.isElement()){ - QDomElement elemNode=menuNode.toElement(); + TQDomElement elemNode=menuNode.toElement(); menuItemFromXML(view,lastChild(view),menuNode.toElement()); } menuNode = menuNode.nextSibling(); @@ -202,15 +202,15 @@ void Config::toListView(KommandoViewList& listViews, QWidgetStack* listViewParen void Config::toKommandoMenu(Kommando* buttonParent) { - QPtrList<Menu> topLevelMenus; + TQPtrList<Menu> topLevelMenus; Menu* defaultMenu = 0; if(doc){ - QDomNode node = doc->documentElement().firstChild(); + TQDomNode node = doc->documentElement().firstChild(); while(!node.isNull()){ if(node.isElement()&&(node.toElement().tagName() == "menu")){ Menu* mainMenu = menuFromXML(node.toElement(),buttonParent); - if((mainMenu->appName() == "default") || (mainMenu->appName() == QString::null)){ + if((mainMenu->appName() == "default") || (mainMenu->appName() == TQString::null)){ defaultMenu = mainMenu; } mainMenu->arrangeButtons(); @@ -237,7 +237,7 @@ void Config::toKommandoMenu(Kommando* buttonParent) void Config::setDefaultValues() { - setTintColor(Qt::black); + setTintColor(TQt::black); setOpacity(0.2f); setShortcut("Alt+Ctrl+H"); setNavButtonSize(32); @@ -248,8 +248,8 @@ void Config::setDefaultValues() if(doc){ delete doc; } - doc = new QDomDocument(); - QDomElement root = doc->createElement("root"); + doc = new TQDomDocument(); + TQDomElement root = doc->createElement("root"); doc->appendChild(root); newNode("access",root,Shortcut(),"method","shortcut"); @@ -260,23 +260,23 @@ void Config::setDefaultValues() newNode("menuradius",root,132); newNode("scheme",root,"Normal"); - QDomElement node= newMenu(root,"default"); + TQDomElement node= newMenu(root,"default"); newButton(node,"konsole","konsole --workdir $HOME"); newButton(node,"kwrite","kwrite"); newButton(node,"konqueror","konqueror"); newButton(node,"kcalc","kcalc"); newButton(node,"gimp","gimp"); newButton(node,"kfm_home","kfmclient openProfile filemanagement"); - node = newMenu(node,QString::null,"kmix"); + node = newMenu(node,TQString::null,"kmix"); newButton(node,"kmix","kmix"); newButton(node,"k3b","k3b"); newButton(node,"amarok","amarok"); newButton(node,"kaffeine","kaffeine"); } -Menu * Config::menuFromXML( const QDomElement & ownNode, Kommando * buttonParent, Menu* parent) +Menu * Config::menuFromXML( const TQDomElement & ownNode, Kommando * buttonParent, Menu* parent) { - QDomNode node=ownNode.firstChild(); + TQDomNode node=ownNode.firstChild(); Menu* newMenu = new Menu(parent,ownNode.attribute("appname")); @@ -303,11 +303,11 @@ Menu * Config::menuFromXML( const QDomElement & ownNode, Kommando * buttonParent return newMenu; } -CommandoButton* Config::comButtonFromXML(const QDomElement& ownNode, Kommando* parent) +CommandoButton* Config::comButtonFromXML(const TQDomElement& ownNode, Kommando* parent) { CommandoButton* button = new CommandoButton(parent,mMenuButtonSize); - QDomNode bnode=ownNode.firstChild(); + TQDomNode bnode=ownNode.firstChild(); while (!bnode.isNull()){ if(bnode.nodeName() == "command"){ button->setCommand(bnode.firstChild().nodeValue()); @@ -319,36 +319,36 @@ CommandoButton* Config::comButtonFromXML(const QDomElement& ownNode, Kommando* p return button; } -QDomElement Config::newNode( const QString& nodename, QDomNode& parent, int value ) +TQDomElement Config::newNode( const TQString& nodename, TQDomNode& parent, int value ) { - QDomElement node=doc->createElement(nodename); - node.appendChild(doc->createTextNode(QString::number(value))); + TQDomElement node=doc->createElement(nodename); + node.appendChild(doc->createTextNode(TQString::number(value))); parent.appendChild(node); return node; } -QDomElement Config::newNode( const QString& nodename, QDomNode& parent, float value ) +TQDomElement Config::newNode( const TQString& nodename, TQDomNode& parent, float value ) { - QDomElement node=doc->createElement(nodename); - node.appendChild(doc->createTextNode(QString::number(value))); + TQDomElement node=doc->createElement(nodename); + node.appendChild(doc->createTextNode(TQString::number(value))); parent.appendChild(node); return node; } -QDomElement Config::newNode( const QString& nodename, QDomNode& parent, const QString& value ) +TQDomElement Config::newNode( const TQString& nodename, TQDomNode& parent, const TQString& value ) { - QDomElement node=doc->createElement(nodename); + TQDomElement node=doc->createElement(nodename); node.appendChild(doc->createTextNode(value)); parent.appendChild(node); return node; } -QDomElement Config::newNode( const QString& nodename, QDomNode& parent, const QString& value, const QString& attrname, const QString& attrvalue ) +TQDomElement Config::newNode( const TQString& nodename, TQDomNode& parent, const TQString& value, const TQString& attrname, const TQString& attrvalue ) { - QDomElement node=doc->createElement(nodename); + TQDomElement node=doc->createElement(nodename); node.setAttribute(attrname,attrvalue); node.appendChild(doc->createTextNode(value)); parent.appendChild(node); @@ -356,16 +356,16 @@ QDomElement Config::newNode( const QString& nodename, QDomNode& parent, const QS return node; } -QDomElement Config::newButton(QDomNode& parent, const QString& icon, const QString& command ) +TQDomElement Config::newButton(TQDomNode& parent, const TQString& icon, const TQString& command ) { - QDomElement root = doc->createElement("button"); + TQDomElement root = doc->createElement("button"); if(command!=""){ - QDomElement node = doc->createElement("command"); + TQDomElement node = doc->createElement("command"); node.appendChild(doc->createTextNode(command)); root.appendChild(node); } if(icon!=""){ - QDomElement node=doc->createElement("icon"); + TQDomElement node=doc->createElement("icon"); node.appendChild(doc->createTextNode(icon)); root.appendChild(node); } @@ -373,14 +373,14 @@ QDomElement Config::newButton(QDomNode& parent, const QString& icon, const QStri return root; } -QDomElement Config::newMenu( QDomNode & parent, const QString& appName, const QString& icon ) +TQDomElement Config::newMenu( TQDomNode & parent, const TQString& appName, const TQString& icon ) { - QDomElement root = doc->createElement("menu"); - if(appName != QString::null){ + TQDomElement root = doc->createElement("menu"); + if(appName != TQString::null){ root.setAttribute("appname", appName); } - if(icon != QString::null){ - QDomElement node=doc->createElement("icon"); + if(icon != TQString::null){ + TQDomElement node=doc->createElement("icon"); node.appendChild(doc->createTextNode(icon)); root.appendChild(node); } @@ -388,11 +388,11 @@ QDomElement Config::newMenu( QDomNode & parent, const QString& appName, const QS return root; } -void Config::menuItemToXML( QDomNode & parent, MenuListViewItem* item) +void Config::menuItemToXML( TQDomNode & parent, MenuListViewItem* item) { if(item->type()==MenuListViewItem::Menu){ - QDomElement node = newMenu(parent,QString::null,item->iconPath()); - QListViewItem* temp = item->firstChild(); + TQDomElement node = newMenu(parent,TQString::null,item->iconPath()); + TQListViewItem* temp = item->firstChild(); while(temp){ menuItemToXML(node,static_cast<MenuListViewItem*>(temp)); temp=temp->nextSibling(); @@ -402,7 +402,7 @@ void Config::menuItemToXML( QDomNode & parent, MenuListViewItem* item) } } -void Config::menuItemFromXML(KommandoView* parent, QListViewItem* after, const QDomElement& ownNode) +void Config::menuItemFromXML(KommandoView* parent, TQListViewItem* after, const TQDomElement& ownNode) { MenuListViewItem* item; if (ownNode.tagName()=="menu"){ @@ -414,7 +414,7 @@ void Config::menuItemFromXML(KommandoView* parent, QListViewItem* after, const Q itemHelper(ownNode,item); //Parse properties and children of this item } -void Config::menuItemFromXML(QListViewItem* parent, QListViewItem* after, const QDomElement& ownNode) +void Config::menuItemFromXML(TQListViewItem* parent, TQListViewItem* after, const TQDomElement& ownNode) { MenuListViewItem* item; if (ownNode.tagName()=="menu"){ @@ -427,13 +427,13 @@ void Config::menuItemFromXML(QListViewItem* parent, QListViewItem* after, const itemHelper(ownNode,item); //Parse properties and children of this item } -void Config::itemHelper(const QDomElement& ownNode, MenuListViewItem* item) +void Config::itemHelper(const TQDomElement& ownNode, MenuListViewItem* item) { - QDomNode temp = ownNode.firstChild(); + TQDomNode temp = ownNode.firstChild(); while(!temp.isNull()){ if(temp.isElement()){ - QDomElement temp2=temp.toElement(); + TQDomElement temp2=temp.toElement(); if(temp2.tagName() == "icon"){ item->setIconPath(temp2.firstChild().nodeValue()); } else if((temp2.tagName() == "command") && (item->type() == MenuListViewItem::Button)){ |