summaryrefslogtreecommitdiffstats
path: root/src/newstuff/manager.cpp
diff options
context:
space:
mode:
authortpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2011-07-02 06:40:27 +0000
committertpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2011-07-02 06:40:27 +0000
commit2595a15ebeb6fc46b7cb241d01ec0c2460ec2111 (patch)
tree18a8f0f4ac5a86dacfa74c3537551ec39bc85e75 /src/newstuff/manager.cpp
parent1d90725a4001fab9d3922b2cbcceeee5e2d1686f (diff)
downloadtellico-2595a15ebeb6fc46b7cb241d01ec0c2460ec2111.tar.gz
tellico-2595a15ebeb6fc46b7cb241d01ec0c2460ec2111.zip
TQt4 port tellico
This enables compilation under both Qt3 and Qt4 git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/applications/tellico@1239054 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'src/newstuff/manager.cpp')
-rw-r--r--src/newstuff/manager.cpp170
1 files changed, 85 insertions, 85 deletions
diff --git a/src/newstuff/manager.cpp b/src/newstuff/manager.cpp
index 3b7efbf..01d9932 100644
--- a/src/newstuff/manager.cpp
+++ b/src/newstuff/manager.cpp
@@ -31,18 +31,18 @@
#include <knewstuff/entry.h>
#include <kstandarddirs.h>
-#include <qfileinfo.h>
-#include <qdir.h>
-#include <qptrstack.h>
-#include <qvaluestack.h>
-#include <qwidget.h>
+#include <tqfileinfo.h>
+#include <tqdir.h>
+#include <tqptrstack.h>
+#include <tqvaluestack.h>
+#include <tqwidget.h>
#include <sys/types.h>
#include <sys/stat.h>
using Tellico::NewStuff::Manager;
-Manager::Manager(QObject* parent_) : QObject(parent_), m_tempFile(0) {
+Manager::Manager(TQObject* tqparent_) : TQObject(tqparent_), m_tempFile(0) {
m_infoList.setAutoDelete(true);
}
@@ -51,11 +51,11 @@ Manager::~Manager() {
m_tempFile = 0;
}
-bool Manager::installTemplate(const KURL& url_, const QString& entryName_) {
+bool Manager::installTemplate(const KURL& url_, const TQString& entryName_) {
FileHandler::FileRef* ref = FileHandler::fileRef(url_);
- QString xslFile;
- QStringList allFiles;
+ TQString xslFile;
+ TQStringList allFiles;
bool success = true;
@@ -64,23 +64,23 @@ bool Manager::installTemplate(const KURL& url_, const QString& entryName_) {
KTar archive(ref->fileName());
if(archive.open(IO_ReadOnly)) {
const KArchiveDirectory* archiveDir = archive.directory();
- archiveDir->copyTo(Tellico::saveLocation(QString::fromLatin1("entry-templates/")));
+ archiveDir->copyTo(Tellico::saveLocation(TQString::tqfromLatin1("entry-templates/")));
allFiles = archiveFiles(archiveDir);
// remember files installed for template
xslFile = findXSL(archiveDir);
} else { // assume it's an xsl file
- QString name = entryName_;
+ TQString name = entryName_;
if(name.isEmpty()) {
name = url_.fileName();
}
- if(!name.endsWith(QString::fromLatin1(".xsl"))) {
- name += QString::fromLatin1(".xsl");
+ if(!name.endsWith(TQString::tqfromLatin1(".xsl"))) {
+ name += TQString::tqfromLatin1(".xsl");
}
KURL dest;
- dest.setPath(Tellico::saveLocation(QString::fromLatin1("entry-templates/")) + name);
+ dest.setPath(Tellico::saveLocation(TQString::tqfromLatin1("entry-templates/")) + name);
success = true;
- if(QFile::exists(dest.path())) {
+ if(TQFile::exists(dest.path())) {
myDebug() << "Manager::installTemplate() - " << dest.path() << " exists!" << endl;
success = false;
} else if(KIO::NetAccess::file_copy(url_, dest)) {
@@ -105,9 +105,9 @@ bool Manager::installTemplate(const KURL& url_, const QString& entryName_) {
return success;
}
-bool Manager::removeTemplate(const QString& name_) {
+bool Manager::removeTemplate(const TQString& name_) {
KConfigGroup fileGroup(KGlobal::config(), "KNewStuffFiles");
- QStringList files = fileGroup.readListEntry(name_);
+ TQStringList files = fileGroup.readListEntry(name_);
// at least, delete xsl file
if(files.isEmpty()) {
kdWarning() << "Manager::deleteTemplate() no file list found for " << name_ << endl;
@@ -115,13 +115,13 @@ bool Manager::removeTemplate(const QString& name_) {
}
bool success = true;
- QString path = Tellico::saveLocation(QString::fromLatin1("entry-templates/"));
- for(QStringList::ConstIterator it = files.begin(); it != files.end(); ++it) {
- if((*it).endsWith(QChar('/'))) {
+ TQString path = Tellico::saveLocation(TQString::tqfromLatin1("entry-templates/"));
+ for(TQStringList::ConstIterator it = files.begin(); it != files.end(); ++it) {
+ if((*it).endsWith(TQChar('/'))) {
// ok to not delete all directories
- QDir().rmdir(path + *it);
+ TQDir().rmdir(path + *it);
} else {
- success = success && QFile(path + *it).remove();
+ success = success && TQFile(path + *it).remove();
if(!success) {
myDebug() << "Manager::removeTemplate() - failed to remove " << (path+*it) << endl;
}
@@ -130,8 +130,8 @@ bool Manager::removeTemplate(const QString& name_) {
// remove config entries even if unsuccessful
fileGroup.deleteEntry(name_);
- KConfigGroup statusGroup(KGlobal::config(), "KNewStuffStatus");
- QString entryName = statusGroup.readEntry(name_);
+ KConfigGroup statusGroup(KGlobal::config(), "KNewStufftqStatus");
+ TQString entryName = statusGroup.readEntry(name_);
statusGroup.deleteEntry(name_);
statusGroup.deleteEntry(entryName);
@@ -149,24 +149,24 @@ bool Manager::installScript(const KURL& url_) {
const KArchiveDirectory* archiveDir = archive.directory();
- QString exeFile = findEXE(archiveDir);
+ TQString exeFile = findEXE(archiveDir);
if(exeFile.isEmpty()) {
myDebug() << "Manager::installScript() - no exe file found" << endl;
return false;
}
- QFileInfo exeInfo(exeFile);
+ TQFileInfo exeInfo(exeFile);
DataSourceInfo* info = new DataSourceInfo();
- QString copyTarget = Tellico::saveLocation(QString::fromLatin1("data-sources/"));
- QString scriptFolder;
+ TQString copyTarget = Tellico::saveLocation(TQString::tqfromLatin1("data-sources/"));
+ TQString scriptFolder;
// package could have a top-level directory or not
// it should have a directory...
const KArchiveEntry* firstEntry = archiveDir->entry(archiveDir->entries().first());
if(firstEntry->isFile()) {
copyTarget += exeInfo.baseName(true) + '/';
- if(QFile::exists(copyTarget)) {
+ if(TQFile::exists(copyTarget)) {
KURL u;
u.setPath(scriptFolder);
myLog() << "Manager::installScript() - deleting " << scriptFolder << endl;
@@ -176,7 +176,7 @@ bool Manager::installScript(const KURL& url_) {
scriptFolder = copyTarget;
} else {
scriptFolder = copyTarget + firstEntry->name() + '/';
- if(QFile::exists(copyTarget + exeFile)) {
+ if(TQFile::exists(copyTarget + exeFile)) {
info->isUpdate = true;
}
}
@@ -185,7 +185,7 @@ bool Manager::installScript(const KURL& url_) {
archiveDir->copyTo(copyTarget);
info->specFile = scriptFolder + exeInfo.baseName(true) + ".spec";
- if(!QFile::exists(info->specFile)) {
+ if(!TQFile::exists(info->specFile)) {
myDebug() << "Manager::installScript() - no spec file for script! " << info->specFile << endl;
delete info;
return false;
@@ -197,7 +197,7 @@ bool Manager::installScript(const KURL& url_) {
KURL dest;
dest.setPath(info->sourceExec);
KFileItem item(KFileItem::Unknown, KFileItem::Unknown, dest, true);
- ::chmod(QFile::encodeName(dest.path()), item.permissions() | S_IXUSR);
+ ::chmod(TQFile::encodeName(dest.path()), item.permissions() | S_IXUSR);
{
KConfig spec(info->specFile, false, false);
@@ -224,18 +224,18 @@ bool Manager::installScript(const KURL& url_) {
return true;
}
-bool Manager::removeScript(const QString& name_) {
+bool Manager::removeScript(const TQString& name_) {
KConfigGroup fileGroup(KGlobal::config(), "KNewStuffFiles");
- QStringList files = fileGroup.readListEntry(name_);
+ TQStringList files = fileGroup.readListEntry(name_);
bool success = true;
- QString path = Tellico::saveLocation(QString::fromLatin1("data-sources/"));
- for(QStringList::ConstIterator it = files.begin(); it != files.end(); ++it) {
- if((*it).endsWith(QChar('/'))) {
+ TQString path = Tellico::saveLocation(TQString::tqfromLatin1("data-sources/"));
+ for(TQStringList::ConstIterator it = files.begin(); it != files.end(); ++it) {
+ if((*it).endsWith(TQChar('/'))) {
// ok to not delete all directories
- QDir().rmdir(path + *it);
+ TQDir().rmdir(path + *it);
} else {
- success = success && QFile(path + *it).remove();
+ success = success && TQFile(path + *it).remove();
if(!success) {
myDebug() << "Manager::removeScript() - failed to remove " << (path+*it) << endl;
}
@@ -244,22 +244,22 @@ bool Manager::removeScript(const QString& name_) {
// remove config entries even if unsuccessful
fileGroup.deleteEntry(name_);
- KConfigGroup statusGroup(KGlobal::config(), "KNewStuffStatus");
- QString entryName = statusGroup.readEntry(name_);
+ KConfigGroup statusGroup(KGlobal::config(), "KNewStufftqStatus");
+ TQString entryName = statusGroup.readEntry(name_);
statusGroup.deleteEntry(name_);
statusGroup.deleteEntry(entryName);
return success;
}
-Tellico::NewStuff::InstallStatus Manager::installStatus(KNS::Entry* entry_) {
- KConfigGroup config(KGlobal::config(), "KNewStuffStatus");
- QString datestring = config.readEntry(entry_->name());
+Tellico::NewStuff::InstalltqStatus Manager::installtqStatus(KNS::Entry* entry_) {
+ KConfigGroup config(KGlobal::config(), "KNewStufftqStatus");
+ TQString datestring = config.readEntry(entry_->name());
if(datestring.isEmpty()) {
return NotInstalled;
}
- QDate date = QDate::fromString(datestring, Qt::ISODate);
+ TQDate date = TQDate::fromString(datestring, Qt::ISODate);
if(!date.isValid()) {
return NotInstalled;
}
@@ -269,22 +269,22 @@ Tellico::NewStuff::InstallStatus Manager::installStatus(KNS::Entry* entry_) {
// also check that executable files exists
KConfigGroup fileGroup(KGlobal::config(), "KNewStuffFiles");
- QStringList files = fileGroup.readListEntry(entry_->name());
- QString path = Tellico::saveLocation(QString::fromLatin1("data-sources/"));
- for(QStringList::ConstIterator it = files.begin(); it != files.end(); ++it) {
- if(!QFile::exists(path + *it)) {
+ TQStringList files = fileGroup.readListEntry(entry_->name());
+ TQString path = Tellico::saveLocation(TQString::tqfromLatin1("data-sources/"));
+ for(TQStringList::ConstIterator it = files.begin(); it != files.end(); ++it) {
+ if(!TQFile::exists(path + *it)) {
return NotInstalled;
}
}
return Current;
}
-QStringList Manager::archiveFiles(const KArchiveDirectory* dir_, const QString& path_) {
- QStringList list;
+TQStringList Manager::archiveFiles(const KArchiveDirectory* dir_, const TQString& path_) {
+ TQStringList list;
- const QStringList dirEntries = dir_->entries();
- for(QStringList::ConstIterator it = dirEntries.begin(); it != dirEntries.end(); ++it) {
- const QString& entry = *it;
+ const TQStringList dirEntries = dir_->entries();
+ for(TQStringList::ConstIterator it = dirEntries.begin(); it != dirEntries.end(); ++it) {
+ const TQString& entry = *it;
const KArchiveEntry* curEntry = dir_->entry(entry);
if(curEntry->isFile()) {
list += path_ + entry;
@@ -299,30 +299,30 @@ QStringList Manager::archiveFiles(const KArchiveDirectory* dir_, const QString&
}
// don't recurse, the .xsl must be in top directory
-QString Manager::findXSL(const KArchiveDirectory* dir_) {
- const QStringList entries = dir_->entries();
- for(QStringList::ConstIterator it = entries.begin(); it != entries.end(); ++it) {
- const QString& entry = *it;
- if(entry.endsWith(QString::fromLatin1(".xsl"))) {
+TQString Manager::findXSL(const KArchiveDirectory* dir_) {
+ const TQStringList entries = dir_->entries();
+ for(TQStringList::ConstIterator it = entries.begin(); it != entries.end(); ++it) {
+ const TQString& entry = *it;
+ if(entry.endsWith(TQString::tqfromLatin1(".xsl"))) {
return entry;
}
}
- return QString();
+ return TQString();
}
-QString Manager::findEXE(const KArchiveDirectory* dir_) {
- QPtrStack<KArchiveDirectory> dirStack;
- QValueStack<QString> dirNameStack;
+TQString Manager::findEXE(const KArchiveDirectory* dir_) {
+ TQPtrStack<KArchiveDirectory> dirStack;
+ TQValueStack<TQString> dirNameStack;
dirStack.push(dir_);
- dirNameStack.push(QString());
+ dirNameStack.push(TQString());
do {
- const QString dirName = dirNameStack.pop();
+ const TQString dirName = dirNameStack.pop();
const KArchiveDirectory* curDir = dirStack.pop();
- const QStringList entries = curDir->entries();
- for(QStringList::ConstIterator it = entries.begin(); it != entries.end(); ++it) {
- const QString& entry = *it;
+ const TQStringList entries = curDir->entries();
+ for(TQStringList::ConstIterator it = entries.begin(); it != entries.end(); ++it) {
+ const TQString& entry = *it;
const KArchiveEntry* archEntry = curDir->entry(entry);
if(archEntry->isFile() && (archEntry->permissions() & S_IEXEC)) {
@@ -334,7 +334,7 @@ QString Manager::findEXE(const KArchiveDirectory* dir_) {
}
} while(!dirStack.isEmpty());
- return QString();
+ return TQString();
}
void Manager::install(DataType type_, KNS::Entry* entry_) {
@@ -347,14 +347,14 @@ void Manager::install(DataType type_, KNS::Entry* entry_) {
KURL destination;
destination.setPath(m_tempFile->name());
KIO::FileCopyJob* job = KIO::file_copy(entry_->payload(), destination, -1, true);
- connect(job, SIGNAL(result(KIO::Job*)), SLOT(slotDownloadJobResult(KIO::Job*)));
+ connect(job, TQT_SIGNAL(result(KIO::Job*)), TQT_SLOT(slotDownloadJobResult(KIO::Job*)));
m_jobMap.insert(job, EntryPair(entry_, type_));
}
void Manager::slotDownloadJobResult(KIO::Job* job_) {
KIO::FileCopyJob* job = static_cast<KIO::FileCopyJob*>(job_);
if(job->error()) {
- GUI::CursorSaver cs(Qt::arrowCursor);
+ GUI::CursorSaver cs(TQt::arrowCursor);
delete m_tempFile;
m_tempFile = 0;
job->showErrorDialog(Kernel::self()->widget());
@@ -372,7 +372,7 @@ void Manager::slotDownloadJobResult(KIO::Job* job_) {
#if KDE_IS_VERSION(3,3,90)
// needed so the GPG signature can be checked
NewScript* newScript = new NewScript(this, Kernel::self()->widget());
- connect(newScript, SIGNAL(installFinished()), this, SLOT(slotInstallFinished()));
+ connect(newScript, TQT_SIGNAL(installFinished()), this, TQT_SLOT(slotInstallFinished()));
// need to delete temp file if install was not a success
// if it was a success, it gets deleted later
deleteTempFile = !newScript->install(job->destURL().path());
@@ -390,16 +390,16 @@ void Manager::slotDownloadJobResult(KIO::Job* job_) {
}
void Manager::slotInstallFinished() {
- const NewScript* newScript = ::qt_cast<const NewScript*>(sender());
+ const NewScript* newScript = ::tqqt_cast<const NewScript*>(sender());
if(newScript && newScript->successfulInstall()) {
- const QString name = m_urlNameMap[newScript->url()];
+ const TQString name = m_urlNameMap[newScript->url()];
KNS::Entry* entry = m_scriptEntryMap[newScript];
- KConfigGroup config(KGlobal::config(), "KNewStuffStatus");
+ KConfigGroup config(KGlobal::config(), "KNewStufftqStatus");
// have to keep a config entry that maps the name of the file to the name
// of the newstuff entry, so we can track which entries are installed
// name and entry-name() are probably the same for scripts, but not a problem
config.writeEntry(name, entry->name());
- config.writeEntry(entry->name(), entry->releaseDate().toString(Qt::ISODate));
+ config.writeEntry(entry->name(), TQString(entry->releaseDate().toString(Qt::ISODate)));
config.sync();
emit signalInstalled(entry);
} else {
@@ -413,32 +413,32 @@ void Manager::slotInstallFinished() {
bool Manager::checkCommonFile() {
// look for a file that gets installed to know the installation directory
// need to check timestamps
- QString userDataDir = Tellico::saveLocation(QString::null);
- QString userCommonFile = userDataDir + '/' + QString::fromLatin1("tellico-common.xsl");
- if(QFile::exists(userCommonFile)) {
+ TQString userDataDir = Tellico::saveLocation(TQString());
+ TQString userCommonFile = userDataDir + '/' + TQString::tqfromLatin1("tellico-common.xsl");
+ if(TQFile::exists(userCommonFile)) {
// check timestamps
// pics/tellico.png is not likely to be in a user directory
- QString installDir = KGlobal::dirs()->findResourceDir("appdata", QString::fromLatin1("pics/tellico.png"));
- QString installCommonFile = installDir + '/' + QString::fromLatin1("tellico-common.xsl");
+ TQString installDir = KGlobal::dirs()->findResourceDir("appdata", TQString::tqfromLatin1("pics/tellico.png"));
+ TQString installCommonFile = installDir + '/' + TQString::tqfromLatin1("tellico-common.xsl");
#ifndef NDEBUG
if(userCommonFile == installCommonFile) {
kdWarning() << "Manager::checkCommonFile() - install location is same as user location" << endl;
}
#endif
- QFileInfo installInfo(installCommonFile);
- QFileInfo userInfo(userCommonFile);
+ TQFileInfo installInfo(installCommonFile);
+ TQFileInfo userInfo(userCommonFile);
if(installInfo.lastModified() > userInfo.lastModified()) {
// the installed file has been modified more recently than the user's
// remove user's tellico-common.xsl file so it gets copied again
myLog() << "Manager::checkCommonFile() - removing " << userCommonFile << endl;
myLog() << "Manager::checkCommonFile() - copying " << installCommonFile << endl;
- QFile::remove(userCommonFile);
+ TQFile::remove(userCommonFile);
} else {
return true;
}
}
KURL src, dest;
- src.setPath(KGlobal::dirs()->findResource("appdata", QString::fromLatin1("tellico-common.xsl")));
+ src.setPath(KGlobal::dirs()->findResource("appdata", TQString::tqfromLatin1("tellico-common.xsl")));
dest.setPath(userCommonFile);
return KIO::NetAccess::file_copy(src, dest);
}