Commit ee4d62a4 authored by Lukas Appelhans's avatar Lukas Appelhans

Start with -Qi

parent 0779d6e7
......@@ -15,7 +15,7 @@ include_directories(${QT_INCLUDES}
${AKABEICLIENT_INCLUDE_DIR}
${AKABEICORE_INCLUDE_DIR})
set(apm_SRCS apm.cpp main.cpp)
set(apm_SRCS apm.cpp queryoperation.cpp main.cpp)
#qt4_automoc(${guzuta_SRCS})
kde4_add_executable(akabei ${apm_SRCS})
target_link_libraries(akabei ${KDE4_KDEUI_LIBRARY} ${AKABEICLIENT_LIBRARIES})
......@@ -9,6 +9,8 @@
*/
#include "apm.h"
#include "queryoperation.h"
#include <akabeiclient/akabeiclientbackend.h>
#include <kdebug.h>
......@@ -42,6 +44,10 @@ void APM::statusChanged(Akabei::Backend::Status status)
void APM::start()
{
if (m_operationType == QueryOperationType) {
QueryOperation * query = new QueryOperation(this);
query->start(m_operations, m_args);
}
QTextStream out(stdout);
//out << endl;
out << "blub";
......
......@@ -21,11 +21,11 @@ Q_OBJECT
public:
enum OperationType {
NoType = 0,
DatabaseOperation = 1,
QueryOperation = 2,
RemoveOperation = 3,
SyncOperation = 4,
UpgradeOperation = 5
DatabaseOperationType = 1,
QueryOperationType = 2,
RemoveOperationType = 3,
SyncOperationType = 4,
UpgradeOperationType = 5
};
enum Operation {
NoOperation = 0,
......
......@@ -24,6 +24,7 @@ int main(int argc, char** argv)
ki18n("<a href=\"mailto:boom1992@chakra-project.org\">boom1992@chakra-project.org</a>"));
aboutData.addAuthor(ki18n("Lukas Appelhans"), ki18n("Maintainer"), "boom1992@chakra-project.org");
KCmdLineArgs::init(argc, argv, &aboutData);
KCmdLineOptions options;
......@@ -52,6 +53,8 @@ int main(int argc, char** argv)
options.add("u", ki18n("Update system"));
options.add("U", ki18n("Upgrade operation"));
options.add("+[arg1]", ki18n("An optional argument 'arg1'"));
KCmdLineArgs::addCmdLineOptions(options);
......@@ -71,9 +74,9 @@ int main(int argc, char** argv)
APM::OperationType type = APM::NoType;
if (args->isSet("D")) {
type = APM::DatabaseOperation;
type = APM::DatabaseOperationType;
} else if (args->isSet("Q")) {
type = APM::QueryOperation;
type = APM::QueryOperationType;
if (args->isSet("c"))
list.append(APM::ShowChangelog);
if (args->isSet("d"))
......@@ -101,15 +104,15 @@ int main(int argc, char** argv)
if (args->isSet("q"))
list.append(APM::ShowLess);
} else if (args->isSet("R")) {
type = APM::RemoveOperation;
type = APM::RemoveOperationType;
} else if (args->isSet("S")) {
type = APM::SyncOperation;
type = APM::SyncOperationType;
if (args->isSet("y"))
list.append(APM::UpdateDatabases);
if (args->isSet("u"))
list.append(APM::UpdateSystem);
} else if (args->isSet("U")) {
type = APM::UpgradeOperation;
type = APM::UpgradeOperationType;
} else {
fprintf(stderr, "Please select an operation to do!\nCall akabei --help for explanation.\n");
return app.exec();
......
/* This file is part of the Chakra project
Copyright (C) 2011 Lukas Appelhans <l.appelhans@gmx.de>
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
*/
#include "queryoperation.h"
#include <akabeibackend.h>
#include <klocale.h>
#include <QTextStream>
QueryOperation::QueryOperation(QObject * parent)
: QObject(parent)
{
}
QueryOperation::~QueryOperation()
{
}
void QueryOperation::start(QList<APM::Operation> operations, QStringList args)
{
if (operations.contains(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());
}
}
void QueryOperation::showInformation(QUuid uuid,QList<Akabei::Package*> packages)
{
Q_UNUSED(uuid)
if (packages.isEmpty())
return;
Akabei::Package * pkg = packages.first();
QTextStream out(stdout);
out << i18n("Name:") << pkg->name() << endl;
out << i18n("Version:") << QString(pkg->version().toByteArray().data()) << endl;
out << i18n("URL") << pkg->url().toString() << endl;
out.flush();
}
/* This file is part of the Chakra project
Copyright (C) 2011 Lukas Appelhans <l.appelhans@gmx.de>
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
*/
#ifndef QUERYOPERATION_H
#define QUERYOPERATION_H
#include <QObject>
#include <QUuid>
#include "apm.h"
#include <akabeipackage.h>
class QueryOperation : public QObject
{
Q_OBJECT
public:
explicit QueryOperation(QObject * parent = 0);
virtual ~QueryOperation();
void start(QList<APM::Operation> operations, QStringList args);
private slots:
void showInformation(QUuid uuid,QList<Akabei::Package*> packages);
};
#endif // QUERYOPERATION_H
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