Projekte are now stored in a QMap
This commit is contained in:
@@ -1,12 +1,13 @@
|
|||||||
#include "kontierungdialog.h"
|
#include "kontierungdialog.h"
|
||||||
#include "ui_kontierungdialog.h"
|
#include "ui_kontierungdialog.h"
|
||||||
|
|
||||||
|
#include <QMap>
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
#include <QStringBuilder>
|
#include <QStringBuilder>
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
|
|
||||||
KontierungDialog::KontierungDialog(Zeiterfassung &erfassung, const Zeiterfassung::UserInfo &userInfo,
|
KontierungDialog::KontierungDialog(Zeiterfassung &erfassung, const Zeiterfassung::UserInfo &userInfo,
|
||||||
const QVector<Zeiterfassung::Projekt> &projekte, QWidget *parent) :
|
const QMap<QString, QString> &projekte, QWidget *parent) :
|
||||||
QDialog(parent),
|
QDialog(parent),
|
||||||
ui(new Ui::KontierungDialog),
|
ui(new Ui::KontierungDialog),
|
||||||
m_erfassung(erfassung),
|
m_erfassung(erfassung),
|
||||||
@@ -14,8 +15,8 @@ KontierungDialog::KontierungDialog(Zeiterfassung &erfassung, const Zeiterfassung
|
|||||||
{
|
{
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
|
|
||||||
for(const auto& projekt : projekte)
|
for(auto iter = projekte.constBegin(); iter != projekte.constEnd(); iter++)
|
||||||
ui->comboBoxProjekt->addItem(projekt.label % " (" % projekt.value % ')', projekt.value);
|
ui->comboBoxProjekt->addItem(iter.value() % " (" % iter.key() % ')', iter.key());
|
||||||
}
|
}
|
||||||
|
|
||||||
KontierungDialog::~KontierungDialog()
|
KontierungDialog::~KontierungDialog()
|
||||||
|
@@ -13,7 +13,7 @@ class KontierungDialog : public QDialog
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
explicit KontierungDialog(Zeiterfassung &erfassung, const Zeiterfassung::UserInfo &userInfo,
|
explicit KontierungDialog(Zeiterfassung &erfassung, const Zeiterfassung::UserInfo &userInfo,
|
||||||
const QVector<Zeiterfassung::Projekt> &projekte, QWidget *parent = 0);
|
const QMap<QString, QString> &projekte, QWidget *parent = 0);
|
||||||
~KontierungDialog();
|
~KontierungDialog();
|
||||||
|
|
||||||
QTime getTime() const;
|
QTime getTime() const;
|
||||||
|
@@ -192,7 +192,10 @@ void MainWindow::getProjekteFinished(bool success, const QString &message, const
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_projekte = projekte;
|
m_projekte.clear();
|
||||||
|
|
||||||
|
for(const auto &projekt : projekte)
|
||||||
|
m_projekte.insert(projekt.value, projekt.label);
|
||||||
|
|
||||||
updateComboboxes();
|
updateComboboxes();
|
||||||
}
|
}
|
||||||
@@ -1086,11 +1089,13 @@ void MainWindow::updateComboboxes()
|
|||||||
|
|
||||||
for(const auto &preferedProjekt : preferedProjekte)
|
for(const auto &preferedProjekt : preferedProjekte)
|
||||||
{
|
{
|
||||||
for(const auto &projekt : m_projekte)
|
if(!m_projekte.contains(preferedProjekt))
|
||||||
{
|
{
|
||||||
if(preferedProjekt == projekt.value)
|
qWarning() << "cannot find projekt" << preferedProjekt;
|
||||||
ui->comboBoxProjekt->addItem(projekt.label % " (" % projekt.value % ')', projekt.value);
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ui->comboBoxProjekt->addItem(m_projekte.value(preferedProjekt) % " (" % preferedProjekt % ')', preferedProjekt);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(preferedProjekte.count())
|
if(preferedProjekte.count())
|
||||||
@@ -1102,10 +1107,10 @@ void MainWindow::updateComboboxes()
|
|||||||
item->setFlags(item->flags() & ~(Qt::ItemIsSelectable|Qt::ItemIsEnabled));
|
item->setFlags(item->flags() & ~(Qt::ItemIsSelectable|Qt::ItemIsEnabled));
|
||||||
}
|
}
|
||||||
|
|
||||||
for(const auto &projekt : m_projekte)
|
for(auto iter = m_projekte.constBegin(); iter != m_projekte.constEnd(); iter++)
|
||||||
{
|
{
|
||||||
if(!preferedProjekte.contains(projekt.value))
|
if(!preferedProjekte.contains(iter.key()))
|
||||||
ui->comboBoxProjekt->addItem(projekt.label % " (" % projekt.value % ')', projekt.value);
|
ui->comboBoxProjekt->addItem(iter.value() % " (" % iter.key() % ')', iter.key());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -2,6 +2,7 @@
|
|||||||
#define MAINWINDOW_H
|
#define MAINWINDOW_H
|
||||||
|
|
||||||
#include <QMainWindow>
|
#include <QMainWindow>
|
||||||
|
#include <QMap>
|
||||||
|
|
||||||
#include "zeiterfassung.h"
|
#include "zeiterfassung.h"
|
||||||
|
|
||||||
@@ -48,7 +49,7 @@ private:
|
|||||||
QSettings &m_settings;
|
QSettings &m_settings;
|
||||||
Zeiterfassung &m_erfassung;
|
Zeiterfassung &m_erfassung;
|
||||||
const Zeiterfassung::UserInfo &m_userInfo;
|
const Zeiterfassung::UserInfo &m_userInfo;
|
||||||
QVector<Zeiterfassung::Projekt> m_projekte;
|
QMap<QString, QString> m_projekte;
|
||||||
QByteArray m_auswertung;
|
QByteArray m_auswertung;
|
||||||
QLabel *m_auswertungLabel;
|
QLabel *m_auswertungLabel;
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user