Skip to content

Commit

Permalink
Merge pull request #295 from bigoulours/feature/connection_reordering
Browse files Browse the repository at this point in the history
Feature/connection reordering
  • Loading branch information
collin80 authored Feb 24, 2021
2 parents f4a5acb + ddcae69 commit 4374798
Show file tree
Hide file tree
Showing 7 changed files with 138 additions and 33 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,4 @@
**/moc_*
**/ui_*.h
**/qrc_*.cpp
SavvyCAN.pro.user.*
28 changes: 28 additions & 0 deletions connections/connectionwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ ConnectionWindow::ConnectionWindow(QWidget *parent) :
connect(ui->tableConnections->selectionModel(), &QItemSelectionModel::currentRowChanged, this, &ConnectionWindow::currentRowChanged);
connect(ui->tabBuses, &QTabBar::currentChanged, this, &ConnectionWindow::currentTabChanged);
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("100000");
Expand Down Expand Up @@ -480,3 +482,29 @@ void ConnectionWindow::saveConnections()
settings.setValue("connections/types", QVariant::fromValue(devTypes));
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 changes: 2 additions & 0 deletions connections/connectionwindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ private slots:
void handleSendHex();
void handleSendText();
void saveBusSettings();
void moveConnUp();
void moveConnDown();
void connectionStatus(CANConStatus);
void readPendingDatagrams();

Expand Down
2 changes: 2 additions & 0 deletions icons.qrc
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,7 @@
<file>images/signal_new.png</file>
<file>images/node_new.png</file>
<file>images/message_new.png</file>
<file>images/move_up.png</file>
<file>images/move_down.png</file>
</qresource>
</RCC>
Binary file added images/move_down.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/move_up.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
138 changes: 105 additions & 33 deletions ui/connectionwindow.ui
Original file line number Diff line number Diff line change
Expand Up @@ -2,28 +2,44 @@
<ui version="4.0">
<class>ConnectionWindow</class>
<widget class="QWidget" name="ConnectionWindow">
<property name="enabled">
<bool>true</bool>
</property>
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>956</width>
<height>665</height>
<width>1086</width>
<height>744</height>
</rect>
</property>
<property name="windowTitle">
<string>Connection Settings</string>
</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>
<layout class="QVBoxLayout" name="verticalLayout">
<item alignment="Qt::AlignHCenter">
<widget class="QLabel" name="label_4">
<layout class="QGridLayout" name="gridLayout" columnstretch="1,0">
<property name="sizeConstraint">
<enum>QLayout::SetMaximumSize</enum>
</property>
<item row="6" column="0" colspan="2">
<widget class="QPushButton" name="btnDisconnect">
<property name="text">
<string>Connected Devices:</string>
<string>Disconnect Selected Device</string>
</property>
</widget>
</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">
<property name="alternatingRowColors">
<bool>true</bool>
Expand All @@ -36,28 +52,7 @@
</property>
</widget>
</item>
<item>
<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>
<item row="7" column="0" colspan="2">
<widget class="QGroupBox" name="groupBus">
<property name="enabled">
<bool>false</bool>
Expand Down Expand Up @@ -124,11 +119,86 @@
</layout>
</widget>
</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>
</item>
<item>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item alignment="Qt::AlignHCenter">
<layout class="QVBoxLayout" name="verticalLayout">
<property name="sizeConstraint">
<enum>QLayout::SetNoConstraint</enum>
</property>
<item>
<widget class="QCheckBox" name="ckEnableConsole">
<property name="text">
<string>Enable Console</string>
Expand Down Expand Up @@ -208,6 +278,8 @@
<header>qtabbar.h</header>
</customwidget>
</customwidgets>
<resources/>
<resources>
<include location="../icons.qrc"/>
</resources>
<connections/>
</ui>

0 comments on commit 4374798

Please sign in to comment.