Replaced lineEdits with comboBoxes in KontierungDialog
This commit is contained in:
@@ -2,10 +2,9 @@
|
|||||||
#define BUCHUNGDIALOG_H
|
#define BUCHUNGDIALOG_H
|
||||||
|
|
||||||
#include <QDialog>
|
#include <QDialog>
|
||||||
|
#include <QTime>
|
||||||
|
|
||||||
namespace Ui {
|
namespace Ui { class BuchungDialog; }
|
||||||
class BuchungDialog;
|
|
||||||
}
|
|
||||||
|
|
||||||
class BuchungDialog : public QDialog
|
class BuchungDialog : public QDialog
|
||||||
{
|
{
|
||||||
|
@@ -85,6 +85,19 @@
|
|||||||
<property name="editable">
|
<property name="editable">
|
||||||
<bool>true</bool>
|
<bool>true</bool>
|
||||||
</property>
|
</property>
|
||||||
|
<property name="insertPolicy">
|
||||||
|
<enum>QComboBox::NoInsert</enum>
|
||||||
|
</property>
|
||||||
|
<item>
|
||||||
|
<property name="text">
|
||||||
|
<string>K</string>
|
||||||
|
</property>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<property name="text">
|
||||||
|
<string>G</string>
|
||||||
|
</property>
|
||||||
|
</item>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
|
@@ -2,21 +2,59 @@
|
|||||||
#include "ui_kontierungdialog.h"
|
#include "ui_kontierungdialog.h"
|
||||||
|
|
||||||
#include <QMap>
|
#include <QMap>
|
||||||
#include <QMessageBox>
|
#include <QSettings>
|
||||||
#include <QStringBuilder>
|
#include <QStringBuilder>
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
|
#include <QStandardItemModel>
|
||||||
|
|
||||||
KontierungDialog::KontierungDialog(Zeiterfassung &erfassung, const Zeiterfassung::UserInfo &userInfo,
|
KontierungDialog::KontierungDialog(const QMap<QString, QString> &projekte, const QSettings &settings,
|
||||||
const QMap<QString, QString> &projekte, QWidget *parent) :
|
QWidget *parent) :
|
||||||
QDialog(parent),
|
QDialog(parent),
|
||||||
ui(new Ui::KontierungDialog),
|
ui(new Ui::KontierungDialog)
|
||||||
m_erfassung(erfassung),
|
|
||||||
m_userInfo(userInfo)
|
|
||||||
{
|
{
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
|
|
||||||
for(auto iter = projekte.constBegin(); iter != projekte.constEnd(); iter++)
|
{
|
||||||
ui->comboBoxProjekt->addItem(iter.value() % " (" % iter.key() % ')', iter.key());
|
auto preferedProjekte = settings.value("projekte", QStringList()).toStringList();
|
||||||
|
|
||||||
|
for(const auto &preferedProjekt : preferedProjekte)
|
||||||
|
{
|
||||||
|
if(!projekte.contains(preferedProjekt))
|
||||||
|
{
|
||||||
|
qWarning() << "cannot find projekt" << preferedProjekt;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
ui->comboBoxProjekt->addItem(projekte.value(preferedProjekt) % " (" % preferedProjekt % ')', preferedProjekt);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(preferedProjekte.count())
|
||||||
|
{
|
||||||
|
ui->comboBoxProjekt->addItem(QStringLiteral("--------------"));
|
||||||
|
|
||||||
|
auto model = qobject_cast<const QStandardItemModel*>(ui->comboBoxProjekt->model());
|
||||||
|
auto item = model->item(ui->comboBoxProjekt->count() - 1);
|
||||||
|
item->setFlags(item->flags() & ~(Qt::ItemIsSelectable|Qt::ItemIsEnabled));
|
||||||
|
}
|
||||||
|
|
||||||
|
for(auto iter = projekte.constBegin(); iter != projekte.constEnd(); iter++)
|
||||||
|
{
|
||||||
|
if(!preferedProjekte.contains(iter.key()))
|
||||||
|
ui->comboBoxProjekt->addItem(iter.value() % " (" % iter.key() % ')', iter.key());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for(const auto &subprojekt : settings.value("subprojekte", QStringList()).toStringList())
|
||||||
|
ui->comboBoxSubprojekt->addItem(subprojekt);
|
||||||
|
ui->comboBoxSubprojekt->clearEditText();
|
||||||
|
|
||||||
|
for(const auto &workpackage : settings.value("workpackages", QStringList()).toStringList())
|
||||||
|
ui->comboBoxWorkpackage->addItem(workpackage);
|
||||||
|
ui->comboBoxWorkpackage->clearEditText();
|
||||||
|
|
||||||
|
for(const auto &text : settings.value("texte", QStringList()).toStringList())
|
||||||
|
ui->comboBoxText->addItem(text);
|
||||||
|
ui->comboBoxText->clearEditText();
|
||||||
}
|
}
|
||||||
|
|
||||||
KontierungDialog::~KontierungDialog()
|
KontierungDialog::~KontierungDialog()
|
||||||
@@ -60,30 +98,30 @@ void KontierungDialog::setProjekt(const QString &projekt)
|
|||||||
|
|
||||||
QString KontierungDialog::getSubprojekt() const
|
QString KontierungDialog::getSubprojekt() const
|
||||||
{
|
{
|
||||||
return ui->lineEditSubprojekt->text();
|
return ui->comboBoxSubprojekt->currentText();
|
||||||
}
|
}
|
||||||
|
|
||||||
void KontierungDialog::setSubprojekt(const QString &subprojekt)
|
void KontierungDialog::setSubprojekt(const QString &subprojekt)
|
||||||
{
|
{
|
||||||
ui->lineEditSubprojekt->setText(subprojekt);
|
ui->comboBoxSubprojekt->setCurrentText(subprojekt);
|
||||||
}
|
}
|
||||||
|
|
||||||
QString KontierungDialog::getWorkpackage() const
|
QString KontierungDialog::getWorkpackage() const
|
||||||
{
|
{
|
||||||
return ui->lineEditWorkpackage->text();
|
return ui->comboBoxWorkpackage->currentText();
|
||||||
}
|
}
|
||||||
|
|
||||||
void KontierungDialog::setWorkpackage(const QString &workpackage)
|
void KontierungDialog::setWorkpackage(const QString &workpackage)
|
||||||
{
|
{
|
||||||
ui->lineEditWorkpackage->setText(workpackage);
|
ui->comboBoxWorkpackage->setCurrentText(workpackage);
|
||||||
}
|
}
|
||||||
|
|
||||||
QString KontierungDialog::getText() const
|
QString KontierungDialog::getText() const
|
||||||
{
|
{
|
||||||
return ui->lineEditText->text();
|
return ui->comboBoxText->currentText();
|
||||||
}
|
}
|
||||||
|
|
||||||
void KontierungDialog::setText(const QString &text)
|
void KontierungDialog::setText(const QString &text)
|
||||||
{
|
{
|
||||||
ui->lineEditText->setText(text);
|
ui->comboBoxText->setCurrentText(text);
|
||||||
}
|
}
|
||||||
|
@@ -2,8 +2,10 @@
|
|||||||
#define KONTIERUNGDIALOG_H
|
#define KONTIERUNGDIALOG_H
|
||||||
|
|
||||||
#include <QDialog>
|
#include <QDialog>
|
||||||
|
#include <QTime>
|
||||||
|
|
||||||
#include "zeiterfassung.h"
|
template <class Key, class T> class QMap;
|
||||||
|
class QSettings;
|
||||||
|
|
||||||
namespace Ui { class KontierungDialog; }
|
namespace Ui { class KontierungDialog; }
|
||||||
|
|
||||||
@@ -12,8 +14,8 @@ class KontierungDialog : public QDialog
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit KontierungDialog(Zeiterfassung &erfassung, const Zeiterfassung::UserInfo &userInfo,
|
explicit KontierungDialog(const QMap<QString, QString> &projekte, const QSettings &settings,
|
||||||
const QMap<QString, QString> &projekte, QWidget *parent = 0);
|
QWidget *parent = 0);
|
||||||
~KontierungDialog();
|
~KontierungDialog();
|
||||||
|
|
||||||
QTime getTime() const;
|
QTime getTime() const;
|
||||||
@@ -36,8 +38,6 @@ public:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
Ui::KontierungDialog *ui;
|
Ui::KontierungDialog *ui;
|
||||||
Zeiterfassung &m_erfassung;
|
|
||||||
const Zeiterfassung::UserInfo &m_userInfo;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // KONTIERUNGDIALOG_H
|
#endif // KONTIERUNGDIALOG_H
|
||||||
|
@@ -58,9 +58,6 @@
|
|||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Subprojekt:</string>
|
<string>Subprojekt:</string>
|
||||||
</property>
|
</property>
|
||||||
<property name="buddy">
|
|
||||||
<cstring>lineEditSubprojekt</cstring>
|
|
||||||
</property>
|
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="4" column="0">
|
<item row="4" column="0">
|
||||||
@@ -68,9 +65,6 @@
|
|||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Workpackage:</string>
|
<string>Workpackage:</string>
|
||||||
</property>
|
</property>
|
||||||
<property name="buddy">
|
|
||||||
<cstring>lineEditWorkpackage</cstring>
|
|
||||||
</property>
|
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="5" column="0">
|
<item row="5" column="0">
|
||||||
@@ -78,9 +72,6 @@
|
|||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Text:</string>
|
<string>Text:</string>
|
||||||
</property>
|
</property>
|
||||||
<property name="buddy">
|
|
||||||
<cstring>lineEditText</cstring>
|
|
||||||
</property>
|
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="0" column="1">
|
<item row="0" column="1">
|
||||||
@@ -108,13 +99,34 @@
|
|||||||
<widget class="QComboBox" name="comboBoxProjekt"/>
|
<widget class="QComboBox" name="comboBoxProjekt"/>
|
||||||
</item>
|
</item>
|
||||||
<item row="3" column="1">
|
<item row="3" column="1">
|
||||||
<widget class="QLineEdit" name="lineEditSubprojekt"/>
|
<widget class="QComboBox" name="comboBoxSubprojekt">
|
||||||
|
<property name="editable">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
<property name="insertPolicy">
|
||||||
|
<enum>QComboBox::NoInsert</enum>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="4" column="1">
|
<item row="4" column="1">
|
||||||
<widget class="QLineEdit" name="lineEditWorkpackage"/>
|
<widget class="QComboBox" name="comboBoxWorkpackage">
|
||||||
|
<property name="editable">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
<property name="insertPolicy">
|
||||||
|
<enum>QComboBox::NoInsert</enum>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="5" column="1">
|
<item row="5" column="1">
|
||||||
<widget class="QLineEdit" name="lineEditText"/>
|
<widget class="QComboBox" name="comboBoxText">
|
||||||
|
<property name="editable">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
<property name="insertPolicy">
|
||||||
|
<enum>QComboBox::NoInsert</enum>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
|
@@ -488,7 +488,7 @@ void MainWindow::contextMenuKontierung(const QPoint &pos)
|
|||||||
auto selectedAction = menu.exec(ui->treeViewKontierungen->viewport()->mapToGlobal(pos));
|
auto selectedAction = menu.exec(ui->treeViewKontierungen->viewport()->mapToGlobal(pos));
|
||||||
if(selectedAction == editAction)
|
if(selectedAction == editAction)
|
||||||
{
|
{
|
||||||
KontierungDialog dialog(m_erfassung, m_userInfo, m_projekte, this);
|
KontierungDialog dialog(m_projekte, m_settings, this);
|
||||||
dialog.setTime(kontierung.time);
|
dialog.setTime(kontierung.time);
|
||||||
dialog.setTimespan(kontierung.timespan);
|
dialog.setTimespan(kontierung.timespan);
|
||||||
dialog.setProjekt(kontierung.projekt);
|
dialog.setProjekt(kontierung.projekt);
|
||||||
@@ -523,6 +523,11 @@ void MainWindow::contextMenuKontierung(const QPoint &pos)
|
|||||||
ui->pushButtonEnd->setEnabled(false);
|
ui->pushButtonEnd->setEnabled(false);
|
||||||
ui->treeViewKontierungen->setEnabled(false);
|
ui->treeViewKontierungen->setEnabled(false);
|
||||||
|
|
||||||
|
addPreferedEntry("projekte", dialog.getProjekt());
|
||||||
|
addPreferedEntry("subprojekte", dialog.getSubprojekt());
|
||||||
|
addPreferedEntry("workpackages", dialog.getWorkpackage());
|
||||||
|
addPreferedEntry("texte", dialog.getText());
|
||||||
|
|
||||||
clearStrips();
|
clearStrips();
|
||||||
|
|
||||||
if(m_kontierungenModel->refresh(m_userInfo.userId, ui->dateEditDate->date(), ui->dateEditDate->date()))
|
if(m_kontierungenModel->refresh(m_userInfo.userId, ui->dateEditDate->date(), ui->dateEditDate->date()))
|
||||||
@@ -606,7 +611,7 @@ void MainWindow::contextMenuKontierung(const QPoint &pos)
|
|||||||
auto selectedAction = menu.exec(ui->treeViewKontierungen->viewport()->mapToGlobal(pos));
|
auto selectedAction = menu.exec(ui->treeViewKontierungen->viewport()->mapToGlobal(pos));
|
||||||
if(selectedAction == createAction)
|
if(selectedAction == createAction)
|
||||||
{
|
{
|
||||||
KontierungDialog dialog(m_erfassung, m_userInfo, m_projekte, this);
|
KontierungDialog dialog(m_projekte, m_settings, this);
|
||||||
again2:
|
again2:
|
||||||
if(dialog.exec() == QDialog::Accepted)
|
if(dialog.exec() == QDialog::Accepted)
|
||||||
{
|
{
|
||||||
@@ -635,6 +640,11 @@ void MainWindow::contextMenuKontierung(const QPoint &pos)
|
|||||||
ui->pushButtonEnd->setEnabled(false);
|
ui->pushButtonEnd->setEnabled(false);
|
||||||
ui->treeViewKontierungen->setEnabled(false);
|
ui->treeViewKontierungen->setEnabled(false);
|
||||||
|
|
||||||
|
addPreferedEntry("projekte", dialog.getProjekt());
|
||||||
|
addPreferedEntry("subprojekte", dialog.getSubprojekt());
|
||||||
|
addPreferedEntry("workpackages", dialog.getWorkpackage());
|
||||||
|
addPreferedEntry("texte", dialog.getText());
|
||||||
|
|
||||||
clearStrips();
|
clearStrips();
|
||||||
|
|
||||||
if(m_kontierungenModel->refresh(m_userInfo.userId, ui->dateEditDate->date(), ui->dateEditDate->date()))
|
if(m_kontierungenModel->refresh(m_userInfo.userId, ui->dateEditDate->date(), ui->dateEditDate->date()))
|
||||||
@@ -736,36 +746,10 @@ void MainWindow::pushButtonStartPressed()
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
addPreferedEntry("projekte", ui->comboBoxProjekt->currentData().toString());
|
||||||
QStringList projekte = m_settings.value("projekte", QStringList()).toStringList();
|
addPreferedEntry("subprojekte", ui->comboBoxSubprojekt->currentText());
|
||||||
projekte.removeAll(ui->comboBoxProjekt->currentData().toString());
|
addPreferedEntry("workpackages", ui->comboBoxWorkpackage->currentText());
|
||||||
projekte.prepend(ui->comboBoxProjekt->currentData().toString());
|
addPreferedEntry("texte", ui->comboBoxText->currentText());
|
||||||
m_settings.setValue("projekte", projekte);
|
|
||||||
}
|
|
||||||
|
|
||||||
if(!ui->comboBoxSubprojekt->currentText().trimmed().isEmpty())
|
|
||||||
{
|
|
||||||
QStringList subprojekte = m_settings.value("subprojekte", QStringList()).toStringList();
|
|
||||||
subprojekte.removeAll(ui->comboBoxSubprojekt->currentText());
|
|
||||||
subprojekte.prepend(ui->comboBoxSubprojekt->currentText());
|
|
||||||
m_settings.setValue("subprojekte", subprojekte);
|
|
||||||
}
|
|
||||||
|
|
||||||
if(!ui->comboBoxWorkpackage->currentText().trimmed().isEmpty())
|
|
||||||
{
|
|
||||||
QStringList workpackages = m_settings.value("workpackages", QStringList()).toStringList();
|
|
||||||
workpackages.removeAll(ui->comboBoxWorkpackage->currentText());
|
|
||||||
workpackages.prepend(ui->comboBoxWorkpackage->currentText());
|
|
||||||
m_settings.setValue("workpackages", workpackages);
|
|
||||||
}
|
|
||||||
|
|
||||||
if(!ui->comboBoxText->currentText().trimmed().isEmpty())
|
|
||||||
{
|
|
||||||
QStringList texte = m_settings.value("texte", QStringList()).toStringList();
|
|
||||||
texte.removeAll(ui->comboBoxText->currentText());
|
|
||||||
texte.prepend(ui->comboBoxText->currentText());
|
|
||||||
m_settings.setValue("texte", texte);
|
|
||||||
}
|
|
||||||
|
|
||||||
updateComboboxes();
|
updateComboboxes();
|
||||||
|
|
||||||
@@ -819,6 +803,17 @@ void MainWindow::pushButtonEndPressed()
|
|||||||
refresh();
|
refresh();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MainWindow::addPreferedEntry(const QString &name, const QString &value)
|
||||||
|
{
|
||||||
|
if(value.trimmed().isEmpty())
|
||||||
|
return;
|
||||||
|
|
||||||
|
QStringList entries = m_settings.value(name, QStringList()).toStringList();
|
||||||
|
entries.removeAll(value);
|
||||||
|
entries.prepend(value);
|
||||||
|
m_settings.setValue(name, entries);
|
||||||
|
}
|
||||||
|
|
||||||
void MainWindow::validateEntries()
|
void MainWindow::validateEntries()
|
||||||
{
|
{
|
||||||
ui->timeEditTime->setMinimumTime(QTime(0, 0));
|
ui->timeEditTime->setMinimumTime(QTime(0, 0));
|
||||||
|
@@ -40,6 +40,7 @@ private Q_SLOTS:
|
|||||||
void pushButtonEndPressed();
|
void pushButtonEndPressed();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
void addPreferedEntry(const QString &name, const QString &value);
|
||||||
void validateEntries();
|
void validateEntries();
|
||||||
void updateComboboxes();
|
void updateComboboxes();
|
||||||
void updateAuswertung();
|
void updateAuswertung();
|
||||||
|
Reference in New Issue
Block a user