Formular zur Erfassung der Amts-Adressen

master
Thomas Hooge 2 years ago
parent c455cd4a4c
commit 75f9aff5dc
  1. 103
      amtadressdialog.cpp
  2. 50
      amtadressdialog.h
  3. 206
      amtadressdialog.ui
  4. 21
      mainwindow.cpp
  5. 2
      mainwindow.h
  6. 12
      mainwindow.ui
  7. 7
      pmv-client.pro

@ -0,0 +1,103 @@
/* Diese Datei ist Teil von pmv-client <https://git.piratenpartei-sh.de>
*
* pmv-client ist Freie Software: Sie können es unter den Bedingungen
* der GNU General Public License, wie von der Free Software Foundation,
* Version 3 der Lizenz weiter verteilen und/oder modifizieren.
*
* Dieses Programm wird in der Hoffnung bereitgestellt, dass es nützlich sein
* wird, jedoch OHNE JEDE GEWÄHR,; sogar ohne die implizite Gewähr der
* MARKTFÄHIGKEIT oder EIGNUNG FÜR EINEN BESTIMMTEN ZWECK.
* Siehe die GNU General Public License für weitere Einzelheiten.
*
* Sie sollten eine Kopie der GNU General Public License zusammen mit diesem
* Programm erhalten haben. Wenn nicht, siehe <https://www.gnu.org/licenses/>.
*
* SPDX-License-Identifier: GPL-3.0-only
*/
#include "amtadressdialog.h"
#include "ui_amtadressdialog.h"
#include <QSqlRecord>
#include <QDebug>
#include <QSqlError>
AmtAdressDialog::AmtAdressDialog(QWidget *parent) :
QDialog(parent),
ui(new Ui::AmtAdressDialog)
{
ui->setupUi(this);
// Modell initialisieren
model = new QSqlTableModel(this);
model->setTable("amtadresse");
model->setEditStrategy(QSqlTableModel::OnManualSubmit);
model->setHeaderData(0, Qt::Horizontal, "ID");
model->setHeaderData(1, Qt::Horizontal, "Bezeichnung");
model->setHeaderData(2, Qt::Horizontal, "Abteilung");
model->setHeaderData(3, Qt::Horizontal, "Zusatz");
model->setHeaderData(4, Qt::Horizontal, "Straße");
model->setHeaderData(5, Qt::Horizontal, "PLZ");
model->setHeaderData(6, Qt::Horizontal, "Ort");
model->setHeaderData(7, Qt::Horizontal, "Telefon");
model->setHeaderData(8, Qt::Horizontal, "Email");
model->setHeaderData(9, Qt::Horizontal, "Bemerkungen");
model->setSort(0, Qt::AscendingOrder);
// View initialisieren
ui->tableView->setModel(model);
ui->tableView->setColumnHidden(0, true);
ui->tableView->setSelectionBehavior(QAbstractItemView::SelectRows);
ui->tableView->setEditTriggers(QAbstractItemView::NoEditTriggers);
ui->tableView->horizontalHeader()->setStretchLastSection(true);
model->select();
// Mapping der Eingabefelder
mapper = new QDataWidgetMapper(this);
mapper->setModel(model);
mapper->addMapping(ui->lineEdit_bezeichnung, model->fieldIndex("bezeichnung"));
mapper->addMapping(ui->lineEdit_abteilung, model->fieldIndex("abteilung"));
mapper->addMapping(ui->lineEdit_zusatz, model->fieldIndex("zusatz"));
mapper->addMapping(ui->lineEdit_strasse, model->fieldIndex("strasse"));
mapper->addMapping(ui->lineEdit_plz, model->fieldIndex("plz"));
mapper->addMapping(ui->lineEdit_ort, model->fieldIndex("ort"));
mapper->addMapping(ui->lineEdit_telefon, model->fieldIndex("telefon"));
mapper->addMapping(ui->lineEdit_email, model->fieldIndex("email"));
mapper->addMapping(ui->plainTextEdit, model->fieldIndex("bemerkungen"));
connect(ui->tableView->selectionModel(),&QItemSelectionModel::currentRowChanged,
mapper, &QDataWidgetMapper::setCurrentModelIndex);
}
AmtAdressDialog::~AmtAdressDialog()
{
delete ui;
}
void AmtAdressDialog::on_buttonBox_accepted()
{
}
void AmtAdressDialog::on_pushButton_neu_clicked()
{
QSqlRecord r = model->record();
r.setGenerated("id", true);
r.setValue("bezeichnung", "Neues Amt");
if (!model->insertRecord(-1, r)) {
qDebug() << model->lastError().text();
}
}
void AmtAdressDialog::on_pushButton_speichern_clicked()
{
mapper->submit();
if (model->submitAll()) {
qDebug() << "Submitted to database";
} else {
qDebug() << "summitAll() failed!";
qDebug() << model->lastError().text();
}
}

