Commit 7820049e authored by Daniele Cocca's avatar Daniele Cocca

Use Akabei::Package::List instead of QList<Akabei::Package*> where applicable.

parent 175188b1
......@@ -34,7 +34,6 @@ QueryOperation::QueryOperation(QList<APM::OperationName> operations, QHash<APM::
QueryOperation::~QueryOperation()
{
}
void QueryOperation::start()
......@@ -43,7 +42,7 @@ void QueryOperation::start()
if (operation == APM::ShowInformation) {
if (m_options.contains(APM::QueryPackageFile)) {
showInformation(QList<Akabei::Package*>() << Akabei::Backend::instance()->loadPackageFromFile(m_args.first()));
showInformation(Akabei::Package::List() << Akabei::Backend::instance()->loadPackageFromFile(m_args.first()));
} else {
showInformation(Akabei::Backend::instance()->localDatabase()->searchPackages(m_args.first(), Akabei::SearchNameEqual));
//CHange back to searchPackages when we have sorted results after Name and description
......@@ -54,7 +53,7 @@ void QueryOperation::start()
Akabei::Backend::instance()->localDatabase()->queryGroups("SELECT * FROM groups WHERE Name LIKE \"" + m_args.first() + "\"");
} else if (operation == APM::ShowChangelog) {
if (m_options.contains(APM::QueryPackageFile)) {
showChangelog(QList<Akabei::Package*>() << Akabei::Backend::instance()->loadPackageFromFile(m_args.first()));
showChangelog(Akabei::Package::List() << Akabei::Backend::instance()->loadPackageFromFile(m_args.first()));
} else {
showChangelog(Akabei::Backend::instance()->localDatabase()->searchPackages(m_args.first()));
}
......@@ -69,7 +68,7 @@ void QueryOperation::start()
showInstalledAsDeps(Akabei::Backend::instance()->localDatabase()->queryPackages(query));
} else if (operation == APM::CheckFiles) {
if (m_options.contains(APM::QueryPackageFile)) {
checkFiles(QList<Akabei::Package*>() << Akabei::Backend::instance()->loadPackageFromFile(m_args.first()));
checkFiles(Akabei::Package::List() << Akabei::Backend::instance()->loadPackageFromFile(m_args.first()));
} else {
checkFiles(Akabei::Backend::instance()->localDatabase()->searchPackages(m_args.first()));
}
......@@ -93,7 +92,7 @@ void QueryOperation::start()
}
}
void QueryOperation::showInformation(QList<Akabei::Package*> packages)
void QueryOperation::showInformation(Akabei::Package::List packages)
{
if (packages.isEmpty()) {
nextOperation();
......@@ -133,7 +132,7 @@ void QueryOperation::showInformation(QList<Akabei::Package*> packages)
nextOperation();
}
void QueryOperation::showGroup(QUuid uuid,QList<Akabei::Group*> groups)
void QueryOperation::showGroup(QUuid uuid, QList<Akabei::Group*> groups)
{
Q_UNUSED(uuid)
if (groups.isEmpty()) {
......@@ -152,21 +151,21 @@ void QueryOperation::showGroup(QUuid uuid,QList<Akabei::Group*> groups)
nextOperation();
}
void QueryOperation::showChangelog(QList< Akabei::Package* > packages)
void QueryOperation::showChangelog(Akabei::Package::List packages)
{
if (packages.isEmpty()) {
nextOperation();
return;
}
Akabei::Package * pkg = packages.first();
Akabei::Package const* pkg( packages.first() );
QTextStream out(stdout);
out << pkg->retrieveChangelog() << endl;
out.flush();
nextOperation();
}
void QueryOperation::showInstalledAsDeps(QList<Akabei::Package*> packages)
void QueryOperation::showInstalledAsDeps(Akabei::Package::List packages)
{
if (packages.isEmpty()) {
nextOperation();
......@@ -183,14 +182,14 @@ void QueryOperation::showInstalledAsDeps(QList<Akabei::Package*> packages)
nextOperation();
}
void QueryOperation::checkFiles(QList<Akabei::Package*> packages)
void QueryOperation::checkFiles(Akabei::Package::List packages)
{
if (packages.isEmpty()) {
nextOperation();
return;
}
Akabei::Package * pkg = packages.first();
Akabei::Package* pkg( packages.first() );
QTextStream out(stdout);
int all = 0;
int missing = 0;
......@@ -207,7 +206,7 @@ void QueryOperation::checkFiles(QList<Akabei::Package*> packages)
void QueryOperation::showLocalPackages(const QString &query)
{
QTextStream out(stdout);
QList<Akabei::Package*> packages;
Akabei::Package::List packages;
if (!query.isEmpty())
packages = Akabei::Backend::instance()->localDatabase()->searchPackages(query);
else
......@@ -255,7 +254,7 @@ void QueryOperation::showOwner(const QString &query)
nextOperation();
}
void QueryOperation::showLocalQuery(QList<Akabei::Package*> packages)
void QueryOperation::showLocalQuery(Akabei::Package::List packages)
{
QTextStream out(stdout);
QMap<QString, Akabei::Package*> sorted;
......@@ -272,7 +271,7 @@ void QueryOperation::showLocalQuery(QList<Akabei::Package*> packages)
void QueryOperation::showNotRequired()
{
QTextStream out(stdout);
QList<Akabei::Package*> packages = Akabei::Backend::instance()->localDatabase()->packages();
Akabei::Package::List packages = Akabei::Backend::instance()->localDatabase()->packages();
QMap<QString, Akabei::Package*> pkgs;
foreach (Akabei::Package* pkg, packages)
pkgs[pkg->name()] = pkg;
......@@ -290,7 +289,7 @@ void QueryOperation::showUpgradeable()
{
//FIXME: Maybe don't even check for the highest version... redundant?
QTextStream out(stdout);
QList<Akabei::Package*> packages = Akabei::Backend::instance()->localDatabase()->packages();
Akabei::Package::List packages = Akabei::Backend::instance()->localDatabase()->packages();
QMap<QString, Akabei::Package*> upgradeable;
foreach (Akabei::Package * pkg, packages) {
foreach (Akabei::Database * db, Akabei::Backend::instance()->databases()) {
......
......@@ -24,28 +24,28 @@ Q_OBJECT
public:
explicit QueryOperation(QList<APM::OperationName> operations, QHash<APM::OptionName, QStringList> options, QStringList args, QObject * parent = 0);
virtual ~QueryOperation();
void start();
private:
QList<APM::OperationName> m_operations;
QHash<APM::OptionName, QStringList> m_options;
QStringList m_args;
void nextOperation();
private slots:
void showInformation(QList<Akabei::Package*> packages);
void showInformation(Akabei::Package::List packages);
void showGroup(QUuid uuid,QList<Akabei::Group*> groups);
void showChangelog(QList<Akabei::Package*> packages);
void showInstalledAsDeps(QList<Akabei::Package*>);
void checkFiles(QList<Akabei::Package*>);
void showChangelog(Akabei::Package::List packages);
void showInstalledAsDeps(Akabei::Package::List);
void checkFiles(Akabei::Package::List);
void showLocalPackages(const QString &query);
void showOwner(const QString &query);
void showLocalQuery(QList<Akabei::Package*>);
void showLocalQuery(Akabei::Package::List);
void showNotRequired();
void showUpgradeable();
signals:
void queryFinished();
};
......
......@@ -55,7 +55,7 @@ QueueOperation::QueueOperation(APM::OperationName operation, QHash<APM::OptionNa
m_processingOptions |= Akabei::RemoveConfigs;
if (options.contains(APM::DatabaseOnly))
m_processingOptions |= Akabei::DatabaseOnly;
connect(AkabeiClient::Backend::instance()->transactionHandler(), SIGNAL(newTransactionMessage(QString)), SLOT(transactionMessage(QString)));
}
......@@ -67,16 +67,16 @@ QueueOperation::~QueueOperation()
void QueueOperation::start(AkabeiClient::PackageAction action, QList<Akabei::Package*> packages)
{
m_action = action;
foreach (Akabei::Package * pkg, packages) {
AkabeiClient::Backend::instance()->queue()->addPackage(pkg, action);
}
QTextStream out(stdout);
out << i18n("Calculating dependencies...") << endl;
connect(AkabeiClient::Backend::instance()->transactionHandler(), SIGNAL(transactionCreated(AkabeiClient::Transaction*)), SLOT(transactionCreated(AkabeiClient::Transaction*)));
AkabeiClient::Backend::instance()->transactionHandler()->start();
}
......@@ -101,7 +101,7 @@ void QueueOperation::transactionCreated(AkabeiClient::Transaction* t)
out << i18n("Y");
else
out << i18n("y");
if (q->possibleAnswers() & AkabeiClient::TransactionQuestion::No)
out << i18n("/");
}
......@@ -120,7 +120,7 @@ void QueueOperation::transactionCreated(AkabeiClient::Transaction* t)
emit finished();
return;
}*/
if (!input.empty() && (input == i18n("y").toStdString() || input == i18n("Y").toStdString())) {
q->setAnswer(AkabeiClient::TransactionQuestion::Yes);
} else if (!input.empty() && (input == i18n("n").toStdString() || input == i18n("N").toStdString())) {
......@@ -135,11 +135,11 @@ void QueueOperation::transactionCreated(AkabeiClient::Transaction* t)
}
//TODO: Tell user what packages are going to be removed/installed/reinstalled/upgraded and confirm
//TODO: Let it stay down there, because we actually have answered the questions just before
if (t->isValid()) {
t->setProcessingOptions(m_processingOptions);
connect(AkabeiClient::Backend::instance()->transactionHandler(), SIGNAL(validationFinished(bool)), SLOT(validationFinished(bool)));
out << i18n("Validating transaction...") << endl;
AkabeiClient::Backend::instance()->transactionHandler()->validate();
} else {
......@@ -159,15 +159,15 @@ void QueueOperation::validationFinished(bool valid)
emit finished();
return;
}
if (m_transaction->toBeInstalled().isEmpty() && m_transaction->toBeReinstalled().isEmpty() && m_transaction->toBeRemoved().isEmpty() && m_transaction->toBeUpgraded().isEmpty()) {
out << i18n("Nothing to do.") << endl;
emit finished();
return;
}
out << i18n("Transaction validated succesfully...") << endl;
//First we check if the packages we're about to remove are needed somewhere
//TODO: Keep it or change behavior?
if (m_action == AkabeiClient::Remove && !(Akabei::Backend::instance()->operationRunner()->processingOptions() & Akabei::SkipDependencies)) {
......@@ -190,7 +190,7 @@ void QueueOperation::validationFinished(bool valid)
return;
}
}
int downloadSize = 0;
int installSize = 0;
Akabei::AkabeiCache c;
......@@ -203,7 +203,7 @@ void QueueOperation::validationFinished(bool valid)
QSet<Akabei::Package*> tmp = m_transaction->toBeUpgraded();
tmp += m_transaction->toBeReinstalled();
foreach (Akabei::Package *i, m_transaction->toBeUpgraded()) {
QList<Akabei::Package*> ps = Akabei::Backend::instance()->localDatabase()->searchPackages(i->name(), Akabei::SearchNameEqual);
Akabei::Package::List ps = Akabei::Backend::instance()->localDatabase()->searchPackages(i->name(), Akabei::SearchNameEqual);
if (ps.isEmpty())
continue;
installSize += (i->installedSize() - ps.first()->installedSize());
......@@ -260,7 +260,7 @@ void QueueOperation::validationFinished(bool valid)
out << i18n("Freed size after transaction: %1", KIO::convertSize(installSize * (-1))) << endl;
}
out.flush();
out << i18n("Continue with processing?[Y/n]");
out.flush();
std::string input;
......@@ -282,7 +282,7 @@ void QueueOperation::showProgress()
{
//I'm sorry that this method looks a bit complicated, but I really see no other way for this... :/
int progress = AkabeiClient::Backend::instance()->transactionHandler()->transactionProgress()->progress();
const unsigned int hashlen = getcols();
QString status;
......@@ -325,13 +325,13 @@ void QueueOperation::showProgress()
pkgs += pkgOutput;
counter++;
}
QString startOut = " | " + i18n("Total progress:") + " [";
QString endOut = "] " + QString::number(progress) + "%";
int pBarLength = startOut.length() + endOut.length() + 10;
bool showPBar = false;
QString output;
output += status;
......@@ -352,11 +352,11 @@ void QueueOperation::showProgress()
}
output += pkgs;
}
if (showPBar) {
QString pBarOut = startOut;
int pBar = qMax(10, (int)(hashlen - output.length() - endOut.length() - startOut.length()));
const unsigned int hash = progress * pBar / 100;
for (unsigned int i = pBar; i > 1; --i) {
/* if special progress bar enabled */
......@@ -369,13 +369,13 @@ void QueueOperation::showProgress()
pBarOut += endOut;
output += pBarOut;
}
QTextStream out(stdout);
out.reset();
out << output;
out.flush();
if (progress == 100) {
out << endl;//FIXME: endl after phase ends, but prolly not at 100%
} else {
......@@ -409,7 +409,7 @@ void QueueOperation::transactionFinished(bool success)
foreach (Akabei::Error * e, m_transaction->errors())
out << e->description() << endl;
out.flush();
}
emit finished();
......
......@@ -16,6 +16,7 @@
#include <akabeicore_global.h>
#include "apm.h"
#include <akabeierror.h>
#include <akabeipackage.h>
namespace AkabeiClient {
class TransactionQuestion;
......@@ -29,11 +30,11 @@ public:
QueueOperation(APM::OperationName operation, QHash<APM::OptionName, QStringList> options, QObject * parent = 0);
virtual ~QueueOperation();
void start(AkabeiClient::PackageAction action, QList<Akabei::Package*> packages);
void start(AkabeiClient::PackageAction action, Akabei::Package::List packages);
signals:
void questionsAnswered(QList<AkabeiClient::TransactionQuestion*> questions);
private slots:
void validationFinished(bool valid);
void showProgress();
......@@ -44,10 +45,10 @@ private slots:
void packageStarted(Akabei::Package*);
void packageEnded(Akabei::Package*);
void transactionCreated(AkabeiClient::Transaction*);
signals:
void finished();
private:
AkabeiClient::PackageAction m_action;
Akabei::ProcessingOptions m_processingOptions;
......
......@@ -39,7 +39,7 @@ RemoveOperation::~RemoveOperation()
void RemoveOperation::start()
{
APM::OperationName operation = m_operations.takeFirst();
QString query = "SELECT * FROM packages WHERE";
foreach (const QString &pkg, m_args) {
query = query + " name=\"" + pkg + "\"";
......@@ -60,13 +60,13 @@ void RemoveOperation::start()
}
}
void RemoveOperation::remove(QList<Akabei::Package*> packages)
{
void RemoveOperation::remove(Akabei::Package::List packages)
{
if (packages.isEmpty()) {
nextOperation();
return;
}
QueueOperation *operation = new QueueOperation(APM::Remove, m_options, this);
operation->start(AkabeiClient::Remove, packages);
connect(operation, SIGNAL(finished()), SLOT(nextOperation()));
......@@ -78,8 +78,8 @@ void RemoveOperation::removeRecursive(QList<Akabei::Package*> packages)
nextOperation();
return;
}
QList<Akabei::Package*> pkgs;
pkgs << packages;
Akabei::Package::List pkgs( packages );
foreach (Akabei::Package * pkg, packages) {
foreach (Akabei::Package * p, pkg->computeDependencies()) {
if (p->installReason() == Akabei::Package::InstalledAsDependencyReason) //FIXME: have -ss for removing all packages
......@@ -91,18 +91,18 @@ void RemoveOperation::removeRecursive(QList<Akabei::Package*> packages)
connect(operation, SIGNAL(finished()), SLOT(nextOperation()));
}
void RemoveOperation::removeUnneeded(QList< Akabei::Package* > packages)
void RemoveOperation::removeUnneeded(Akabei::Package::List packages)
{
if (packages.isEmpty()) {
nextOperation();
return;
}
qDebug() << "APM::Remove" << packages.count() << "unnneeded";
QList<Akabei::Package*> unneeded;
foreach (Akabei::Package * pkg, packages) {
Akabei::Package::List unneeded;
foreach (Akabei::Package* pkg, packages) {
bool required = false;
foreach(Akabei::Package * p, pkg->computeRequiredBy()) {
foreach(Akabei::Package* p, pkg->computeRequiredBy()) {
required = required || p->database() == Akabei::Backend::instance()->localDatabase();
if (required)
break;
......
......@@ -15,6 +15,7 @@
#include "apm.h"
#include "cmdlineparsing.h"
#include <akabeierror.h>
#include <akabeipackage.h>
class RemoveOperation : public QObject
{
......@@ -22,20 +23,20 @@ Q_OBJECT
public:
RemoveOperation(QList<APM::OperationName> operations, QHash<APM::OptionName, QStringList> options, QStringList args, QObject * parent = 0);
virtual ~RemoveOperation();
void start();
public slots:
void remove(QList<Akabei::Package*> packages);
void removeRecursive(QList<Akabei::Package*> packages);
void removeUnneeded(QList< Akabei::Package* > packages);
void remove(Akabei::Package::List packages);
void removeRecursive(Akabei::Package::List packages);
void removeUnneeded(Akabei::Package::List packages);
void nextOperation();
private:
QList<APM::OperationName> m_operations;
QHash<APM::OptionName, QStringList> m_options;
QStringList m_args;
signals:
void removeFinished();
};
......
......@@ -37,18 +37,18 @@ UpgradeOperation::~UpgradeOperation()
void UpgradeOperation::start(QList<APM::OperationName> operations, QHash<APM::OptionName, QStringList> options, QStringList args)
{
QList<Akabei::Package*> pkgs;
Akabei::Package::List pkgs;
foreach (const QString &p, args) {
Akabei::Package * pkg = Akabei::Backend::instance()->loadPackageFromFile(p);
if (pkg)
pkgs << pkg;
}
if (pkgs.isEmpty()) {
emit upgradeFinished();
return;
}
QueueOperation *op = new QueueOperation(operations.first(), options, this);
op->start(AkabeiClient::Install, pkgs);
connect(op, SIGNAL(finished()), this, SIGNAL(upgradeFinished()));
......
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