File tree Expand file tree Collapse file tree 3 files changed +54
-2
lines changed
Expand file tree Collapse file tree 3 files changed +54
-2
lines changed Original file line number Diff line number Diff line change @@ -169,10 +169,41 @@ void MainWindow::on_bAddNewDevice_clicked()
169169
170170}
171171
172+ void MainWindow::on_bRemoveDevice_clicked ()
173+ {
174+ int row = ui->twDevices ->currentRow ();
175+ if (row >= 0 ){
176+ QTableWidgetItem *item_name = ui->twDevices ->item (row,0 );
177+ QTableWidgetItem *item_ip = ui->twDevices ->item (row,1 );
178+
179+ QMessageBox msgBox;
180+ msgBox.setWindowTitle (" Delete device?" );
181+ msgBox.setText (QString (" Do you want to delete device \" " ) + item_name->text () + " \" with ip \" " + item_ip->text () + " \" ?" );
182+ msgBox.setStandardButtons (QMessageBox::Cancel | QMessageBox::Ok);
183+ msgBox.setDefaultButton (QMessageBox::Cancel);
184+
185+ int ret = msgBox.exec ();
186+ switch (ret) {
187+ case QMessageBox::Ok:
188+
189+ // remove single device
190+ esp.device_names .removeOne (item_name->text ());
191+ esp.device_ips .removeOne (item_ip->text ());
192+
193+ ui->twDevices ->removeRow (row);
194+
195+ QMessageBox::information (this , " Removed" , " Device was removed" );
196+ break ;
197+ case QMessageBox::Cancel:
198+ break ;
199+ }
200+ }
201+ }
202+
172203void MainWindow::on_bClearAllDevices_clicked ()
173204{
174205 QMessageBox msgBox;
175- msgBox.setWindowTitle (" Sure ?" );
206+ msgBox.setWindowTitle (" Delete ALL devices ?" );
176207 msgBox.setText (" Do you want to delete all devices?" );
177208 msgBox.setStandardButtons (QMessageBox::Cancel | QMessageBox::Ok);
178209 msgBox.setDefaultButton (QMessageBox::Cancel);
Original file line number Diff line number Diff line change @@ -39,6 +39,8 @@ private slots:
3939
4040 void on_cbEraseFlash_toggled (bool checked);
4141
42+ void on_bRemoveDevice_clicked ();
43+
4244private:
4345 QProcess *process;
4446 char last_char;
Original file line number Diff line number Diff line change 3030 <item >
3131 <widget class =" QTabWidget" name =" twTabs" >
3232 <property name =" currentIndex" >
33- <number >0 </number >
33+ <number >1 </number >
3434 </property >
3535 <widget class =" QWidget" name =" tab" >
3636 <attribute name =" title" >
576576 <height >200</height >
577577 </size >
578578 </property >
579+ <property name =" selectionMode" >
580+ <enum >QAbstractItemView::SingleSelection</enum >
581+ </property >
582+ <property name =" selectionBehavior" >
583+ <enum >QAbstractItemView::SelectRows</enum >
584+ </property >
579585 <attribute name =" horizontalHeaderCascadingSectionResizes" >
580586 <bool >true</bool >
581587 </attribute >
829835 </property >
830836 </widget >
831837 </item >
838+ <item >
839+ <widget class =" QPushButton" name =" bRemoveDevice" >
840+ <property name =" minimumSize" >
841+ <size >
842+ <width >0</width >
843+ <height >35</height >
844+ </size >
845+ </property >
846+ <property name =" text" >
847+ <string >Remove selected Device</string >
848+ </property >
849+ </widget >
850+ </item >
832851 <item >
833852 <widget class =" QPushButton" name =" bClearAllDevices" >
834853 <property name =" minimumSize" >
You can’t perform that action at this time.
0 commit comments