summaryrefslogtreecommitdiffstats
path: root/kmymoney2/converter/mymoneytemplate.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'kmymoney2/converter/mymoneytemplate.cpp')
-rw-r--r--kmymoney2/converter/mymoneytemplate.cpp142
1 files changed, 71 insertions, 71 deletions
diff --git a/kmymoney2/converter/mymoneytemplate.cpp b/kmymoney2/converter/mymoneytemplate.cpp
index 63305c6..1a8860b 100644
--- a/kmymoney2/converter/mymoneytemplate.cpp
+++ b/kmymoney2/converter/mymoneytemplate.cpp
@@ -20,9 +20,9 @@
// ----------------------------------------------------------------------------
// QT Includes
-#include <qfile.h>
-#include <qfileinfo.h>
-#include <qapplication.h>
+#include <tqfile.h>
+#include <tqfileinfo.h>
+#include <tqapplication.h>
// ----------------------------------------------------------------------------
// KDE Includes
@@ -54,7 +54,7 @@ MyMoneyTemplate::~MyMoneyTemplate()
bool MyMoneyTemplate::loadTemplate(const KURL& url)
{
- QString filename;
+ TQString filename;
if(!url.isValid()) {
qDebug("Invalid template URL '%s'", url.url().latin1());
@@ -67,10 +67,10 @@ bool MyMoneyTemplate::loadTemplate(const KURL& url)
} else {
bool rc;
- rc = KIO::NetAccess::download(url, filename, qApp->mainWidget());
+ rc = KIO::NetAccess::download(url, filename, tqApp->mainWidget());
if(!rc) {
- KMessageBox::detailedError(qApp->mainWidget(),
- i18n("Error while loading file '%1'!").arg(url.url()),
+ KMessageBox::detailedError(tqApp->mainWidget(),
+ i18n("Error while loading file '%1'!").tqarg(url.url()),
KIO::NetAccess::lastErrorString(),
i18n("File access error"));
return false;
@@ -78,27 +78,27 @@ bool MyMoneyTemplate::loadTemplate(const KURL& url)
}
bool rc = true;
- QFile file(filename);
- QFileInfo info(file);
+ TQFile file(filename);
+ TQFileInfo info(file);
if(!info.isFile()) {
- QString msg=i18n("<b>%1</b> is not a template file.").arg(filename);
- KMessageBox::error(qApp->mainWidget(), QString("<p>")+msg, i18n("Filetype Error"));
+ TQString msg=i18n("<b>%1</b> is not a template file.").tqarg(filename);
+ KMessageBox::error(tqApp->mainWidget(), TQString("<p>")+msg, i18n("Filetype Error"));
return false;
}
if(file.open(IO_ReadOnly)) {
- QString errMsg;
+ TQString errMsg;
int errLine, errColumn;
if(!m_doc.setContent(&file, &errMsg, &errLine, &errColumn)) {
- QString msg=i18n("Error while reading template file <b>%1</b> in line %2, column %3").arg(filename).arg(errLine).arg(errColumn);
- KMessageBox::detailedError(qApp->mainWidget(), QString("<p>")+msg, errMsg, i18n("Template Error"));
+ TQString msg=i18n("Error while reading template file <b>%1</b> in line %2, column %3").tqarg(filename).tqarg(errLine).tqarg(errColumn);
+ KMessageBox::detailedError(tqApp->mainWidget(), TQString("<p>")+msg, errMsg, i18n("Template Error"));
rc = false;
} else {
rc = loadDescription();
}
file.close();
} else {
- KMessageBox::sorry(qApp->mainWidget(), i18n("File '%1' not found!").arg(filename));
+ KMessageBox::sorry(tqApp->mainWidget(), i18n("File '%1' not found!").tqarg(filename));
rc = false;
}
@@ -119,12 +119,12 @@ bool MyMoneyTemplate::loadDescription(void)
const int invalid = 0x10;
const int validHeader = 0x0F;
- QDomElement rootElement = m_doc.documentElement();
+ TQDomElement rootElement = m_doc.documentElement();
if(!rootElement.isNull()
&& rootElement.tagName() == "kmymoney-account-template") {
- QDomNode child = rootElement.firstChild();
+ TQDomNode child = rootElement.firstChild();
while(!child.isNull() && child.isElement()) {
- QDomElement childElement = child.toElement();
+ TQDomElement childElement = child.toElement();
// qDebug("MyMoneyTemplate::import: Processing child node %s", childElement.tagName().data());
if(childElement.tagName() == "accounts") {
m_accounts = childElement.firstChild();
@@ -139,7 +139,7 @@ bool MyMoneyTemplate::loadDescription(void)
m_longDesc = childElement.text();
validMask |= validLong;
} else {
- KMessageBox::error(qApp->mainWidget(), QString("<p>")+i18n("Invalid tag <b>%1</b> in template file <b>%2</b>!").arg(childElement.tagName()).arg(m_source.prettyURL()));
+ KMessageBox::error(tqApp->mainWidget(), TQString("<p>")+i18n("Invalid tag <b>%1</b> in template file <b>%2</b>!").tqarg(childElement.tagName()).tqarg(m_source.prettyURL()));
validMask |= invalid;
}
child = child.nextSibling();
@@ -148,14 +148,14 @@ bool MyMoneyTemplate::loadDescription(void)
return validMask == validHeader;
}
-bool MyMoneyTemplate::hierarchy(QMap<QString, QListViewItem*>& list, const QString& parent, QDomNode account)
+bool MyMoneyTemplate::hierarchy(TQMap<TQString, TQListViewItem*>& list, const TQString& tqparent, TQDomNode account)
{
bool rc = true;
while(rc == true && !account.isNull()) {
if(account.isElement()) {
- QDomElement accountElement = account.toElement();
+ TQDomElement accountElement = account.toElement();
if(accountElement.tagName() == "account") {
- QString name = QString("%1:%2").arg(parent).arg(accountElement.attribute("name"));
+ TQString name = TQString("%1:%2").tqarg(tqparent).tqarg(accountElement.attribute("name"));
list[name] = 0;
hierarchy(list, name, account.firstChild());
}
@@ -165,12 +165,12 @@ bool MyMoneyTemplate::hierarchy(QMap<QString, QListViewItem*>& list, const QStri
return rc;
}
-void MyMoneyTemplate::hierarchy(QMap<QString, QListViewItem*>& list)
+void MyMoneyTemplate::hierarchy(TQMap<TQString, TQListViewItem*>& list)
{
bool rc = !m_accounts.isNull();
- QDomNode accounts = m_accounts;
+ TQDomNode accounts = m_accounts;
while(rc == true && !accounts.isNull() && accounts.isElement()) {
- QDomElement childElement = accounts.toElement();
+ TQDomElement childElement = accounts.toElement();
if(childElement.tagName() == "account"
&& childElement.attribute("name") == "") {
switch(childElement.attribute("type").toUInt()) {
@@ -206,44 +206,44 @@ void MyMoneyTemplate::hierarchy(QMap<QString, QListViewItem*>& list)
}
}
-bool MyMoneyTemplate::importTemplate(void(*callback)(int, int, const QString&))
+bool MyMoneyTemplate::importTemplate(void(*callback)(int, int, const TQString&))
{
m_progressCallback = callback;
bool rc = !m_accounts.isNull();
MyMoneyFile* file = MyMoneyFile::instance();
- signalProgress(0, m_doc.elementsByTagName("account").count(), i18n("Loading template %1").arg(m_source.url()));
+ signalProgress(0, m_doc.elementsByTagName("account").count(), i18n("Loading template %1").tqarg(m_source.url()));
m_accountsRead = 0;
while(rc == true && !m_accounts.isNull() && m_accounts.isElement()) {
- QDomElement childElement = m_accounts.toElement();
+ TQDomElement childElement = m_accounts.toElement();
if(childElement.tagName() == "account"
&& childElement.attribute("name") == "") {
++m_accountsRead;
- MyMoneyAccount parent;
+ MyMoneyAccount tqparent;
switch(childElement.attribute("type").toUInt()) {
case MyMoneyAccount::Asset:
- parent = file->asset();
+ tqparent = file->asset();
break;
case MyMoneyAccount::Liability:
- parent = file->liability();
+ tqparent = file->liability();
break;
case MyMoneyAccount::Income:
- parent = file->income();
+ tqparent = file->income();
break;
case MyMoneyAccount::Expense:
- parent = file->expense();
+ tqparent = file->expense();
break;
case MyMoneyAccount::Equity:
- parent = file->equity();
+ tqparent = file->equity();
break;
default:
- KMessageBox::error(qApp->mainWidget(), QString("<p>")+i18n("Invalid top-level account type <b>%1</b> in template file <b>%2</b>!").arg(childElement.attribute("type")).arg(m_source.prettyURL()));
+ KMessageBox::error(tqApp->mainWidget(), TQString("<p>")+i18n("Invalid top-level account type <b>%1</b> in template file <b>%2</b>!").tqarg(childElement.attribute("type")).tqarg(m_source.prettyURL()));
rc = false;
}
if(rc == true) {
- rc = createAccounts(parent, childElement.firstChild());
+ rc = createAccounts(tqparent, childElement.firstChild());
}
} else {
rc = false;
@@ -254,20 +254,20 @@ bool MyMoneyTemplate::importTemplate(void(*callback)(int, int, const QString&))
return rc;
}
-bool MyMoneyTemplate::createAccounts(MyMoneyAccount& parent, QDomNode account)
+bool MyMoneyTemplate::createAccounts(MyMoneyAccount& tqparent, TQDomNode account)
{
bool rc = true;
while(rc == true && !account.isNull()) {
MyMoneyAccount acc;
if(account.isElement()) {
- QDomElement accountElement = account.toElement();
+ TQDomElement accountElement = account.toElement();
if(accountElement.tagName() == "account") {
signalProgress(++m_accountsRead, 0);
- QValueList<MyMoneyAccount> subAccountList;
- QValueList<MyMoneyAccount>::ConstIterator it;
+ TQValueList<MyMoneyAccount> subAccountList;
+ TQValueList<MyMoneyAccount>::ConstIterator it;
it = subAccountList.end();
- if(!parent.accountList().isEmpty()) {
- MyMoneyFile::instance()->accountList(subAccountList, parent.accountList());
+ if(!tqparent.accountList().isEmpty()) {
+ MyMoneyFile::instance()->accountList(subAccountList, tqparent.accountList());
for(it = subAccountList.begin(); it != subAccountList.end(); ++it) {
if((*it).name() == accountElement.attribute("name")) {
acc = *it;
@@ -281,7 +281,7 @@ bool MyMoneyTemplate::createAccounts(MyMoneyAccount& parent, QDomNode account)
acc.setAccountType(static_cast<MyMoneyAccount::_accountTypeE>(accountElement.attribute("type").toUInt()));
setFlags(acc, account.firstChild());
try {
- MyMoneyFile::instance()->addAccount(acc, parent);
+ MyMoneyFile::instance()->addAccount(acc, tqparent);
} catch(MyMoneyException *e) {
delete e;
}
@@ -294,19 +294,19 @@ bool MyMoneyTemplate::createAccounts(MyMoneyAccount& parent, QDomNode account)
return rc;
}
-bool MyMoneyTemplate::setFlags(MyMoneyAccount& acc, QDomNode flags)
+bool MyMoneyTemplate::setFlags(MyMoneyAccount& acc, TQDomNode flags)
{
bool rc = true;
while(rc == true && !flags.isNull()) {
if(flags.isElement()) {
- QDomElement flagElement = flags.toElement();
+ TQDomElement flagElement = flags.toElement();
if(flagElement.tagName() == "flag") {
// make sure, we only store flags we know!
- QString value = flagElement.attribute("name");
+ TQString value = flagElement.attribute("name");
if(value == "Tax") {
acc.setValue(value.latin1(), "Yes");
} else {
- KMessageBox::error(qApp->mainWidget(), QString("<p>")+i18n("Invalid flag type <b>%1</b> for account <b>%3</b> in template file <b>%2</b>!").arg(flagElement.attribute("name")).arg(m_source.prettyURL()).arg(acc.name()));
+ KMessageBox::error(tqApp->mainWidget(), TQString("<p>")+i18n("Invalid flag type <b>%1</b> for account <b>%3</b> in template file <b>%2</b>!").tqarg(flagElement.attribute("name")).tqarg(m_source.prettyURL()).tqarg(acc.name()));
rc = false;
}
}
@@ -316,34 +316,34 @@ bool MyMoneyTemplate::setFlags(MyMoneyAccount& acc, QDomNode flags)
return rc;
}
-void MyMoneyTemplate::signalProgress(int current, int total, const QString& msg)
+void MyMoneyTemplate::signalProgress(int current, int total, const TQString& msg)
{
if(m_progressCallback != 0)
(*m_progressCallback)(current, total, msg);
}
-bool MyMoneyTemplate::exportTemplate(void(*callback)(int, int, const QString&))
+bool MyMoneyTemplate::exportTemplate(void(*callback)(int, int, const TQString&))
{
m_progressCallback = callback;
- m_doc = QDomDocument("KMYMONEY-TEMPLATE");
+ m_doc = TQDomDocument("KMYMONEY-TEMPLATE");
- QDomProcessingInstruction instruct = m_doc.createProcessingInstruction(QString("xml"), QString("version=\"1.0\" encoding=\"utf-8\""));
+ TQDomProcessingInstruction instruct = m_doc.createProcessingInstruction(TQString("xml"), TQString("version=\"1.0\" encoding=\"utf-8\""));
m_doc.appendChild(instruct);
- QDomElement mainElement = m_doc.createElement("kmymoney-account-template");
+ TQDomElement mainElement = m_doc.createElement("kmymoney-account-template");
m_doc.appendChild(mainElement);
- QDomElement title = m_doc.createElement("title");
+ TQDomElement title = m_doc.createElement("title");
mainElement.appendChild(title);
- QDomElement shortDesc = m_doc.createElement("shortdesc");
+ TQDomElement shortDesc = m_doc.createElement("shortdesc");
mainElement.appendChild(shortDesc);
- QDomElement longDesc = m_doc.createElement("longdesc");
+ TQDomElement longDesc = m_doc.createElement("longdesc");
mainElement.appendChild(longDesc);
- QDomElement accounts = m_doc.createElement("accounts");
+ TQDomElement accounts = m_doc.createElement("accounts");
mainElement.appendChild(accounts);
// addAccountStructure(accounts, MyMoneyFile::instance()->asset());
@@ -355,24 +355,24 @@ bool MyMoneyTemplate::exportTemplate(void(*callback)(int, int, const QString&))
return true;
}
-bool MyMoneyTemplate::addAccountStructure(QDomElement& parent, const MyMoneyAccount& acc)
+bool MyMoneyTemplate::addAccountStructure(TQDomElement& tqparent, const MyMoneyAccount& acc)
{
- QDomElement account = m_doc.createElement("account");
- parent.appendChild(account);
+ TQDomElement account = m_doc.createElement("account");
+ tqparent.appendChild(account);
if(MyMoneyFile::instance()->isStandardAccount(acc.id()))
- account.setAttribute(QString("name"), QString());
+ account.setAttribute(TQString("name"), TQString());
else
- account.setAttribute(QString("name"), acc.name());
- account.setAttribute(QString("type"), acc.accountType());
+ account.setAttribute(TQString("name"), acc.name());
+ account.setAttribute(TQString("type"), acc.accountType());
// FIXME: add tax flag stuff
// any child accounts?
if(acc.accountList().count() > 0) {
- QValueList<MyMoneyAccount> list;
+ TQValueList<MyMoneyAccount> list;
MyMoneyFile::instance()->accountList(list, acc.accountList(), false);
- QValueList<MyMoneyAccount>::Iterator it;
+ TQValueList<MyMoneyAccount>::Iterator it;
for(it = list.begin(); it != list.end(); ++it) {
addAccountStructure(account, *it);
}
@@ -382,7 +382,7 @@ bool MyMoneyTemplate::addAccountStructure(QDomElement& parent, const MyMoneyAcco
bool MyMoneyTemplate::saveTemplate(const KURL& url)
{
- QString filename;
+ TQString filename;
if(!url.isValid()) {
qDebug("Invalid template URL '%s'", url.url().latin1());
@@ -395,25 +395,25 @@ bool MyMoneyTemplate::saveTemplate(const KURL& url)
if(qfile.status() == 0) {
saveToLocalFile(qfile.file());
if(!qfile.close()) {
- throw new MYMONEYEXCEPTION(i18n("Unable to write changes to '%1'").arg(filename));
+ throw new MYMONEYEXCEPTION(i18n("Unable to write changes to '%1'").tqarg(filename));
}
} else {
- throw new MYMONEYEXCEPTION(i18n("Unable to write changes to '%1'").arg(filename));
+ throw new MYMONEYEXCEPTION(i18n("Unable to write changes to '%1'").tqarg(filename));
}
} else {
KTempFile tmpfile;
saveToLocalFile(tmpfile.file());
if(!KIO::NetAccess::upload(tmpfile.name(), url, NULL))
- throw new MYMONEYEXCEPTION(i18n("Unable to upload to '%1'").arg(url.url()));
+ throw new MYMONEYEXCEPTION(i18n("Unable to upload to '%1'").tqarg(url.url()));
tmpfile.unlink();
}
return true;
}
-bool MyMoneyTemplate::saveToLocalFile(QFile* qfile)
+bool MyMoneyTemplate::saveToLocalFile(TQFile* qfile)
{
- QTextStream stream(qfile);
- stream.setEncoding(QTextStream::UnicodeUTF8);
+ TQTextStream stream(qfile);
+ stream.setEncoding(TQTextStream::UnicodeUTF8);
stream << m_doc.toString();
return true;