Skip to content

Commit

Permalink
database read & display in qml test
Browse files Browse the repository at this point in the history
very clumsy, nearly works, does compile :p
  • Loading branch information
vierlex committed Jun 9, 2013
1 parent 7364b2a commit 290734c
Show file tree
Hide file tree
Showing 15 changed files with 55 additions and 202 deletions.
10 changes: 10 additions & 0 deletions databasecontroller.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#include "databasecontroller.h"
#include "db/QDjango.h"
#include "db/QDjangoQuerySet.h"
#include "user.h"
#include "mos_user.h"
#include "admin.h"
Expand Down Expand Up @@ -39,3 +40,12 @@ DatabaseController::DatabaseController(){
QDjango::registerModel<Product>();
QDjango::registerModel<Project>();
}

QList<QVariantList> DatabaseController::listProjects(){
QDjangoQuerySet<Project> projects;
// QDjangoQuerySet<Project> someProjects;
// someProjects = projects.filter(QDjangoWhere("name", QDjangoWhere::Equals, "*") &&
// QDjangoWhere("valid_until", QDjangoWhere::NotEquals, "bla"));

return projects.valuesList();
}
11 changes: 6 additions & 5 deletions databasecontroller.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include "project.h"
#include "product.h"
#include "user.h"
#include "moneycode.h"

class DatabaseController{

Expand All @@ -13,20 +14,20 @@ class DatabaseController{
DatabaseController();

bool newProject();
bool shutdownProject(Project project); // allen usern gutscheine verschicken
bool finishProject(Project project); // email an alle, es war ein erfolg
bool shutdownProject(Project project); // sends all MOS users their redeem code again, set valid_until to hide the project (if not set)
bool finishProject(Project project); // payout the money & email MOS users, success!, set valid_until to hide the project (if not set)

bool newProduct(Project project);
bool deleteProduct(Product product); // generate moneycodes and/or send updates

bool newUser(QString email);
bool addMoneycode(User user); //generates and adds a moneycode to a user
bool sendMoneycode(User user); //sends an email about all the open moneycode for this user
bool redeemMoneycode(User user, QString moneycode); //paout that moneycode
bool redeemMoneycode(User user, QString code); //payout that moneycode

QList<Project> listProjects(QDateTime from, QDateTime to=QDateTime::currentDateTime());
QList<Project> listProjects(User user);
QList<Product> listProducts(User user);
QList<QVariantList> listProjects();
QList<Product> listProducts(Project project);

// new/edit/del projekte
// (nur leute die member sind duerfen projekte anlegen)
Expand Down
57 changes: 0 additions & 57 deletions databasecontroller.h.autosave

This file was deleted.

1 change: 0 additions & 1 deletion kassomatcontroller.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ class KassomatController : public QObject
void setState(const QString &state);

signals:

void smartPayoutDeviceChanged(const QString &newDevice);
void creditChanged(unsigned int);
void stateChanged(QString);
Expand Down
41 changes: 0 additions & 41 deletions kassomatcontroller.h.autosave

This file was deleted.

4 changes: 4 additions & 0 deletions main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,15 @@ int main(int argc, char *argv[])
KassomatController kassomatController;
DatabaseController databaseController;

QList<QVariantList> temp;

temp = databaseController.listProjects();
//kassomatController.setSmartPayoutDevice("/dev/ttyACM0");

QtQuick2ApplicationViewer viewer;
//in .qml files eine variable namens "controller" global verfuegbar machen
viewer.rootContext()->setContextProperty("controller", &kassomatController);
viewer.rootContext()->setContextProperty("projectlist", QVariant::fromValue(temp));
viewer.setMainQmlFile(QStringLiteral("qml/kassomat/main.qml"));
viewer.showExpanded();

Expand Down
11 changes: 8 additions & 3 deletions moneycode.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#ifndef MONEYCODES_H
#define MONEYCODES_H
#ifndef MONEYCODE_H
#define MONEYCODE_H

#include "db/QDjangoModel.h"
class Moneycode : public QDjangoModel
Expand All @@ -9,27 +9,32 @@ class Moneycode : public QDjangoModel

Q_PROPERTY(QString id READ id WRITE setId)
Q_PROPERTY(QString user_id READ user_id WRITE setUser_id)
Q_PROPERTY(QString booking_id READ booking_id WRITE setBooking_id)
Q_PROPERTY(QString code READ code WRITE setCode)

Q_CLASSINFO("__meta__", "db_table=moneycodes")

Q_CLASSINFO("id", "primary_key=true")
Q_CLASSINFO("user_id", "on_delete=Users.id")
Q_CLASSINFO("booking_id", "on_delete=Bookings.id")
Q_CLASSINFO("code", "max_length=100")

public:
QString id() const{ return m_id; }
QString user_id() const{ return m_user_id; }
QString booking_id() const{ return m_booking_id; }
QString code() const{ return m_code; }

void setId(const QString &id){ m_id = id; }
void setUser_id(const QString &user_id){ m_user_id = user_id; }
void setBooking_id(const QString &booking_id){ m_booking_id = booking_id; }
void setCode(const QString &code){ m_code = code; }

private:
QString m_id;
QString m_user_id;
QString m_booking_id;
QString m_code;
};

#endif // MONEYCODES_H
#endif // MONEYCODE_H
40 changes: 0 additions & 40 deletions moneycode.h.autosave

This file was deleted.

7 changes: 5 additions & 2 deletions projectcontroller.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,14 @@

#include <QObject>

class projectcontroller : public QObject
class ProjectController : public QObject
{
Q_OBJECT



public:
explicit projectcontroller(QObject *parent = 0);
explicit ProjectController(QObject *parent = 0);

signals:

Expand Down
21 changes: 0 additions & 21 deletions projectcontroller.h.autosave

This file was deleted.

14 changes: 14 additions & 0 deletions qml/kassomat/ProjectScreen.qml
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,19 @@ Rectangle{
anchors.fill: parent;
}

ListView {
id: list_view

anchors.fill: parent
//model: qmlModel
model: projectlist
delegate: Rectangle {
height: 20
width: 200
color: colour
Text { text: name }
}
}


}
3 changes: 3 additions & 0 deletions transactionlogcontroller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,7 @@
transactionlogcontroller::transactionlogcontroller(QObject *parent) :
QObject(parent)
{



}
9 changes: 0 additions & 9 deletions transactionlogcontroller.cpp.autosave

This file was deleted.

10 changes: 5 additions & 5 deletions transactionlogcontroller.h
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
#ifndef LOGCONTROLLER_H
#define LOGCONTROLLER_H
#ifndef TRANSACTIONLOGCONTROLLER_H
#define TRANSACTIONLOGCONTROLLER_H

#include <QObject>

class logcontroller : public QObject
class transactionlogcontroller : public QObject
{
Q_OBJECT
public:
explicit logcontroller(QObject *parent = 0);
explicit transactionlogcontroller(QObject *parent = 0);

signals:

public slots:

};

#endif // LOGCONTROLLER_H
#endif // TRANSACTIONLOGCONTROLLER_H
18 changes: 0 additions & 18 deletions transactionlogcontroller.h.autosave

This file was deleted.

0 comments on commit 290734c

Please sign in to comment.