From b9f81d4e7e6342787f6b35b4a7133005108c537d Mon Sep 17 00:00:00 2001 From: zedamota Date: Sat, 5 Jun 2010 20:08:07 +0000 Subject: [PATCH] OP-77 GCS-Removed alterations from the lib (serial port qlists sorting moved to plugins sources), added conditional compilation to serialplugin and uploader plugin. git-svn-id: svn://svn.openpilot.org/OpenPilot/trunk@719 ebee16cc-31ac-478f-84a7-5cbb03baadba --- .../qextserialport/src/qextserialenumerator.h | 3 --- .../plugins/serialconnection/serialplugin.cpp | 22 ++++++++++++++----- .../plugins/serialconnection/serialplugin.h | 3 ++- .../uploader/uploadergadgetoptionspage.cpp | 9 +++++--- .../uploader/uploadergadgetoptionspage.h | 2 +- 5 files changed, 25 insertions(+), 14 deletions(-) diff --git a/ground/src/libs/qextserialport/src/qextserialenumerator.h b/ground/src/libs/qextserialport/src/qextserialenumerator.h index fdbef98e3..de173715c 100644 --- a/ground/src/libs/qextserialport/src/qextserialenumerator.h +++ b/ground/src/libs/qextserialport/src/qextserialenumerator.h @@ -33,9 +33,6 @@ struct QextPortInfo { QString enumName; ///< Enumerator name. int vendorID; ///< Vendor ID. int productID; ///< Product ID - //added operator to alow sorting (PT_Dreamer) - bool operator<(const QextPortInfo & other) const { - return portName < other.portName;} }; #ifdef Q_OS_WIN diff --git a/ground/src/plugins/serialconnection/serialplugin.cpp b/ground/src/plugins/serialconnection/serialplugin.cpp index 9faab00ba..0de044247 100644 --- a/ground/src/plugins/serialconnection/serialplugin.cpp +++ b/ground/src/plugins/serialconnection/serialplugin.cpp @@ -32,8 +32,6 @@ #include #include -#include -#include #include @@ -55,6 +53,10 @@ void SerialConnection::onEnumerationChanged() { emit availableDevChanged(this); } +bool sortPorts(const QextPortInfo &s1,const QextPortInfo &s2) +{ + return s1.portName ports = QextSerialEnumerator::getPorts(); //sort the list by port number (nice idea from PT_Dreamer :)) - qSort(ports.begin(), ports.end()); + qSort(ports.begin(), ports.end(),sortPorts); foreach( QextPortInfo port, ports ) { - list.append(port.friendName); +#ifdef Q_OS_WIN + list.append(port.portName); +#else + list.append(port.physName); +#endif } return list; @@ -74,8 +80,12 @@ QIODevice *SerialConnection::openDevice(const QString &deviceName) { QList ports = QextSerialEnumerator::getPorts(); foreach( QextPortInfo port, ports ) { - if(port.friendName == deviceName) - { +#ifdef Q_OS_WIN + if(port.portName == deviceName) +#else + if(port.physName == deviceName) +#endif + { //we need to handle port settings here... PortSettings set; set.BaudRate = BAUD57600; diff --git a/ground/src/plugins/serialconnection/serialplugin.h b/ground/src/plugins/serialconnection/serialplugin.h index c17aa1d23..513da0c49 100644 --- a/ground/src/plugins/serialconnection/serialplugin.h +++ b/ground/src/plugins/serialconnection/serialplugin.h @@ -29,7 +29,8 @@ #define SERIALPLUGIN_H #include "serial_global.h" - +#include +#include #include "coreplugin/iconnection.h" #include diff --git a/ground/src/plugins/uploader/uploadergadgetoptionspage.cpp b/ground/src/plugins/uploader/uploadergadgetoptionspage.cpp index 53f10b333..c4fb731b0 100755 --- a/ground/src/plugins/uploader/uploadergadgetoptionspage.cpp +++ b/ground/src/plugins/uploader/uploadergadgetoptionspage.cpp @@ -36,7 +36,7 @@ #include #include #include -#include + UploaderGadgetOptionsPage::UploaderGadgetOptionsPage(UploaderGadgetConfiguration *config, QObject *parent) : IOptionsPage(parent), @@ -158,7 +158,10 @@ UploaderGadgetOptionsPage::UploaderGadgetOptionsPage(UploaderGadgetConfiguration <<"FLOW_HARDWARE" <<"FLOW_XONXOFF"; } - +bool sortPorts(QextPortInfo const& s1,QextPortInfo const& s2) +{ + return s1.portName ports =QextSerialEnumerator ::getPorts(); - qSort(ports.begin(), ports.end()); + qSort(ports.begin(), ports.end(),sortPorts); qDebug() << "List of ports:"; for (int i = 0; i < ports.size(); i++) { qDebug() << "port name:" << ports.at(i).portName; diff --git a/ground/src/plugins/uploader/uploadergadgetoptionspage.h b/ground/src/plugins/uploader/uploadergadgetoptionspage.h index 3702ba010..28fae3d4f 100755 --- a/ground/src/plugins/uploader/uploadergadgetoptionspage.h +++ b/ground/src/plugins/uploader/uploadergadgetoptionspage.h @@ -27,7 +27,7 @@ #ifndef UPLOADERGADGETOPTIONSPAGE_H #define UPLOADERGADGETOPTIONSPAGE_H - +#include #include "coreplugin/dialogs/ioptionspage.h" #include "QString" #include