Using new projects model
This commit is contained in:
@@ -164,7 +164,7 @@ void AdvancedViewDialog::contextMenuTimeAssignment(const QPoint &pos)
|
|||||||
auto selectedAction = menu.exec(ui->timeAssignmentsView->viewport()->mapToGlobal(pos));
|
auto selectedAction = menu.exec(ui->timeAssignmentsView->viewport()->mapToGlobal(pos));
|
||||||
if(selectedAction == createAction)
|
if(selectedAction == createAction)
|
||||||
{
|
{
|
||||||
TimeAssignmentDialog dialog(m_stripsWidget.mainWindow().projects(),
|
TimeAssignmentDialog dialog(m_stripsWidget.mainWindow().projectsModel(),
|
||||||
m_stripsWidget.mainWindow().settings(), this);
|
m_stripsWidget.mainWindow().settings(), this);
|
||||||
again2:
|
again2:
|
||||||
if(dialog.exec() == QDialog::Accepted)
|
if(dialog.exec() == QDialog::Accepted)
|
||||||
@@ -207,12 +207,11 @@ void AdvancedViewDialog::contextMenuTimeAssignment(const QPoint &pos)
|
|||||||
auto selectedAction = menu.exec(ui->timeAssignmentsView->viewport()->mapToGlobal(pos));
|
auto selectedAction = menu.exec(ui->timeAssignmentsView->viewport()->mapToGlobal(pos));
|
||||||
if(selectedAction == editAction)
|
if(selectedAction == editAction)
|
||||||
{
|
{
|
||||||
TimeAssignmentDialog dialog(m_stripsWidget.mainWindow().projects(),
|
TimeAssignmentDialog dialog(m_stripsWidget.mainWindow().projectsModel(),
|
||||||
m_stripsWidget.mainWindow().settings(), this);
|
m_stripsWidget.mainWindow().settings(), this);
|
||||||
dialog.setTime(timeAssignment.time);
|
dialog.setTime(timeAssignment.time);
|
||||||
dialog.setTimespan(timeAssignment.timespan);
|
dialog.setTimespan(timeAssignment.timespan);
|
||||||
dialog.setProject(timeAssignment.project);
|
dialog.setProject(timeAssignment.project, timeAssignment.workpackage);
|
||||||
dialog.setWorkpackage(timeAssignment.workpackage);
|
|
||||||
dialog.setText(timeAssignment.text);
|
dialog.setText(timeAssignment.text);
|
||||||
again1:
|
again1:
|
||||||
if(dialog.exec() == QDialog::Accepted)
|
if(dialog.exec() == QDialog::Accepted)
|
||||||
|
@@ -5,40 +5,16 @@
|
|||||||
#include <QStringBuilder>
|
#include <QStringBuilder>
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
|
|
||||||
|
#include "projectsmodel.h"
|
||||||
#include "zeiterfassungsettings.h"
|
#include "zeiterfassungsettings.h"
|
||||||
|
|
||||||
TimeAssignmentDialog::TimeAssignmentDialog(const QMap<QString, QString> &projects, const ZeiterfassungSettings &settings,
|
TimeAssignmentDialog::TimeAssignmentDialog(ProjectsModel &projectsModel, const ZeiterfassungSettings &settings, QWidget *parent) :
|
||||||
QWidget *parent) :
|
|
||||||
ZeiterfassungDialog(parent),
|
ZeiterfassungDialog(parent),
|
||||||
ui(new Ui::TimeAssignmentDialog)
|
ui(new Ui::TimeAssignmentDialog)
|
||||||
{
|
{
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
|
|
||||||
{
|
ui->comboBoxProject->setModel(&projectsModel);
|
||||||
for(const auto &preferedProject : settings.projects())
|
|
||||||
{
|
|
||||||
if(!projects.contains(preferedProject))
|
|
||||||
{
|
|
||||||
qWarning() << "cannot find project" << preferedProject;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
ui->comboBoxProject->addItem(tr("%0 (%1)").arg(projects.value(preferedProject)).arg(preferedProject), preferedProject);
|
|
||||||
}
|
|
||||||
|
|
||||||
if(settings.projects().count())
|
|
||||||
ui->comboBoxProject->insertSeparator(ui->comboBoxProject->count());
|
|
||||||
|
|
||||||
for(auto iter = projects.constBegin(); iter != projects.constEnd(); iter++)
|
|
||||||
{
|
|
||||||
if(!settings.projects().contains(iter.key()))
|
|
||||||
ui->comboBoxProject->addItem(tr("%0 (%1)").arg(iter.value()).arg(iter.key()), iter.key());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
for(const auto &workpackage : settings.workpackages())
|
|
||||||
ui->comboBoxWorkpackage->addItem(workpackage);
|
|
||||||
ui->comboBoxWorkpackage->clearEditText();
|
|
||||||
|
|
||||||
for(const auto &text : settings.texts())
|
for(const auto &text : settings.texts())
|
||||||
ui->comboBoxText->addItem(text);
|
ui->comboBoxText->addItem(text);
|
||||||
@@ -72,26 +48,17 @@ void TimeAssignmentDialog::setTimespan(const QTime ×pan)
|
|||||||
|
|
||||||
QString TimeAssignmentDialog::getProject() const
|
QString TimeAssignmentDialog::getProject() const
|
||||||
{
|
{
|
||||||
return ui->comboBoxProject->currentData().toString();
|
return ui->comboBoxProject->currentData(Qt::UserRole).toString();
|
||||||
}
|
|
||||||
|
|
||||||
void TimeAssignmentDialog::setProject(const QString &project)
|
|
||||||
{
|
|
||||||
auto index = ui->comboBoxProject->findData(project);
|
|
||||||
if(index >= 0)
|
|
||||||
ui->comboBoxProject->setCurrentIndex(index);
|
|
||||||
else
|
|
||||||
qWarning() << "could not find project" << project;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QString TimeAssignmentDialog::getWorkpackage() const
|
QString TimeAssignmentDialog::getWorkpackage() const
|
||||||
{
|
{
|
||||||
return ui->comboBoxWorkpackage->currentText();
|
return ui->comboBoxProject->currentData(Qt::EditRole).toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
void TimeAssignmentDialog::setWorkpackage(const QString &workpackage)
|
void TimeAssignmentDialog::setProject(const QString &project, const QString &workpackage)
|
||||||
{
|
{
|
||||||
ui->comboBoxWorkpackage->setCurrentText(workpackage);
|
qCritical() << "not implemented";
|
||||||
}
|
}
|
||||||
|
|
||||||
QString TimeAssignmentDialog::getText() const
|
QString TimeAssignmentDialog::getText() const
|
||||||
|
@@ -1,11 +1,8 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <QTime>
|
|
||||||
|
|
||||||
#include "zeiterfassungdialog.h"
|
#include "zeiterfassungdialog.h"
|
||||||
|
|
||||||
template <class Key, class T> class QMap;
|
class ProjectsModel;
|
||||||
|
|
||||||
class ZeiterfassungSettings;
|
class ZeiterfassungSettings;
|
||||||
|
|
||||||
namespace Ui { class TimeAssignmentDialog; }
|
namespace Ui { class TimeAssignmentDialog; }
|
||||||
@@ -15,8 +12,7 @@ class TimeAssignmentDialog : public ZeiterfassungDialog
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit TimeAssignmentDialog(const QMap<QString, QString> &projects, const ZeiterfassungSettings &settings,
|
explicit TimeAssignmentDialog(ProjectsModel &projectsModel, const ZeiterfassungSettings &settings, QWidget *parent = Q_NULLPTR);
|
||||||
QWidget *parent = Q_NULLPTR);
|
|
||||||
~TimeAssignmentDialog();
|
~TimeAssignmentDialog();
|
||||||
|
|
||||||
QTime getTime() const;
|
QTime getTime() const;
|
||||||
@@ -26,10 +22,8 @@ public:
|
|||||||
void setTimespan(const QTime ×pan);
|
void setTimespan(const QTime ×pan);
|
||||||
|
|
||||||
QString getProject() const;
|
QString getProject() const;
|
||||||
void setProject(const QString &project);
|
|
||||||
|
|
||||||
QString getWorkpackage() const;
|
QString getWorkpackage() const;
|
||||||
void setWorkpackage(const QString &workpackage);
|
void setProject(const QString &project, const QString &workpackage);
|
||||||
|
|
||||||
QString getText() const;
|
QString getText() const;
|
||||||
void setText(const QString &text);
|
void setText(const QString &text);
|
||||||
|
@@ -10,12 +10,6 @@
|
|||||||
<height>307</height>
|
<height>307</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="maximumSize">
|
|
||||||
<size>
|
|
||||||
<width>16777215</width>
|
|
||||||
<height>0</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
<property name="windowTitle">
|
<property name="windowTitle">
|
||||||
<string>Time assignment</string>
|
<string>Time assignment</string>
|
||||||
</property>
|
</property>
|
||||||
@@ -44,6 +38,13 @@
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
<item row="0" column="1">
|
||||||
|
<widget class="QTimeEdit" name="timeEditTime">
|
||||||
|
<property name="displayFormat">
|
||||||
|
<string notr="true">HH:mm:ss</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
<item row="1" column="0">
|
<item row="1" column="0">
|
||||||
<widget class="QLabel" name="labelTimespan">
|
<widget class="QLabel" name="labelTimespan">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
@@ -54,6 +55,13 @@
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
<item row="1" column="1">
|
||||||
|
<widget class="QTimeEdit" name="timeEditTimespan">
|
||||||
|
<property name="displayFormat">
|
||||||
|
<string notr="true">HH:mm:ss</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
<item row="2" column="0">
|
<item row="2" column="0">
|
||||||
<widget class="QLabel" name="labelProject">
|
<widget class="QLabel" name="labelProject">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
@@ -64,48 +72,17 @@
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="3" column="0">
|
<item row="2" column="1">
|
||||||
<widget class="QLabel" name="labelWorkpackage">
|
<widget class="QComboBox" name="comboBoxProject"/>
|
||||||
<property name="text">
|
|
||||||
<string>Workpackage:</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
</item>
|
||||||
<item row="4" column="0">
|
<item row="3" column="0">
|
||||||
<widget class="QLabel" name="labelText">
|
<widget class="QLabel" name="labelText">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Text:</string>
|
<string>Text:</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="0" column="1">
|
|
||||||
<widget class="QTimeEdit" name="timeEditTime">
|
|
||||||
<property name="displayFormat">
|
|
||||||
<string notr="true">HH:mm:ss</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="1" column="1">
|
|
||||||
<widget class="QTimeEdit" name="timeEditTimespan">
|
|
||||||
<property name="displayFormat">
|
|
||||||
<string notr="true">HH:mm:ss</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="2" column="1">
|
|
||||||
<widget class="QComboBox" name="comboBoxProject"/>
|
|
||||||
</item>
|
|
||||||
<item row="3" column="1">
|
<item row="3" column="1">
|
||||||
<widget class="QComboBox" name="comboBoxWorkpackage">
|
|
||||||
<property name="editable">
|
|
||||||
<bool>true</bool>
|
|
||||||
</property>
|
|
||||||
<property name="insertPolicy">
|
|
||||||
<enum>QComboBox::NoInsert</enum>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="4" column="1">
|
|
||||||
<widget class="QComboBox" name="comboBoxText">
|
<widget class="QComboBox" name="comboBoxText">
|
||||||
<property name="editable">
|
<property name="editable">
|
||||||
<bool>true</bool>
|
<bool>true</bool>
|
||||||
|
@@ -74,17 +74,17 @@
|
|||||||
<translation>Kontierung löschen</translation>
|
<translation>Kontierung löschen</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../advancedviewdialog.cpp" line="239"/>
|
<location filename="../advancedviewdialog.cpp" line="238"/>
|
||||||
<source>Could not edit time assignment!</source>
|
<source>Could not edit time assignment!</source>
|
||||||
<translation>Konnte Kontierung nicht bearbeiten!</translation>
|
<translation>Konnte Kontierung nicht bearbeiten!</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../advancedviewdialog.cpp" line="247"/>
|
<location filename="../advancedviewdialog.cpp" line="246"/>
|
||||||
<source>Do you really want to delete the time assignment?</source>
|
<source>Do you really want to delete the time assignment?</source>
|
||||||
<translation>Möchten Sie die Kontierung wirklich löschen?</translation>
|
<translation>Möchten Sie die Kontierung wirklich löschen?</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../advancedviewdialog.cpp" line="261"/>
|
<location filename="../advancedviewdialog.cpp" line="260"/>
|
||||||
<source>Could not delete time assignment!</source>
|
<source>Could not delete time assignment!</source>
|
||||||
<translation>Konnte Kontierung nicht löschen!</translation>
|
<translation>Konnte Kontierung nicht löschen!</translation>
|
||||||
</message>
|
</message>
|
||||||
@@ -157,42 +157,31 @@
|
|||||||
<context>
|
<context>
|
||||||
<name>TimeAssignmentDialog</name>
|
<name>TimeAssignmentDialog</name>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../dialogs/timeassignmentdialog.ui" line="20"/>
|
<location filename="../dialogs/timeassignmentdialog.ui" line="14"/>
|
||||||
<location filename="../dialogs/timeassignmentdialog.ui" line="31"/>
|
<location filename="../dialogs/timeassignmentdialog.ui" line="25"/>
|
||||||
<source>Time assignment</source>
|
<source>Time assignment</source>
|
||||||
<translation>Kontierung</translation>
|
<translation>Kontierung</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../dialogs/timeassignmentdialog.ui" line="40"/>
|
<location filename="../dialogs/timeassignmentdialog.ui" line="34"/>
|
||||||
<source>Time:</source>
|
<source>Time:</source>
|
||||||
<translation>Zeit:</translation>
|
<translation>Zeit:</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../dialogs/timeassignmentdialog.ui" line="50"/>
|
<location filename="../dialogs/timeassignmentdialog.ui" line="51"/>
|
||||||
<source>Timespan:</source>
|
<source>Timespan:</source>
|
||||||
<translation>Zeitspanne:</translation>
|
<translation>Zeitspanne:</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../dialogs/timeassignmentdialog.ui" line="60"/>
|
<location filename="../dialogs/timeassignmentdialog.ui" line="68"/>
|
||||||
<source>Project:</source>
|
<source>Project:</source>
|
||||||
<translation>Projekt:</translation>
|
<translation>Projekt:</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../dialogs/timeassignmentdialog.ui" line="70"/>
|
<location filename="../dialogs/timeassignmentdialog.ui" line="81"/>
|
||||||
<source>Workpackage:</source>
|
|
||||||
<translation>Arbeitspaket:</translation>
|
|
||||||
</message>
|
|
||||||
<message>
|
|
||||||
<location filename="../dialogs/timeassignmentdialog.ui" line="77"/>
|
|
||||||
<source>Text:</source>
|
<source>Text:</source>
|
||||||
<translation>Text:</translation>
|
<translation>Text:</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
|
||||||
<location filename="../dialogs/timeassignmentdialog.cpp" line="26"/>
|
|
||||||
<location filename="../dialogs/timeassignmentdialog.cpp" line="35"/>
|
|
||||||
<source>%0 (%1)</source>
|
|
||||||
<translation>%0 (%1)</translation>
|
|
||||||
</message>
|
|
||||||
</context>
|
</context>
|
||||||
<context>
|
<context>
|
||||||
<name>TimeAssignmentsModel</name>
|
<name>TimeAssignmentsModel</name>
|
||||||
|
@@ -74,17 +74,17 @@
|
|||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../advancedviewdialog.cpp" line="239"/>
|
<location filename="../advancedviewdialog.cpp" line="238"/>
|
||||||
<source>Could not edit time assignment!</source>
|
<source>Could not edit time assignment!</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../advancedviewdialog.cpp" line="247"/>
|
<location filename="../advancedviewdialog.cpp" line="246"/>
|
||||||
<source>Do you really want to delete the time assignment?</source>
|
<source>Do you really want to delete the time assignment?</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../advancedviewdialog.cpp" line="261"/>
|
<location filename="../advancedviewdialog.cpp" line="260"/>
|
||||||
<source>Could not delete time assignment!</source>
|
<source>Could not delete time assignment!</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
@@ -157,42 +157,31 @@
|
|||||||
<context>
|
<context>
|
||||||
<name>TimeAssignmentDialog</name>
|
<name>TimeAssignmentDialog</name>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../dialogs/timeassignmentdialog.ui" line="20"/>
|
<location filename="../dialogs/timeassignmentdialog.ui" line="14"/>
|
||||||
<location filename="../dialogs/timeassignmentdialog.ui" line="31"/>
|
<location filename="../dialogs/timeassignmentdialog.ui" line="25"/>
|
||||||
<source>Time assignment</source>
|
<source>Time assignment</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../dialogs/timeassignmentdialog.ui" line="40"/>
|
<location filename="../dialogs/timeassignmentdialog.ui" line="34"/>
|
||||||
<source>Time:</source>
|
<source>Time:</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../dialogs/timeassignmentdialog.ui" line="50"/>
|
<location filename="../dialogs/timeassignmentdialog.ui" line="51"/>
|
||||||
<source>Timespan:</source>
|
<source>Timespan:</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../dialogs/timeassignmentdialog.ui" line="60"/>
|
<location filename="../dialogs/timeassignmentdialog.ui" line="68"/>
|
||||||
<source>Project:</source>
|
<source>Project:</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../dialogs/timeassignmentdialog.ui" line="70"/>
|
<location filename="../dialogs/timeassignmentdialog.ui" line="81"/>
|
||||||
<source>Workpackage:</source>
|
|
||||||
<translation type="unfinished"></translation>
|
|
||||||
</message>
|
|
||||||
<message>
|
|
||||||
<location filename="../dialogs/timeassignmentdialog.ui" line="77"/>
|
|
||||||
<source>Text:</source>
|
<source>Text:</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
|
||||||
<location filename="../dialogs/timeassignmentdialog.cpp" line="26"/>
|
|
||||||
<location filename="../dialogs/timeassignmentdialog.cpp" line="35"/>
|
|
||||||
<source>%0 (%1)</source>
|
|
||||||
<translation type="unfinished"></translation>
|
|
||||||
</message>
|
|
||||||
</context>
|
</context>
|
||||||
<context>
|
<context>
|
||||||
<name>TimeAssignmentsModel</name>
|
<name>TimeAssignmentsModel</name>
|
||||||
|
Reference in New Issue
Block a user