1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2025-01-17 02:52:12 +01:00

OP-885 Fixed some code formatting issues.

This commit is contained in:
Fredrik Arvidsson 2013-04-14 13:24:07 +02:00
parent 471afde5f8
commit 361f8397c9
6 changed files with 75 additions and 86 deletions

View File

@ -15,27 +15,34 @@ public:
static QString idToBoardName(int id)
{
switch (id) {
case 0x0101://MB
case 0x0101:
// MB
return QString("OpenPilot MainBoard");
break;
case 0x0201://INS
case 0x0201:
// INS
return QString("OpenPilot INS");
break;
case 0x0301://PipX
case 0x0301:
// OPLink Mini
return QString("OPLink");
break;
case 0x0401://Coptercontrol
case 0x0401:
// Coptercontrol
return QString("CopterControl");
break;
case 0x0402://Coptercontrol
case 0x0402:
// Coptercontrol 3D
// It would be nice to say CC3D here but since currently we use string comparisons
// for firmware compatibility and the filename path that would break
return QString("CopterControl");
break;
case 0x0901://Revolution
case 0x0901:
// Revolution
return QString("Revolution");
break;
case 0x0903://Revo Mini
case 0x0903:
// Revo Mini
return QString("Revolution");
break;
default:

View File

@ -26,7 +26,7 @@
*/
#include "devicewidget.h"
deviceWidget::deviceWidget(QWidget *parent) :
DeviceWidget::DeviceWidget(QWidget *parent) :
QWidget(parent)
{
myDevice = new Ui_deviceWidget();
@ -47,8 +47,7 @@ deviceWidget::deviceWidget(QWidget *parent) :
myDevice->lblCertified->setText("");
}
void deviceWidget::showEvent(QShowEvent *event)
void DeviceWidget::showEvent(QShowEvent *event)
{
Q_UNUSED(event)
// Thit fitInView method should only be called now, once the
@ -57,18 +56,18 @@ void deviceWidget::showEvent(QShowEvent *event)
myDevice->gVDevice->fitInView(devicePic.rect(),Qt::KeepAspectRatio);
}
void deviceWidget::resizeEvent(QResizeEvent* event)
void DeviceWidget::resizeEvent(QResizeEvent* event)
{
Q_UNUSED(event);
myDevice->gVDevice->fitInView(devicePic.rect(), Qt::KeepAspectRatio);
}
void deviceWidget::setDeviceID(int devID){
void DeviceWidget::setDeviceID(int devID)
{
deviceID = devID;
}
void deviceWidget::setDfu(DFUObject *dfu)
void DeviceWidget::setDfu(DFUObject *dfu)
{
m_dfu = dfu;
}
@ -76,9 +75,8 @@ void deviceWidget::setDfu(DFUObject *dfu)
/**
Fills the various fields for the device
*/
void deviceWidget::populate()
void DeviceWidget::populate()
{
int id = m_dfu->devices[deviceID].ID;
myDevice->lbldevID->setText(QString("Device ID: ") + QString::number(id, 16));
// DeviceID tells us what sort of HW we have detected:
@ -89,10 +87,8 @@ void deviceWidget::populate()
switch (id) {
case 0x0101:
devicePic.load("");//TODO
break;
case 0x0201:
devicePic.load("");//TODO
devicePic.load("");
break;
case 0x0301:
devicePic.load(":/uploader/images/gcs-board-oplink.png");
@ -107,7 +103,8 @@ void deviceWidget::populate()
devicePic.load(":/uploader/images/gcs-board-revo.png");
break;
default:
devicePic.load(""); //Clear
// Clear
devicePic.load("");
break;
}
myDevice->gVDevice->scene()->addPixmap(devicePic);
@ -145,12 +142,12 @@ void deviceWidget::populate()
Freezes the contents of the widget so that a user cannot
try to modify the contents
*/
void deviceWidget::freeze()
void DeviceWidget::freeze()
{
updateButtons(false);
}
void deviceWidget::updateButtons(bool enabled)
void DeviceWidget::updateButtons(bool enabled)
{
if (!enabled) {
myDevice->description->setEnabled(false);
@ -175,22 +172,19 @@ void deviceWidget::updateButtons(bool enabled)
Populates the widget field with the description in case
it is structured properly
*/
bool deviceWidget::populateBoardStructuredDescription(QByteArray desc)
bool DeviceWidget::populateBoardStructuredDescription(QByteArray desc)
{
if(UAVObjectUtilManager::descriptionToStructure(desc,onBoardDescription))
{
if(UAVObjectUtilManager::descriptionToStructure(desc,onBoardDescription)) {
myDevice->lblGitTag->setText(onBoardDescription.gitHash);
myDevice->lblBuildDate->setText(onBoardDescription.gitDate.insert(4,"-").insert(7,"-"));
if(onBoardDescription.gitTag.startsWith("RELEASE",Qt::CaseSensitive))
{
if(onBoardDescription.gitTag.startsWith("RELEASE",Qt::CaseSensitive)) {
myDevice->lblDescription->setText(onBoardDescription.gitTag);
QPixmap pix = QPixmap(QString(":uploader/images/application-certificate.svg"));
myDevice->lblCertified->setPixmap(pix);
myDevice->lblCertified->setToolTip(tr("Tagged officially released firmware build"));
}
else
{
else {
myDevice->lblDescription->setText(onBoardDescription.gitTag);
QPixmap pix = QPixmap(QString(":uploader/images/warning.svg"));
myDevice->lblCertified->setPixmap(pix);
@ -203,24 +197,20 @@ bool deviceWidget::populateBoardStructuredDescription(QByteArray desc)
}
return false;
}
bool deviceWidget::populateLoadedStructuredDescription(QByteArray desc)
bool DeviceWidget::populateLoadedStructuredDescription(QByteArray desc)
{
if(UAVObjectUtilManager::descriptionToStructure(desc,LoadedDescription))
{
if(UAVObjectUtilManager::descriptionToStructure(desc,LoadedDescription)) {
myDevice->lblGitTagL->setText(LoadedDescription.gitHash);
myDevice->lblBuildDateL->setText( LoadedDescription.gitDate.insert(4,"-").insert(7,"-"));
if(LoadedDescription.gitTag.startsWith("RELEASE",Qt::CaseSensitive))
{
myDevice->lblBuildDateL->setText( LoadedDescription.gitDate.insert(4, "-").insert(7, "-"));
if(LoadedDescription.gitTag.startsWith("RELEASE",Qt::CaseSensitive)) {
myDevice->lblDescritpionL->setText(LoadedDescription.gitTag);
myDevice->description->setText(LoadedDescription.gitTag);
QPixmap pix = QPixmap(QString(":uploader/images/application-certificate.svg"));
myDevice->lblCertifiedL->setPixmap(pix);
myDevice->lblCertifiedL->setToolTip(tr("Tagged officially released firmware build"));
}
else
{
} else {
myDevice->lblDescritpionL->setText(LoadedDescription.gitTag);
myDevice->description->setText(LoadedDescription.gitTag);
QPixmap pix = QPixmap(QString(":uploader/images/warning.svg"));
@ -231,19 +221,18 @@ bool deviceWidget::populateLoadedStructuredDescription(QByteArray desc)
return true;
}
return false;
}
/**
Updates status message for messages coming from DFU
*/
void deviceWidget::dfuStatus(QString str)
void DeviceWidget::dfuStatus(QString str)
{
status(str, STATUSICON_RUNNING);
}
void deviceWidget::confirmCB(int value)
void DeviceWidget::confirmCB(int value)
{
updateButtons(true);
}
@ -251,7 +240,7 @@ void deviceWidget::confirmCB(int value)
/**
Updates status message
*/
void deviceWidget::status(QString str, StatusIcon ic)
void DeviceWidget::status(QString str, StatusIcon ic)
{
QPixmap px;
myDevice->statusLabel->setText(str);
@ -271,8 +260,7 @@ void deviceWidget::status(QString str, StatusIcon ic)
myDevice->statusIcon->setPixmap(px);
}
void deviceWidget::loadFirmware()
void DeviceWidget::loadFirmware()
{
myDevice->verticalGroupBox_loaded->setVisible(false);
myDevice->groupCustom->setVisible(false);
@ -299,13 +287,12 @@ void deviceWidget::loadFirmware()
QPixmap px;
if (loadedFW.length()>m_dfu->devices[deviceID].SizeOfCode) {
myDevice->lblCRCL->setText(tr("Can't calculate, file too big for device"));
}
else {
} else {
myDevice->lblCRCL->setText( QString::number(DFUObject::CRCFromQBArray(loadedFW,m_dfu->devices[deviceID].SizeOfCode)));
}
//myDevice->lblFirmwareSizeL->setText(QString("Firmware size: ")+QVariant(loadedFW.length()).toString()+ QString(" bytes"));
if (populateLoadedStructuredDescription(desc))
{
if (populateLoadedStructuredDescription(desc)) {
myDevice->confirmCheckBox->setChecked(true);
myDevice->verticalGroupBox_loaded->setVisible(true);
myDevice->groupCustom->setVisible(false);
@ -339,7 +326,7 @@ void deviceWidget::loadFirmware()
/**
Sends a firmware to the device
*/
void deviceWidget::uploadFirmware()
void DeviceWidget::uploadFirmware()
{
// clear progress bar now
// this avoids displaying an error message and the progress at 100% at the same time
@ -422,7 +409,7 @@ void deviceWidget::uploadFirmware()
/**
Retrieves the firmware from the device
*/
void deviceWidget::downloadFirmware()
void DeviceWidget::downloadFirmware()
{
// clear progress bar now
// this avoids displaying an error message and the progress at 100% at the same time
@ -466,7 +453,7 @@ void deviceWidget::downloadFirmware()
/**
Callback for the firmware download result
*/
void deviceWidget::downloadFinished()
void DeviceWidget::downloadFinished()
{
disconnect(m_dfu, SIGNAL(downloadFinished()), this, SLOT(downloadFinished()));
disconnect(m_dfu, SIGNAL(progressUpdated(int)), this, SLOT(setProgress(int)));
@ -482,7 +469,7 @@ void deviceWidget::downloadFinished()
/**
Callback for the firmware upload result
*/
void deviceWidget::uploadFinished(OP_DFU::Status retstatus)
void DeviceWidget::uploadFinished(OP_DFU::Status retstatus)
{
disconnect(m_dfu, SIGNAL(uploadFinished(OP_DFU::Status)), this, SLOT(uploadFinished(OP_DFU::Status)));
disconnect(m_dfu, SIGNAL(progressUpdated(int)), this, SLOT(setProgress(int)));
@ -529,7 +516,7 @@ void deviceWidget::uploadFinished(OP_DFU::Status retstatus)
/**
Slot to update the progress bar
*/
void deviceWidget::setProgress(int percent)
void DeviceWidget::setProgress(int percent)
{
myDevice->progressBar->setValue(percent);
}
@ -537,7 +524,7 @@ void deviceWidget::setProgress(int percent)
/**
*Opens an open file dialog.
*/
QString deviceWidget::setOpenFileName()
QString DeviceWidget::setOpenFileName()
{
QFileDialog::Options options;
QString selectedFilter;
@ -576,7 +563,7 @@ QString deviceWidget::setOpenFileName()
/**
*Set the save file name
*/
QString deviceWidget::setSaveFileName()
QString DeviceWidget::setSaveFileName()
{
QFileDialog::Options options;
QString selectedFilter;

View File

@ -45,11 +45,11 @@
#include "uploader_global.h"
using namespace OP_DFU;
class UPLOADER_EXPORT deviceWidget : public QWidget
class UPLOADER_EXPORT DeviceWidget : public QWidget
{
Q_OBJECT
public:
deviceWidget(QWidget *parent = 0);
DeviceWidget(QWidget *parent = 0);
void setDeviceID(int devID);
void setDfu(DFUObject* dfu);
void populate();

View File

@ -27,7 +27,8 @@
#include "runningdevicewidget.h"
#include "devicedescriptorstruct.h"
#include "uploadergadgetwidget.h"
runningDeviceWidget::runningDeviceWidget(QWidget *parent) :
RunningDeviceWidget::RunningDeviceWidget(QWidget *parent) :
QWidget(parent)
{
myDevice = new Ui_runningDeviceWidget();
@ -35,11 +36,9 @@ runningDeviceWidget::runningDeviceWidget(QWidget *parent) :
// Initialization of the Device icon display
myDevice->devicePicture->setScene(new QGraphicsScene(this));
}
void runningDeviceWidget::showEvent(QShowEvent *event)
void RunningDeviceWidget::showEvent(QShowEvent *event)
{
Q_UNUSED(event)
// Thit fitInView method should only be called now, once the
@ -48,7 +47,7 @@ void runningDeviceWidget::showEvent(QShowEvent *event)
myDevice->devicePicture->fitInView(devicePic.rect(),Qt::KeepAspectRatio);
}
void runningDeviceWidget::resizeEvent(QResizeEvent* event)
void RunningDeviceWidget::resizeEvent(QResizeEvent* event)
{
Q_UNUSED(event);
myDevice->devicePicture->fitInView(devicePic.rect(), Qt::KeepAspectRatio);
@ -57,7 +56,7 @@ void runningDeviceWidget::resizeEvent(QResizeEvent* event)
/**
Fills the various fields for the device
*/
void runningDeviceWidget::populate()
void RunningDeviceWidget::populate()
{
ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance();
UAVObjectUtilManager* utilMngr = pm->getObject<UAVObjectUtilManager>();
@ -65,19 +64,17 @@ void runningDeviceWidget::populate()
myDevice->lblDeviceID->setText(QString("Device ID: ") + QString::number(id, 16));
myDevice->lblBoardName->setText(deviceDescriptorStruct::idToBoardName(id));
myDevice->lblHWRev->setText(QString(tr("HW Revision: "))+QString::number(id & 0x00FF, 16));
qDebug()<<"CRC"<<utilMngr->getFirmwareCRC();
myDevice->lblCRC->setText(QString(tr("Firmware CRC: "))+QVariant(utilMngr->getFirmwareCRC()).toString());
myDevice->lblHWRev->setText(QString(tr("HW Revision: ")) + QString::number(id & 0x00FF, 16));
qDebug() << "CRC" << utilMngr->getFirmwareCRC();
myDevice->lblCRC->setText(QString(tr("Firmware CRC: ")) + QVariant(utilMngr->getFirmwareCRC()).toString());
// DeviceID tells us what sort of HW we have detected:
// display a nice icon:
myDevice->devicePicture->scene()->clear();
switch (id) {
case 0x0101:
devicePic.load("");//TODO
break;
case 0x0201:
devicePic.load("");//TODO
devicePic.load("");
break;
case 0x0301:
devicePic.load(":/uploader/images/gcs-board-oplink.png");
@ -92,7 +89,8 @@ void runningDeviceWidget::populate()
devicePic.load(":/uploader/images/gcs-board-revo.png");
break;
default:
devicePic.load(""); //Clear
// Clear
devicePic.load("");
break;
}
myDevice->devicePicture->scene()->addPixmap(devicePic);
@ -119,9 +117,7 @@ void runningDeviceWidget::populate()
}
myDevice->lblGitCommitTag->setText("Git commit hash: " + devDesc.gitHash);
myDevice->lblFWDate->setText(QString("Firmware date: ") + devDesc.gitDate.insert(4,"-").insert(7,"-"));
}
else
{
} else {
myDevice->lblFWTag->setText(QString("Firmware tag: ") + QString(description).left(QString(description).indexOf(QChar(255))));
myDevice->lblGitCommitTag->setText("Git commit tag: Unknown");
myDevice->lblFWDate->setText(QString("Firmware date: Unknown"));

View File

@ -41,11 +41,11 @@
#include "uavobjectutilmanager.h"
#include "uploader_global.h"
class UPLOADER_EXPORT runningDeviceWidget : public QWidget
class UPLOADER_EXPORT RunningDeviceWidget : public QWidget
{
Q_OBJECT
public:
runningDeviceWidget( QWidget *parent = 0);
RunningDeviceWidget( QWidget *parent = 0);
void populate();
void freeze();
QString setOpenFileName();
@ -58,7 +58,6 @@ private:
QPixmap devicePic;
//void status(QString str, StatusIcon ic);
signals:
protected:

View File

@ -118,10 +118,10 @@ QString UploaderGadgetWidget::getPortDevice(const QString &friendName)
void UploaderGadgetWidget::connectSignalSlot(QWidget *widget)
{
connect(qobject_cast<deviceWidget *>(widget),SIGNAL(uploadStarted()),this,SLOT(uploadStarted()));
connect(qobject_cast<deviceWidget *>(widget),SIGNAL(uploadEnded(bool)),this,SLOT(uploadEnded(bool)));
connect(qobject_cast<deviceWidget *>(widget),SIGNAL(downloadStarted()),this,SLOT(downloadStarted()));
connect(qobject_cast<deviceWidget *>(widget),SIGNAL(downloadEnded(bool)),this,SLOT(downloadEnded(bool)));
connect(qobject_cast<DeviceWidget *>(widget),SIGNAL(uploadStarted()),this,SLOT(uploadStarted()));
connect(qobject_cast<DeviceWidget *>(widget),SIGNAL(uploadEnded(bool)),this,SLOT(uploadEnded(bool)));
connect(qobject_cast<DeviceWidget *>(widget),SIGNAL(downloadStarted()),this,SLOT(downloadStarted()));
connect(qobject_cast<DeviceWidget *>(widget),SIGNAL(downloadEnded(bool)),this,SLOT(downloadEnded(bool)));
}
FlightStatus *UploaderGadgetWidget::getFlightStatus()
@ -166,7 +166,7 @@ void UploaderGadgetWidget::populate()
m_config->systemElements->removeTab(0);
delete qw;
}
runningDeviceWidget* dw = new runningDeviceWidget(this);
RunningDeviceWidget* dw = new RunningDeviceWidget(this);
dw->populate();
m_config->systemElements->addTab(dw, QString("Connected Device"));
}
@ -332,7 +332,7 @@ void UploaderGadgetWidget::goToBootloader(UAVObject* callerObj, bool success)
delete qw;
}
for(int i=0;i<dfu->numberOfDevices;i++) {
deviceWidget* dw = new deviceWidget(this);
DeviceWidget* dw = new DeviceWidget(this);
connectSignalSlot(dw);
dw->setDeviceID(i);
dw->setDfu(dfu);
@ -477,7 +477,7 @@ void UploaderGadgetWidget::commonSystemBoot(bool safeboot)
for (int i=0; i< m_config->systemElements->count(); i++) {
// OP-682 arriving here too "early" (before the devices are refreshed) was leading to a crash
// OP-682 the crash was due to an unchecked cast in the line below that would cast a RunningDeviceGadget to a DeviceGadget
deviceWidget *qw = dynamic_cast<deviceWidget*>(m_config->systemElements->widget(i));
DeviceWidget *qw = dynamic_cast<DeviceWidget*>(m_config->systemElements->widget(i));
if (qw) {
// OP-682 fixed a second crash by disabling *all* buttons in the device widget
// disabling the buttons is only half of the solution as even if the buttons are enabled
@ -729,7 +729,7 @@ void UploaderGadgetWidget::systemRescue()
return;
}
for(int i=0;i<dfu->numberOfDevices;i++) {
deviceWidget* dw = new deviceWidget(this);
DeviceWidget* dw = new DeviceWidget(this);
connectSignalSlot(dw);
dw->setDeviceID(i);
dw->setDfu(dfu);