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

Removed unused code, bit of a clean up.

git-svn-id: svn://svn.openpilot.org/OpenPilot/trunk@2747 ebee16cc-31ac-478f-84a7-5cbb03baadba
This commit is contained in:
pip 2011-02-07 12:29:35 +00:00 committed by pip
parent 2496c41ea2
commit 73d134ad98
6 changed files with 194 additions and 219 deletions

View File

@ -29,7 +29,8 @@ SOURCES += pipxtremegadget.cpp \
OTHER_FILES += PipXtreme.pluginspec OTHER_FILES += PipXtreme.pluginspec
FORMS += \ FORMS += \
pipxtreme.ui pipxtreme.ui \
pipxtremegadgetoptionspage.ui
RESOURCES += \ RESOURCES += \
pipxtreme.qrc pipxtreme.qrc

View File

@ -31,44 +31,11 @@
* *
*/ */
PipXtremeGadgetConfiguration::PipXtremeGadgetConfiguration(QString classId, QSettings* qSettings, QObject *parent) : PipXtremeGadgetConfiguration::PipXtremeGadgetConfiguration(QString classId, QSettings* qSettings, QObject *parent) :
IUAVGadgetConfiguration(classId, parent), IUAVGadgetConfiguration(classId, parent)
m_defaultPort("Unknown"),
m_defaultSpeed(BAUD57600),
m_defaultDataBits(DATA_8),
m_defaultFlow(FLOW_OFF),
m_defaultParity(PAR_NONE),
m_defaultStopBits(STOP_1),
m_defaultTimeOut(5000)
{ {
//if a saved configuration exists load it //if a saved configuration exists load it
if (qSettings != 0) if (qSettings != 0)
{ {
BaudRateType speed;
DataBitsType databits;
FlowType flow;
ParityType parity;
StopBitsType stopbits;
int ispeed = qSettings->value("defaultSpeed").toInt();
int idatabits = qSettings->value("defaultDataBits").toInt();
int iflow = qSettings->value("defaultFlow").toInt();
int iparity = qSettings->value("defaultParity").toInt();
int istopbits = qSettings->value("defaultStopBits").toInt();
QString port = qSettings->value("defaultPort").toString();
databits=(DataBitsType) idatabits;
flow=(FlowType)iflow;
parity=(ParityType)iparity;
stopbits=(StopBitsType)istopbits;
speed=(BaudRateType)ispeed;
m_defaultPort=port;
m_defaultSpeed=speed;
m_defaultDataBits=databits;
m_defaultFlow=flow;
m_defaultParity=parity;
m_defaultStopBits=stopbits;
} }
} }
@ -83,14 +50,6 @@ PipXtremeGadgetConfiguration::~PipXtremeGadgetConfiguration()
IUAVGadgetConfiguration *PipXtremeGadgetConfiguration::clone() IUAVGadgetConfiguration *PipXtremeGadgetConfiguration::clone()
{ {
PipXtremeGadgetConfiguration *m = new PipXtremeGadgetConfiguration(this->classId()); PipXtremeGadgetConfiguration *m = new PipXtremeGadgetConfiguration(this->classId());
m->m_defaultSpeed = m_defaultSpeed;
m->m_defaultDataBits = m_defaultDataBits;
m->m_defaultFlow = m_defaultFlow;
m->m_defaultParity = m_defaultParity;
m->m_defaultStopBits = m_defaultStopBits;
m->m_defaultPort = m_defaultPort;
return m; return m;
} }
@ -98,12 +57,10 @@ IUAVGadgetConfiguration *PipXtremeGadgetConfiguration::clone()
* Saves a configuration. * Saves a configuration.
* *
*/ */
void PipXtremeGadgetConfiguration::saveConfig(QSettings* qSettings) const void PipXtremeGadgetConfiguration::saveConfig(QSettings *qSettings) const
{ {
qSettings->setValue("defaultSpeed", m_defaultSpeed); if (qSettings)
qSettings->setValue("defaultDataBits", m_defaultDataBits); {
qSettings->setValue("defaultFlow", m_defaultFlow);
qSettings->setValue("defaultParity", m_defaultParity); }
qSettings->setValue("defaultStopBits", m_defaultStopBits);
qSettings->setValue("defaultPort", m_defaultPort);
} }

