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