mirror of
https://github.com/subsurface/subsurface.git
synced 2025-01-19 06:15:26 +00:00
Turn application state into enum
The application state was encoded in a QByteArray. Thus, there was no compile-time checking. Typos would lead to silent failures. Turn the application state into an enum. Use the enum-class construct, so that the values don't polute the global namespace. Moreover, this makes them strongly typed, i.e. they don't auto-convert to integers. A disadvantage is that the enums now have to be cast to int explicitly when used to index an array. Replace two hash-maps in MainWindow to arrays of fixed sizes. Move the application-state details into their own files. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
parent
114b3d9d47
commit
75767c456a
11 changed files with 100 additions and 75 deletions
|
@ -37,6 +37,8 @@ endif()
|
||||||
|
|
||||||
# compile the core library part in C, part in C++
|
# compile the core library part in C, part in C++
|
||||||
set(SUBSURFACE_CORE_LIB_SRCS
|
set(SUBSURFACE_CORE_LIB_SRCS
|
||||||
|
applicationstate.cpp
|
||||||
|
applicationstate.h
|
||||||
checkcloudconnection.cpp
|
checkcloudconnection.cpp
|
||||||
checkcloudconnection.h
|
checkcloudconnection.h
|
||||||
cloudstorage.cpp
|
cloudstorage.cpp
|
||||||
|
|
15
core/applicationstate.cpp
Normal file
15
core/applicationstate.cpp
Normal file
|
@ -0,0 +1,15 @@
|
||||||
|
// SPDX-License-Identifier: GPL-2.0
|
||||||
|
#include "applicationstate.h"
|
||||||
|
|
||||||
|
static ApplicationState appState = (ApplicationState)-1; // Set to an invalid value
|
||||||
|
|
||||||
|
ApplicationState getAppState()
|
||||||
|
{
|
||||||
|
return appState;
|
||||||
|
}
|
||||||
|
|
||||||
|
void setAppState(ApplicationState state)
|
||||||
|
{
|
||||||
|
appState = state;
|
||||||
|
}
|
||||||
|
|
21
core/applicationstate.h
Normal file
21
core/applicationstate.h
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
// SPDX-License-Identifier: GPL-2.0
|
||||||
|
#ifndef APPLICATIONSTATE_H
|
||||||
|
#define APPLICATIONSTATE_H
|
||||||
|
|
||||||
|
// By using an enum class, the enum entries don't polute the global namespace.
|
||||||
|
// Moreover, they are strongly typed. This means that they are not auto-converted
|
||||||
|
// to integer types if e.g. used as array-indices.
|
||||||
|
enum class ApplicationState {
|
||||||
|
Default,
|
||||||
|
EditDive,
|
||||||
|
PlanDive,
|
||||||
|
EditPlannedDive,
|
||||||
|
EditDiveSite,
|
||||||
|
FilterDive,
|
||||||
|
Count
|
||||||
|
};
|
||||||
|
|
||||||
|
ApplicationState getAppState();
|
||||||
|
void setAppState(ApplicationState state);
|
||||||
|
|
||||||
|
#endif
|
|
@ -12,6 +12,7 @@
|
||||||
#include "divecomputer.h"
|
#include "divecomputer.h"
|
||||||
#include "time.h"
|
#include "time.h"
|
||||||
#include "gettextfromc.h"
|
#include "gettextfromc.h"
|
||||||
|
#include "applicationstate.h"
|
||||||
#include "metadata.h"
|
#include "metadata.h"
|
||||||
#include <sys/time.h>
|
#include <sys/time.h>
|
||||||
#include "exif.h"
|
#include "exif.h"
|
||||||
|
@ -1362,21 +1363,9 @@ extern "C" void parse_display_units(char *line)
|
||||||
qDebug() << line;
|
qDebug() << line;
|
||||||
}
|
}
|
||||||
|
|
||||||
static QByteArray currentApplicationState;
|
|
||||||
|
|
||||||
QByteArray getCurrentAppState()
|
|
||||||
{
|
|
||||||
return currentApplicationState;
|
|
||||||
}
|
|
||||||
|
|
||||||
void setCurrentAppState(const QByteArray &state)
|
|
||||||
{
|
|
||||||
currentApplicationState = state;
|
|
||||||
}
|
|
||||||
|
|
||||||
extern "C" bool in_planner()
|
extern "C" bool in_planner()
|
||||||
{
|
{
|
||||||
return currentApplicationState == "PlanDive" || currentApplicationState == "EditPlannedDive";
|
return getAppState() == ApplicationState::PlanDive || getAppState() == ApplicationState::EditPlannedDive;
|
||||||
}
|
}
|
||||||
|
|
||||||
extern "C" enum deco_mode decoMode()
|
extern "C" enum deco_mode decoMode()
|
||||||
|
|
|
@ -40,8 +40,6 @@ volume_t string_to_volume(const char *str, pressure_t workp);
|
||||||
fraction_t string_to_fraction(const char *str);
|
fraction_t string_to_fraction(const char *str);
|
||||||
int getCloudURL(QString &filename);
|
int getCloudURL(QString &filename);
|
||||||
bool parseGpsText(const QString &gps_text, double *latitude, double *longitude);
|
bool parseGpsText(const QString &gps_text, double *latitude, double *longitude);
|
||||||
QByteArray getCurrentAppState();
|
|
||||||
void setCurrentAppState(const QByteArray &state);
|
|
||||||
void init_proxy();
|
void init_proxy();
|
||||||
QString getUUID();
|
QString getUUID();
|
||||||
extern const QStringList videoExtensionsList;
|
extern const QStringList videoExtensionsList;
|
||||||
|
|
|
@ -161,7 +161,7 @@ void FilterWidget2::clearFilter()
|
||||||
|
|
||||||
void FilterWidget2::closeFilter()
|
void FilterWidget2::closeFilter()
|
||||||
{
|
{
|
||||||
MainWindow::instance()->setApplicationState("Default");
|
MainWindow::instance()->setApplicationState(ApplicationState::Default);
|
||||||
}
|
}
|
||||||
|
|
||||||
void FilterWidget2::temperatureChanged()
|
void FilterWidget2::temperatureChanged()
|
||||||
|
|
|
@ -181,7 +181,7 @@ void LocationInformationWidget::acceptChanges()
|
||||||
{
|
{
|
||||||
MainWindow::instance()->diveList->setEnabled(true);
|
MainWindow::instance()->diveList->setEnabled(true);
|
||||||
MainWindow::instance()->setEnabledToolbar(true);
|
MainWindow::instance()->setEnabledToolbar(true);
|
||||||
MainWindow::instance()->setApplicationState("Default");
|
MainWindow::instance()->setApplicationState(ApplicationState::Default);
|
||||||
MapWidget::instance()->repopulateLabels();
|
MapWidget::instance()->repopulateLabels();
|
||||||
MultiFilterSortModel::instance()->stopFilterDiveSites();
|
MultiFilterSortModel::instance()->stopFilterDiveSites();
|
||||||
}
|
}
|
||||||
|
|
|
@ -178,20 +178,20 @@ MainWindow::MainWindow() : QMainWindow(),
|
||||||
enabledList.push_back(enabled);
|
enabledList.push_back(enabled);
|
||||||
disabledList.push_back(disabled);
|
disabledList.push_back(disabled);
|
||||||
|
|
||||||
registerApplicationState("Default", mainTab.get(), profileContainer, diveList, mapWidget );
|
registerApplicationState(ApplicationState::Default, mainTab.get(), profileContainer, diveList, mapWidget );
|
||||||
registerApplicationState("EditDive", mainTab.get(), profileContainer, diveList, mapWidget );
|
registerApplicationState(ApplicationState::EditDive, mainTab.get(), profileContainer, diveList, mapWidget );
|
||||||
registerApplicationState("PlanDive", divePlannerWidget, profileContainer, divePlannerSettingsWidget, plannerDetails );
|
registerApplicationState(ApplicationState::PlanDive, divePlannerWidget, profileContainer, divePlannerSettingsWidget, plannerDetails );
|
||||||
registerApplicationState("EditPlannedDive", divePlannerWidget, profileContainer, diveList, mapWidget );
|
registerApplicationState(ApplicationState::EditPlannedDive, divePlannerWidget, profileContainer, diveList, mapWidget );
|
||||||
registerApplicationState("EditDiveSite", diveSiteEdit, profileContainer, diveList, mapWidget);
|
registerApplicationState(ApplicationState::EditDiveSite, diveSiteEdit, profileContainer, diveList, mapWidget);
|
||||||
registerApplicationState("FilterDive", mainTab.get(), profileContainer, diveList, &filterWidget2);
|
registerApplicationState(ApplicationState::FilterDive, mainTab.get(), profileContainer, diveList, &filterWidget2);
|
||||||
|
|
||||||
setStateProperties("Default", enabledList, enabledList, enabledList, enabledList);
|
setStateProperties(ApplicationState::Default, enabledList, enabledList, enabledList, enabledList);
|
||||||
setStateProperties("EditDive", enabledList, enabledList, enabledList, enabledList);
|
setStateProperties(ApplicationState::EditDive, enabledList, enabledList, enabledList, enabledList);
|
||||||
setStateProperties("PlanDive", enabledList, enabledList, enabledList, enabledList);
|
setStateProperties(ApplicationState::PlanDive, enabledList, enabledList, enabledList, enabledList);
|
||||||
setStateProperties("EditPlannedDive", enabledList, enabledList, enabledList, enabledList);
|
setStateProperties(ApplicationState::EditPlannedDive, enabledList, enabledList, enabledList, enabledList);
|
||||||
setStateProperties("EditDiveSite", enabledList, disabledList, disabledList, enabledList);
|
setStateProperties(ApplicationState::EditDiveSite, enabledList, disabledList, disabledList, enabledList);
|
||||||
setStateProperties("FilterDive", enabledList, enabledList, enabledList, enabledList);
|
setStateProperties(ApplicationState::FilterDive, enabledList, enabledList, enabledList, enabledList);
|
||||||
setApplicationState("Default");
|
setApplicationState(ApplicationState::Default);
|
||||||
|
|
||||||
setWindowIcon(QIcon(":subsurface-icon"));
|
setWindowIcon(QIcon(":subsurface-icon"));
|
||||||
if (!QIcon::hasThemeIcon("window-close")) {
|
if (!QIcon::hasThemeIcon("window-close")) {
|
||||||
|
@ -369,9 +369,9 @@ void MainWindow::setupSocialNetworkMenu()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::setStateProperties(const QByteArray& state, const PropertyList& tl, const PropertyList& tr, const PropertyList& bl, const PropertyList& br)
|
void MainWindow::setStateProperties(ApplicationState state, const PropertyList& tl, const PropertyList& tr, const PropertyList& bl, const PropertyList& br)
|
||||||
{
|
{
|
||||||
stateProperties[state] = PropertiesForQuadrant(tl, tr, bl, br);
|
stateProperties[(int)state] = PropertiesForQuadrant(tl, tr, bl, br);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::editDiveSite(dive_site *ds)
|
void MainWindow::editDiveSite(dive_site *ds)
|
||||||
|
@ -379,7 +379,7 @@ void MainWindow::editDiveSite(dive_site *ds)
|
||||||
if (!ds)
|
if (!ds)
|
||||||
return;
|
return;
|
||||||
diveSiteEdit->initFields(ds);
|
diveSiteEdit->initFields(ds);
|
||||||
setApplicationState("EditDiveSite");
|
setApplicationState(ApplicationState::EditDiveSite);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::startDiveSiteEdit()
|
void MainWindow::startDiveSiteEdit()
|
||||||
|
@ -403,7 +403,7 @@ void MainWindow::enableDisableOtherDCsActions()
|
||||||
|
|
||||||
void MainWindow::setDefaultState()
|
void MainWindow::setDefaultState()
|
||||||
{
|
{
|
||||||
setApplicationState("Default");
|
setApplicationState(ApplicationState::Default);
|
||||||
if (mainTab->isEditing())
|
if (mainTab->isEditing())
|
||||||
ui.bottomLeft->currentWidget()->setEnabled(false);
|
ui.bottomLeft->currentWidget()->setEnabled(false);
|
||||||
}
|
}
|
||||||
|
@ -422,7 +422,7 @@ void MainWindow::refreshDisplay(bool doRecreateDiveList)
|
||||||
if (doRecreateDiveList)
|
if (doRecreateDiveList)
|
||||||
recreateDiveList();
|
recreateDiveList();
|
||||||
|
|
||||||
setApplicationState("Default");
|
setApplicationState(ApplicationState::Default);
|
||||||
diveList->setEnabled(true);
|
diveList->setEnabled(true);
|
||||||
diveList->setFocus();
|
diveList->setFocus();
|
||||||
WSInfoModel::instance()->update();
|
WSInfoModel::instance()->update();
|
||||||
|
@ -713,7 +713,7 @@ void MainWindow::on_actionClose_triggered()
|
||||||
if (okToClose(tr("Please save or cancel the current dive edit before closing the file."))) {
|
if (okToClose(tr("Please save or cancel the current dive edit before closing the file."))) {
|
||||||
closeCurrentFile();
|
closeCurrentFile();
|
||||||
DivePictureModel::instance()->updateDivePictures();
|
DivePictureModel::instance()->updateDivePictures();
|
||||||
setApplicationState("Default");
|
setApplicationState(ApplicationState::Default);
|
||||||
recreateDiveList();
|
recreateDiveList();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -753,7 +753,7 @@ void MainWindow::showProfile()
|
||||||
{
|
{
|
||||||
enableShortcuts();
|
enableShortcuts();
|
||||||
graphics->setProfileState();
|
graphics->setProfileState();
|
||||||
setApplicationState("Default");
|
setApplicationState(ApplicationState::Default);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::on_actionPreferences_triggered()
|
void MainWindow::on_actionPreferences_triggered()
|
||||||
|
@ -839,7 +839,7 @@ void MainWindow::planCreated()
|
||||||
{
|
{
|
||||||
// make sure our UI is in a consistent state
|
// make sure our UI is in a consistent state
|
||||||
showProfile();
|
showProfile();
|
||||||
setApplicationState("Default");
|
setApplicationState(ApplicationState::Default);
|
||||||
diveList->setEnabled(true);
|
diveList->setEnabled(true);
|
||||||
diveList->setFocus();
|
diveList->setFocus();
|
||||||
}
|
}
|
||||||
|
@ -931,7 +931,7 @@ void MainWindow::on_actionReplanDive_triggered()
|
||||||
|
|
||||||
graphics->setPlanState();
|
graphics->setPlanState();
|
||||||
graphics->clearHandlers();
|
graphics->clearHandlers();
|
||||||
setApplicationState("PlanDive");
|
setApplicationState(ApplicationState::PlanDive);
|
||||||
divePlannerWidget->setReplanButton(true);
|
divePlannerWidget->setReplanButton(true);
|
||||||
divePlannerWidget->setupStartTime(QDateTime::fromMSecsSinceEpoch(1000 * current_dive->when, Qt::UTC));
|
divePlannerWidget->setupStartTime(QDateTime::fromMSecsSinceEpoch(1000 * current_dive->when, Qt::UTC));
|
||||||
if (current_dive->surface_pressure.mbar)
|
if (current_dive->surface_pressure.mbar)
|
||||||
|
@ -950,7 +950,7 @@ void MainWindow::on_actionDivePlanner_triggered()
|
||||||
|
|
||||||
// put us in PLAN mode
|
// put us in PLAN mode
|
||||||
DivePlannerPointsModel::instance()->setPlanMode(DivePlannerPointsModel::PLAN);
|
DivePlannerPointsModel::instance()->setPlanMode(DivePlannerPointsModel::PLAN);
|
||||||
setApplicationState("PlanDive");
|
setApplicationState(ApplicationState::PlanDive);
|
||||||
|
|
||||||
graphics->setPlanState();
|
graphics->setPlanState();
|
||||||
|
|
||||||
|
@ -1808,16 +1808,16 @@ void MainWindow::editCurrentDive()
|
||||||
if (defaultDC == "manually added dive") {
|
if (defaultDC == "manually added dive") {
|
||||||
DivePlannerPointsModel::instance()->setPlanMode(DivePlannerPointsModel::ADD);
|
DivePlannerPointsModel::instance()->setPlanMode(DivePlannerPointsModel::ADD);
|
||||||
graphics->setAddState();
|
graphics->setAddState();
|
||||||
setApplicationState("EditDive");
|
setApplicationState(ApplicationState::EditDive);
|
||||||
DivePlannerPointsModel::instance()->loadFromDive(d);
|
DivePlannerPointsModel::instance()->loadFromDive(d);
|
||||||
mainTab->enableEdition(MainTab::MANUALLY_ADDED_DIVE);
|
mainTab->enableEdition(MainTab::MANUALLY_ADDED_DIVE);
|
||||||
} else if (defaultDC == "planned dive") {
|
} else if (defaultDC == "planned dive") {
|
||||||
DivePlannerPointsModel::instance()->setPlanMode(DivePlannerPointsModel::PLAN);
|
DivePlannerPointsModel::instance()->setPlanMode(DivePlannerPointsModel::PLAN);
|
||||||
setApplicationState("EditPlannedDive");
|
setApplicationState(ApplicationState::EditPlannedDive);
|
||||||
DivePlannerPointsModel::instance()->loadFromDive(d);
|
DivePlannerPointsModel::instance()->loadFromDive(d);
|
||||||
mainTab->enableEdition(MainTab::MANUALLY_ADDED_DIVE);
|
mainTab->enableEdition(MainTab::MANUALLY_ADDED_DIVE);
|
||||||
} else {
|
} else {
|
||||||
setApplicationState("EditDive");
|
setApplicationState(ApplicationState::EditDive);
|
||||||
mainTab->enableEdition();
|
mainTab->enableEdition();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1863,14 +1863,14 @@ void MainWindow::on_paste_triggered()
|
||||||
|
|
||||||
void MainWindow::on_actionFilterTags_triggered()
|
void MainWindow::on_actionFilterTags_triggered()
|
||||||
{
|
{
|
||||||
setApplicationState(getCurrentAppState() == "FilterDive" ? "Default" : "FilterDive");
|
setApplicationState(getAppState() == ApplicationState::FilterDive ? ApplicationState::Default : ApplicationState::FilterDive);
|
||||||
if (state == LIST_MAXIMIZED)
|
if (state == LIST_MAXIMIZED)
|
||||||
showFilterIfEnabled();
|
showFilterIfEnabled();
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::showFilterIfEnabled()
|
void MainWindow::showFilterIfEnabled()
|
||||||
{
|
{
|
||||||
if (getCurrentAppState() == "FilterDive") {
|
if (getAppState() == ApplicationState::FilterDive) {
|
||||||
const int appW = qApp->desktop()->size().width();
|
const int appW = qApp->desktop()->size().width();
|
||||||
QList<int> profileFilterSizes = { round_int(appW * 0.7), round_int(appW * 0.3) };
|
QList<int> profileFilterSizes = { round_int(appW * 0.7), round_int(appW * 0.3) };
|
||||||
ui.bottomSplitter->setSizes(profileFilterSizes);
|
ui.bottomSplitter->setSizes(profileFilterSizes);
|
||||||
|
@ -1878,9 +1878,9 @@ void MainWindow::showFilterIfEnabled()
|
||||||
ui.bottomSplitter->setSizes({ EXPANDED, COLLAPSED });
|
ui.bottomSplitter->setSizes({ EXPANDED, COLLAPSED });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
void MainWindow::registerApplicationState(const QByteArray& state, QWidget *topLeft, QWidget *topRight, QWidget *bottomLeft, QWidget *bottomRight)
|
void MainWindow::registerApplicationState(ApplicationState state, QWidget *topLeft, QWidget *topRight, QWidget *bottomLeft, QWidget *bottomRight)
|
||||||
{
|
{
|
||||||
applicationState[state] = WidgetForQuadrant(topLeft, topRight, bottomLeft, bottomRight);
|
applicationState[(int)state] = WidgetForQuadrant(topLeft, topRight, bottomLeft, bottomRight);
|
||||||
if (ui.topLeft->indexOf(topLeft) == -1 && topLeft) {
|
if (ui.topLeft->indexOf(topLeft) == -1 && topLeft) {
|
||||||
ui.topLeft->addWidget(topLeft);
|
ui.topLeft->addWidget(topLeft);
|
||||||
}
|
}
|
||||||
|
@ -1895,38 +1895,35 @@ void MainWindow::registerApplicationState(const QByteArray& state, QWidget *topL
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::setApplicationState(const QByteArray &state)
|
void MainWindow::setApplicationState(ApplicationState state)
|
||||||
{
|
{
|
||||||
if (!applicationState.keys().contains(state))
|
if (getAppState() == state)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (getCurrentAppState() == state)
|
setAppState(state);
|
||||||
return;
|
|
||||||
|
|
||||||
setCurrentAppState(state);
|
|
||||||
|
|
||||||
#define SET_CURRENT_INDEX( X ) \
|
#define SET_CURRENT_INDEX( X ) \
|
||||||
if (applicationState[state].X) { \
|
if (applicationState[(int)state].X) { \
|
||||||
ui.X->setCurrentWidget( applicationState[state].X); \
|
ui.X->setCurrentWidget( applicationState[(int)state].X); \
|
||||||
ui.X->show(); \
|
ui.X->show(); \
|
||||||
} else { \
|
} else { \
|
||||||
ui.X->hide(); \
|
ui.X->hide(); \
|
||||||
}
|
}
|
||||||
|
|
||||||
SET_CURRENT_INDEX( topLeft )
|
SET_CURRENT_INDEX( topLeft )
|
||||||
Q_FOREACH(const WidgetProperty& p, stateProperties[state].topLeft) {
|
Q_FOREACH(const WidgetProperty& p, stateProperties[(int)state].topLeft) {
|
||||||
ui.topLeft->currentWidget()->setProperty( p.first.data(), p.second);
|
ui.topLeft->currentWidget()->setProperty( p.first.data(), p.second);
|
||||||
}
|
}
|
||||||
SET_CURRENT_INDEX( topRight )
|
SET_CURRENT_INDEX( topRight )
|
||||||
Q_FOREACH(const WidgetProperty& p, stateProperties[state].topRight) {
|
Q_FOREACH(const WidgetProperty& p, stateProperties[(int)state].topRight) {
|
||||||
ui.topRight->currentWidget()->setProperty( p.first.data(), p.second);
|
ui.topRight->currentWidget()->setProperty( p.first.data(), p.second);
|
||||||
}
|
}
|
||||||
SET_CURRENT_INDEX( bottomLeft )
|
SET_CURRENT_INDEX( bottomLeft )
|
||||||
Q_FOREACH(const WidgetProperty& p, stateProperties[state].bottomLeft) {
|
Q_FOREACH(const WidgetProperty& p, stateProperties[(int)state].bottomLeft) {
|
||||||
ui.bottomLeft->currentWidget()->setProperty( p.first.data(), p.second);
|
ui.bottomLeft->currentWidget()->setProperty( p.first.data(), p.second);
|
||||||
}
|
}
|
||||||
SET_CURRENT_INDEX( bottomRight )
|
SET_CURRENT_INDEX( bottomRight )
|
||||||
Q_FOREACH(const WidgetProperty& p, stateProperties[state].bottomRight) {
|
Q_FOREACH(const WidgetProperty& p, stateProperties[(int)state].bottomRight) {
|
||||||
ui.bottomRight->currentWidget()->setProperty( p.first.data(), p.second);
|
ui.bottomRight->currentWidget()->setProperty( p.first.data(), p.second);
|
||||||
}
|
}
|
||||||
#undef SET_CURRENT_INDEX
|
#undef SET_CURRENT_INDEX
|
||||||
|
|
|
@ -19,6 +19,7 @@
|
||||||
#include "ui_plannerDetails.h"
|
#include "ui_plannerDetails.h"
|
||||||
#include "desktop-widgets/notificationwidget.h"
|
#include "desktop-widgets/notificationwidget.h"
|
||||||
#include "desktop-widgets/filterwidget2.h"
|
#include "desktop-widgets/filterwidget2.h"
|
||||||
|
#include "core/applicationstate.h"
|
||||||
#include "core/gpslocation.h"
|
#include "core/gpslocation.h"
|
||||||
#include "core/dive.h"
|
#include "core/dive.h"
|
||||||
|
|
||||||
|
@ -56,7 +57,7 @@ public:
|
||||||
INFO_MAXIMIZED,
|
INFO_MAXIMIZED,
|
||||||
PROFILE_MAXIMIZED,
|
PROFILE_MAXIMIZED,
|
||||||
LIST_MAXIMIZED,
|
LIST_MAXIMIZED,
|
||||||
EDIT
|
EDIT,
|
||||||
};
|
};
|
||||||
|
|
||||||
MainWindow();
|
MainWindow();
|
||||||
|
@ -75,8 +76,8 @@ public:
|
||||||
void setToolButtonsEnabled(bool enabled);
|
void setToolButtonsEnabled(bool enabled);
|
||||||
void printPlan();
|
void printPlan();
|
||||||
void checkSurvey();
|
void checkSurvey();
|
||||||
void setApplicationState(const QByteArray& state);
|
void setApplicationState(ApplicationState state);
|
||||||
void setStateProperties(const QByteArray& state, const PropertyList& tl, const PropertyList& tr, const PropertyList& bl,const PropertyList& br);
|
void setStateProperties(ApplicationState state, const PropertyList& tl, const PropertyList& tr, const PropertyList& bl,const PropertyList& br);
|
||||||
bool inPlanner();
|
bool inPlanner();
|
||||||
NotificationWidget *getNotificationWidget();
|
NotificationWidget *getNotificationWidget();
|
||||||
void enableDisableCloudActions();
|
void enableDisableCloudActions();
|
||||||
|
@ -212,7 +213,7 @@ private:
|
||||||
void toggleCollapsible(bool toggle);
|
void toggleCollapsible(bool toggle);
|
||||||
void showFilterIfEnabled();
|
void showFilterIfEnabled();
|
||||||
void updateLastUsedDir(const QString &s);
|
void updateLastUsedDir(const QString &s);
|
||||||
void registerApplicationState(const QByteArray& state, QWidget *topLeft, QWidget *topRight, QWidget *bottomLeft, QWidget *bottomRight);
|
void registerApplicationState(ApplicationState state, QWidget *topLeft, QWidget *topRight, QWidget *bottomLeft, QWidget *bottomRight);
|
||||||
void enterState(CurrentState);
|
void enterState(CurrentState);
|
||||||
bool filesAsArguments;
|
bool filesAsArguments;
|
||||||
UpdateManager *updateManager;
|
UpdateManager *updateManager;
|
||||||
|
@ -249,8 +250,8 @@ private:
|
||||||
PropertyList bottomRight;
|
PropertyList bottomRight;
|
||||||
};
|
};
|
||||||
|
|
||||||
QHash<QByteArray, WidgetForQuadrant> applicationState;
|
WidgetForQuadrant applicationState[(size_t)ApplicationState::Count];
|
||||||
QHash<QByteArray, PropertiesForQuadrant> stateProperties;
|
PropertiesForQuadrant stateProperties[(size_t)ApplicationState::Count];
|
||||||
|
|
||||||
GpsLocation *locationProvider;
|
GpsLocation *locationProvider;
|
||||||
QMenu *connections;
|
QMenu *connections;
|
||||||
|
|
|
@ -18,6 +18,7 @@ SOURCES += ../../subsurface-mobile-main.cpp \
|
||||||
../../core/qtserialbluetooth.cpp \
|
../../core/qtserialbluetooth.cpp \
|
||||||
../../core/plannernotes.c \
|
../../core/plannernotes.c \
|
||||||
../../core/uemis-downloader.c \
|
../../core/uemis-downloader.c \
|
||||||
|
../../core/applicationstate.cpp \
|
||||||
../../core/qthelper.cpp \
|
../../core/qthelper.cpp \
|
||||||
../../core/checkcloudconnection.cpp \
|
../../core/checkcloudconnection.cpp \
|
||||||
../../core/color.cpp \
|
../../core/color.cpp \
|
||||||
|
|
|
@ -5,6 +5,7 @@
|
||||||
#include "core/qthelper.h"
|
#include "core/qthelper.h"
|
||||||
#include "core/subsurfacestartup.h"
|
#include "core/subsurfacestartup.h"
|
||||||
#include "core/units.h"
|
#include "core/units.h"
|
||||||
|
#include "core/applicationstate.h"
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
|
|
||||||
#define DEBUG 1
|
#define DEBUG 1
|
||||||
|
@ -469,7 +470,7 @@ void TestPlan::testVpmbMetric45m30minTx()
|
||||||
|
|
||||||
struct diveplan testPlan = {};
|
struct diveplan testPlan = {};
|
||||||
setupPlanVpmb45m30mTx(&testPlan);
|
setupPlanVpmb45m30mTx(&testPlan);
|
||||||
setCurrentAppState("PlanDive");
|
setAppState(ApplicationState::PlanDive);
|
||||||
|
|
||||||
plan(&test_deco_state, &testPlan, &displayed_dive, 60, stoptable, &cache, 1, 0);
|
plan(&test_deco_state, &testPlan, &displayed_dive, 60, stoptable, &cache, 1, 0);
|
||||||
|
|
||||||
|
@ -500,7 +501,7 @@ void TestPlan::testVpmbMetric60m10minTx()
|
||||||
|
|
||||||
struct diveplan testPlan = {};
|
struct diveplan testPlan = {};
|
||||||
setupPlanVpmb60m10mTx(&testPlan);
|
setupPlanVpmb60m10mTx(&testPlan);
|
||||||
setCurrentAppState("PlanDive");
|
setAppState(ApplicationState::PlanDive);
|
||||||
|
|
||||||
plan(&test_deco_state, &testPlan, &displayed_dive, 60, stoptable, &cache, 1, 0);
|
plan(&test_deco_state, &testPlan, &displayed_dive, 60, stoptable, &cache, 1, 0);
|
||||||
|
|
||||||
|
@ -531,7 +532,7 @@ void TestPlan::testVpmbMetric60m30minAir()
|
||||||
|
|
||||||
struct diveplan testPlan = {};
|
struct diveplan testPlan = {};
|
||||||
setupPlanVpmb60m30minAir(&testPlan);
|
setupPlanVpmb60m30minAir(&testPlan);
|
||||||
setCurrentAppState("PlanDive");
|
setAppState(ApplicationState::PlanDive);
|
||||||
|
|
||||||
plan(&test_deco_state, &testPlan, &displayed_dive, 60, stoptable, &cache, 1, 0);
|
plan(&test_deco_state, &testPlan, &displayed_dive, 60, stoptable, &cache, 1, 0);
|
||||||
|
|
||||||
|
@ -562,7 +563,7 @@ void TestPlan::testVpmbMetric60m30minEan50()
|
||||||
|
|
||||||
struct diveplan testPlan = {};
|
struct diveplan testPlan = {};
|
||||||
setupPlanVpmb60m30minEan50(&testPlan);
|
setupPlanVpmb60m30minEan50(&testPlan);
|
||||||
setCurrentAppState("PlanDive");
|
setAppState(ApplicationState::PlanDive);
|
||||||
|
|
||||||
plan(&test_deco_state, &testPlan, &displayed_dive, 60, stoptable, &cache, 1, 0);
|
plan(&test_deco_state, &testPlan, &displayed_dive, 60, stoptable, &cache, 1, 0);
|
||||||
|
|
||||||
|
@ -599,7 +600,7 @@ void TestPlan::testVpmbMetric60m30minTx()
|
||||||
|
|
||||||
struct diveplan testPlan = {};
|
struct diveplan testPlan = {};
|
||||||
setupPlanVpmb60m30minTx(&testPlan);
|
setupPlanVpmb60m30minTx(&testPlan);
|
||||||
setCurrentAppState("PlanDive");
|
setAppState(ApplicationState::PlanDive);
|
||||||
|
|
||||||
plan(&test_deco_state, &testPlan, &displayed_dive, 60, stoptable, &cache, 1, 0);
|
plan(&test_deco_state, &testPlan, &displayed_dive, 60, stoptable, &cache, 1, 0);
|
||||||
|
|
||||||
|
@ -636,7 +637,7 @@ void TestPlan::testVpmbMetric100m60min()
|
||||||
|
|
||||||
struct diveplan testPlan = {};
|
struct diveplan testPlan = {};
|
||||||
setupPlanVpmb100m60min(&testPlan);
|
setupPlanVpmb100m60min(&testPlan);
|
||||||
setCurrentAppState("PlanDive");
|
setAppState(ApplicationState::PlanDive);
|
||||||
|
|
||||||
plan(&test_deco_state, &testPlan, &displayed_dive, 60, stoptable, &cache, 1, 0);
|
plan(&test_deco_state, &testPlan, &displayed_dive, 60, stoptable, &cache, 1, 0);
|
||||||
|
|
||||||
|
@ -680,7 +681,7 @@ void TestPlan::testMultipleGases()
|
||||||
struct diveplan testPlan = {};
|
struct diveplan testPlan = {};
|
||||||
|
|
||||||
setupPlanSeveralGases(&testPlan);
|
setupPlanSeveralGases(&testPlan);
|
||||||
setCurrentAppState("PlanDive");
|
setAppState(ApplicationState::PlanDive);
|
||||||
|
|
||||||
plan(&test_deco_state, &testPlan, &displayed_dive, 60, stoptable, &cache, 1, 0);
|
plan(&test_deco_state, &testPlan, &displayed_dive, 60, stoptable, &cache, 1, 0);
|
||||||
|
|
||||||
|
@ -706,7 +707,7 @@ void TestPlan::testVpmbMetricMultiLevelAir()
|
||||||
|
|
||||||
struct diveplan testPlan = {};
|
struct diveplan testPlan = {};
|
||||||
setupPlanVpmbMultiLevelAir(&testPlan);
|
setupPlanVpmbMultiLevelAir(&testPlan);
|
||||||
setCurrentAppState("PlanDive");
|
setAppState(ApplicationState::PlanDive);
|
||||||
|
|
||||||
plan(&test_deco_state, &testPlan, &displayed_dive, 60, stoptable, &cache, 1, 0);
|
plan(&test_deco_state, &testPlan, &displayed_dive, 60, stoptable, &cache, 1, 0);
|
||||||
|
|
||||||
|
@ -737,7 +738,7 @@ void TestPlan::testVpmbMetric100m10min()
|
||||||
|
|
||||||
struct diveplan testPlan = {};
|
struct diveplan testPlan = {};
|
||||||
setupPlanVpmb100m10min(&testPlan);
|
setupPlanVpmb100m10min(&testPlan);
|
||||||
setCurrentAppState("PlanDive");
|
setAppState(ApplicationState::PlanDive);
|
||||||
|
|
||||||
plan(&test_deco_state, &testPlan, &displayed_dive, 60, stoptable, &cache, 1, 0);
|
plan(&test_deco_state, &testPlan, &displayed_dive, 60, stoptable, &cache, 1, 0);
|
||||||
|
|
||||||
|
@ -784,7 +785,7 @@ void TestPlan::testVpmbMetricRepeat()
|
||||||
|
|
||||||
struct diveplan testPlan = {};
|
struct diveplan testPlan = {};
|
||||||
setupPlanVpmb30m20min(&testPlan);
|
setupPlanVpmb30m20min(&testPlan);
|
||||||
setCurrentAppState("PlanDive");
|
setAppState(ApplicationState::PlanDive);
|
||||||
|
|
||||||
plan(&test_deco_state, &testPlan, &displayed_dive, 60, stoptable, &cache, 1, 0);
|
plan(&test_deco_state, &testPlan, &displayed_dive, 60, stoptable, &cache, 1, 0);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue