diff --git a/connectionlistmodel.cpp b/connectionlistmodel.cpp index 406844e..29fc5f0 100644 --- a/connectionlistmodel.cpp +++ b/connectionlistmodel.cpp @@ -65,13 +65,25 @@ int ConnectionListModel::rowCount(const QModelIndex &parent) const return m_connections.size(); } +int ConnectionListModel::columnCount(const QModelIndex &/*parent*/) const +{ + return 2; +} + QVariant ConnectionListModel::data(const QModelIndex &index, int role) const { QVariant result; - if (role == Qt::DisplayRole) { + if (role == Qt::DisplayRole || role == Qt::EditRole) { int row = index.row(); - result = makeLongDescription(m_connections.at(row)); + int col = index.column(); +// if (col == 0) { + result = makeLongDescription(m_connections.at(row)); + // } + //else { + //result = QString("other col"); + //} } + return result; } diff --git a/connectionlistmodel.h b/connectionlistmodel.h index e99b51d..31dd0f0 100644 --- a/connectionlistmodel.h +++ b/connectionlistmodel.h @@ -15,6 +15,7 @@ public: ConnectionListModel(QObject *parent); virtual int rowCount(const QModelIndex &parent = QModelIndex()) const override; + virtual int columnCount(const QModelIndex &/*parent*/) const override; virtual QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override; // virtual QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const override; diff --git a/connectionmanagerwindow.cpp b/connectionmanagerwindow.cpp index 2855c09..029d856 100644 --- a/connectionmanagerwindow.cpp +++ b/connectionmanagerwindow.cpp @@ -1,5 +1,7 @@ #include "connectionmanagerwindow.h" #include "ui_connectionmanagerwindow.h" +#include +#include #include "connectionlistmodel.h" @@ -16,15 +18,22 @@ ConnectionManagerWindow::ConnectionManagerWindow(QWidget *parent) ui->listView->setModel(m_listModel); + m_mapper = new QDataWidgetMapper(this); + m_mapper->setModel(m_listModel); + m_mapper->addMapping(ui->edtUser, 1); + m_mapper->toFirst(); + connect(ui->listView->selectionModel(), SIGNAL(currentChanged(QModelIndex,QModelIndex)), this, SLOT(on_currentChanged(QModelIndex,QModelIndex))); } + ConnectionManagerWindow::~ConnectionManagerWindow() { delete ui; delete m_listModel; + delete m_mapper; } void ConnectionManagerWindow::on_actionAdd_Connection_triggered() @@ -38,9 +47,12 @@ void ConnectionManagerWindow::on_currentChanged(const QModelIndex ¤t, const QModelIndex &previous) { int currow = current.row(); - int prevrow = previous.row(); - ui->lineEdit->setText(QString::number(currow)); - ui->lineEdit_2->setText(QString::number(prevrow)); +// int prevrow = previous.row(); + + m_mapper->setCurrentIndex(currow); +// ui->lineEdit->setText(QString::number(currow)); +// ui->lineEdit_2->setText(QString::number(prevrow)); + // if(selection.indexes().isEmpty()) { // clearMyView(); // } else { @@ -55,3 +67,9 @@ void ConnectionManagerWindow::on_actionDelete_connection_triggered() //m_listModel->removeRow(ci.row()); } } + + +void ConnectionManagerWindow::controlsToConfig(ConnectionConfig &cfg) +{ +// ui-> +} diff --git a/connectionmanagerwindow.h b/connectionmanagerwindow.h index 0dcdf5b..b9838ad 100644 --- a/connectionmanagerwindow.h +++ b/connectionmanagerwindow.h @@ -8,6 +8,9 @@ class ConnectionManagerWindow; } class ConnectionListModel; +class ConnectionConfig; +class QDataWidgetMapper; +class QStandardItemModel; class ConnectionManagerWindow : public QMainWindow { @@ -25,6 +28,9 @@ private slots: private: Ui::ConnectionManagerWindow *ui; ConnectionListModel *m_listModel = nullptr; + QDataWidgetMapper *m_mapper = nullptr; + + void controlsToConfig(ConnectionConfig &cfg); }; #endif // CONNECTIONMANAGERWINDOW_H diff --git a/connectionmanagerwindow.ui b/connectionmanagerwindow.ui index 6f7031f..ba42b67 100644 --- a/connectionmanagerwindow.ui +++ b/connectionmanagerwindow.ui @@ -38,7 +38,7 @@ - + @@ -48,7 +48,7 @@ - + @@ -58,63 +58,130 @@ - + 65535 - - - Maintenance DB - - - - - - - true - - - 0 - - - - postgres - - - - - template1 - - - - - Username - - + + - + Password - - + + QLineEdit::Password + + + + Database + + + + + + + + + + 2 + + + + reject + + + + + allow + + + + + prefer + + + + + require + + + + + verify-ca + + + + + verify-full + + + + + + + + SSL + + + + + + + Certificate + + + + + + + + + + Key + + + + + + + + + + Root cert. + + + + + + + + + + Revocation list + + + + + + diff --git a/ui_connectionmanagerwindow.h b/ui_connectionmanagerwindow.h index 7f5adab..f29f26a 100644 --- a/ui_connectionmanagerwindow.h +++ b/ui_connectionmanagerwindow.h @@ -43,17 +43,27 @@ public: QWidget *layoutWidget; QFormLayout *formLayout_2; QLabel *label; - QLineEdit *lineEdit; + QLineEdit *edtName; QLabel *label_2; - QLineEdit *lineEdit_2; + QLineEdit *edtHost; QLabel *label_3; - QSpinBox *spinBox; - QLabel *label_4; - QComboBox *comboBox; + QSpinBox *spinPort; QLabel *label_5; - QLineEdit *lineEdit_3; + QLineEdit *edtUser; QLabel *label_6; - QLineEdit *lineEdit_4; + QLineEdit *edtPassword; + QLabel *label_4; + QLineEdit *edtDbname; + QComboBox *cmbbxSsl; + QLabel *label_7; + QLabel *label_8; + QLineEdit *edtCert; + QLabel *label_9; + QLineEdit *edtKey; + QLabel *label_10; + QLineEdit *edtRootCert; + QLabel *label_11; + QLineEdit *edtCrl; QMenuBar *menubar; QStatusBar *statusbar; QToolBar *toolBar; @@ -102,63 +112,112 @@ public: formLayout_2->setWidget(0, QFormLayout::LabelRole, label); - lineEdit = new QLineEdit(layoutWidget); - lineEdit->setObjectName(QStringLiteral("lineEdit")); + edtName = new QLineEdit(layoutWidget); + edtName->setObjectName(QStringLiteral("edtName")); - formLayout_2->setWidget(0, QFormLayout::FieldRole, lineEdit); + formLayout_2->setWidget(0, QFormLayout::FieldRole, edtName); label_2 = new QLabel(layoutWidget); label_2->setObjectName(QStringLiteral("label_2")); formLayout_2->setWidget(1, QFormLayout::LabelRole, label_2); - lineEdit_2 = new QLineEdit(layoutWidget); - lineEdit_2->setObjectName(QStringLiteral("lineEdit_2")); + edtHost = new QLineEdit(layoutWidget); + edtHost->setObjectName(QStringLiteral("edtHost")); - formLayout_2->setWidget(1, QFormLayout::FieldRole, lineEdit_2); + formLayout_2->setWidget(1, QFormLayout::FieldRole, edtHost); label_3 = new QLabel(layoutWidget); label_3->setObjectName(QStringLiteral("label_3")); formLayout_2->setWidget(2, QFormLayout::LabelRole, label_3); - spinBox = new QSpinBox(layoutWidget); - spinBox->setObjectName(QStringLiteral("spinBox")); - spinBox->setMaximum(65535); + spinPort = new QSpinBox(layoutWidget); + spinPort->setObjectName(QStringLiteral("spinPort")); + spinPort->setMaximum(65535); - formLayout_2->setWidget(2, QFormLayout::FieldRole, spinBox); - - label_4 = new QLabel(layoutWidget); - label_4->setObjectName(QStringLiteral("label_4")); - - formLayout_2->setWidget(3, QFormLayout::LabelRole, label_4); - - comboBox = new QComboBox(layoutWidget); - comboBox->setObjectName(QStringLiteral("comboBox")); - comboBox->setEditable(true); - - formLayout_2->setWidget(3, QFormLayout::FieldRole, comboBox); + formLayout_2->setWidget(2, QFormLayout::FieldRole, spinPort); label_5 = new QLabel(layoutWidget); label_5->setObjectName(QStringLiteral("label_5")); - formLayout_2->setWidget(4, QFormLayout::LabelRole, label_5); + formLayout_2->setWidget(3, QFormLayout::LabelRole, label_5); - lineEdit_3 = new QLineEdit(layoutWidget); - lineEdit_3->setObjectName(QStringLiteral("lineEdit_3")); + edtUser = new QLineEdit(layoutWidget); + edtUser->setObjectName(QStringLiteral("edtUser")); - formLayout_2->setWidget(4, QFormLayout::FieldRole, lineEdit_3); + formLayout_2->setWidget(3, QFormLayout::FieldRole, edtUser); label_6 = new QLabel(layoutWidget); label_6->setObjectName(QStringLiteral("label_6")); - formLayout_2->setWidget(5, QFormLayout::LabelRole, label_6); + formLayout_2->setWidget(4, QFormLayout::LabelRole, label_6); - lineEdit_4 = new QLineEdit(layoutWidget); - lineEdit_4->setObjectName(QStringLiteral("lineEdit_4")); - lineEdit_4->setEchoMode(QLineEdit::Password); + edtPassword = new QLineEdit(layoutWidget); + edtPassword->setObjectName(QStringLiteral("edtPassword")); + edtPassword->setEchoMode(QLineEdit::Password); - formLayout_2->setWidget(5, QFormLayout::FieldRole, lineEdit_4); + formLayout_2->setWidget(4, QFormLayout::FieldRole, edtPassword); + + label_4 = new QLabel(layoutWidget); + label_4->setObjectName(QStringLiteral("label_4")); + + formLayout_2->setWidget(5, QFormLayout::LabelRole, label_4); + + edtDbname = new QLineEdit(layoutWidget); + edtDbname->setObjectName(QStringLiteral("edtDbname")); + + formLayout_2->setWidget(5, QFormLayout::FieldRole, edtDbname); + + cmbbxSsl = new QComboBox(layoutWidget); + cmbbxSsl->setObjectName(QStringLiteral("cmbbxSsl")); + + formLayout_2->setWidget(6, QFormLayout::FieldRole, cmbbxSsl); + + label_7 = new QLabel(layoutWidget); + label_7->setObjectName(QStringLiteral("label_7")); + + formLayout_2->setWidget(6, QFormLayout::LabelRole, label_7); + + label_8 = new QLabel(layoutWidget); + label_8->setObjectName(QStringLiteral("label_8")); + + formLayout_2->setWidget(7, QFormLayout::LabelRole, label_8); + + edtCert = new QLineEdit(layoutWidget); + edtCert->setObjectName(QStringLiteral("edtCert")); + + formLayout_2->setWidget(7, QFormLayout::FieldRole, edtCert); + + label_9 = new QLabel(layoutWidget); + label_9->setObjectName(QStringLiteral("label_9")); + + formLayout_2->setWidget(8, QFormLayout::LabelRole, label_9); + + edtKey = new QLineEdit(layoutWidget); + edtKey->setObjectName(QStringLiteral("edtKey")); + + formLayout_2->setWidget(8, QFormLayout::FieldRole, edtKey); + + label_10 = new QLabel(layoutWidget); + label_10->setObjectName(QStringLiteral("label_10")); + + formLayout_2->setWidget(9, QFormLayout::LabelRole, label_10); + + edtRootCert = new QLineEdit(layoutWidget); + edtRootCert->setObjectName(QStringLiteral("edtRootCert")); + + formLayout_2->setWidget(9, QFormLayout::FieldRole, edtRootCert); + + label_11 = new QLabel(layoutWidget); + label_11->setObjectName(QStringLiteral("label_11")); + + formLayout_2->setWidget(10, QFormLayout::LabelRole, label_11); + + edtCrl = new QLineEdit(layoutWidget); + edtCrl->setObjectName(QStringLiteral("edtCrl")); + + formLayout_2->setWidget(10, QFormLayout::FieldRole, edtCrl); splitter->addWidget(layoutWidget); @@ -184,7 +243,7 @@ public: retranslateUi(ConnectionManagerWindow); - comboBox->setCurrentIndex(0); + cmbbxSsl->setCurrentIndex(2); QMetaObject::connectSlotsByName(ConnectionManagerWindow); @@ -200,14 +259,23 @@ public: label->setText(QApplication::translate("ConnectionManagerWindow", "Name", Q_NULLPTR)); label_2->setText(QApplication::translate("ConnectionManagerWindow", "Host", Q_NULLPTR)); label_3->setText(QApplication::translate("ConnectionManagerWindow", "Port", Q_NULLPTR)); - label_4->setText(QApplication::translate("ConnectionManagerWindow", "Maintenance DB", Q_NULLPTR)); - comboBox->clear(); - comboBox->insertItems(0, QStringList() - << QApplication::translate("ConnectionManagerWindow", "postgres", Q_NULLPTR) - << QApplication::translate("ConnectionManagerWindow", "template1", Q_NULLPTR) - ); label_5->setText(QApplication::translate("ConnectionManagerWindow", "Username", Q_NULLPTR)); label_6->setText(QApplication::translate("ConnectionManagerWindow", "Password", Q_NULLPTR)); + label_4->setText(QApplication::translate("ConnectionManagerWindow", "Database", Q_NULLPTR)); + cmbbxSsl->clear(); + cmbbxSsl->insertItems(0, QStringList() + << QApplication::translate("ConnectionManagerWindow", "reject", Q_NULLPTR) + << QApplication::translate("ConnectionManagerWindow", "allow", Q_NULLPTR) + << QApplication::translate("ConnectionManagerWindow", "prefer", Q_NULLPTR) + << QApplication::translate("ConnectionManagerWindow", "require", Q_NULLPTR) + << QApplication::translate("ConnectionManagerWindow", "verify-ca", Q_NULLPTR) + << QApplication::translate("ConnectionManagerWindow", "verify-full", Q_NULLPTR) + ); + label_7->setText(QApplication::translate("ConnectionManagerWindow", "SSL", Q_NULLPTR)); + label_8->setText(QApplication::translate("ConnectionManagerWindow", "Certificate", Q_NULLPTR)); + label_9->setText(QApplication::translate("ConnectionManagerWindow", "Key", Q_NULLPTR)); + label_10->setText(QApplication::translate("ConnectionManagerWindow", "Root cert.", Q_NULLPTR)); + label_11->setText(QApplication::translate("ConnectionManagerWindow", "Revocation list", Q_NULLPTR)); toolBar->setWindowTitle(QApplication::translate("ConnectionManagerWindow", "toolBar", Q_NULLPTR)); } // retranslateUi