First test with QDataWidgetMapper to connect controls to the items in the connection list is working.
This commit is contained in:
parent
f5eab84c24
commit
c235169304
6 changed files with 256 additions and 84 deletions
|
|
@ -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();
|
||||
int col = index.column();
|
||||
// if (col == 0) {
|
||||
result = makeLongDescription(m_connections.at(row));
|
||||
// }
|
||||
//else {
|
||||
//result = QString("other col");
|
||||
//}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
#include "connectionmanagerwindow.h"
|
||||
#include "ui_connectionmanagerwindow.h"
|
||||
#include <QDataWidgetMapper>
|
||||
#include <QStandardItemModel>
|
||||
|
||||
#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->
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -38,7 +38,7 @@
|
|||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QLineEdit" name="lineEdit"/>
|
||||
<widget class="QLineEdit" name="edtName"/>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="label_2">
|
||||
|
|
@ -48,7 +48,7 @@
|
|||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QLineEdit" name="lineEdit_2"/>
|
||||
<widget class="QLineEdit" name="edtHost"/>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="label_3">
|
||||
|
|
@ -58,63 +58,130 @@
|
|||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="QSpinBox" name="spinBox">
|
||||
<widget class="QSpinBox" name="spinPort">
|
||||
<property name="maximum">
|
||||
<number>65535</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<widget class="QLabel" name="label_4">
|
||||
<property name="text">
|
||||
<string>Maintenance DB</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="1">
|
||||
<widget class="QComboBox" name="comboBox">
|
||||
<property name="editable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="currentIndex">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>postgres</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>template1</string>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="0">
|
||||
<widget class="QLabel" name="label_5">
|
||||
<property name="text">
|
||||
<string>Username</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="1">
|
||||
<widget class="QLineEdit" name="lineEdit_3"/>
|
||||
<item row="3" column="1">
|
||||
<widget class="QLineEdit" name="edtUser"/>
|
||||
</item>
|
||||
<item row="5" column="0">
|
||||
<item row="4" column="0">
|
||||
<widget class="QLabel" name="label_6">
|
||||
<property name="text">
|
||||
<string>Password</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="1">
|
||||
<widget class="QLineEdit" name="lineEdit_4">
|
||||
<item row="4" column="1">
|
||||
<widget class="QLineEdit" name="edtPassword">
|
||||
<property name="echoMode">
|
||||
<enum>QLineEdit::Password</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="0">
|
||||
<widget class="QLabel" name="label_4">
|
||||
<property name="text">
|
||||
<string>Database</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="1">
|
||||
<widget class="QLineEdit" name="edtDbname"/>
|
||||
</item>
|
||||
<item row="6" column="1">
|
||||
<widget class="QComboBox" name="cmbbxSsl">
|
||||
<property name="currentIndex">
|
||||
<number>2</number>
|
||||
</property>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>reject</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>allow</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>prefer</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>require</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>verify-ca</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>verify-full</string>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="6" column="0">
|
||||
<widget class="QLabel" name="label_7">
|
||||
<property name="text">
|
||||
<string>SSL</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="7" column="0">
|
||||
<widget class="QLabel" name="label_8">
|
||||
<property name="text">
|
||||
<string>Certificate</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="7" column="1">
|
||||
<widget class="QLineEdit" name="edtCert"/>
|
||||
</item>
|
||||
<item row="8" column="0">
|
||||
<widget class="QLabel" name="label_9">
|
||||
<property name="text">
|
||||
<string>Key</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="8" column="1">
|
||||
<widget class="QLineEdit" name="edtKey"/>
|
||||
</item>
|
||||
<item row="9" column="0">
|
||||
<widget class="QLabel" name="label_10">
|
||||
<property name="text">
|
||||
<string>Root cert.</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="9" column="1">
|
||||
<widget class="QLineEdit" name="edtRootCert"/>
|
||||
</item>
|
||||
<item row="10" column="0">
|
||||
<widget class="QLabel" name="label_11">
|
||||
<property name="text">
|
||||
<string>Revocation list</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="10" column="1">
|
||||
<widget class="QLineEdit" name="edtCrl"/>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue