mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
Transform the DiveProfileItem to an Abstract Generalization
The DiveProfileItem contained much of the complexity and algorithms for almost all line-based items on the canvas, so I transformed that to a general abstraction and implemented a new DiveProfileItem that uses it. this should reduce a bit of code since the implementation of the PP Graphs, Temperature Cylinder Pressure and maybe a few others will only need to reimplement the paint() and the modelDataChanged() methods. The rest is ready. Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
1f80788286
commit
254beef5d4
4 changed files with 37 additions and 27 deletions
|
|
@ -14,19 +14,19 @@ DiveEventItem::DiveEventItem(QObject* parent): DivePixmapItem(parent),
|
|||
void DiveEventItem::setHorizontalAxis(DiveCartesianAxis* axis)
|
||||
{
|
||||
hAxis = axis;
|
||||
recalculate();
|
||||
recalculatePos();
|
||||
}
|
||||
|
||||
void DiveEventItem::setModel(DivePlotDataModel* model)
|
||||
{
|
||||
dataModel = model;
|
||||
recalculate();
|
||||
recalculatePos();
|
||||
}
|
||||
|
||||
void DiveEventItem::setVerticalAxis(DiveCartesianAxis* axis)
|
||||
{
|
||||
vAxis = axis;
|
||||
recalculate();
|
||||
recalculatePos();
|
||||
}
|
||||
|
||||
void DiveEventItem::setEvent(struct event* ev)
|
||||
|
|
@ -34,7 +34,7 @@ void DiveEventItem::setEvent(struct event* ev)
|
|||
internalEvent = ev;
|
||||
setupPixmap();
|
||||
setupToolTipString();
|
||||
recalculate();
|
||||
recalculatePos();
|
||||
}
|
||||
|
||||
void DiveEventItem::setupPixmap()
|
||||
|
|
@ -102,12 +102,11 @@ void DiveEventItem::eventVisibilityChanged(const QString& eventName, bool visibl
|
|||
|
||||
}
|
||||
|
||||
void DiveEventItem::recalculate()
|
||||
void DiveEventItem::recalculatePos()
|
||||
{
|
||||
if (!vAxis || !hAxis || !internalEvent || !dataModel){
|
||||
return;
|
||||
}
|
||||
qDebug() << "Calculating.";
|
||||
QModelIndexList result = dataModel->match(dataModel->index(0,DivePlotDataModel::TIME), Qt::DisplayRole, internalEvent->time.seconds );
|
||||
if(result.isEmpty()){
|
||||
hide();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue