summaryrefslogtreecommitdiffstats
path: root/src/parsers/list.cpp
diff options
context:
space:
mode:
authortpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2010-02-10 20:23:29 +0000
committertpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2010-02-10 20:23:29 +0000
commitea4406b4779306f4d0c65f0619cd8241bbdcef7b (patch)
treea63d24ddd768559eb993d9bb847acbc3750ef261 /src/parsers/list.cpp
downloadtdeio-apt-ea4406b4779306f4d0c65f0619cd8241bbdcef7b.tar.gz
tdeio-apt-ea4406b4779306f4d0c65f0619cd8241bbdcef7b.zip
Added abandoned version of kio-apt
git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/applications/kio-apt@1088432 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'src/parsers/list.cpp')
-rw-r--r--src/parsers/list.cpp69
1 files changed, 69 insertions, 0 deletions
diff --git a/src/parsers/list.cpp b/src/parsers/list.cpp
new file mode 100644
index 0000000..afaac7f
--- /dev/null
+++ b/src/parsers/list.cpp
@@ -0,0 +1,69 @@
+/***************************************************************************
+ * Copyright (C) 2003 by Sylvain Joyeux *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ ***************************************************************************/
+
+#include "parsers.h"
+#include "../apt.h"
+
+#include <kio/slavebase.h>
+#include <klocale.h>
+#include <qregexp.h>
+#include <kurl.h>
+
+namespace Parsers
+{
+ List::List(bool links)
+ : m_links(links) {}
+
+ /** Parses the tokens sent by PackageManager::list */
+ void List::operator() (AptProtocol* slave, const QString& tag, const QString& value )
+ {
+ static QRegExp rx_manpage("/man/.*\\.\\d[^/]*$");
+
+ static QStringList files;
+
+ if (tag == "begin")
+ {
+ m_result_count = 0;
+ }
+ else if (tag == "error")
+ {
+ *slave << "<div class=\"error\">" + value + "</div>";
+ }
+ else if (tag == "file" && value != "/.")
+ {
+ if (m_links)
+ {
+ KURL url;
+ if (rx_manpage.search(value) >= 0)
+ url.setProtocol("man");
+ else
+ url.setProtocol("file");
+
+ url.setPath(value);
+
+ files += "<a href=\"" + url.htmlURL() + "\">" + value + "</a>";
+ }
+ else
+ {
+ files += value;
+ }
+
+ ++m_result_count;
+ }
+ else if (tag == "end")
+ {
+ files.sort();
+ *slave <<
+ "<div class=\"filelist\">\n" + files.join("\n<br>") + "\n</div>\n"
+ "<div class=\"footer\">" + i18n("%1 files in the package").arg(result_count()) + "</div>\n";
+ files.clear();
+ }
+ }
+}