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