Commit 721176ae authored by Lukas Appelhans's avatar Lukas Appelhans

Impl questions + random stuff

parent d0b87634
......@@ -70,13 +70,13 @@ void QueueOperation::start(AkabeiClient::PackageAction action, QList<Akabei::Pac
QTextStream out(stdout);
out << i18n("Validating transaction...") << endl;
connect(AkabeiClient::Backend::instance()->transactionHandler(), SIGNAL(validationFinished(bool)), SLOT(validationFinished(bool)));
connect(AkabeiClient::Backend::instance()->transactionHandler(), SIGNAL(validationFinished(bool, QList<AkabeiClient::TransactionQuestion*>)), SLOT(validationFinished(bool, QList<AkabeiClient::TransactionQuestion*>)));
connect(AkabeiClient::Backend::instance()->transactionHandler(), SIGNAL(errorsOccurred(QList<Akabei::Error*>&)), SLOT(errors(QList<Akabei::Error*>&)));
connect(AkabeiClient::Backend::instance()->transactionHandler(), SIGNAL(newTransactionMessage(QString)), SLOT(transactionMessage(QString)));
AkabeiClient::Backend::instance()->transactionHandler()->validate(m_processingOptions);
}
void QueueOperation::validationFinished(bool valid)
void QueueOperation::validationFinished(bool valid, QList<AkabeiClient::TransactionQuestion*> questions)
{
QTextStream out(stdout);
if (!valid) {
......@@ -86,6 +86,35 @@ void QueueOperation::validationFinished(bool valid)
return;
}
if (!questions.isEmpty()) { //TODO Rework and abstract this
foreach (AkabeiClient::TransactionQuestion *q, questions) {
out << q->question() << "[";
if (q->possibleAnswers() & AkabeiClient::TransactionQuestion::Yes) {
if (q->correctAnswer() == AkabeiClient::TransactionQuestion::Yes)
out << i18n("Y");
else
out << i18n("y");
if (q->possibleAnswers() & AkabeiClient::TransactionQuestion::No)
out << i18n("/");
}
if (q->possibleAnswers() & AkabeiClient::TransactionQuestion::No) {
if (q->correctAnswer() == AkabeiClient::TransactionQuestion::No)
out << i18n("N");
else
out << i18n("n");
}
out.flush();
std::string input;
getline(std::cin, input);
if (!input.empty() && (((input == i18n("y").toStdString() || input == i18n("Y").toStdString()) && q->correctAnswer() == AkabeiClient::TransactionQuestion::No) ||
((input == i18n("n").toStdString() || input == i18n("N").toStdString()) && q->correctAnswer() == AkabeiClient::TransactionQuestion::Yes))) {
emit finished();
return;
}
}
}
//First we check if the packages we're about to remove are needed somewhere
if (m_action == AkabeiClient::Remove && !m_operations.contains(APM::Cascade) && !(Akabei::Backend::instance()->operationRunner()->processingOptions() & Akabei::SkipDependencies)) {
QList<Akabei::Package*> conflict;
......
......@@ -17,6 +17,10 @@
#include "apm.h"
#include <akabeierror.h>
namespace AkabeiClient {
class TransactionQuestion;
}
class QueueOperation : public QObject
{
Q_OBJECT
......@@ -27,7 +31,7 @@ public:
void start(AkabeiClient::PackageAction action, QList<Akabei::Package*> packages);
private slots:
void validationFinished(bool valid);
void validationFinished(bool valid, QList<AkabeiClient::TransactionQuestion*> questions);
void showProgress();
void errors(QList<Akabei::Error*>& errors);
void transactionMessage(const QString &message);
......
......@@ -56,7 +56,7 @@ void SyncOperation::start(QList<APM::Operation> operations, QMultiHash<APM::Oper
case APM::Search:
{
if (args.isEmpty()) {
err << "akabei: An argument is needed." << endl;
err << i18n("akabei: An argument is needed.") << endl;
return;
}
......@@ -68,7 +68,7 @@ void SyncOperation::start(QList<APM::Operation> operations, QMultiHash<APM::Oper
case APM::ListRepo:
{
if (args.isEmpty()) {
err << "akabei: An argument is needed." << endl;
err << i18n("akabei: An argument is needed.") << endl;
return;
}
......@@ -79,7 +79,7 @@ void SyncOperation::start(QList<APM::Operation> operations, QMultiHash<APM::Oper
case APM::ShowInformation:
{
if (args.isEmpty()) {
err << "akabei: An argument is needed" << endl;
err << i18n("akabei: An argument is needed") << endl;
return;
}
......@@ -91,7 +91,7 @@ void SyncOperation::start(QList<APM::Operation> operations, QMultiHash<APM::Oper
case APM::ShowPackagesOfGroup:
{
if (args.isEmpty()) {
err << "akabei: An argument is needed" << endl;
err << i18n("akabei: An argument is needed") << endl;
return;
}
......@@ -133,7 +133,7 @@ void SyncOperation::start(QList<APM::Operation> operations, QMultiHash<APM::Oper
case APM::Install:
{
if (args.isEmpty()) {
err << "akabei: An argument is needed." << endl;
err << i18n("akabei: An argument is needed.") << endl;
}
connect(backend, SIGNAL(queryPackagesCompleted(QUuid,QList<Akabei::Package*>)), SLOT(install(QUuid,QList<Akabei::Package*>)));
......@@ -143,7 +143,7 @@ void SyncOperation::start(QList<APM::Operation> operations, QMultiHash<APM::Oper
default:
{
err << "akabei: No operation specified." << endl;
err << i18n("akabei: No operation specified.") << endl;
QCoreApplication::instance()->quit();
return;
}
......@@ -215,7 +215,9 @@ void SyncOperation::install(QUuid uuid, QList< Akabei::Package* > packages)
QMap<QString, Akabei::Package*> local;
foreach (Akabei::Package * pkg, packages) {
qDebug() << "Found" << pkg->name();
if (pkg->database() == Akabei::Backend::instance()->localDatabase()) {
qDebug() << "Local";
local[pkg->name()] = pkg;
packages.removeAll(pkg);
}
......
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