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-11-12 00:43:13 +00:00
|
|
|
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
|
|
|
struct dive *d = get_dive_by_uniq_id(m_diveId.toInt());
|
|
|
|
if (m_diveId.toInt() < 1)
|
|
|
|
return;
|
|
|
|
if (!d)
|
|
|
|
return;
|
|
|
|
|
2015-12-02 19:26:32 +00:00
|
|
|
// set the profile widget's geometry and scale the viewport so
|
|
|
|
// the scene fills it, then plot the dive on that widget
|
2015-12-01 23:22:38 +00:00
|
|
|
m_profileWidget->setGeometry(QRect(x(), y(), width(), height()));
|
2015-12-02 19:26:32 +00:00
|
|
|
QTransform profileTransform;
|
|
|
|
profileTransform.scale(width() / 100, height() / 100);
|
|
|
|
m_profileWidget->setTransform(profileTransform);
|
2015-12-01 23:22:38 +00:00
|
|
|
m_profileWidget->plotDive(d);
|
2015-07-17 16:09:42 +00:00
|
|
|
}
|