diff options
author | tpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2011-07-04 21:38:25 +0000 |
---|---|---|
committer | tpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2011-07-04 21:38:25 +0000 |
commit | f22f5c856d0ee7ec953825828bba094f14c9cade (patch) | |
tree | 1c89a4d4c420bce13c002b650e610bff026f6d06 /src/aptcache.cpp | |
parent | 0bceb5251f3c826f8fc4ee021ab76ee29f1dfdd7 (diff) | |
download | tdeio-apt-f22f5c856d0ee7ec953825828bba094f14c9cade.tar.gz tdeio-apt-f22f5c856d0ee7ec953825828bba094f14c9cade.zip |
TQt4 port kio-apt
This enables compilation under both Qt3 and Qt4
git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/applications/kio-apt@1239302 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'src/aptcache.cpp')
-rw-r--r-- | src/aptcache.cpp | 94 |
1 files changed, 47 insertions, 47 deletions
diff --git a/src/aptcache.cpp b/src/aptcache.cpp index 9511760..ec5342f 100644 --- a/src/aptcache.cpp +++ b/src/aptcache.cpp @@ -13,8 +13,8 @@ #include "regexps.h" -#include <qstringlist.h> -#include <qregexp.h> +#include <tqstringlist.h> +#include <tqregexp.h> #include <kdebug.h> @@ -25,20 +25,20 @@ AptCache::AptCache() { - connect(&m_process, SIGNAL(receivedStderr(KProcess*, char*, int)), - this, SLOT(receivedStdErr(KProcess*, char*, int ))); - connect(&m_process, SIGNAL(receivedStdout(KProcess*, char*, int)), - this, SLOT(receivedStdOut(KProcess*, char*, int ))); + connect(&m_process, TQT_SIGNAL(receivedStderr(KProcess*, char*, int)), + this, TQT_SLOT(receivedStdErr(KProcess*, char*, int ))); + connect(&m_process, TQT_SIGNAL(receivedStdout(KProcess*, char*, int)), + this, TQT_SLOT(receivedStdOut(KProcess*, char*, int ))); } AptCache::~AptCache() {} -static QStringList received(QString& buffer, char* input, int input_len) +static TQStringList received(TQString& buffer, char* input, int input_len) { - buffer += QString::fromLatin1(input, input_len); - QStringList ret = QStringList::split('\n', buffer, true); + buffer += TQString::tqfromLatin1(input, input_len); + TQStringList ret = TQStringList::split('\n', buffer, true); if (!buffer.endsWith("\n")) { buffer = ret.last(); @@ -51,10 +51,10 @@ static QStringList received(QString& buffer, char* input, int input_len) } void AptCache::receivedStdErr( KProcess * /*process*/, char * buffer, int len ) { - static QRegExp rx_we("(W|E):\\s+(.*)"); + static TQRegExp rx_we("(W|E):\\s+(.*)"); - QStringList lines = received(m_received_err, buffer, len); - for (QStringList::ConstIterator i = lines.begin(); i != lines.end(); ++i) + TQStringList lines = received(m_received_err, buffer, len); + for (TQStringList::ConstIterator i = lines.begin(); i != lines.end(); ++i) { if (rx_we.exactMatch(*i)) { @@ -69,7 +69,7 @@ void AptCache::receivedStdErr( KProcess * /*process*/, char * buffer, int len ) } void AptCache::receivedStdOut( KProcess * /*process*/, char * buffer, int len ) { - QStringList lines = received(m_received_out, buffer, len); + TQStringList lines = received(m_received_out, buffer, len); (this->*m_receive)(lines); } @@ -84,22 +84,22 @@ void AptCache::clear() m_received_out = ""; } -bool AptCache::search(const QString& expression) +bool AptCache::search(const TQString& expression) { clear(); m_process.setEnvironment("LANGUAGE", "C"); m_process << "apt-cache" << "search"; - m_process << QStringList::split(" ", expression); + m_process << TQStringList::split(" ", expression); m_receive = &AptCache::receiveSearch; return m_process.start(KProcess::Block, KProcess::Stdout ); } -void AptCache::receiveSearch(const QStringList& lines) +void AptCache::receiveSearch(const TQStringList& lines) { - static QRegExp rx_parse("([^ ]+) - (.*)"); + static TQRegExp rx_parse("([^ ]+) - (.*)"); - QStringList::ConstIterator i; + TQStringList::ConstIterator i; for (i = lines.begin(); i != lines.end(); ++i) { if ((*i).isEmpty()) continue; @@ -117,7 +117,7 @@ void AptCache::receiveSearch(const QStringList& lines) } } -bool AptCache::show(const QString& package) +bool AptCache::show(const TQString& package) { clear(); @@ -127,19 +127,19 @@ bool AptCache::show(const QString& package) return m_process.start(KProcess::Block, KProcess::Stdout ); } -void AptCache::receiveShow(const QStringList& lines) +void AptCache::receiveShow(const TQStringList& lines) { static bool pkgfield = false, insert_newline = false; static int indent = 0; - static QRegExp rx_attribute("([\\w-]+): (.*)"); - static const QString pkg_fields[] = - { "Suggests", "Replaces", "Depends", "Conflicts", QString::null }; + static TQRegExp rx_attribute("([\\w-]+): (.*)"); + static const TQString pkg_fields[] = + { "Suggests", "Replaces", "Depends", "Conflicts", TQString() }; - QStringList::ConstIterator i; + TQStringList::ConstIterator i; for (i = lines.begin(); i != lines.end(); ++i) { - QString data(*i); + TQString data(*i); if (data.isEmpty()) continue; if (rx_attribute.exactMatch(*i)) @@ -153,7 +153,7 @@ void AptCache::receiveShow(const QStringList& lines) insert_newline = pkgfield = false; indent = 0; - const QString * test_field; + const TQString * test_field; for (test_field = pkg_fields; !test_field -> isNull(); ++test_field) if (*test_field == m_attribute) { @@ -168,7 +168,7 @@ void AptCache::receiveShow(const QStringList& lines) parse_pkgfield(data); else { - int new_indent = data.find( QRegExp("[^\\s]") ); + int new_indent = data.tqfind( TQRegExp("[^\\s]") ); // new_indent > 0 means that we are in a multi-line // field. Those lines always begin with " ", so we want @@ -177,7 +177,7 @@ void AptCache::receiveShow(const QStringList& lines) if (new_indent != indent) { - emit token("indent", QString::number(new_indent) ); + emit token("indent", TQString::number(new_indent) ); indent = new_indent; insert_newline = false; } @@ -200,20 +200,20 @@ void AptCache::receiveShow(const QStringList& lines) } } -void AptCache::parse_pkgfield(const QString& data) +void AptCache::parse_pkgfield(const TQString& data) { - QStringList split(QStringList::split(",", data)); - for (QStringList::ConstIterator i = split.begin(); i != split.end(); ++i) + TQStringList split(TQStringList::split(",", data)); + for (TQStringList::ConstIterator i = split.begin(); i != split.end(); ++i) { if (i != split.begin()) emit token("data", ", "); - QStringList bar(QStringList::split("|", *i)); - for (QStringList::ConstIterator j = bar.begin(); j != bar.end(); ++j) + TQStringList bar(TQStringList::split("|", *i)); + for (TQStringList::ConstIterator j = bar.begin(); j != bar.end(); ++j) { if (j != bar.begin()) emit token("data", " | "); - QString pkg, remaining; + TQString pkg, remaining; - int paren = (*j).find('('); + int paren = (*j).tqfind('('); if (paren != -1) { pkg = (*j).left(paren - 1); @@ -233,7 +233,7 @@ void AptCache::parse_pkgfield(const QString& data) } } -bool AptCache::policy( const QString & package ) +bool AptCache::policy( const TQString & package ) { clear(); @@ -243,32 +243,32 @@ bool AptCache::policy( const QString & package ) return m_process.start(KProcess::Block, KProcess::Stdout ); } -void AptCache::receivePolicy(const QStringList& lines) +void AptCache::receivePolicy(const TQStringList& lines) { - static QRegExp rx_pkgname("(\\w[\\w+-.]+):"); - static QRegExp rx_location("^\\s*\\d+\\s[^\\d]"); + static TQRegExp rx_pkgname("(\\w[\\w+-.]+):"); + static TQRegExp rx_location("^\\s*\\d+\\s[^\\d]"); - for(QStringList::ConstIterator l = lines.begin(); l != lines.end(); ++l) + for(TQStringList::ConstIterator l = lines.begin(); l != lines.end(); ++l) { if ((*l).isEmpty()) continue; - QString data( (*l).stripWhiteSpace() ); + TQString data( (*l).stripWhiteSpace() ); if (rx_pkgname.exactMatch(*l)) emit token("package", rx_pkgname.cap(1)); - else if (data.startsWith("Installed:", false)) + else if (data.tqstartsWith("Installed:", false)) { data = data.right(data.length() - 11); emit token("installed", data); m_installed = data; } - else if (data.startsWith("Candidate:", false)) + else if (data.tqstartsWith("Candidate:", false)) { data = data.right(data.length() - 11); emit token("candidate", data); m_candidate = data; } - else if (data.startsWith("Version table:", false)) - emit token("version_table", QString::null); + else if (data.tqstartsWith("Version table:", false)) + emit token("version_table", TQString()); else if (rx_location.search(data) > -1) emit token("location", data); else @@ -282,9 +282,9 @@ void AptCache::receivePolicy(const QStringList& lines) } } -QString AptCache::policy_installed() const +TQString AptCache::policy_installed() const { return m_installed; } -QString AptCache::policy_candidate() const +TQString AptCache::policy_candidate() const { return m_candidate; } |