1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2025-01-18 03:52:11 +01:00

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
This commit is contained in:
zedamota 2010-06-05 20:08:07 +00:00 committed by zedamota
parent fb9e8563b8
commit b9f81d4e7e
5 changed files with 25 additions and 14 deletions

View File

@ -33,9 +33,6 @@ struct QextPortInfo {
QString enumName; ///< Enumerator name. QString enumName; ///< Enumerator name.
int vendorID; ///< Vendor ID. int vendorID; ///< Vendor ID.
int productID; ///< Product 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 #ifdef Q_OS_WIN

View File

@ -32,8 +32,6 @@
#include <QtCore/QtPlugin> #include <QtCore/QtPlugin>
#include <QtGui/QMainWindow> #include <QtGui/QMainWindow>
#include <qextserialport.h>
#include <qextserialenumerator.h>
#include <QDebug> #include <QDebug>
@ -55,6 +53,10 @@ void SerialConnection::onEnumerationChanged()
{ {
emit availableDevChanged(this); emit availableDevChanged(this);
} }
bool sortPorts(const QextPortInfo &s1,const QextPortInfo &s2)
{
return s1.portName<s2.portName;
}
QStringList SerialConnection::availableDevices() QStringList SerialConnection::availableDevices()
{ {
@ -62,9 +64,13 @@ QStringList SerialConnection::availableDevices()
QList<QextPortInfo> ports = QextSerialEnumerator::getPorts(); QList<QextPortInfo> ports = QextSerialEnumerator::getPorts();
//sort the list by port number (nice idea from PT_Dreamer :)) //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 ) { foreach( QextPortInfo port, ports ) {
list.append(port.friendName); #ifdef Q_OS_WIN
list.append(port.portName);
#else
list.append(port.physName);
#endif
} }
return list; return list;
@ -74,7 +80,11 @@ QIODevice *SerialConnection::openDevice(const QString &deviceName)
{ {
QList<QextPortInfo> ports = QextSerialEnumerator::getPorts(); QList<QextPortInfo> ports = QextSerialEnumerator::getPorts();
foreach( QextPortInfo port, ports ) { 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... //we need to handle port settings here...
PortSettings set; PortSettings set;

View File

@ -29,7 +29,8 @@
#define SERIALPLUGIN_H #define SERIALPLUGIN_H
#include "serial_global.h" #include "serial_global.h"
#include <qextserialport.h>
#include <qextserialenumerator.h>
#include "coreplugin/iconnection.h" #include "coreplugin/iconnection.h"
#include <extensionsystem/iplugin.h> #include <extensionsystem/iplugin.h>

View File

@ -36,7 +36,7 @@
#include <QtGui/QComboBox> #include <QtGui/QComboBox>
#include <QtAlgorithms> #include <QtAlgorithms>
#include <QStringList> #include <QStringList>
#include <qextserialport/src/qextserialenumerator.h>
UploaderGadgetOptionsPage::UploaderGadgetOptionsPage(UploaderGadgetConfiguration *config, QObject *parent) : UploaderGadgetOptionsPage::UploaderGadgetOptionsPage(UploaderGadgetConfiguration *config, QObject *parent) :
IOptionsPage(parent), IOptionsPage(parent),
@ -158,7 +158,10 @@ UploaderGadgetOptionsPage::UploaderGadgetOptionsPage(UploaderGadgetConfiguration
<<"FLOW_HARDWARE" <<"FLOW_HARDWARE"
<<"FLOW_XONXOFF"; <<"FLOW_XONXOFF";
} }
bool sortPorts(QextPortInfo const& s1,QextPortInfo const& s2)
{
return s1.portName<s2.portName;
}
//creates options page widget //creates options page widget
QWidget *UploaderGadgetOptionsPage::createPage(QWidget *parent) QWidget *UploaderGadgetOptionsPage::createPage(QWidget *parent)
{ {
@ -263,7 +266,7 @@ QWidget *UploaderGadgetOptionsPage::createPage(QWidget *parent)
//gets available serial ports //gets available serial ports
QList<QextPortInfo> ports =QextSerialEnumerator ::getPorts(); QList<QextPortInfo> ports =QextSerialEnumerator ::getPorts();
qSort(ports.begin(), ports.end()); qSort(ports.begin(), ports.end(),sortPorts);
qDebug() << "List of ports:"; qDebug() << "List of ports:";
for (int i = 0; i < ports.size(); i++) { for (int i = 0; i < ports.size(); i++) {
qDebug() << "port name:" << ports.at(i).portName; qDebug() << "port name:" << ports.at(i).portName;

View File

@ -27,7 +27,7 @@
#ifndef UPLOADERGADGETOPTIONSPAGE_H #ifndef UPLOADERGADGETOPTIONSPAGE_H
#define UPLOADERGADGETOPTIONSPAGE_H #define UPLOADERGADGETOPTIONSPAGE_H
#include <qextserialport/src/qextserialenumerator.h>
#include "coreplugin/dialogs/ioptionspage.h" #include "coreplugin/dialogs/ioptionspage.h"
#include "QString" #include "QString"
#include <QStringList> #include <QStringList>