2015-07-17 16:09:42 +00:00
|
|
|
#include "qmlprofile.h"
|
2015-11-05 15:59:09 +00:00
|
|
|
#include "profile-widget/profilewidget2.h"
|
|
|
|
#include "subsurface-core/dive.h"
|
2015-07-25 16:10:51 +00:00
|
|
|
#include <QTransform>
|
2015-07-17 16:09:42 +00:00
|
|
|
|
|
|
|
QMLProfile::QMLProfile(QQuickItem *parent) :
|
|
|
|
QQuickPaintedItem(parent)
|
|
|
|
{
|
2015-11-12 00:43:13 +00:00
|
|
|
m_profileWidget = new ProfileWidget2(0);
|
|
|
|
m_profileWidget->setProfileState();
|
|
|
|
m_profileWidget->setToolTipVisibile(false);
|
|
|
|
//m_profileWidget->setGeometry(this->geometry());
|
|
|
|
}
|
|
|
|
|
|
|
|
QMLProfile::~QMLProfile()
|
|
|
|
{
|
|
|
|
m_profileWidget->deleteLater();
|
2015-07-17 16:09:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void QMLProfile::paint(QPainter *painter)
|
|
|
|
{
|
2015-07-25 16:10:51 +00:00
|
|
|
QTransform profileTransform;
|
2015-12-01 23:22:38 +00:00
|
|
|
profileTransform.scale(width() / 100, height() / 100);
|
2015-11-12 00:43:13 +00:00
|
|
|
m_profileWidget->setTransform(profileTransform);
|
|
|
|
m_profileWidget->render(painter);
|
2015-07-17 16:09:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
QString QMLProfile::diveId() const
|
|
|
|
{
|
|
|
|
return m_diveId;
|
|
|
|
}
|
|
|
|
|
|
|
|
void QMLProfile::setDiveId(const QString &diveId)
|
|
|
|
{
|
|
|
|
m_diveId = diveId;
|
2015-12-01 23:22:38 +00:00
|
|
|
int no = -1;
|
|
|
|
struct dive *d = get_dive_by_uniq_id(m_diveId.toInt());
|
|
|
|
if (d)
|
|
|
|
no = d->number;
|
|
|
|
if (m_diveId.toInt() < 1)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (!d)
|
|
|
|
return;
|
|
|
|
|
|
|
|
m_profileWidget->setGeometry(QRect(x(), y(), width(), height()));
|
|
|
|
m_profileWidget->plotDive(d);
|
2015-07-17 16:09:42 +00:00
|
|
|
}
|