Thank you for this fast answer! 
Here are the code, I hope it's okay to post it here, if PasteBin is better please let me know!
Freiertag.hpp
#ifndef FREIERTAG_HPP_
#define FREIERTAG_HPP_
#include <QObject>
#include <QString>
#include <QDebug>
#include "FreiListModel.hpp"
Q_OBJECT
public:
Freiertag
(FreiListModel
*model,
QObject *parent
= 0);
//FreiListModel freiModel; // use here the passed model?!
~Freiertag();
private:
void sucheFeiertage();
void sucheAlleFeiertage();
};
#endif /* FREIERTAG_HPP_ */
#ifndef FREIERTAG_HPP_
#define FREIERTAG_HPP_
#include <QObject>
#include <QString>
#include <QDebug>
#include "FreiListModel.hpp"
class Freiertag : public QObject {
Q_OBJECT
public:
Freiertag(FreiListModel *model, QObject *parent = 0);
//FreiListModel freiModel; // use here the passed model?!
Q_INVOKABLE void suche(QString bland, QString jahr, QString typ);
~Freiertag();
private:
void sucheFerien(const QString &bland, const QString &jahr);
void sucheFeiertage();
void sucheAlleFeiertage();
};
#endif /* FREIERTAG_HPP_ */
To copy to clipboard, switch view to plain text mode
FreiListModel.hpp
ifndef FREILISTMODEL_HPP_
#define FREILISTMODEL_HPP_
#include <QAbstractListModel>
#include <QVariant>
#include <QList>
#include <QString>
class FreiEvent
{
public:
FreiEvent();
~FreiEvent();
};
{
Q_OBJECT
enum ModelRoles {
EventRole = Qt::UserRole + 1,
DateRole
};
public:
FreiListModel
(QObject *parent
= 0);
void printInfo();
~FreiListModel();
private:
QList<FreiEvent> resultList;
};
#endif /* FREILISTMODEL_HPP_ */
ifndef FREILISTMODEL_HPP_
#define FREILISTMODEL_HPP_
#include <QAbstractListModel>
#include <QVariant>
#include <QList>
#include <QString>
class FreiEvent
{
public:
QString eventName;
QString eventDate;
FreiEvent();
FreiEvent(QString event, QString date);
~FreiEvent();
};
class FreiListModel : public QAbstractListModel
{
Q_OBJECT
enum ModelRoles {
EventRole = Qt::UserRole + 1,
DateRole
};
public:
FreiListModel(QObject *parent = 0);
int rowCount(const QModelIndex &parent) const;
QVariant data(const QModelIndex &parent, int role=Qt::DisplayRole) const;
void addEvent(QString event, QString date);
void printInfo();
~FreiListModel();
private:
QList<FreiEvent> resultList;
};
#endif /* FREILISTMODEL_HPP_ */
To copy to clipboard, switch view to plain text mode
part of main.cpp
//create a new ListModel for the results
FreiListModel *freiModel = new FreiListModel(app);
//create a new instance of our object that is doing the most work
Freiertag *frei = new Freiertag(freiModel, app);
QDeclarativeView viewer;
viewer.rootContext()->setContextProperty("frei", frei);
viewer.rootContext()->setContextProperty("freiModel", freiModel);
//create a new ListModel for the results
FreiListModel *freiModel = new FreiListModel(app);
//create a new instance of our object that is doing the most work
Freiertag *frei = new Freiertag(freiModel, app);
QDeclarativeView viewer;
viewer.rootContext()->setContextProperty("frei", frei);
viewer.rootContext()->setContextProperty("freiModel", freiModel);
To copy to clipboard, switch view to plain text mode
Thank you!
AlphaX2
Bookmarks