Commit 76c0acee authored by Lisa's avatar Lisa

Astyle used over this branch

parent 384b7dc1
...@@ -23,11 +23,11 @@ ...@@ -23,11 +23,11 @@
#include <QTimer> #include <QTimer>
OperationManager::OperationManager(APM::OperationType type, APM::OperationName operation, QHash<APM::OptionName, AkabeiOption> options, QStringList args, QObject * parent) OperationManager::OperationManager(APM::OperationType type, APM::OperationName operation, QHash<APM::OptionName, AkabeiOption> options, QStringList args, QObject * parent)
: QObject(parent), : QObject(parent),
m_type(type), m_type(type),
m_operation(operation), m_operation(operation),
m_options(options), m_options(options),
m_args(args) m_args(args)
{ {
//QTimer::singleShot(0, AkabeiClient::Backend::instance(), SLOT(initialize())); //QTimer::singleShot(0, AkabeiClient::Backend::instance(), SLOT(initialize()));
//QCoreApplication::instance()->quit(); //QCoreApplication::instance()->quit();
...@@ -36,7 +36,7 @@ OperationManager::OperationManager(APM::OperationType type, APM::OperationName o ...@@ -36,7 +36,7 @@ OperationManager::OperationManager(APM::OperationType type, APM::OperationName o
QString root; QString root;
QString cache; QString cache;
QString dbs; QString dbs;
if (options.contains(APM::RootDir)) { if (options.contains(APM::RootDir)) {
root = options[APM::RootDir].args[0]; root = options[APM::RootDir].args[0];
} }
...@@ -46,7 +46,7 @@ OperationManager::OperationManager(APM::OperationType type, APM::OperationName o ...@@ -46,7 +46,7 @@ OperationManager::OperationManager(APM::OperationType type, APM::OperationName o
if (options.contains(APM::DBPath)) { if (options.contains(APM::DBPath)) {
dbs = options[APM::DBPath].args[0]; dbs = options[APM::DBPath].args[0];
} }
AkabeiClient::Backend::instance()->initialize(root, cache, dbs); AkabeiClient::Backend::instance()->initialize(root, cache, dbs);
} }
...@@ -64,28 +64,28 @@ void OperationManager::statusChanged(Akabei::Backend::Status status) ...@@ -64,28 +64,28 @@ void OperationManager::statusChanged(Akabei::Backend::Status status)
void OperationManager::start() void OperationManager::start()
{ {
switch (m_type) { switch (m_type) {
case APM::QueryOperationType: { case APM::QueryOperationType: {
QueryOperation * query = new QueryOperation(this); QueryOperation * query = new QueryOperation(this);
query->start(m_operation, m_options, m_args); query->start(m_operation, m_options, m_args);
break; break;
} }
case APM::RemoveOperationType: { case APM::RemoveOperationType: {
RemoveOperation * remove = new RemoveOperation(this); RemoveOperation * remove = new RemoveOperation(this);
remove->start(m_operation, m_options, m_args); remove->start(m_operation, m_options, m_args);
break; break;
} }
case APM::SyncOperationType: { case APM::SyncOperationType: {
SyncOperation * sync = new SyncOperation(this); SyncOperation * sync = new SyncOperation(this);
sync->start(m_operation, m_options, m_args); sync->start(m_operation, m_options, m_args);
break; break;
} }
case APM::UpgradeOperationType: { case APM::UpgradeOperationType: {
UpgradeOperation * upgrade = new UpgradeOperation(this); UpgradeOperation * upgrade = new UpgradeOperation(this);
upgrade->start(m_operation, m_options, m_args); upgrade->start(m_operation, m_options, m_args);
break; break;
} }
default: default:
break; break;
} }
} }
......
...@@ -19,15 +19,15 @@ ...@@ -19,15 +19,15 @@
class OperationManager : public QObject class OperationManager : public QObject
{ {
Q_OBJECT Q_OBJECT
public: public:
explicit OperationManager(APM::OperationType type, APM::OperationName operation, QHash<APM::OptionName, AkabeiOption> options, QStringList args, QObject* parent = 0); explicit OperationManager(APM::OperationType type, APM::OperationName operation, QHash<APM::OptionName, AkabeiOption> options, QStringList args, QObject* parent = 0);
virtual ~OperationManager(); virtual ~OperationManager();
private slots: private slots:
void statusChanged(Akabei::Backend::Status); void statusChanged(Akabei::Backend::Status);
void start(); void start();
private: private:
APM::OperationType m_type; APM::OperationType m_type;
APM::OperationName m_operation; APM::OperationName m_operation;
......
This diff is collapsed.
...@@ -39,7 +39,7 @@ enum OperationName { ...@@ -39,7 +39,7 @@ enum OperationName {
None, None,
ShowChangelog, ShowInstalledAsDeps, ShowInstalledExplicitely, ShowPackagesOfGroup, ShowPackagesOfGroupLocal, ShowInformationLocal, ShowChangelog, ShowInstalledAsDeps, ShowInstalledExplicitely, ShowPackagesOfGroup, ShowPackagesOfGroupLocal, ShowInformationLocal,
ShowInformation, CheckFiles, ShowOwner, ShowNotRequired, ShowUpgradeable, ShowInformation, CheckFiles, ShowOwner, ShowNotRequired, ShowUpgradeable,
Install, RemoveOldFromCache, RemoveAllCache, ListRepo, Search, UpdateDatabases, UpdateSystem, UpdateDatabaseAndSystem, Install, RemoveOldFromCache, RemoveAllCache, ListRepo, Search, UpdateDatabases, UpdateSystem, UpdateDatabaseAndSystem,
Remove, Cascade, Unneeded, SearchLocal, Remove, Cascade, Unneeded, SearchLocal,
DatabaseOperation, Upgrade, Help, Version DatabaseOperation, Upgrade, Help, Version
}; };
...@@ -53,19 +53,19 @@ typedef enum OperationName OperationName; ...@@ -53,19 +53,19 @@ typedef enum OperationName OperationName;
class AkabeiOption class AkabeiOption
{ {
private: private:
void init(APM::OptionName, const char *, const char *, const char *, bool, QStringList); void init(APM::OptionName, const char *, const char *, const char *, bool, QStringList);
public: public:
APM::OptionName name; APM::OptionName name;
QByteArray commandShort, commandLong; QByteArray commandShort, commandLong;
KLocalizedString description; KLocalizedString description;
bool hasArg; bool hasArg;
/* /*
* Args are required by some options like --ignore or --ignoregroup * Args are required by some options like --ignore or --ignoregroup
*/ */
QStringList args; QStringList args;
AkabeiOption(APM::OptionName, const char *, const char *, const char *, bool); AkabeiOption(APM::OptionName, const char *, const char *, const char *, bool);
AkabeiOption(APM::OptionName, const char *, const char *, const char *, bool, QStringList); AkabeiOption(APM::OptionName, const char *, const char *, const char *, bool, QStringList);
AkabeiOption() {} AkabeiOption() {}
...@@ -80,7 +80,7 @@ class AkabeiOperation ...@@ -80,7 +80,7 @@ class AkabeiOperation
{ {
private: private:
void init(APM::OperationType, APM::OperationName, const char *, const char *, const char *, bool, QStringList); void init(APM::OperationType, APM::OperationName, const char *, const char *, const char *, bool, QStringList);
public: public:
APM::OperationType type; APM::OperationType type;
APM::OperationName name; APM::OperationName name;
...@@ -88,22 +88,22 @@ public: ...@@ -88,22 +88,22 @@ public:
KLocalizedString description; KLocalizedString description;
QHash<APM::OptionName, AkabeiOption> options; /* options that can be associated to this operation */ QHash<APM::OptionName, AkabeiOption> options; /* options that can be associated to this operation */
bool hasFreeArgs; bool hasFreeArgs;
/* /*
* An example of free args is the list of packages following an install command * An example of free args is the list of packages following an install command
*/ */
QStringList freeArgs; QStringList freeArgs;
AkabeiOperation(); AkabeiOperation();
AkabeiOperation(APM::OperationType, APM::OperationName, const char *, const char *, const char *, bool); AkabeiOperation(APM::OperationType, APM::OperationName, const char *, const char *, const char *, bool);
AkabeiOperation(APM::OperationType, APM::OperationName, const char *, const char *, const char *, bool, QStringList); AkabeiOperation(APM::OperationType, APM::OperationName, const char *, const char *, const char *, bool, QStringList);
/* /*
* Checks, with special rules, than no more than one operation is specified on the command line * Checks, with special rules, than no more than one operation is specified on the command line
* see cmdline.cpp for a more detailed explanation * see cmdline.cpp for a more detailed explanation
*/ */
void set(AkabeiOperation &); void set(AkabeiOperation &);
/* /*
* Options checking * Options checking
*/ */
...@@ -119,23 +119,23 @@ private: ...@@ -119,23 +119,23 @@ private:
AkabeiOperation m_operation; AkabeiOperation m_operation;
QHash<APM::OptionName, AkabeiOption> m_options; QHash<APM::OptionName, AkabeiOption> m_options;
QStringList m_freeArgs; QStringList m_freeArgs;
/* Database */ /* Database */
QMultiHash<APM::OperationType, AkabeiOperation> acceptedOperations; QMultiHash<APM::OperationType, AkabeiOperation> acceptedOperations;
AkabeiOptionList acceptedOptions; AkabeiOptionList acceptedOptions;
QHash<QByteArray, APM::OperationType> typechars; QHash<QByteArray, APM::OperationType> typechars;
/* This is for the few operations that we need to access quickly later */ /* This is for the few operations that we need to access quickly later */
AkabeiOperationList specialOperations; AkabeiOperationList specialOperations;
bool parsed; bool parsed;
void secondParse(QStringList, QList<QByteArray> &); void secondParse(QStringList, QList<QByteArray> &);
public: public:
CmdLine(); CmdLine();
void parse(int argc, char **argv); void parse(int argc, char **argv);
APM::OperationType type(); APM::OperationType type();
APM::OperationName operation(); APM::OperationName operation();
QHash<APM::OptionName, AkabeiOption> options(); QHash<APM::OptionName, AkabeiOption> options();
......
...@@ -14,12 +14,13 @@ ...@@ -14,12 +14,13 @@
#include <kdebug.h> #include <kdebug.h>
#include "apm.h" #include "apm.h"
#include "cmdline.h" #include "cmdline.h"
#include <akabeilog.h>
int main(int argc, char** argv) int main(int argc, char** argv)
{ {
QCoreApplication app(argc, argv); QCoreApplication app(argc, argv);
CmdLine cmd; CmdLine cmd;
try { try {
cmd.parse(argc, argv); cmd.parse(argc, argv);
} catch (CmdLineException& ex) { } catch (CmdLineException& ex) {
...@@ -27,7 +28,8 @@ int main(int argc, char** argv) ...@@ -27,7 +28,8 @@ int main(int argc, char** argv)
err << "Fatal error parsing command line: " << ex.what() << endl; err << "Fatal error parsing command line: " << ex.what() << endl;
return -1; return -1;
} }
Akabei::logInit("akabei.log");
OperationManager apm(cmd.type(), cmd.operation(), cmd.options(), cmd.freeArgs()); OperationManager apm(cmd.type(), cmd.operation(), cmd.options(), cmd.freeArgs());
return app.exec(); return app.exec();
} }
...@@ -24,7 +24,7 @@ ...@@ -24,7 +24,7 @@
#include <QCoreApplication> #include <QCoreApplication>
QueryOperation::QueryOperation(QObject * parent) QueryOperation::QueryOperation(QObject * parent)
: QObject(parent) : QObject(parent)
{ {
} }
...@@ -44,8 +44,8 @@ void QueryOperation::start(APM::OperationName operation, QHash<APM::OptionName, ...@@ -44,8 +44,8 @@ void QueryOperation::start(APM::OperationName operation, QHash<APM::OptionName,
//CHange back to searchPackages when we have sorted results after Name and description //CHange back to searchPackages when we have sorted results after Name and description
} }
} else if (operation == APM::ShowPackagesOfGroupLocal) { } else if (operation == APM::ShowPackagesOfGroupLocal) {
connect(Akabei::Backend::instance(), SIGNAL(queryGroupsCompleted(QUuid,QList<Akabei::Group*>)), connect(Akabei::Backend::instance(), SIGNAL(queryGroupsCompleted(QUuid, QList<Akabei::Group*>)),
SLOT(showGroup(QUuid,QList<Akabei::Group*>))); SLOT(showGroup(QUuid, QList<Akabei::Group*>)));
Akabei::Backend::instance()->localDatabase()->queryGroups("SELECT * FROM groups WHERE Name LIKE \"" + args.first() + "\""); Akabei::Backend::instance()->localDatabase()->queryGroups("SELECT * FROM groups WHERE Name LIKE \"" + args.first() + "\"");
} else if (operation == APM::ShowChangelog) { } else if (operation == APM::ShowChangelog) {
if (options.contains(APM::QueryPackageFile)) { if (options.contains(APM::QueryPackageFile)) {
...@@ -101,8 +101,8 @@ void QueryOperation::showInformation(QList<Akabei::Package*> packages) ...@@ -101,8 +101,8 @@ void QueryOperation::showInformation(QList<Akabei::Package*> packages)
out << i18n("URL") << qSetFieldWidth(2) << ":" << qSetFieldWidth(20) << pkg->url().toString() << endl; out << i18n("URL") << qSetFieldWidth(2) << ":" << qSetFieldWidth(20) << pkg->url().toString() << endl;
out << i18n("Licenses") << qSetFieldWidth(2) << ":" << qSetFieldWidth(20) << pkg->license() << endl; out << i18n("Licenses") << qSetFieldWidth(2) << ":" << qSetFieldWidth(20) << pkg->license() << endl;
QStringList groups; QStringList groups;
foreach (Akabei::Group * g, pkg->groups()) foreach(Akabei::Group * g, pkg->groups())
groups << g->name(); groups << g->name();
out << i18n("Groups") << qSetFieldWidth(2) << ":" << qSetFieldWidth(20) << groups.join(" ") << endl; out << i18n("Groups") << qSetFieldWidth(2) << ":" << qSetFieldWidth(20) << groups.join(" ") << endl;
out << i18n("Provides") << qSetFieldWidth(2) << ":" << qSetFieldWidth(20) << pkg->provides().join(" ") << endl; out << i18n("Provides") << qSetFieldWidth(2) << ":" << qSetFieldWidth(20) << pkg->provides().join(" ") << endl;
out << i18n("Depends on") << qSetFieldWidth(2) << ":" << qSetFieldWidth(20) << pkg->dependencies().join(" ") << endl; out << i18n("Depends on") << qSetFieldWidth(2) << ":" << qSetFieldWidth(20) << pkg->dependencies().join(" ") << endl;
...@@ -121,7 +121,7 @@ void QueryOperation::showInformation(QList<Akabei::Package*> packages) ...@@ -121,7 +121,7 @@ void QueryOperation::showInformation(QList<Akabei::Package*> packages)
QCoreApplication::instance()->quit(); QCoreApplication::instance()->quit();
} }
void QueryOperation::showGroup(QUuid uuid,QList<Akabei::Group*> groups) void QueryOperation::showGroup(QUuid uuid, QList<Akabei::Group*> groups)
{ {
Q_UNUSED(uuid) Q_UNUSED(uuid)
if (groups.isEmpty()) { if (groups.isEmpty()) {
...@@ -129,13 +129,13 @@ void QueryOperation::showGroup(QUuid uuid,QList<Akabei::Group*> groups) ...@@ -129,13 +129,13 @@ void QueryOperation::showGroup(QUuid uuid,QList<Akabei::Group*> groups)
return; return;
} }
Akabei::Group * group = groups.first(); Akabei::Group * group = groups.first();
QTextStream out(stdout); QTextStream out(stdout);
QMap<QString, Akabei::Package*> sorted; QMap<QString, Akabei::Package*> sorted;
foreach (Akabei::Package * pkg, group->packages()) foreach(Akabei::Package * pkg, group->packages())
sorted[pkg->name()] = pkg; sorted[pkg->name()] = pkg;
foreach (Akabei::Package * pkg, sorted.values()) foreach(Akabei::Package * pkg, sorted.values())
out << group->name() << ' ' << pkg->name() << endl; out << group->name() << ' ' << pkg->name() << endl;
out.flush(); out.flush();
QCoreApplication::instance()->quit(); QCoreApplication::instance()->quit();
} }
...@@ -161,10 +161,10 @@ void QueryOperation::showInstalledAsDeps(QList<Akabei::Package*> packages) ...@@ -161,10 +161,10 @@ void QueryOperation::showInstalledAsDeps(QList<Akabei::Package*> packages)
} }
QTextStream out(stdout); QTextStream out(stdout);
QMap<QString, Akabei::Package*> sorted; QMap<QString, Akabei::Package*> sorted;
foreach (Akabei::Package * pkg, packages) foreach(Akabei::Package * pkg, packages)
sorted[pkg->name()] = pkg; sorted[pkg->name()] = pkg;
foreach (Akabei::Package * pkg, sorted.values()) foreach(Akabei::Package * pkg, sorted.values())
out << pkg->name() << ' ' << pkg->version().toByteArray().data() << endl; out << pkg->name() << ' ' << pkg->version().toByteArray().data() << endl;
out.flush(); out.flush();
QCoreApplication::instance()->quit(); QCoreApplication::instance()->quit();
} }
...@@ -179,7 +179,7 @@ void QueryOperation::checkFiles(QList<Akabei::Package*> packages) ...@@ -179,7 +179,7 @@ void QueryOperation::checkFiles(QList<Akabei::Package*> packages)
QTextStream out(stdout); QTextStream out(stdout);
int all = 0; int all = 0;
int missing = 0; int missing = 0;
foreach (const QString &file, pkg->retrieveFiles()) { foreach(const QString & file, pkg->retrieveFiles()) {
all++; all++;
if (!QFile::exists(Akabei::Config::instance()->rootDir().absoluteFilePath(file))) if (!QFile::exists(Akabei::Config::instance()->rootDir().absoluteFilePath(file)))
missing++; missing++;
...@@ -190,17 +190,17 @@ void QueryOperation::checkFiles(QList<Akabei::Package*> packages) ...@@ -190,17 +190,17 @@ void QueryOperation::checkFiles(QList<Akabei::Package*> packages)
} }
void QueryOperation::showLocalPackages(const QString &query) void QueryOperation::showLocalPackages(const QString &query)
{ {
QTextStream out(stdout); QTextStream out(stdout);
QList<Akabei::Package*> packages; QList<Akabei::Package*> packages;
if (!query.isEmpty()) if (!query.isEmpty())
packages = Akabei::Backend::instance()->localDatabase()->searchPackages(query); packages = Akabei::Backend::instance()->localDatabase()->searchPackages(query);
else else
packages = Akabei::Backend::instance()->localDatabase()->packages(); packages = Akabei::Backend::instance()->localDatabase()->packages();
foreach (Akabei::Package* pkg, packages) { foreach(Akabei::Package * pkg, packages) {
bool found = false; bool found = false;
foreach (Akabei::Database* db, Akabei::Backend::instance()->databases()) { foreach(Akabei::Database * db, Akabei::Backend::instance()->databases()) {
foreach (Akabei::Package* p, db->searchPackages(pkg->name())) { foreach(Akabei::Package * p, db->searchPackages(pkg->name())) {
if (p->name() == pkg->name()) { if (p->name() == pkg->name()) {
found = true; found = true;
break; break;
...@@ -225,8 +225,8 @@ void QueryOperation::showOwner(const QString &query) ...@@ -225,8 +225,8 @@ void QueryOperation::showOwner(const QString &query)
QCoreApplication::instance()->quit(); QCoreApplication::instance()->quit();
return; return;
} }
foreach (Akabei::Package * pkg, Akabei::Backend::instance()->localDatabase()->packages()) { foreach(Akabei::Package * pkg, Akabei::Backend::instance()->localDatabase()->packages()) {
foreach (const QString &file, pkg->retrieveFiles()) { foreach(const QString & file, pkg->retrieveFiles()) {
if (Akabei::Config::instance()->rootDir().absoluteFilePath(file) == query) { if (Akabei::Config::instance()->rootDir().absoluteFilePath(file) == query) {
out << query << " is owned by " << pkg->name() << ' ' << pkg->version().toByteArray().data() << endl; out << query << " is owned by " << pkg->name() << ' ' << pkg->version().toByteArray().data() << endl;
out.flush(); out.flush();
...@@ -244,9 +244,9 @@ void QueryOperation::showLocalQuery(QList<Akabei::Package*> packages) ...@@ -244,9 +244,9 @@ void QueryOperation::showLocalQuery(QList<Akabei::Package*> packages)
{ {
QTextStream out(stdout); QTextStream out(stdout);
QMap<QString, Akabei::Package*> sorted; QMap<QString, Akabei::Package*> sorted;
foreach (Akabei::Package * pkg, packages) foreach(Akabei::Package * pkg, packages)
sorted[pkg->name()] = pkg; sorted[pkg->name()] = pkg;
foreach (Akabei::Package * pkg, sorted.values()) { foreach(Akabei::Package * pkg, sorted.values()) {
out << "local/" << pkg->name() << ' ' << pkg->version().toByteArray().data() << endl; out << "local/" << pkg->name() << ' ' << pkg->version().toByteArray().data() << endl;
out << "\t" << pkg->description() << endl; out << "\t" << pkg->description() << endl;
} }
...@@ -259,14 +259,14 @@ void QueryOperation::showNotRequired() ...@@ -259,14 +259,14 @@ void QueryOperation::showNotRequired()
QTextStream out(stdout); QTextStream out(stdout);
QList<Akabei::Package*> packages = Akabei::Backend::instance()->localDatabase()->packages(); QList<Akabei::Package*> packages = Akabei::Backend::instance()->localDatabase()->packages();
QMap<QString, Akabei::Package*> pkgs; QMap<QString, Akabei::Package*> pkgs;
foreach (Akabei::Package* pkg, packages) foreach(Akabei::Package * pkg, packages)
pkgs[pkg->name()] = pkg; pkgs[pkg->name()] = pkg;
foreach (Akabei::Package* pkg, packages) { foreach(Akabei::Package * pkg, packages) {
foreach (const QString &dep, pkg->dependencies()) foreach(const QString & dep, pkg->dependencies())
pkgs.remove(dep); pkgs.remove(dep);
} }
foreach (Akabei::Package * pkg, pkgs.values()) foreach(Akabei::Package * pkg, pkgs.values())
out << pkg->name() << ' ' << pkg->version().toByteArray().data() << endl; out << pkg->name() << ' ' << pkg->version().toByteArray().data() << endl;
out.flush(); out.flush();
QCoreApplication::instance()->quit(); QCoreApplication::instance()->quit();
} }
...@@ -277,11 +277,11 @@ void QueryOperation::showUpgradeable() ...@@ -277,11 +277,11 @@ void QueryOperation::showUpgradeable()
QTextStream out(stdout); QTextStream out(stdout);
QList<Akabei::Package*> packages = Akabei::Backend::instance()->localDatabase()->packages(); QList<Akabei::Package*> packages = Akabei::Backend::instance()->localDatabase()->packages();
QMap<QString, Akabei::Package*> upgradeable; QMap<QString, Akabei::Package*> upgradeable;
foreach (Akabei::Package * pkg, packages) { foreach(Akabei::Package * pkg, packages) {
foreach (Akabei::Database * db, Akabei::Backend::instance()->databases()) { foreach(Akabei::Database * db, Akabei::Backend::instance()->databases()) {
Akabei::Package::List list = db->queryPackages("SELECT * FROM packages WHERE Name LIKE \"" + pkg->name() + "\""); Akabei::Package::List list = db->queryPackages("SELECT * FROM packages WHERE Name LIKE \"" + pkg->name() + "\"");
if (!list.isEmpty()) { if (!list.isEmpty()) {
foreach (Akabei::Package * p, list) { foreach(Akabei::Package * p, list) {
if (p->version() > pkg->version() && p->name() == pkg->name()) { if (p->version() > pkg->version() && p->name() == pkg->name()) {
if (upgradeable[p->name()] && upgradeable[p->name()]->version() > p->version()) if (upgradeable[p->name()] && upgradeable[p->name()]->version() > p->version())
continue; continue;
...@@ -291,9 +291,9 @@ void QueryOperation::showUpgradeable() ...@@ -291,9 +291,9 @@ void QueryOperation::showUpgradeable()
} }
} }
} }
foreach (Akabei::Package * pkg, upgradeable.values()) foreach(Akabei::Package * pkg, upgradeable.values())
out << pkg->name() << ' ' << pkg->version().toByteArray().data() << endl; out << pkg->name() << ' ' << pkg->version().toByteArray().data() << endl;
out.flush(); out.flush();
QCoreApplication::instance()->quit(); QCoreApplication::instance()->quit();
} }
...@@ -20,16 +20,16 @@ ...@@ -20,16 +20,16 @@
class QueryOperation : public QObject class QueryOperation : public QObject
{ {
Q_OBJECT Q_OBJECT
public: public:
explicit QueryOperation(QObject * parent = 0); explicit QueryOperation(QObject * parent = 0);
virtual ~QueryOperation(); virtual ~QueryOperation();
void start(APM::OperationName operation, QHash<APM::OptionName, AkabeiOption> options, QStringList args); void start(APM::OperationName operation, QHash<APM::OptionName, AkabeiOption> options, QStringList args);
private slots: private slots:
void showInformation(QList<Akabei::Package*> packages); void showInformation(QList<Akabei::Package*> packages);
void showGroup(QUuid uuid,QList<Akabei::Group*> groups); void showGroup(QUuid uuid, QList<Akabei::Group*> groups);
void showChangelog(QList<Akabei::Package*> packages); void showChangelog(QList<Akabei::Package*> packages);
void showInstalledAsDeps(QList<Akabei::Package*>); void showInstalledAsDeps(QList<Akabei::Package*>);
void checkFiles(QList<Akabei::Package*>); void checkFiles(QList<Akabei::Package*>);
......
This diff is collapsed.
...@@ -17,27 +17,28 @@ ...@@ -17,27 +17,28 @@
#include "apm.h" #include "apm.h"
#include <akabeierror.h> #include <akabeierror.h>
namespace AkabeiClient { namespace AkabeiClient
class TransactionQuestion; {
class TransactionQuestion;
} }
class QueueOperation : public QObject class QueueOperation : public QObject
{ {
Q_OBJECT Q_OBJECT
public: public:
QueueOperation(APM::OperationName operation, QHash<APM::OptionName, AkabeiOption> options, QObject * parent = 0); QueueOperation(APM::OperationName operation, QHash<APM::OptionName, AkabeiOption> options, QObject * parent = 0);
virtual ~QueueOperation(); virtual ~QueueOperation();
void start(AkabeiClient::PackageAction action, QList<Akabei::Package*> packages); void start(AkabeiClient::PackageAction action, QList<Akabei::Package*> packages);
private slots: private slots:
void validationFinished(bool valid, QList<AkabeiClient::TransactionQuestion*> questions); void validationFinished(bool valid, QList<AkabeiClient::TransactionQuestion*> questions);
void showProgress(); void showProgress();
void errors(QList<Akabei::Error*>& errors); void errors(QList<Akabei::Error*>& errors);
void transactionMessage(const QString &message); void transactionMessage(const QString &message);
void transationFinished(); void transationFinished();
void packageProgressChanged(Akabei::Package*,int); void packageProgressChanged(Akabei::Package*, int);
signals: signals:
void finished(); void finished();
......
...@@ -25,7 +25,7 @@ ...@@ -25,7 +25,7 @@
#include "queueoperation.h" #include "queueoperation.h"
RemoveOperation::RemoveOperation(QObject * parent) RemoveOperation::RemoveOperation(QObject * parent)
: QObject(parent) : QObject(parent)
{ {
} }
...@@ -40,14 +40,14 @@ void RemoveOperation::start(APM::OperationName operation, QHash<APM::OptionName, ...@@ -40,14 +40,14 @@ void RemoveOperation::start(APM::OperationName operation, QHash<APM::OptionName,
m_operation = operation; m_operation = operation;
m_options = options; m_options = options;
m_args = args; m_args = args;
QString query = "SELECT * FROM packages WHERE"; QString query = "SELECT * FROM packages WHERE";
foreach (const QString &pkg, args) { foreach(const QString & pkg, args) {
query = query + " name=\"" + pkg + "\""; query = query + " name=\"" + pkg + "\"";
if (args.last() != pkg) if (args.last() != pkg)
query = query + " OR"; query = query + " OR";
} }
if (operation == APM::Unneeded) { if (operation == APM::Unneeded) {
removeUnneeded(Akabei::Backend::instance()->localDatabase()->packages()); removeUnneeded(Akabei::Backend::instance()->localDatabase()->packages());
} else if (operation == APM::Remove) { } else if (operation == APM::Remove) {
...@@ -80,8 +80,8 @@ void RemoveOperation::removeRecursive(QList<Akabei::Package*> packages) ...@@ -80,8 +80,8 @@ void RemoveOperation::removeRecursive(QList<Akabei::Package*> packages)
} }
QList<Akabei::Package*> pkgs; QList<Akabei::Package*> pkgs;
pkgs << packages; pkgs << packages;
foreach (Akabei::Package * pkg, packages) { foreach(Akabei::Package * pkg, packages) {
foreach (Akabei::Package * p, pkg->computeDependencies()) { foreach(Akabei::Package * p, pkg->computeDependencies()) {
if (p->installReason() == Akabei::Package::InstalledAsDependencyReason) //FIXME: have -ss for removing all packages if (p->installReason() == Akabei::Package::InstalledAsDependencyReason) //FIXME: have -ss for removing all packages
pkgs << p; pkgs << p;
} }
...@@ -99,13 +99,13 @@ void RemoveOperation::removeUnneeded(QList< Akabei::Package* > packages) ...@@ -99,13 +99,13 @@ void RemoveOperation::removeUnneeded(QList< Akabei::Package* > packages)
} }
qDebug() << "APM::Remove" << packages.count() << "unnneeded"; qDebug() << "APM::Remove" << packages.count() << "unnneeded";
QList<Akabei::Package*> unneeded; QList<Akabei::Package*> unneeded;
foreach (Akabei::Package * pkg, packages) { foreach(Akabei::Package * pkg, packages) {
bool required = false; bool required = false;
foreach (Akabei::Package * p, pkg->computeRequiredBy()) { foreach(Akabei::Package * p, pkg->computeRequiredBy()) {
<