parent
c455cd4a4c
commit
75f9aff5dc
@ -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> |
Loading…
Reference in new issue