Profile: don't compile the desktop specific parts on mobile

When building subsurface-mobile we won't be using all these UI elements,
so let's not build them.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
Dirk Hohndel 2015-11-05 16:05:44 -08:00
parent 662e2a0ff3
commit f3232b1a6f
2 changed files with 35 additions and 5 deletions

View file

@ -14,8 +14,10 @@
#include "diveplannermodel.h" #include "diveplannermodel.h"
#include "models.h" #include "models.h"
#include "divepicturemodel.h" #include "divepicturemodel.h"
#ifndef SUBSURFACE_MOBILE
#include "diveplanner.h" #include "diveplanner.h"
#include "simplewidgets.h" #include "simplewidgets.h"
#endif
#include <libdivecomputer/parser.h> #include <libdivecomputer/parser.h>
#include <QScrollBar> #include <QScrollBar>
@ -680,11 +682,13 @@ void ProfileWidget2::plotDive(struct dive *d, bool force)
prefs.animation_speed = animSpeedBackup; prefs.animation_speed = animSpeedBackup;
} }
#ifndef SUBSURFACE_MOBILE
if (currentState == ADD || currentState == PLAN) { // TODO: figure a way to move this from here. if (currentState == ADD || currentState == PLAN) { // TODO: figure a way to move this from here.
repositionDiveHandlers(); repositionDiveHandlers();
DivePlannerPointsModel *model = DivePlannerPointsModel::instance(); DivePlannerPointsModel *model = DivePlannerPointsModel::instance();
model->deleteTemporaryPlan(); model->deleteTemporaryPlan();
} }
#endif
plotPictures(); plotPictures();
// OK, how long did this take us? Anything above the second is way too long, // OK, how long did this take us? Anything above the second is way too long,
@ -785,6 +789,7 @@ void ProfileWidget2::mousePressEvent(QMouseEvent *event)
shouldCalculateMaxTime = false; shouldCalculateMaxTime = false;
} }
#ifndef SUBSURFACE_MOBILE
void ProfileWidget2::divePlannerHandlerClicked() void ProfileWidget2::divePlannerHandlerClicked()
{ {
if (zoomLevel) if (zoomLevel)
@ -800,6 +805,7 @@ void ProfileWidget2::divePlannerHandlerReleased()
shouldCalculateMaxDepth = true; shouldCalculateMaxDepth = true;
replot(); replot();
} }
#endif
void ProfileWidget2::mouseReleaseEvent(QMouseEvent *event) void ProfileWidget2::mouseReleaseEvent(QMouseEvent *event)
{ {
@ -958,7 +964,9 @@ void ProfileWidget2::setEmptyState()
HIDE_ALL(DiveCalculatedTissue, allTissues); HIDE_ALL(DiveCalculatedTissue, allTissues);
HIDE_ALL(DivePercentageItem, allPercentages); HIDE_ALL(DivePercentageItem, allPercentages);
HIDE_ALL(DiveEventItem, eventItems); HIDE_ALL(DiveEventItem, eventItems);
#ifndef SUBSURFACE_MOBILE
HIDE_ALL(DiveHandler, handles); HIDE_ALL(DiveHandler, handles);
#endif
HIDE_ALL(QGraphicsSimpleTextItem, gases); HIDE_ALL(QGraphicsSimpleTextItem, gases);
#undef HIDE_ALL #undef HIDE_ALL
} }
@ -1087,13 +1095,17 @@ void ProfileWidget2::setProfileState()
#define HIDE_ALL(TYPE, CONTAINER) \ #define HIDE_ALL(TYPE, CONTAINER) \
Q_FOREACH (TYPE *item, CONTAINER) item->setVisible(false); Q_FOREACH (TYPE *item, CONTAINER) item->setVisible(false);
#ifndef SUBSURFACE_MOBILE
HIDE_ALL(DiveHandler, handles); HIDE_ALL(DiveHandler, handles);
#endif
HIDE_ALL(QGraphicsSimpleTextItem, gases); HIDE_ALL(QGraphicsSimpleTextItem, gases);
#undef HIDE_ALL #undef HIDE_ALL
mouseFollowerHorizontal->setVisible(false); mouseFollowerHorizontal->setVisible(false);
mouseFollowerVertical->setVisible(false); mouseFollowerVertical->setVisible(false);
} }
#ifndef SUBSURFACE_MOBILE
void ProfileWidget2::clearHandlers() void ProfileWidget2::clearHandlers()
{ {
if (handles.count()) { if (handles.count()) {
@ -1104,6 +1116,7 @@ void ProfileWidget2::clearHandlers()
handles.clear(); handles.clear();
} }
} }
#endif
void ProfileWidget2::setToolTipVisibile(bool visible) void ProfileWidget2::setToolTipVisibile(bool visible)
{ {
@ -1115,7 +1128,9 @@ void ProfileWidget2::setAddState()
if (currentState == ADD) if (currentState == ADD)
return; return;
#ifndef SUBSURFACE_MOBILE
clearHandlers(); clearHandlers();
#endif
setProfileState(); setProfileState();
mouseFollowerHorizontal->setVisible(true); mouseFollowerHorizontal->setVisible(true);
mouseFollowerVertical->setVisible(true); mouseFollowerVertical->setVisible(true);
@ -1210,6 +1225,7 @@ void ProfileWidget2::setReplot(bool state)
replotEnabled = state; replotEnabled = state;
} }
#ifndef SUBSURFACE_MOBILE
void ProfileWidget2::contextMenuEvent(QContextMenuEvent *event) void ProfileWidget2::contextMenuEvent(QContextMenuEvent *event)
{ {
if (currentState == ADD || currentState == PLAN) { if (currentState == ADD || currentState == PLAN) {
@ -1478,6 +1494,7 @@ void ProfileWidget2::changeGas()
mark_divelist_changed(true); mark_divelist_changed(true);
replot(); replot();
} }
#endif
bool ProfileWidget2::getPrintMode() bool ProfileWidget2::getPrintMode()
{ {
@ -1517,6 +1534,7 @@ double ProfileWidget2::getFontPrintScale()
return 1.0; return 1.0;
} }
#ifndef SUBSURFACE_MOBILE
void ProfileWidget2::editName() void ProfileWidget2::editName()
{ {
QAction *action = qobject_cast<QAction *>(sender()); QAction *action = qobject_cast<QAction *>(sender());
@ -1542,6 +1560,7 @@ void ProfileWidget2::editName()
replot(); replot();
} }
} }
#endif
void ProfileWidget2::disconnectTemporaryConnections() void ProfileWidget2::disconnectTemporaryConnections()
{ {
@ -1560,6 +1579,7 @@ void ProfileWidget2::disconnectTemporaryConnections()
} }
} }
#ifndef SUBSURFACE_MOBILE
void ProfileWidget2::pointInserted(const QModelIndex &parent, int start, int end) void ProfileWidget2::pointInserted(const QModelIndex &parent, int start, int end)
{ {
DiveHandler *item = new DiveHandler(); DiveHandler *item = new DiveHandler();
@ -1804,6 +1824,7 @@ void ProfileWidget2::keyEscAction()
if (plannerModel->isPlanner()) if (plannerModel->isPlanner())
plannerModel->cancelPlan(); plannerModel->cancelPlan();
} }
#endif
void ProfileWidget2::plotPictures() void ProfileWidget2::plotPictures()
{ {

View file

@ -81,7 +81,9 @@ public:
bool isAddOrPlanner(); bool isAddOrPlanner();
double getFontPrintScale(); double getFontPrintScale();
void setFontPrintScale(double scale); void setFontPrintScale(double scale);
#ifndef SUBSURFACE_MOBILE
void clearHandlers(); void clearHandlers();
#endif
void recalcCeiling(); void recalcCeiling();
void setToolTipVisibile(bool visible); void setToolTipVisibile(bool visible);
State currentState; State currentState;
@ -103,6 +105,10 @@ slots: // Necessary to call from QAction's signals.
void setProfileState(); void setProfileState();
void setPlanState(); void setPlanState();
void setAddState(); void setAddState();
void plotPictures();
void setReplot(bool state);
void replot(dive *d = 0);
#ifndef SUBSURFACE_MOBILE
void changeGas(); void changeGas();
void addSetpointChange(); void addSetpointChange();
void addBookmark(); void addBookmark();
@ -114,9 +120,6 @@ slots: // Necessary to call from QAction's signals.
void deleteCurrentDC(); void deleteCurrentDC();
void pointInserted(const QModelIndex &parent, int start, int end); void pointInserted(const QModelIndex &parent, int start, int end);
void pointsRemoved(const QModelIndex &, int start, int end); void pointsRemoved(const QModelIndex &, int start, int end);
void plotPictures();
void setReplot(bool state);
void replot(dive *d = 0);
/* this is called for every move on the handlers. maybe we can speed up this a bit? */ /* this is called for every move on the handlers. maybe we can speed up this a bit? */
void recreatePlannedDive(); void recreatePlannedDive();
@ -131,13 +134,16 @@ slots: // Necessary to call from QAction's signals.
void divePlannerHandlerClicked(); void divePlannerHandlerClicked();
void divePlannerHandlerReleased(); void divePlannerHandlerReleased();
#endif
protected: protected:
virtual ~ProfileWidget2(); virtual ~ProfileWidget2();
virtual void resizeEvent(QResizeEvent *event); virtual void resizeEvent(QResizeEvent *event);
virtual void wheelEvent(QWheelEvent *event); virtual void wheelEvent(QWheelEvent *event);
virtual void mouseMoveEvent(QMouseEvent *event); virtual void mouseMoveEvent(QMouseEvent *event);
#ifndef SUBSURFACE_MOBILE
virtual void contextMenuEvent(QContextMenuEvent *event); virtual void contextMenuEvent(QContextMenuEvent *event);
#endif
virtual void mouseDoubleClickEvent(QMouseEvent *event); virtual void mouseDoubleClickEvent(QMouseEvent *event);
virtual void mousePressEvent(QMouseEvent *event); virtual void mousePressEvent(QMouseEvent *event);
virtual void mouseReleaseEvent(QMouseEvent *event); virtual void mouseReleaseEvent(QMouseEvent *event);
@ -200,13 +206,16 @@ private:
bool isGrayscale; bool isGrayscale;
bool printMode; bool printMode;
//specifics for ADD and PLAN
QList<DiveHandler *> handles;
QList<QGraphicsSimpleTextItem *> gases; QList<QGraphicsSimpleTextItem *> gases;
QList<DivePictureItem *> pictures; QList<DivePictureItem *> pictures;
//specifics for ADD and PLAN
#ifndef SUBSURFACE_MOBILE
QList<DiveHandler *> handles;
void repositionDiveHandlers(); void repositionDiveHandlers();
int fixHandlerIndex(DiveHandler *activeHandler); int fixHandlerIndex(DiveHandler *activeHandler);
friend class DiveHandler; friend class DiveHandler;
#endif
QHash<Qt::Key, QAction *> actionsForKeys; QHash<Qt::Key, QAction *> actionsForKeys;
bool shouldCalculateMaxTime; bool shouldCalculateMaxTime;
bool shouldCalculateMaxDepth; bool shouldCalculateMaxDepth;