diff options
author | Berthold Stoeger <bstoeger@mail.tuwien.ac.at> | 2019-11-24 13:26:29 +0100 |
---|---|---|
committer | bstoeger <32835590+bstoeger@users.noreply.github.com> | 2019-12-04 13:00:23 +0100 |
commit | 7787bfbf9e39595d98c459e4af121f3174762c7d (patch) | |
tree | 6791a300e342ad9b87edcb4781f56f9712e411f3 | |
parent | d0b3a06e036cf5523cf03c22ec698742bd01048a (diff) | |
download | subsurface-7787bfbf9e39595d98c459e4af121f3174762c7d.tar.gz |
Selection: move commands/command_private.* to core/selection.*
The file command_private.cpp had functions concerning selections
only. To make these functions accessible from outside the undo
machinery, turn it into a part of the core-library. Currently,
only C++ functions are exported. We might think about also
exporting a C interface.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
-rw-r--r-- | commands/CMakeLists.txt | 2 | ||||
-rw-r--r-- | commands/command_divelist.cpp | 2 | ||||
-rw-r--r-- | commands/command_divesite.cpp | 1 | ||||
-rw-r--r-- | commands/command_edit.cpp | 2 | ||||
-rw-r--r-- | commands/command_edit_trip.cpp | 2 | ||||
-rw-r--r-- | core/CMakeLists.txt | 2 | ||||
-rw-r--r-- | core/selection.cpp (renamed from commands/command_private.cpp) | 12 | ||||
-rw-r--r-- | core/selection.h (renamed from commands/command_private.h) | 19 |
8 files changed, 19 insertions, 23 deletions
diff --git a/commands/CMakeLists.txt b/commands/CMakeLists.txt index 76ad42603..dcf7f3892 100644 --- a/commands/CMakeLists.txt +++ b/commands/CMakeLists.txt @@ -14,8 +14,6 @@ set(SUBSURFACE_GENERIC_COMMANDS_SRCS command_edit.h command_edit_trip.cpp command_edit_trip.h - command_private.cpp - command_private.h ) if (SUBSURFACE_TARGET_EXECUTABLE MATCHES "DesktopExecutable") add_library(subsurface_commands_desktop STATIC ${SUBSURFACE_GENERIC_COMMANDS_SRCS}) diff --git a/commands/command_divelist.cpp b/commands/command_divelist.cpp index 4fabac9fc..12e1c9309 100644 --- a/commands/command_divelist.cpp +++ b/commands/command_divelist.cpp @@ -1,10 +1,10 @@ // SPDX-License-Identifier: GPL-2.0 #include "command_divelist.h" -#include "command_private.h" #include "core/divelist.h" #include "core/display.h" // for amount_selected #include "core/qthelper.h" +#include "core/selection.h" #include "core/subsurface-qt/DiveListNotifier.h" #include "qt-models/filtermodels.h" #include "../profile-widget/profilewidget2.h" diff --git a/commands/command_divesite.cpp b/commands/command_divesite.cpp index b5fb46f91..45d0abcaf 100644 --- a/commands/command_divesite.cpp +++ b/commands/command_divesite.cpp @@ -1,7 +1,6 @@ // SPDX-License-Identifier: GPL-2.0 #include "command_divesite.h" -#include "command_private.h" #include "core/divesite.h" #include "core/subsurface-qt/DiveListNotifier.h" #include "core/qthelper.h" diff --git a/commands/command_edit.cpp b/commands/command_edit.cpp index 7f4726a6b..5e02ed80e 100644 --- a/commands/command_edit.cpp +++ b/commands/command_edit.cpp @@ -1,9 +1,9 @@ // SPDX-License-Identifier: GPL-2.0 #include "command_edit.h" -#include "command_private.h" #include "core/divelist.h" #include "core/qthelper.h" // for copy_qstring +#include "core/selection.h" #include "core/subsurface-string.h" #include "core/tag.h" diff --git a/commands/command_edit_trip.cpp b/commands/command_edit_trip.cpp index b25e3fcc5..c0f512907 100644 --- a/commands/command_edit_trip.cpp +++ b/commands/command_edit_trip.cpp @@ -1,8 +1,8 @@ // SPDX-License-Identifier: GPL-2.0 #include "command_edit_trip.h" -#include "command_private.h" #include "core/qthelper.h" +#include "core/selection.h" namespace Command { diff --git a/core/CMakeLists.txt b/core/CMakeLists.txt index 0c8f88141..0622a859a 100644 --- a/core/CMakeLists.txt +++ b/core/CMakeLists.txt @@ -139,6 +139,8 @@ set(SUBSURFACE_CORE_LIB_SRCS save-html.h save-profiledata.c save-xml.c + selection.cpp + selection.h sha1.c sha1.h ssrf.h diff --git a/commands/command_private.cpp b/core/selection.cpp index 714ffd9b6..ce0b0aa42 100644 --- a/commands/command_private.cpp +++ b/core/selection.cpp @@ -1,12 +1,12 @@ // SPDX-License-Identifier: GPL-2.0 // Helper functions for the undo-commands -#include "command_private.h" -#include "core/divelist.h" -#include "core/display.h" // for amount_selected -#include "core/subsurface-qt/DiveListNotifier.h" +#include "selection.h" +#include "divelist.h" +#include "display.h" // for amount_selected +#include "subsurface-qt/DiveListNotifier.h" -namespace Command { +#include <QVector> // Set the current dive either from a list of selected dives, // or a newly selected dive. In both cases, try to select the @@ -104,5 +104,3 @@ std::vector<dive *> getDiveSelection() } return res; } - -} // namespace Command diff --git a/commands/command_private.h b/core/selection.h index 280654a93..0fb226949 100644 --- a/commands/command_private.h +++ b/core/selection.h @@ -1,25 +1,24 @@ // SPDX-License-Identifier: GPL-2.0 -// Private definitions for the command-objects +// Selection related functions -#ifndef COMMAND_PRIVATE_H -#define COMMAND_PRIVATE_H +#ifndef SELECTION_H +#define SELECTION_H -#include "core/dive.h" +/*** C++-only functions ***/ +#ifdef __cplusplus #include <vector> -#include <utility> -#include <QVector> -namespace Command { +struct dive; // Reset the selection to the dives of the "selection" vector and send the appropriate signals. // Set the current dive to "currentDive". "currentDive" must be an element of "selection" (or -// null if "seletion" is empty). Return true if the selection or current dive changed. +// null if "seletion" is empty). void setSelection(const std::vector<dive *> &selection, dive *currentDive); // Get currently selectd dives std::vector<dive *> getDiveSelection(); -} // namespace Command +#endif // __cplusplus -#endif // COMMAND_PRIVATE_H +#endif // SELECTION_H |