View File

@ -39,35 +39,10 @@ public:
explicit PipXtremeGadgetConfiguration(QString classId, QSettings* qSettings = 0, QObject *parent = 0); explicit PipXtremeGadgetConfiguration(QString classId, QSettings* qSettings = 0, QObject *parent = 0);
~PipXtremeGadgetConfiguration(); ~PipXtremeGadgetConfiguration();
//set port configuration functions void saveConfig(QSettings *settings) const;
void setSpeed(BaudRateType speed) {m_defaultSpeed=speed;}
void setDataBits(DataBitsType databits) {m_defaultDataBits=databits;}
void setFlow(FlowType flow) {m_defaultFlow=flow;}
void setParity(ParityType parity) {m_defaultParity=parity;}
void setStopBits(StopBitsType stopbits) {m_defaultStopBits=stopbits;}
void setPort(QString port){m_defaultPort=port;}
void setTimeOut(long timeout){m_defaultTimeOut=timeout;}
//get port configuration functions
BaudRateType Speed() {return m_defaultSpeed;}
DataBitsType DataBits() {return m_defaultDataBits;}
FlowType Flow() {return m_defaultFlow;}
ParityType Parity() {return m_defaultParity;}
StopBitsType StopBits() {return m_defaultStopBits;}
QString Port(){return m_defaultPort;}
long TimeOut(){return m_defaultTimeOut;}
void saveConfig(QSettings* settings) const;
IUAVGadgetConfiguration *clone(); IUAVGadgetConfiguration *clone();
private: private:
QString m_defaultPort;
BaudRateType m_defaultSpeed;
DataBitsType m_defaultDataBits;
FlowType m_defaultFlow;
ParityType m_defaultParity;
StopBitsType m_defaultStopBits;
long m_defaultTimeOut;
}; };
#endif #endif

View File

@ -1,69 +1,72 @@
/** /**
****************************************************************************** ******************************************************************************
* *
* @file pipxtremegadgetoptionspage.cpp * @file pipxtremegadgetoptionspage.cpp
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010. * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
* @addtogroup GCSPlugins GCS Plugins * @addtogroup GCSPlugins GCS Plugins
* @{ * @{
* @{ * @{
*****************************************************************************/ *****************************************************************************/
/* /*
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or * the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version. * (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, but * This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* for more details. * for more details.
* *
* You should have received a copy of the GNU General Public License along * You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc., * with this program; if not, write to the Free Software Foundation, Inc.,
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/ */
#include "pipxtremegadgetoptionspage.h" #include "pipxtremegadgetoptionspage.h"
#include "pipxtremegadgetconfiguration.h" #include "pipxtremegadgetconfiguration.h"
#include <QtGui/QLabel> #include "ui_pipxtremegadgetoptionspage.h"
#include <QtGui/QSpinBox>
#include <QtGui/QDoubleSpinBox> PipXtremeGadgetOptionsPage::PipXtremeGadgetOptionsPage(PipXtremeGadgetConfiguration *config, QObject *parent) :
#include <QtGui/QHBoxLayout> IOptionsPage(parent),
#include <QtGui/QVBoxLayout> options_page(NULL),
#include <QtGui/QTextEdit> m_config(config)
#include <QtGui/QComboBox> {
#include <QtAlgorithms> }
#include <QStringList>
//creates options page widget
QWidget *PipXtremeGadgetOptionsPage::createPage(QWidget *parent)
PipXtremeGadgetOptionsPage::PipXtremeGadgetOptionsPage(PipXtremeGadgetConfiguration *config, QObject *parent) : {
IOptionsPage(parent), // QWidget *widget = new QWidget;
m_config(config) // return widget;
{
} options_page = new Ui::PipXtremeGadgetOptionsPage();
QWidget *optionsPageWidget = new QWidget;
//creates options page widget options_page->setupUi(optionsPageWidget);
QWidget *PipXtremeGadgetOptionsPage::createPage(QWidget *parent)
{
//main widget
QWidget *widget = new QWidget;
return optionsPageWidget;
return widget; }
} /**
/** * Called when the user presses apply or OK.
* Called when the user presses apply or OK. *
* * Saves the current values
* Saves the current values *
* */
*/ void PipXtremeGadgetOptionsPage::apply()
void PipXtremeGadgetOptionsPage::apply() {
{
}
}
void PipXtremeGadgetOptionsPage::finish()
void PipXtremeGadgetOptionsPage::finish() {
{ if (options_page)
{
} delete options_page;
options_page = NULL;
}
}

