adding connection reordering (move up/down)

replacing connectionwindow.ui with own version
This commit is contained in:
Bertrand
2021-02-23 08:55:24 +01:00
parent de6dc1e554
commit 0283571d16
6 changed files with 137 additions and 33 deletions
+28
View File
@@ -59,6 +59,8 @@ ConnectionWindow::ConnectionWindow(QWidget *parent) :
connect(ui->tableConnections->selectionModel(), &QItemSelectionModel::currentRowChanged, this, &ConnectionWindow::currentRowChanged); connect(ui->tableConnections->selectionModel(), &QItemSelectionModel::currentRowChanged, this, &ConnectionWindow::currentRowChanged);
connect(ui->tabBuses, &QTabBar::currentChanged, this, &ConnectionWindow::currentTabChanged); connect(ui->tabBuses, &QTabBar::currentChanged, this, &ConnectionWindow::currentTabChanged);
connect(ui->btnSaveBus, &QPushButton::clicked, this, &ConnectionWindow::saveBusSettings); connect(ui->btnSaveBus, &QPushButton::clicked, this, &ConnectionWindow::saveBusSettings);
connect(ui->btnMoveUp, &QPushButton::clicked, this, &ConnectionWindow::moveConnUp);
connect(ui->btnMoveDown, &QPushButton::clicked, this, &ConnectionWindow::moveConnDown);
ui->cbBusSpeed->addItem("50000"); ui->cbBusSpeed->addItem("50000");
ui->cbBusSpeed->addItem("100000"); ui->cbBusSpeed->addItem("100000");
@@ -480,3 +482,29 @@ void ConnectionWindow::saveConnections()
settings.setValue("connections/types", QVariant::fromValue(devTypes)); settings.setValue("connections/types", QVariant::fromValue(devTypes));
settings.setValue("connections/driverNames", QVariant::fromValue(driverNames)); settings.setValue("connections/driverNames", QVariant::fromValue(driverNames));
} }
void ConnectionWindow::moveConnUp()
{
int selIdx = ui->tableConnections->selectionModel()->currentIndex().row();
if (selIdx > 0)
{
CANConnection* selConn = connModel->getAtIdx(selIdx);
CANConnection* prevConn = connModel->getAtIdx(selIdx - 1);
connModel->replace(selIdx - 1, selConn);
connModel->replace(selIdx, prevConn);
ui->tableConnections->selectRow(selIdx - 1);
}
}
void ConnectionWindow::moveConnDown()
{
int selIdx = ui->tableConnections->selectionModel()->currentIndex().row();
if (selIdx < connModel->rowCount() - 1)
{
CANConnection* selConn = connModel->getAtIdx(selIdx);
CANConnection* nextConn = connModel->getAtIdx(selIdx + 1);
connModel->replace(selIdx + 1, selConn);
connModel->replace(selIdx, nextConn);
ui->tableConnections->selectRow(selIdx + 1);
}
}
+2
View File
@@ -51,6 +51,8 @@ private slots:
void handleSendHex(); void handleSendHex();
void handleSendText(); void handleSendText();
void saveBusSettings(); void saveBusSettings();
void moveConnUp();
void moveConnDown();
void connectionStatus(CANConStatus); void connectionStatus(CANConStatus);
void readPendingDatagrams(); void readPendingDatagrams();
+2
View File
@@ -15,5 +15,7 @@
<file>images/signal_new.png</file> <file>images/signal_new.png</file>
<file>images/node_new.png</file> <file>images/node_new.png</file>
<file>images/message_new.png</file> <file>images/message_new.png</file>
<file>images/move_up.png</file>
<file>images/move_down.png</file>
</qresource> </qresource>
</RCC> </RCC>
Binary file not shown.

After

Width:  |  Height:  |  Size: 478 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 343 B

