Changeset - 9b75748e06be
[Not reviewed]
Mehmet Aslan - 7 years ago 2019-03-30 07:12:17
aaslan-mehmet@hotmail.com
_selectPort function changed to selectListedPort
unnecessary speed word removed from baudrate option
code optimization with portIndex
3 files changed with 11 insertions and 13 deletions:
0 comments (0 inline, 0 general)
src/mainwindow.cpp
Show inline comments
 
@@ -631,7 +631,7 @@ void MainWindow::handleCommandLineOption
 

	
 
    QCommandLineOption loadOpt({"l", "load"}, "Load settings from file.", "filename");
 
    QCommandLineOption portOpt({"p", "port"}, "Set port name.", "port name");
 
    QCommandLineOption baudrateOpt({"b" ,"baudrate"}, "Set port baudrate speed.", "baudrate speed");
 
    QCommandLineOption baudrateOpt({"b" ,"baudrate"}, "Set port baud rate.", "baud rate");
 
    QCommandLineOption openPortOpt({"o", "open"}, "Open serial port.");
 

	
 
    parser.addOption(loadOpt);
src/portcontrol.cpp
Show inline comments
 
@@ -79,10 +79,10 @@ PortControl::PortControl(QSerialPort* po
 
                     this, &PortControl::onTbPortListActivated);
 
    QObject::connect(ui->cbPortList,
 
                     SELECT<const QString&>::OVERLOAD_OF(&QComboBox::activated),
 
                     this, &PortControl::_selectPort);
 
                     this, &PortControl::selectListedPort);
 
    QObject::connect(&tbPortList,
 
                     SELECT<const QString&>::OVERLOAD_OF(&QComboBox::activated),
 
                     this, &PortControl::_selectPort);
 
                     this, &PortControl::selectListedPort);
 

	
 
    // setup buttons
 
    ui->pbOpenPort->setDefaultAction(&openAction);
 
@@ -310,7 +310,7 @@ void PortControl::togglePort()
 
    openAction.setChecked(serialPort->isOpen());
 
}
 

	
 
void PortControl::_selectPort(QString portName)
 
void PortControl::selectListedPort(QString portName)
 
{
 
    // portName may be coming from combobox
 
    portName = portName.split(" ")[0];
 
@@ -476,15 +476,13 @@ void PortControl::selectPort(QString por
 
    if (portIndex < 0) // not in list, add to model and update the selections
 
    {
 
        portList.appendRow(new PortListItem(portName));
 
        ui->cbPortList->setCurrentIndex(portList.rowCount()-1);
 
        tbPortList.setCurrentIndex(portList.rowCount()-1);
 
        portIndex = portList.rowCount()-1;
 
    }
 
    else
 
    {
 
        ui->cbPortList->setCurrentIndex(portIndex);
 
        tbPortList.setCurrentIndex(portIndex);
 
    }
 
    _selectPort(portName);
 

	
 
    ui->cbPortList->setCurrentIndex(portIndex);
 
    tbPortList.setCurrentIndex(portIndex);
 

	
 
    selectListedPort(portName);
 
}
 

	
 
void PortControl::selectBaudrate(QString baudRate)
src/portcontrol.h
Show inline comments
 
@@ -84,7 +84,7 @@ private slots:
 
    void loadPortList();
 
    void loadBaudRateList();
 
    void togglePort();
 
    void _selectPort(QString portName);
 
    void selectListedPort(QString portName);
 

	
 
    void _selectBaudRate(QString baudRate);
 
    void selectParity(int parity); // parity must be one of QSerialPort::Parity
0 comments (0 inline, 0 general)