View File

@ -1,74 +1,62 @@
/** /**
****************************************************************************** ******************************************************************************
* *
* @file pipxtremegadgetoptionspage.h * @file pipxtremegadgetoptionspage.h
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010. * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
* @addtogroup GCSPlugins GCS Plugins * @addtogroup GCSPlugins GCS Plugins
* @{ * @{
* @{ * @{
*****************************************************************************/ *****************************************************************************/
/* /*
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or * the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version. * (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, but * This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* for more details. * for more details.
* *
* You should have received a copy of the GNU General Public License along * You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc., * with this program; if not, write to the Free Software Foundation, Inc.,
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/ */
#ifndef PIPXTREMEGADGETOPTIONSPAGE_H #ifndef PIPXTREMEGADGETOPTIONSPAGE_H
#define PIPXTREMEGADGETOPTIONSPAGE_H #define PIPXTREMEGADGETOPTIONSPAGE_H
#include <qextserialport/src/qextserialenumerator.h>
#include "coreplugin/dialogs/ioptionspage.h" #include <qextserialport/src/qextserialenumerator.h>
#include "QString" #include "coreplugin/dialogs/ioptionspage.h"
#include <QStringList> #include "QString"
#include <QDebug> #include <QStringList>
#include <QDebug>
namespace Core {
class IUAVGadgetConfiguration; namespace Core {
} class IUAVGadgetConfiguration;
class PipXtremeGadgetConfiguration; }
class QTextEdit;
class QComboBox; class PipXtremeGadgetConfiguration;
class QSpinBox;
namespace Ui {
using namespace Core; class PipXtremeGadgetOptionsPage;
}
class PipXtremeGadgetOptionsPage : public IOptionsPage
{ using namespace Core;
Q_OBJECT
public: class PipXtremeGadgetOptionsPage : public IOptionsPage
explicit PipXtremeGadgetOptionsPage(PipXtremeGadgetConfiguration *config, QObject *parent = 0); {
Q_OBJECT
QWidget *createPage(QWidget *parent); public:
void apply(); explicit PipXtremeGadgetOptionsPage(PipXtremeGadgetConfiguration *config, QObject *parent = 0);
void finish();
QWidget *createPage(QWidget *parent);
private: void apply();
PipXtremeGadgetConfiguration *m_config; void finish();
QComboBox *m_portCB;
QComboBox *m_speedCB; private:
QComboBox *m_databitsCB; Ui::PipXtremeGadgetOptionsPage *options_page;
QComboBox *m_flowCB; PipXtremeGadgetConfiguration *m_config;
QComboBox *m_parityCB; };
QComboBox *m_stopbitsCB;
QSpinBox *m_timeoutSpin; #endif
QStringList BaudRateTypeString;
QStringList BaudRateTypeStringALL;
QStringList DataBitsTypeStringALL;
QStringList ParityTypeStringALL;
QStringList StopBitsTypeStringALL;
QStringList DataBitsTypeString;
QStringList ParityTypeString;
QStringList StopBitsTypeString;
QStringList FlowTypeString;
};
#endif

View File

@ -0,0 +1,51 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>PipXtremeGadgetOptionsPage</class>
<widget class="QWidget" name="PipXtremeGadgetOptionsPage">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>587</width>
<height>359</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<property name="margin">
<number>0</number>
</property>
<item row="0" column="0">
<widget class="QWidget" name="widget" native="true">
<layout class="QVBoxLayout" name="verticalLayout_4">
<item>
<widget class="QLabel" name="label">
<property name="font">
<font>
<pointsize>10</pointsize>
</font>
</property>
<property name="text">
<string>No options to set</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>