mirror of
https://github.com/subsurface/subsurface.git
synced 2024-12-11 03:21:29 +00:00
75767c456a
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>
21 lines
504 B
C
21 lines
504 B
C
// 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
|