Commit 051d56a9 authored by Michael Carpenter's avatar Michael Carpenter

Abstraction of UASQuickViewItem, and addition of new Text item to use the abstraction

parent c6cd2cc0
......@@ -378,7 +378,8 @@ HEADERS += src/MG.h \
src/ui/dockwidgettitlebareventfilter.h \
src/ui/uas/UASQuickView.h \
src/ui/uas/UASQuickViewItem.h \
src/ui/uas/UASQuickViewItemSelect.h
src/ui/uas/UASQuickViewItemSelect.h \
src/ui/uas/UASQuickViewTextItem.h
# Google Earth is only supported on Mac OS and Windows with Visual Studio Compiler
macx|macx-g++|macx-g++42|win32-msvc2008|win32-msvc2010|win32-msvc2012::HEADERS += src/ui/map3D/QGCGoogleEarthView.h
......@@ -547,7 +548,8 @@ SOURCES += src/main.cc \
src/ui/dockwidgettitlebareventfilter.cpp \
src/ui/uas/UASQuickViewItem.cc \
src/ui/uas/UASQuickView.cc \
src/ui/uas/UASQuickViewItemSelect.cpp
src/ui/uas/UASQuickViewTextItem.cc \
src/ui/uas/UASQuickViewItemSelect.cc
# Enable Google Earth only on Mac OS and Windows with Visual Studio compiler
macx|macx-g++|macx-g++42|win32-msvc2008|win32-msvc2010|win32-msvc2012::SOURCES += src/ui/map3D/QGCGoogleEarthView.cc
......
......@@ -2,6 +2,7 @@
#include <QMetaMethod>
#include <QDebug>
#include "UASQuickViewItemSelect.h"
#include "UASQuickViewTextItem.h"
#include <QSettings>
UASQuickView::UASQuickView(QWidget *parent) : QWidget(parent)
{
......@@ -146,7 +147,7 @@ void UASQuickView::loadSettings()
void UASQuickView::valueEnabled(QString value)
{
UASQuickViewItem *item = new UASQuickViewItem(this);
UASQuickViewItem *item = new UASQuickViewTextItem(this);
item->setTitle(value);
ui.verticalLayout->addWidget(item);
uasPropertyToLabelMap[value] = item;
......@@ -359,7 +360,7 @@ void UASQuickView::actionTriggered(bool checked)
}
if (checked)
{
UASQuickViewItem *item = new UASQuickViewItem(this);
UASQuickViewItem *item = new UASQuickViewTextItem(this);
item->setTitle(senderlabel->text());
ui.verticalLayout->addWidget(item);
uasPropertyToLabelMap[senderlabel->text()] = item;
......
......@@ -3,24 +3,5 @@
UASQuickViewItem::UASQuickViewItem(QWidget *parent) : QWidget(parent)
{
QVBoxLayout *layout = new QVBoxLayout();
this->setLayout(layout);
titleLabel = new QLabel(this);
titleLabel->setAlignment(Qt::AlignHCenter);
this->layout()->addWidget(titleLabel);
valueLabel = new QLabel(this);
valueLabel->setAlignment(Qt::AlignHCenter);
valueLabel->setText("<h1>0.00</h1>");
this->layout()->addWidget(valueLabel);
layout->addSpacerItem(new QSpacerItem(20, 40, QSizePolicy::Minimum, QSizePolicy::Expanding));
}
void UASQuickViewItem::setValue(double value)
{
valueLabel->setText("<h1>" + QString::number(value,'f',4) + "</h1>");
}
void UASQuickViewItem::setTitle(QString title)
{
titleLabel->setText(title);
}
......@@ -8,15 +8,8 @@ class UASQuickViewItem : public QWidget
Q_OBJECT
public:
explicit UASQuickViewItem(QWidget *parent = 0);
void setValue(double value);
void setTitle(QString title);
private:
QLabel *titleLabel;
QLabel *valueLabel;
signals:
public slots:
virtual void setValue(double value)=0;
virtual void setTitle(QString title)=0;
};
#endif // UASQUICKVIEWITEM_H
#include "UASQuickViewTextItem.h"
#include <QVBoxLayout>
UASQuickViewTextItem::UASQuickViewTextItem(QWidget *parent) : UASQuickViewItem(parent)
{
QVBoxLayout *layout = new QVBoxLayout();
this->setLayout(layout);
titleLabel = new QLabel(this);
titleLabel->setAlignment(Qt::AlignHCenter);
this->layout()->addWidget(titleLabel);
valueLabel = new QLabel(this);
valueLabel->setAlignment(Qt::AlignHCenter);
valueLabel->setText("<h1>0.00</h1>");
this->layout()->addWidget(valueLabel);
layout->addSpacerItem(new QSpacerItem(20, 40, QSizePolicy::Minimum, QSizePolicy::Expanding));
}
void UASQuickViewTextItem::setValue(double value)
{
valueLabel->setText("<h1>" + QString::number(value,'f',4) + "</h1>");
}
void UASQuickViewTextItem::setTitle(QString title)
{
titleLabel->setText(title);
}
#ifndef UASQUICKVIEWTEXTITEM_H
#define UASQUICKVIEWTEXTITEM_H
#include "UASQuickViewItem.h"
#include <QLabel>
class UASQuickViewTextItem : public UASQuickViewItem
{
public:
UASQuickViewTextItem(QWidget *parent=0);
void setValue(double value);
void setTitle(QString title);
private:
QLabel *titleLabel;
QLabel *valueLabel;
};
#endif // UASQUICKVIEWTEXTITEM_H
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment