Commit 9a3d4492 authored by Lukas Appelhans's avatar Lukas Appelhans

Actually working more operations after each other... more to come

parent f62e5182
......@@ -47,29 +47,33 @@ void SyncOperation::start(QList<APM::Operation> operations, QMultiHash<APM::Oper
m_operations = operations;
m_options = options;
m_args = args;
if (operations.contains(APM::Search)) {
APM::Operation operation = APM::NoOperation;
if (!operations.isEmpty()) {
operation = operations.first();
}
if (operation == APM::Search) {
if (args.isEmpty())
return;
connect(Akabei::Backend::instance(), SIGNAL(queryPackagesCompleted(QUuid,QList<Akabei::Package*>)),
SLOT(searchResult(QUuid,QList<Akabei::Package*>)));
Akabei::Backend::instance()->searchPackages(args.first());
} else if (operations.contains(APM::ListRepo)) {
} else if (operation == APM::ListRepo) {
if (args.isEmpty())
return;
listRepo(args.first());
} else if (operations.contains(APM::ShowInformation)) {
} else if (operation == APM::ShowInformation) {
if (args.isEmpty())
return;
connect(Akabei::Backend::instance(), SIGNAL(queryPackagesCompleted(QUuid,QList<Akabei::Package*>)),
SLOT(showInformation(QUuid,QList<Akabei::Package*>)));
Akabei::Backend::instance()->searchPackages(args.first());
} else if (operations.contains(APM::ShowPackagesOfGroup)) {
} else if (operation == APM::ShowPackagesOfGroup) {
if (args.isEmpty())
return;
connect(Akabei::Backend::instance(), SIGNAL(queryGroupsCompleted(QUuid,QList<Akabei::Group*>)),
SLOT(showGroup(QUuid,QList<Akabei::Group*>)));
Akabei::Backend::instance()->queryGroups("SELECT * FROM groups WHERE Name LIKE \"" + args.first() + "\"");
} else if (operations.contains(APM::UpdateDatabases)) {
} else if (operation == APM::UpdateDatabases) {
if (AkabeiClient::Backend::instance()->databases().isEmpty())
return;
QTextStream out(stdout);
......@@ -267,7 +271,12 @@ void SyncOperation::searchResult(QUuid , QList< Akabei::Package* > packages)
out << " " << p->description() << endl;
}
out.flush();
QCoreApplication::instance()->quit();
QList<APM::Operation> opts = m_operations;
opts.removeAll(APM::Search);
QStringList args = m_args;
if (!args.isEmpty())
args.removeFirst();
start(opts, m_options, args);
}
void SyncOperation::listRepo(const QString &repo)
......@@ -294,7 +303,12 @@ void SyncOperation::listRepo(const QString &repo)
out << endl;
}
out.flush();
QCoreApplication::instance()->quit();
QList<APM::Operation> opts = m_operations;
opts.removeAll(APM::ListRepo);
QStringList args = m_args;
if (!args.isEmpty())
args.removeFirst();
start(opts, m_options, args);
}
void SyncOperation::showInformation(QUuid,QList<Akabei::Package*> packages)
......@@ -344,7 +358,12 @@ void SyncOperation::showInformation(QUuid,QList<Akabei::Package*> packages)
out << i18n("MD5 sum") << qSetFieldWidth(2) << ":" << qSetFieldWidth(20) << pkg->md5sum().data() << endl;
out << i18n("Description") << qSetFieldWidth(2) << ":" << qSetFieldWidth(20) << pkg->description() << endl;
out.flush();
QCoreApplication::instance()->quit();
QList<APM::Operation> opts = m_operations;
opts.removeAll(APM::ShowInformation);
QStringList args = m_args;
if (!args.isEmpty())
args.removeFirst();
start(opts, m_options, args);
}
void SyncOperation::showGroup(QUuid uuid,QList<Akabei::Group*> groups)
......@@ -361,7 +380,12 @@ void SyncOperation::showGroup(QUuid uuid,QList<Akabei::Group*> groups)
foreach (Akabei::Package * pkg, sorted.values())
out << group->name() << ' ' << pkg->name() << endl;
out.flush();
QCoreApplication::instance()->quit();
QList<APM::Operation> opts = m_operations;
opts.removeAll(APM::ShowPackagesOfGroup);
QStringList args = m_args;
if (!args.isEmpty())
args.removeFirst();
start(opts, m_options, args);
}
void SyncOperation::updateNextDatabase()
......
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