summaryrefslogtreecommitdiffstats
path: root/src/filehandler.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/filehandler.cpp')
-rw-r--r--src/filehandler.cpp118
1 files changed, 59 insertions, 59 deletions
diff --git a/src/filehandler.cpp b/src/filehandler.cpp
index ce5501a..900257a 100644
--- a/src/filehandler.cpp
+++ b/src/filehandler.cpp
@@ -30,16 +30,16 @@
#include <kio/chmodjob.h>
#include <kfilterdev.h>
-#include <qdom.h>
-#include <qfile.h>
+#include <tqdom.h>
+#include <tqfile.h>
using Tellico::FileHandler;
-class FileHandler::ItemDeleter : public QObject {
+class FileHandler::ItemDeleter : public TQObject {
public:
- ItemDeleter(KIO::Job* job, KFileItem* item) : QObject(), m_job(job), m_item(item) {
+ ItemDeleter(KIO::Job* job, KFileItem* item) : TQObject(), m_job(job), m_item(item) {
FileHandler::s_deleterList.append(this);
- connect(job, SIGNAL(result(KIO::Job*)), SLOT(deleteLater()));
+ connect(job, TQT_SIGNAL(result(KIO::Job*)), TQT_SLOT(deleteLater()));
}
~ItemDeleter() {
FileHandler::s_deleterList.removeRef(this);
@@ -47,11 +47,11 @@ public:
delete m_item; m_item = 0;
}
private:
- QGuardedPtr<KIO::Job> m_job;
+ TQGuardedPtr<KIO::Job> m_job;
KFileItem* m_item;
};
-QPtrList<FileHandler::ItemDeleter> FileHandler::s_deleterList;
+TQPtrList<FileHandler::ItemDeleter> FileHandler::s_deleterList;
FileHandler::FileRef::FileRef(const KURL& url_, bool quiet_, bool allowCompressed_) : m_device(0), m_isValid(false) {
if(url_.isEmpty()) {
@@ -60,18 +60,18 @@ FileHandler::FileRef::FileRef(const KURL& url_, bool quiet_, bool allowCompresse
if(!Tellico::NetAccess::download(url_, m_filename, Kernel::self()->widget())) {
myDebug() << "FileRef::FileRef() - can't download " << url_ << endl;
- QString s = KIO::NetAccess::lastErrorString();
+ TQString s = KIO::NetAccess::lastErrorString();
if(!s.isEmpty()) {
myDebug() << s << endl;
}
if(!quiet_) {
- Kernel::self()->sorry(i18n(errorLoad).arg(url_.fileName()));
+ Kernel::self()->sorry(i18n(errorLoad).tqarg(url_.fileName()));
}
return;
}
/*
- QFile* file = new QFile(m_filename);
+ TQFile* file = new TQFile(m_filename);
if(file->exists()) {
m_isValid = true;
m_device = file;
@@ -82,7 +82,7 @@ FileHandler::FileRef::FileRef(const KURL& url_, bool quiet_, bool allowCompresse
if(allowCompressed_) {
m_device = KFilterDev::deviceForFile(m_filename);
} else {
- m_device = new QFile(m_filename);
+ m_device = TQT_TQIODEVICE(new TQFile(m_filename));
}
m_isValid = true;
}
@@ -107,7 +107,7 @@ bool FileHandler::FileRef::open(bool quiet_) {
if(!quiet_) {
KURL u;
u.setPath(fileName());
- Kernel::self()->sorry(i18n(errorLoad).arg(u.fileName()));
+ Kernel::self()->sorry(i18n(errorLoad).tqarg(u.fileName()));
}
delete m_device;
m_device = 0;
@@ -121,52 +121,52 @@ FileHandler::FileRef* FileHandler::fileRef(const KURL& url_, bool quiet_) {
return new FileRef(url_, quiet_);
}
-QString FileHandler::readTextFile(const KURL& url_, bool quiet_/*=false*/, bool useUTF8_ /*false*/, bool compress_/*=false*/) {
+TQString FileHandler::readTextFile(const KURL& url_, bool quiet_/*=false*/, bool useUTF8_ /*false*/, bool compress_/*=false*/) {
FileRef f(url_, quiet_, compress_);
if(!f.isValid()) {
- return QString::null;
+ return TQString();
}
if(f.open(quiet_)) {
- QTextStream stream(f.file());
+ TQTextStream stream(f.file());
if(useUTF8_) {
- stream.setEncoding(QTextStream::UnicodeUTF8);
+ stream.setEncoding(TQTextStream::UnicodeUTF8);
}
return stream.read();
}
- return QString();
+ return TQString();
}
-QDomDocument FileHandler::readXMLFile(const KURL& url_, bool processNamespace_, bool quiet_) {
+TQDomDocument FileHandler::readXMLFile(const KURL& url_, bool processNamespace_, bool quiet_) {
FileRef f(url_, quiet_);
if(!f.isValid()) {
- return QDomDocument();
+ return TQDomDocument();
}
- QDomDocument doc;
- QString errorMsg;
+ TQDomDocument doc;
+ TQString errorMsg;
int errorLine, errorColumn;
if(!f.open(quiet_)) {
- return QDomDocument();
+ return TQDomDocument();
}
if(!doc.setContent(f.file(), processNamespace_, &errorMsg, &errorLine, &errorColumn)) {
if(!quiet_) {
- QString details = i18n("There is an XML parsing error in line %1, column %2.").arg(errorLine).arg(errorColumn);
- details += QString::fromLatin1("\n");
- details += i18n("The error message from Qt is:");
- details += QString::fromLatin1("\n\t") + errorMsg;
- GUI::CursorSaver cs(Qt::arrowCursor);
- KMessageBox::detailedSorry(Kernel::self()->widget(), i18n(errorLoad).arg(url_.fileName()), details);
+ TQString details = i18n("There is an XML parsing error in line %1, column %2.").tqarg(errorLine).tqarg(errorColumn);
+ details += TQString::tqfromLatin1("\n");
+ details += i18n("The error message from TQt is:");
+ details += TQString::tqfromLatin1("\n\t") + errorMsg;
+ GUI::CursorSaver cs(TQt::arrowCursor);
+ KMessageBox::detailedSorry(Kernel::self()->widget(), i18n(errorLoad).tqarg(url_.fileName()), details);
}
- return QDomDocument();
+ return TQDomDocument();
}
return doc;
}
-QByteArray FileHandler::readDataFile(const KURL& url_, bool quiet_) {
+TQByteArray FileHandler::readDataFile(const KURL& url_, bool quiet_) {
FileRef f(url_, quiet_);
if(!f.isValid()) {
- return QByteArray();
+ return TQByteArray();
}
f.open(quiet_);
@@ -184,11 +184,11 @@ Tellico::Data::Image* FileHandler::readImageFile(const KURL& url_, bool quiet_,
tmpFile.setAutoDelete(true);
KIO::Job* job = KIO::file_copy(url_, tmpURL, -1, true /* overwrite */);
- job->addMetaData(QString::fromLatin1("referrer"), referrer_.url());
+ job->addMetaData(TQString::tqfromLatin1("referrer"), referrer_.url());
if(!KIO::NetAccess::synchronousRun(job, Kernel::self()->widget())) {
if(!quiet_) {
- Kernel::self()->sorry(i18n(errorLoad).arg(url_.fileName()));
+ Kernel::self()->sorry(i18n(errorLoad).tqarg(url_.fileName()));
}
return 0;
}
@@ -203,7 +203,7 @@ Tellico::Data::Image* FileHandler::readImageFile(const KURL& url_, bool quiet_)
Data::Image* img = new Data::Image(f.fileName());
if(img->isNull() && !quiet_) {
- QString str = i18n("Tellico is unable to load the image - %1.").arg(url_.fileName());
+ TQString str = i18n("Tellico is unable to load the image - %1.").tqarg(url_.fileName());
Kernel::self()->sorry(str);
}
return img;
@@ -216,9 +216,9 @@ bool FileHandler::queryExists(const KURL& url_) {
// we always overwrite the current URL without asking
if(url_ != Kernel::self()->URL()) {
- GUI::CursorSaver cs(Qt::arrowCursor);
- QString str = i18n("A file named \"%1\" already exists. "
- "Are you sure you want to overwrite it?").arg(url_.fileName());
+ GUI::CursorSaver cs(TQt::arrowCursor);
+ TQString str = i18n("A file named \"%1\" already exists. "
+ "Are you sure you want to overwrite it?").tqarg(url_.fileName());
int want_continue = KMessageBox::warningContinueCancel(Kernel::self()->widget(), str,
i18n("Overwrite File?"),
i18n("Overwrite"));
@@ -229,7 +229,7 @@ bool FileHandler::queryExists(const KURL& url_) {
}
KURL backup(url_);
- backup.setPath(backup.path() + QString::fromLatin1("~"));
+ backup.setPath(backup.path() + TQString::tqfromLatin1("~"));
bool success = true;
if(url_.isLocalFile()) {
@@ -237,7 +237,7 @@ bool FileHandler::queryExists(const KURL& url_) {
// the user is always reset to the current user
KFileItemList list;
int perm = -1;
- QString grp;
+ TQString grp;
if(KIO::NetAccess::exists(url_, false, Kernel::self()->widget())) {
KFileItem item(KFileItem::Unknown, KFileItem::Unknown, url_, true);
perm = item.permissions();
@@ -250,7 +250,7 @@ bool FileHandler::queryExists(const KURL& url_) {
success = KSaveFile::backupFile(url_.path());
if(!list.isEmpty()) {
// have to leave the user alone
- KIO::Job* job = KIO::chmod(list, perm, 0, QString(), grp, true, false);
+ KIO::Job* job = KIO::chmod(list, perm, 0, TQString(), grp, true, false);
new ItemDeleter(job, list.first());
}
} else {
@@ -259,12 +259,12 @@ bool FileHandler::queryExists(const KURL& url_) {
false /* resume */, Kernel::self()->widget());
}
if(!success) {
- Kernel::self()->sorry(i18n(errorWrite).arg(url_.fileName() + '~'));
+ Kernel::self()->sorry(i18n(errorWrite).tqarg(url_.fileName() + '~'));
}
return success;
}
-bool FileHandler::writeTextURL(const KURL& url_, const QString& text_, bool encodeUTF8_, bool force_, bool quiet_) {
+bool FileHandler::writeTextURL(const KURL& url_, const TQString& text_, bool encodeUTF8_, bool force_, bool quiet_) {
if((!force_ && !queryExists(url_)) || text_.isNull()) {
if(text_.isNull()) {
myDebug() << "FileHandler::writeTextURL() - null string for " << url_ << endl;
@@ -277,7 +277,7 @@ bool FileHandler::writeTextURL(const KURL& url_, const QString& text_, bool enco
// the user is always reset to the current user
KFileItemList list;
int perm = -1;
- QString grp;
+ TQString grp;
if(KIO::NetAccess::exists(url_, false, Kernel::self()->widget())) {
KFileItem* item = new KFileItem(KFileItem::Unknown, KFileItem::Unknown, url_, true);
list.append(item);
@@ -288,14 +288,14 @@ bool FileHandler::writeTextURL(const KURL& url_, const QString& text_, bool enco
KSaveFile f(url_.path());
if(f.status() != 0) {
if(!quiet_) {
- Kernel::self()->sorry(i18n(errorWrite).arg(url_.fileName()));
+ Kernel::self()->sorry(i18n(errorWrite).tqarg(url_.fileName()));
}
return false;
}
bool success = FileHandler::writeTextFile(f, text_, encodeUTF8_);
if(!list.isEmpty()) {
// have to leave the user alone
- KIO::Job* job = KIO::chmod(list, perm, 0, QString(), grp, true, false);
+ KIO::Job* job = KIO::chmod(list, perm, 0, TQString(), grp, true, false);
new ItemDeleter(job, list.first());
}
return success;
@@ -307,7 +307,7 @@ bool FileHandler::writeTextURL(const KURL& url_, const QString& text_, bool enco
if(f.status() != 0) {
tempfile.unlink();
if(!quiet_) {
- Kernel::self()->sorry(i18n(errorWrite).arg(url_.fileName()));
+ Kernel::self()->sorry(i18n(errorWrite).tqarg(url_.fileName()));
}
return false;
}
@@ -318,7 +318,7 @@ bool FileHandler::writeTextURL(const KURL& url_, const QString& text_, bool enco
if(!uploaded) {
tempfile.unlink();
if(!quiet_) {
- Kernel::self()->sorry(i18n(errorUpload).arg(url_.fileName()));
+ Kernel::self()->sorry(i18n(errorUpload).tqarg(url_.fileName()));
}
success = false;
}
@@ -328,12 +328,12 @@ bool FileHandler::writeTextURL(const KURL& url_, const QString& text_, bool enco
return success;
}
-bool FileHandler::writeTextFile(KSaveFile& f_, const QString& text_, bool encodeUTF8_) {
- QTextStream* t = f_.textStream();
+bool FileHandler::writeTextFile(KSaveFile& f_, const TQString& text_, bool encodeUTF8_) {
+ TQTextStream* t = f_.textStream();
if(encodeUTF8_) {
- t->setEncoding(QTextStream::UnicodeUTF8);
+ t->setEncoding(TQTextStream::UnicodeUTF8);
} else {
- t->setEncoding(QTextStream::Locale);
+ t->setEncoding(TQTextStream::Locale);
}
// kdDebug() << "-----------------------------" << endl
// << text_ << endl
@@ -348,7 +348,7 @@ bool FileHandler::writeTextFile(KSaveFile& f_, const QString& text_, bool encode
return success;
}
-bool FileHandler::writeDataURL(const KURL& url_, const QByteArray& data_, bool force_, bool quiet_) {
+bool FileHandler::writeDataURL(const KURL& url_, const TQByteArray& data_, bool force_, bool quiet_) {
if(!force_ && !queryExists(url_)) {
return false;
}
@@ -358,7 +358,7 @@ bool FileHandler::writeDataURL(const KURL& url_, const QByteArray& data_, bool f
// the user is always reset to the current user
KFileItemList list;
int perm = -1;
- QString grp;
+ TQString grp;
if(KIO::NetAccess::exists(url_, false, Kernel::self()->widget())) {
KFileItem* item = new KFileItem(KFileItem::Unknown, KFileItem::Unknown, url_, true);
list.append(item);
@@ -369,14 +369,14 @@ bool FileHandler::writeDataURL(const KURL& url_, const QByteArray& data_, bool f
KSaveFile f(url_.path());
if(f.status() != 0) {
if(!quiet_) {
- Kernel::self()->sorry(i18n(errorWrite).arg(url_.fileName()));
+ Kernel::self()->sorry(i18n(errorWrite).tqarg(url_.fileName()));
}
return false;
}
bool success = FileHandler::writeDataFile(f, data_);
if(!list.isEmpty()) {
// have to leave the user alone
- KIO::Job* job = KIO::chmod(list, perm, 0, QString(), grp, true, false);
+ KIO::Job* job = KIO::chmod(list, perm, 0, TQString(), grp, true, false);
new ItemDeleter(job, list.first());
}
return success;
@@ -387,7 +387,7 @@ bool FileHandler::writeDataURL(const KURL& url_, const QByteArray& data_, bool f
KSaveFile f(tempfile.name());
if(f.status() != 0) {
if(!quiet_) {
- Kernel::self()->sorry(i18n(errorWrite).arg(url_.fileName()));
+ Kernel::self()->sorry(i18n(errorWrite).tqarg(url_.fileName()));
}
return false;
}
@@ -396,7 +396,7 @@ bool FileHandler::writeDataURL(const KURL& url_, const QByteArray& data_, bool f
if(success) {
success = KIO::NetAccess::upload(tempfile.name(), url_, Kernel::self()->widget());
if(!success && !quiet_) {
- Kernel::self()->sorry(i18n(errorUpload).arg(url_.fileName()));
+ Kernel::self()->sorry(i18n(errorUpload).tqarg(url_.fileName()));
}
}
tempfile.unlink();
@@ -404,9 +404,9 @@ bool FileHandler::writeDataURL(const KURL& url_, const QByteArray& data_, bool f
return success;
}
-bool FileHandler::writeDataFile(KSaveFile& f_, const QByteArray& data_) {
+bool FileHandler::writeDataFile(KSaveFile& f_, const TQByteArray& data_) {
// myDebug() << "FileHandler::writeDataFile()" << endl;
- QDataStream* s = f_.dataStream();
+ TQDataStream* s = f_.dataStream();
s->writeRawBytes(data_.data(), data_.size());
return f_.close();
}