Commit 5846aaf7 authored by Lukas Appelhans's avatar Lukas Appelhans

So -Ru should be working

parent 357b538d
......@@ -44,7 +44,8 @@ void RemoveOperation::start(QList<APM::Operation> operations, QMultiHash<APM::Op
if (!operations.isEmpty())
operation = operations.first();
if (operation == APM::Unneeded) { //TODO: Implement those!
} else {
removeUnneeded(Akabei::Backend::instance()->localDatabase()->packages());
} else if (!args.isEmpty()) {
QString query = "SELECT * FROM packages WHERE";
foreach (const QString &pkg, args) {
query = query + " Name LIKE \"" + pkg + "\"";
......@@ -55,6 +56,10 @@ void RemoveOperation::start(QList<APM::Operation> operations, QMultiHash<APM::Op
removeRecursive(Akabei::Backend::instance()->localDatabase()->queryPackages(query));
else
remove(Akabei::Backend::instance()->localDatabase()->queryPackages(query));
} else {
QList<APM::Operation> ops = operations;
ops.removeFirst();
start(ops, options, args);
}
}
......@@ -87,3 +92,30 @@ void RemoveOperation::removeRecursive(QList<Akabei::Package*> packages)
operation->start(AkabeiClient::Remove, pkgs);
connect(operation, SIGNAL(finished()), QCoreApplication::instance(), SLOT(quit()));
}
void RemoveOperation::removeUnneeded(QList< Akabei::Package* > packages)
{
if (packages.isEmpty()) {
QCoreApplication::instance()->quit();
return;
}
qDebug() << "Remove" << packages.count() << "unnneeded";
QList<Akabei::Package*> unneeded;
foreach (Akabei::Package * pkg, packages) {
bool required = false;
foreach (Akabei::Package * p, pkg->computeRequiredBy()) {
required = required || p->database() == Akabei::Backend::instance()->localDatabase();
if (required)
break;
}
if (pkg->installReason() == Akabei::Package::InstalledAsDependencyReason && !required)
unneeded << pkg;
}
if (unneeded.isEmpty()) {
QCoreApplication::instance()->quit();
return;
}
QueueOperation *operation = new QueueOperation(m_operations, m_options, this);
operation->start(AkabeiClient::Remove, unneeded);
connect(operation, SIGNAL(finished()), QCoreApplication::instance(), SLOT(quit()));
}
......@@ -27,6 +27,7 @@ public:
public slots:
void remove(QList<Akabei::Package*> packages);
void removeRecursive(QList<Akabei::Package*> packages);
void removeUnneeded(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