Commit d35d446c authored by Lukas Appelhans's avatar Lukas Appelhans

Recursive should work

parent c1375459
......@@ -44,15 +44,6 @@ void RemoveOperation::start(QList<APM::Operation> operations, QMultiHash<APM::Op
if (!operations.isEmpty())
operation = operations.first();
if (operation == APM::Unneeded) { //TODO: Implement those!
} else if (operation == APM::Cascade) {
QString query = "SELECT * FROM packages WHERE";//FIXME: I don't think we need this as this is normal AkabeiClient behavior
foreach (const QString &pkg, args) {
query = query + " Name LIKE \"" + pkg + "\" OR Depends LIKE \"%" + pkg + "%\"";
if (args.last() != pkg)
query = query + " OR";
}
kDebug() << query;
removeCascade(args, Akabei::Backend::instance()->localDatabase()->queryPackages(query));
} else {
QString query = "SELECT * FROM packages WHERE";
foreach (const QString &pkg, args) {
......@@ -60,37 +51,36 @@ void RemoveOperation::start(QList<APM::Operation> operations, QMultiHash<APM::Op
if (args.last() != pkg)
query = query + " OR";
}
remove(Akabei::Backend::instance()->localDatabase()->queryPackages(query));
if (operations.contains(APM::Recursive))
removeRecursive(Akabei::Backend::instance()->localDatabase()->queryPackages(query));
else
remove(Akabei::Backend::instance()->localDatabase()->queryPackages(query));
}
}
void RemoveOperation::removeCascade(const QStringList &args, QList<Akabei::Package*> packages)
void RemoveOperation::remove(QList<Akabei::Package*> packages)
{
QList<Akabei::Package*> cleaned;
foreach (Akabei::Package * p, packages) {
kDebug() << p->name();
if (args.contains(p->name())) {
cleaned << p;
kDebug() << "That";
} else {
foreach (const QString &dep, p->dependencies()) {
if (args.contains(Akabei::Helpers::versionedTarget(dep).first)) {
cleaned << p;
break;
}
}
}
if (packages.isEmpty()) {
QCoreApplication::instance()->quit();
return;
}
remove(cleaned);
QueueOperation *operation = new QueueOperation(m_operations, m_options, this);
operation->start(AkabeiClient::Remove, packages);
connect(operation, SIGNAL(finished()), QCoreApplication::instance(), SLOT(quit()));
}
void RemoveOperation::remove(QList<Akabei::Package*> packages)
void RemoveOperation::removeRecursive(QList<Akabei::Package*> packages)
{
if (packages.isEmpty()) {
QCoreApplication::instance()->quit();
return;
}
QList<Akabei::Package*> pkgs;
pkgs << packages;
foreach (Akabei::Package * pkg, packages) {
pkgs << pkg->computeDependencies();
}
QueueOperation *operation = new QueueOperation(m_operations, m_options, this);
operation->start(AkabeiClient::Remove, packages);
operation->start(AkabeiClient::Remove, pkgs);
connect(operation, SIGNAL(finished()), QCoreApplication::instance(), SLOT(quit()));
}
......@@ -23,9 +23,10 @@ public:
virtual ~RemoveOperation();
void start(QList<APM::Operation> operations, QMultiHash<APM::Operation, QString> options, QStringList args);
public slots:
void remove(QList<Akabei::Package*> packages);
void removeCascade(const QStringList &args, QList<Akabei::Package*> packages);
void removeRecursive(QList<Akabei::Package*> packages);
private:
QList<APM::Operation> m_operations;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment