diff options
author | tpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2011-07-01 03:43:07 +0000 |
---|---|---|
committer | tpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2011-07-01 03:43:07 +0000 |
commit | 70b9eea2ba01c3691497f49e4c45cb070c16193c (patch) | |
tree | 9a6df61aa247a27275aad9c5245e419e89c2c640 /kradio3/src/stationlist.cpp | |
parent | 998c1384ace4ae4655997c181fa33242148cd0a4 (diff) | |
download | tderadio-70b9eea2ba01c3691497f49e4c45cb070c16193c.tar.gz tderadio-70b9eea2ba01c3691497f49e4c45cb070c16193c.zip |
TQt4 port kradio
This enables compilation under both Qt3 and Qt4
git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/applications/kradio@1238952 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'kradio3/src/stationlist.cpp')
-rw-r--r-- | kradio3/src/stationlist.cpp | 132 |
1 files changed, 66 insertions, 66 deletions
diff --git a/kradio3/src/stationlist.cpp b/kradio3/src/stationlist.cpp index f0f0ace..737fd72 100644 --- a/kradio3/src/stationlist.cpp +++ b/kradio3/src/stationlist.cpp @@ -22,10 +22,10 @@ #include "include/stationlistxmlhandler.h" #include "include/kradioversion.h" -#include <qstring.h> -#include <qfile.h> -#include <qiodevice.h> -#include <qmessagebox.h> +#include <tqstring.h> +#include <tqfile.h> +#include <tqiodevice.h> +#include <tqmessagebox.h> #include <kio/netaccess.h> #include <ktempfile.h> #include <klocale.h> @@ -43,7 +43,7 @@ RawStationList::RawStationList () RawStationList::RawStationList (const RawStationList &sl) - : QPtrList<RadioStation>(sl) + : TQPtrList<RadioStation>(sl) { setAutoDelete(true); } @@ -55,7 +55,7 @@ RawStationList::~RawStationList () } -QPtrCollection::Item RawStationList::newItem (QPtrCollection::Item s) +TQPtrCollection::Item RawStationList::newItem (TQPtrCollection::Item s) { if (s) return ((RadioStation*)s)->copy(); @@ -64,14 +64,14 @@ QPtrCollection::Item RawStationList::newItem (QPtrCollection::Item s) } -void RawStationList::deleteItem (QPtrCollection::Item s) +void RawStationList::deleteItem (TQPtrCollection::Item s) { if (autoDelete()) delete (RadioStation*)s; } -int RawStationList::compareItems(QPtrCollection::Item a, QPtrCollection::Item b) +int RawStationList::compareItems(TQPtrCollection::Item a, TQPtrCollection::Item b) { if (!a && !b) return 0; @@ -104,7 +104,7 @@ bool RawStationList::insert (const RadioStation * item ) if (!item) return false; int idx = idxWithID(item->stationID()); if (idx >= 0) { - return replace(idx, item); + return tqreplace(idx, item); } else { append(item); return true; @@ -145,11 +145,11 @@ void RawStationList::append ( const RadioStation * item ) } -bool RawStationList::replace ( uint index, const RadioStation * item ) +bool RawStationList::tqreplace ( uint index, const RadioStation * item ) { bool r = true; RadioStation *rs = &stationWithID(item->stationID()); - r = BaseClass::replace(index, item); + r = BaseClass::tqreplace(index, item); if (rs != item) { BaseClass::removeRef(rs); } @@ -157,7 +157,7 @@ bool RawStationList::replace ( uint index, const RadioStation * item ) } -const RadioStation &RawStationList::stationWithID(const QString &sid) const +const RadioStation &RawStationList::stationWithID(const TQString &sid) const { Iterator it(*this); for (; const RadioStation *s = it.current(); ++it) { @@ -168,7 +168,7 @@ const RadioStation &RawStationList::stationWithID(const QString &sid) const } -RadioStation &RawStationList::stationWithID(const QString &sid) +RadioStation &RawStationList::stationWithID(const TQString &sid) { Iterator it(*this); for (; RadioStation *s = it.current(); ++it) { @@ -180,7 +180,7 @@ RadioStation &RawStationList::stationWithID(const QString &sid) -int RawStationList::idxWithID(const QString &sid) const +int RawStationList::idxWithID(const TQString &sid) const { int i = 0; Iterator it(*this); @@ -194,8 +194,8 @@ int RawStationList::idxWithID(const QString &sid) const bool RawStationList::operator == (const RawStationList &l) const { - QPtrListIterator<RadioStation> it1(*this); - QPtrListIterator<RadioStation> it2(l); + TQPtrListIterator<RadioStation> it1(*this); + TQPtrListIterator<RadioStation> it2(l); if (count() != l.count()) return false; for (; it1.current() && it2.current(); ++it1, ++it2) { @@ -235,29 +235,29 @@ void StationList::merge(const StationList & other) if (! m_metaData.comment.isEmpty()) m_metaData.comment += "\n"; - m_metaData.lastChange = QDateTime::currentDateTime(); + m_metaData.lastChange = TQDateTime::tqcurrentDateTime(); if (!metaData.maintainer.isEmpty()) - m_metaData.maintainer += (count() ? QString(" / ") : QString::null) + metaData.maintainer; + m_metaData.maintainer += (count() ? TQString(" / ") : TQString()) + metaData.maintainer; if (!metaData.country.isEmpty()) - m_metaData.country += (count() ? QString(" / ") : QString::null) + metaData.country; + m_metaData.country += (count() ? TQString(" / ") : TQString()) + metaData.country; if (!metaData.city.isEmpty()) - m_metaData.city = (count() ? QString(" / ") : QString::null) + metaData.city; + m_metaData.city = (count() ? TQString(" / ") : TQString()) + metaData.city; if (!metaData.media.isEmpty()) - m_metaData.media += (count() ? QString(" / ") : QString::null) + metaData.media; + m_metaData.media += (count() ? TQString(" / ") : TQString()) + metaData.media; if (!metaData.comment.isEmpty()) - m_metaData.comment += (count() ? QString(" / ") : QString::null) + metaData.comment; + m_metaData.comment += (count() ? TQString(" / ") : TQString()) + metaData.comment; if (count() && other.count()) m_metaData.comment += " " + i18n("Contains merged Data"); // merge stations - QPtrListIterator<RadioStation> it(other.all()); + TQPtrListIterator<RadioStation> it(other.all()); for (RadioStation *s = it.current(); s; s = ++it) { m_all.insert(s); } @@ -289,29 +289,29 @@ RadioStation &StationList::at(int idx) } -const RadioStation &StationList::stationWithID(const QString &sid) const +const RadioStation &StationList::stationWithID(const TQString &sid) const { return m_all.stationWithID(sid); } -RadioStation &StationList::stationWithID(const QString &sid) +RadioStation &StationList::stationWithID(const TQString &sid) { return m_all.stationWithID(sid); } -bool StationList::readXML (const QString &dat, const IErrorLogClient &logger, bool enableMessageBox) +bool StationList::readXML (const TQString &dat, const IErrorLogClient &logger, bool enableMessageBox) { // FIXME: TODO: error handling - QXmlInputSource source; + TQXmlInputSource source; source.setData(dat); - QXmlSimpleReader reader; + TQXmlSimpleReader reader; StationListXmlHandler handler(logger); reader.setContentHandler (&handler); if (reader.parse(source)) { if (handler.wasCompatMode() && enableMessageBox) { - QMessageBox::information(NULL, "KRadio", + TQMessageBox::information(NULL, "KRadio", i18n("Probably an old station preset file was read.\n" "You have to rebuild your station selections for " "the quickbar and the docking menu.") @@ -325,7 +325,7 @@ bool StationList::readXML (const QString &dat, const IErrorLogClient &logger, bo logger.logError("StationList::readXML: " + i18n("parsing failed")); if (enableMessageBox) { - QMessageBox::warning(NULL, "KRadio", + TQMessageBox::warning(NULL, "KRadio", i18n("Parsing the station preset file failed.\n" "See console output for more details.")); } @@ -336,17 +336,17 @@ bool StationList::readXML (const QString &dat, const IErrorLogClient &logger, bo bool StationList::readXML (const KURL &url, const IErrorLogClient &logger, bool enableMessageBox) { - QString tmpfile; + TQString tmpfile; if (!KIO::NetAccess::download(url, tmpfile, NULL)) { if (enableMessageBox) { logger.logError("StationList::readXML: " + - i18n("error downloading preset file %1").arg(url.url())); - QMessageBox::warning(NULL, "KRadio", + i18n("error downloading preset file %1").tqarg(url.url())); + TQMessageBox::warning(NULL, "KRadio", i18n("Download of the station preset file at %1 failed.") - .arg(url.url())); + .tqarg(url.url())); } else { logger.logWarning("StationList::readXML: " + - i18n("error downloading preset file %1").arg(url.url())); + i18n("error downloading preset file %1").tqarg(url.url())); } return false; } @@ -354,40 +354,40 @@ bool StationList::readXML (const KURL &url, const IErrorLogClient &logger, bool logger.logDebug("StationList::readXML: " + i18n("temporary file: ") + tmpfile); - QFile presetFile (tmpfile); + TQFile presetFile (tmpfile); if (! presetFile.open(IO_ReadOnly)) { logger.logError("StationList::readXML: " + - i18n("error opening preset file %1").arg(tmpfile)); + i18n("error opening preset file %1").tqarg(tmpfile)); if (enableMessageBox) { - QMessageBox::warning(NULL, "KRadio", + TQMessageBox::warning(NULL, "KRadio", i18n("Opening of the station preset file at %1 failed.") - .arg(tmpfile)); + .tqarg(tmpfile)); } return false; } - QString xmlData; + TQString xmlData; // make sure that qtextstream is gone when we close presetFile - QString tmp; + TQString tmp; { - QTextStream ins(&presetFile); + TQTextStream ins(&presetFile); tmp = ins.read(); } presetFile.reset(); // preset file written with kradio <= 0.2.x - if (tmp.find("<format>") < 0) { + if (tmp.tqfind("<format>") < 0) { logger.logInfo(i18n("Old Preset File Format detected")); - QTextStream ins(&presetFile); - ins.setEncoding(QTextStream::Locale); + TQTextStream ins(&presetFile); + ins.setEncoding(TQTextStream::Locale); xmlData = ins.read(); } // preset file written with kradio >= 0.3.0 else { - QXmlInputSource tmp(&presetFile); + TQXmlInputSource tmp(TQT_TQIODEVICE(&presetFile)); xmlData = tmp.data(); } @@ -399,15 +399,15 @@ bool StationList::readXML (const KURL &url, const IErrorLogClient &logger, bool } -QString StationList::writeXML (const IErrorLogClient &/*logger*/) const +TQString StationList::writeXML (const IErrorLogClient &/*logger*/) const { - QString data = QString::null; + TQString data = TQString(); // write station list - QString t = "\t"; - QString tt = "\t\t"; - QString ttt = "\t\t\t"; + TQString t = "\t"; + TQString tt = "\t\t"; + TQString ttt = "\t\t\t"; data += xmlOpenTag(KRadioConfigElement) + t + xmlOpenTag(StationListElement) + @@ -427,9 +427,9 @@ QString StationList::writeXML (const IErrorLogClient &/*logger*/) const data += tt + xmlOpenTag (s->getClassName()); - QStringList properties = s->getPropertyNames(); - QStringList::iterator end = properties.end(); - for (QStringList::iterator sit = properties.begin(); sit != end; ++sit) { + TQStringList properties = s->getPropertyNames(); + TQStringList::iterator end = properties.end(); + for (TQStringList::iterator sit = properties.begin(); sit != end; ++sit) { data += ttt + xmlTag (*sit, s->getProperty(*sit)); } data += tt + xmlCloseTag(s->getClassName()); @@ -447,22 +447,22 @@ bool StationList::writeXML (const KURL &url, const IErrorLogClient &logger, bool { KTempFile tmpFile; tmpFile.setAutoDelete(true); - QFile *outf = tmpFile.file(); + TQFile *outf = tmpFile.file(); - QTextStream outs(outf); - outs.setEncoding(QTextStream::UnicodeUTF8); + TQTextStream outs(outf); + outs.setEncoding(TQTextStream::UnicodeUTF8); outs << "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" << endl; - QString output = writeXML(logger); + TQString output = writeXML(logger); outs << output; if (outf->status() != IO_Ok) { logger.logError("StationList::writeXML: " + - i18n("error writing to tempfile %1").arg(tmpFile.name())); + i18n("error writing to tempfile %1").tqarg(tmpFile.name())); if (enableMessageBox) { - QMessageBox::warning(NULL, "KRadio", + TQMessageBox::warning(NULL, "KRadio", i18n("Writing station preset file %1 failed.") - .arg(tmpFile.name())); + .tqarg(tmpFile.name())); } return false; } @@ -472,19 +472,19 @@ bool StationList::writeXML (const KURL &url, const IErrorLogClient &logger, bool if (count() <= 1) { logger.logWarning("StationList::writeXML: " + - i18n("uploading preset file %1: ").arg(url.url())); + i18n("uploading preset file %1: ").tqarg(url.url())); logger.logWarning("StationList::writeXML: " + - i18n("something strange happend, station list has only %1 entries. Writing station preset file skipped").arg(count())); + i18n("something strange happend, station list has only %1 entries. Writing station preset file skipped").tqarg(count())); } else { if (!KIO::NetAccess::upload(tmpFile.name(), url, NULL)) { logger.logError("StationList::writeXML: " + - i18n("error uploading preset file %1").arg(url.url())); + i18n("error uploading preset file %1").tqarg(url.url())); if (enableMessageBox) { - QMessageBox::warning(NULL, "KRadio", + TQMessageBox::warning(NULL, "KRadio", i18n("Upload of station preset file to %1 failed.") - .arg(url.url())); + .tqarg(url.url())); } return false; } |