+105 -33
View File
@@ -2,28 +2,44 @@
<ui version="4.0"> <ui version="4.0">
<class>ConnectionWindow</class> <class>ConnectionWindow</class>
<widget class="QWidget" name="ConnectionWindow"> <widget class="QWidget" name="ConnectionWindow">
<property name="enabled">
<bool>true</bool>
</property>
<property name="geometry"> <property name="geometry">
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>956</width> <width>1086</width>
<height>665</height> <height>744</height>
</rect> </rect>
</property> </property>
<property name="windowTitle"> <property name="windowTitle">
<string>Connection Settings</string> <string>Connection Settings</string>
</property> </property>
<layout class="QHBoxLayout" name="horizontalLayout" stretch="2,1"> <layout class="QHBoxLayout" name="horizontalLayout_2" stretch="2,1">
<property name="sizeConstraint">
<enum>QLayout::SetDefaultConstraint</enum>
</property>
<item> <item>
<layout class="QVBoxLayout" name="verticalLayout"> <layout class="QGridLayout" name="gridLayout" columnstretch="1,0">
<item alignment="Qt::AlignHCenter"> <property name="sizeConstraint">
<widget class="QLabel" name="label_4"> <enum>QLayout::SetMaximumSize</enum>
</property>
<item row="6" column="0" colspan="2">
<widget class="QPushButton" name="btnDisconnect">
<property name="text"> <property name="text">
<string>Connected Devices:</string> <string>Disconnect Selected Device</string>
</property> </property>
</widget> </widget>
</item> </item>
<item> <item row="5" column="0" colspan="2">
<widget class="QPushButton" name="btnResetConn">
<property name="text">
<string>Reset Selected Device</string>
</property>
</widget>
</item>
<item row="1" column="0" rowspan="3">
<widget class="QTableView" name="tableConnections"> <widget class="QTableView" name="tableConnections">
<property name="alternatingRowColors"> <property name="alternatingRowColors">
<bool>true</bool> <bool>true</bool>
@@ -36,28 +52,7 @@
</property> </property>
</widget> </widget>
</item> </item>
<item> <item row="7" column="0" colspan="2">
<widget class="QPushButton" name="btnNewConnection">
<property name="text">
<string>Add New Device Connection</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="btnResetConn">
<property name="text">
<string>Reset Selected Device</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="btnDisconnect">
<property name="text">
<string>Disconnect Selected Device</string>
</property>
</widget>
</item>
<item>
<widget class="QGroupBox" name="groupBus"> <widget class="QGroupBox" name="groupBus">
<property name="enabled"> <property name="enabled">
<bool>false</bool> <bool>false</bool>
@@ -124,11 +119,86 @@
</layout> </layout>
</widget> </widget>
</item> </item>
<item row="2" column="1">
<widget class="QPushButton" name="btnMoveDown">
<property name="enabled">
<bool>true</bool>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="maximumSize">
<size>
<width>20</width>
<height>16777215</height>
</size>
</property>
<property name="text">
<string/>
</property>
<property name="icon">
<iconset resource="../icons.qrc">
<normaloff>:/icons/images/move_down.png</normaloff>:/icons/images/move_down.png</iconset>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="label_4">
<property name="text">
<string>Connected Devices:</string>
</property>
</widget>
</item>
<item row="4" column="0" colspan="2">
<widget class="QPushButton" name="btnNewConnection">
<property name="text">
<string>Add New Device Connection</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QPushButton" name="btnMoveUp">
<property name="enabled">
<bool>true</bool>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="maximumSize">
<size>
<width>20</width>
<height>16777215</height>
</size>
</property>
<property name="text">
<string/>
</property>
<property name="icon">
<iconset resource="../icons.qrc">
<normaloff>:/icons/images/move_up.png</normaloff>:/icons/images/move_up.png</iconset>
</property>
<property name="iconSize">
<size>
<width>16</width>
<height>16</height>
</size>
</property>
</widget>
</item>
</layout> </layout>
</item> </item>
<item> <item>
<layout class="QVBoxLayout" name="verticalLayout_2"> <layout class="QVBoxLayout" name="verticalLayout">
<item alignment="Qt::AlignHCenter"> <property name="sizeConstraint">
<enum>QLayout::SetNoConstraint</enum>
</property>
<item>
<widget class="QCheckBox" name="ckEnableConsole"> <widget class="QCheckBox" name="ckEnableConsole">
<property name="text"> <property name="text">
<string>Enable Console</string> <string>Enable Console</string>
@@ -208,6 +278,8 @@
<header>qtabbar.h</header> <header>qtabbar.h</header>
</customwidget> </customwidget>
</customwidgets> </customwidgets>
<resources/> <resources>
<include location="../icons.qrc"/>
</resources>
<connections/> <connections/>
</ui> </ui>