@ -0,0 +1,50 @@
/* Diese Datei ist Teil von pmv-client <https://git.piratenpartei-sh.de>
*
* pmv-client ist Freie Software: Sie können es unter den Bedingungen
* der GNU General Public License, wie von der Free Software Foundation,
* Version 3 der Lizenz weiter verteilen und/oder modifizieren.
*
* Dieses Programm wird in der Hoffnung bereitgestellt, dass es nützlich sein
* wird, jedoch OHNE JEDE GEWÄHR,; sogar ohne die implizite Gewähr der
* MARKTFÄHIGKEIT oder EIGNUNG FÜR EINEN BESTIMMTEN ZWECK.
* Siehe die GNU General Public License für weitere Einzelheiten.
*
* Sie sollten eine Kopie der GNU General Public License zusammen mit diesem
* Programm erhalten haben. Wenn nicht, siehe <https://www.gnu.org/licenses/>.
*
* SPDX-License-Identifier: GPL-3.0-only
*/
#ifndef AMTADRESSDIALOG_H
#define AMTADRESSDIALOG_H
#include <QDialog>
#include <QSqlTableModel>
#include <QDataWidgetMapper>
namespace Ui {
class AmtAdressDialog;
}
class AmtAdressDialog : public QDialog
{
Q_OBJECT
public:
explicit AmtAdressDialog(QWidget *parent = nullptr);
~AmtAdressDialog();
private slots:
void on_buttonBox_accepted();
void on_pushButton_neu_clicked();
void on_pushButton_speichern_clicked();
private:
Ui::AmtAdressDialog *ui;
QSqlTableModel *model;
QDataWidgetMapper *mapper;
};
#endif // AMTADRESSDIALOG_H

@ -0,0 +1,206 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>AmtAdressDialog</class>
<widget class="QDialog" name="AmtAdressDialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>833</width>
<height>566</height>
</rect>
</property>
<property name="windowTitle">
<string>Amtadressen</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QTableView" name="tableView"/>
</item>
<item>
<layout class="QGridLayout" name="gridLayout">
<item row="1" column="1">
<widget class="QLineEdit" name="lineEdit_abteilung"/>
</item>
<item row="0" column="1">
<widget class="QLineEdit" name="lineEdit_bezeichnung"/>
</item>
<item row="3" column="0">
<widget class="QLabel" name="label_4">
<property name="text">
<string>Straße</string>
</property>
</widget>
</item>
<item row="4" column="1">
<widget class="QLineEdit" name="lineEdit_plz"/>
</item>
<item row="4" column="0">
<widget class="QLabel" name="label_5">
<property name="text">
<string>PLZ</string>
</property>
</widget>
</item>
<item row="1" column="3">
<widget class="QLabel" name="label_8">
<property name="text">
<string>Email</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_2">
<property name="text">
<string>Abteilung</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QLineEdit" name="lineEdit_zusatz"/>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_3">
<property name="text">
<string>Zusatz</string>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>Bezeichnung</string>
</property>
</widget>
</item>
<item row="0" column="4">
<widget class="QLineEdit" name="lineEdit_telefon"/>
</item>
<item row="0" column="3">
<widget class="QLabel" name="label_7">
<property name="text">
<string>Telefon</string>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QLineEdit" name="lineEdit_strasse"/>
</item>
<item row="1" column="4">
<widget class="QLineEdit" name="lineEdit_email"/>
</item>
<item row="5" column="0">
<widget class="QLabel" name="label_6">
<property name="text">
<string>Ort</string>
</property>
</widget>
</item>
<item row="5" column="1">
<widget class="QLineEdit" name="lineEdit_ort"/>
</item>
<item row="2" column="3">
<widget class="QLabel" name="label_9">
<property name="text">
<string>Bemerkungen</string>
</property>
</widget>
</item>
<item row="2" column="4" rowspan="4">
<widget class="QPlainTextEdit" name="plainTextEdit"/>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QPushButton" name="pushButton_neu">
<property name="text">
<string>Neu</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pushButton_speichern">
<property name="text">
<string>Speichern</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item>
<widget class="QDialogButtonBox" name="buttonBox">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Close</set>
</property>
</widget>
</item>
</layout>
</widget>
<tabstops>
<tabstop>tableView</tabstop>
<tabstop>lineEdit_bezeichnung</tabstop>
<tabstop>lineEdit_abteilung</tabstop>
<tabstop>lineEdit_zusatz</tabstop>
<tabstop>lineEdit_strasse</tabstop>
<tabstop>lineEdit_plz</tabstop>
<tabstop>lineEdit_ort</tabstop>
<tabstop>lineEdit_telefon</tabstop>
<tabstop>lineEdit_email</tabstop>
<tabstop>plainTextEdit</tabstop>
<tabstop>pushButton_neu</tabstop>
<tabstop>pushButton_speichern</tabstop>
</tabstops>
<resources/>
<connections>
<connection>
<sender>buttonBox</sender>
<signal>accepted()</signal>
<receiver>AmtAdressDialog</receiver>
<slot>accept()</slot>
<hints>
<hint type="sourcelabel">
<x>248</x>
<y>254</y>
</hint>
<hint type="destinationlabel">
<x>157</x>
<y>274</y>
</hint>
</hints>
</connection>
<connection>
<sender>buttonBox</sender>
<signal>rejected()</signal>
<receiver>AmtAdressDialog</receiver>
<slot>reject()</slot>
<hints>
<hint type="sourcelabel">
<x>316</x>
<y>260</y>
</hint>
<hint type="destinationlabel">
<x>286</x>
<y>274</y>
</hint>
</hints>
</connection>
</connections>
</ui>

@ -33,6 +33,7 @@
#include "importdialog.h"
#include "wahldialog.h"
#include "wahlkreisdialog.h"
#include "amtadressdialog.h"
#include "configdialog.h"
MainWindow::MainWindow(QWidget *parent)
@ -254,8 +255,17 @@ void MainWindow::on_actionVerbindung_triggered()
void MainWindow::on_actionUeber_triggered()
{
QMessageBox msg;
msg.about(this, "Über PMV", "Piraten Mitglieder Verwaltung.<br>"
"Schneller Hack um Ausfall des Bundessystems zu kompensieren.");
QString msgstr = "<p>Piraten Mitglieder Verwaltung.<br>Schneller Hack um Ausfall des Bundessystems zu kompensieren.</p>";
if (db.isValid() && db.isOpen()) {
msgstr += QString("<p>Datenbankversion %1\n</p>").arg(lv.getVersion());
// TODO Versionsdatum einbauen. Funktionsweise von .arg() mit mehreren Variablen?
}
else {
msgstr += "Datenbank nicht geöffnet.";
}
msg.about(this, "Über PMV", msgstr);
}
void MainWindow::on_pushButton_edit_clicked()
@ -315,6 +325,12 @@ void MainWindow::on_actionWahlkreise_triggered()
wkd.exec();
}
void MainWindow::on_actionAmtadressen_triggered()
{
AmtAdressDialog dlg(this);
dlg.exec();
}
void MainWindow::on_actionEinstellungen_triggered()
{
ConfigDialog dialog(this, &lv);
@ -381,3 +397,4 @@ void MainWindow::on_checkBox_stateChanged(int arg1)
model->setQuery("SELECT nr, vorname, nachname, status FROM mitglied WHERE status<>'ausgetreten' ORDER BY nr");
}
}

@ -70,6 +70,8 @@ private slots:
void on_checkBox_stateChanged(int arg1);
void on_actionAmtadressen_triggered();
private:
Ui::MainWindow *ui;
QSqlQueryModel *model;

@ -149,6 +149,8 @@
<addaction name="actionWahlen"/>
<addaction name="actionWahlkreise"/>
<addaction name="separator"/>
<addaction name="actionAmtadressen"/>
<addaction name="separator"/>
<addaction name="actionImport"/>
<addaction name="actionExport"/>
</widget>
@ -231,6 +233,16 @@
<string>Einstellungen</string>
</property>
</action>
<action name="actionAmtadressen">
<property name="text">
<string>Amtadressen</string>
</property>
</action>
<action name="action">
<property name="text">
<string>----</string>
</property>
</action>
</widget>
<tabstops>
<tabstop>tableView</tabstop>

@ -7,11 +7,16 @@ TEMPLATE = app
CONFIG += c++11
OBJECTS_DIR = build
MOC_DIR = build/moc
UI_DIR = build/ui
# You can make your code fail to compile if it uses deprecated APIs.
# In order to do so, uncomment the following line.
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0
SOURCES += \
amtadressdialog.cpp \
configdialog.cpp \
conndialog.cpp \
datedelegate.cpp \
@ -26,6 +31,7 @@ SOURCES += \
wahlkreisdialog.cpp
HEADERS += \
amtadressdialog.h \
configdialog.h \
conndialog.h \
datedelegate.h \
@ -39,6 +45,7 @@ HEADERS += \
wahlkreisdialog.h
FORMS += \
amtadressdialog.ui \
configdialog.ui \
conndialog.ui \
editdialog.ui \

Loading…
Cancel
Save