Debian Codegraph @

src/Gui/TaskView/TaskSelectLinkProperty.h

raw
1 // SPDX-License-Identifier: LGPL-2.1-or-later
2 /***************************************************************************
3 * Copyright (c) 2009 Jürgen Riegel <[email protected]> *
4 * *
5 * This file is part of the FreeCAD CAx development system. *
6 * *
7 * This library is free software; you can redistribute it and/or *
8 * modify it under the terms of the GNU Library General Public *
9 * License as published by the Free Software Foundation; either *
10 * version 2 of the License, or (at your option) any later version. *
11 * *
12 * This library is distributed in the hope that it will be useful, *
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
15 * GNU Library General Public License for more details. *
16 * *
17 * You should have received a copy of the GNU Library General Public *
18 * License along with this library; see the file COPYING.LIB. If not, *
19 * write to the Free Software Foundation, Inc., 59 Temple Place, *
20 * Suite 330, Boston, MA 02111-1307, USA *
21 * *
22 ***************************************************************************/
23
24
25 #ifndef GUI_TASKVIEW_TaskSelectLinkProperty_H
26 #define GUI_TASKVIEW_TaskSelectLinkProperty_H
27
28 #include "TaskView.h"
29 #include <Gui/Selection/Selection.h>
30 #include <App/PropertyLinks.h>
31
32
33 class Ui_TaskSelectLinkProperty;
34
35 namespace App
36 {
37 class Property;
38 }
39
40 namespace Gui
41 {
42 class ViewProvider;
43 namespace TaskView
44 {
45
46 /** General Link/Selection editor for the Task view
47 * This can be used as part of a TaskDialog to alter
48 * the content of a LinkProperty by user input/selection.
49 * If set active it reflects the selection to the Property
50 * given and acts due the selection filter given to the constructor.
51 * It will allow only allowed elements to be selected (SelectionFilter)
52 * and shows by the background color if the selection criterion is met.
53 * With the call of accept() or reject() the result gets permanent or
54 * discarded in the given Property.
55 */
56
57
58 class GuiExport TaskSelectLinkProperty: public TaskBox, public Gui::SelectionSingleton::ObserverType
59 {
60 Q_OBJECT
61
62 public:
63 TaskSelectLinkProperty(const char*, App::Property*, QWidget* parent = nullptr);
64 ~TaskSelectLinkProperty() override;
65 /// Observer message from the Selection
66 void OnChange(
67 Gui::SelectionSingleton::SubjectType& rCaller,
68 Gui::SelectionSingleton::MessageType Reason
69 ) override;
70
71 /// set the filter criterion (same as in constructor)
72 bool setFilter(const char*);
73
74 /// set the TaskSelectLinkProperty active, means setting the selection and control it
75 void activate();
76
77 /// call this to accept the changes the user has made and send back to the Property (Ok)
78 bool accept();
79 /// This discards the changes of the user and leaves the Property untouched (Cancel)
80 bool reject();
81 /// send the selection to the Property for e.g. forced recomputation of a feature
82 void sendSelection2Property();
83 /// checks if the filter is currently met
84 inline bool isSelectionValid() const
85 {
86 return Filter->match();
87 }
88
89 private:
90 void setupConnections();
91 void onRemoveClicked(bool);
92 void onAddClicked(bool);
93 void onInvertClicked(bool);
94 void onHelpClicked(bool);
95
96 Q_SIGNALS:
97 void emitSelectionFit();
98 void emitSelectionMisfit();
99
100 protected:
101 void changeEvent(QEvent* e) override;
102
103 private:
104 // checks for selection and set background color and signals
105 void checkSelectionStatus();
106
107 QWidget* proxy;
108 Ui_TaskSelectLinkProperty* ui;
109
110 // selection filter for the session
111 Gui::SelectionFilter* Filter;
112
113 // possible used property types, only one is used
114 App::PropertyLinkSub* LinkSub;
115 App::PropertyLinkList* LinkList;
116
117 // string stores the Property at the beginning (for Cancel)
118 std::vector<std::string> StartValueBuffer;
119 App::DocumentObject* StartObject;
120 };
121
122 } // namespace TaskView
123 } // namespace Gui
124
125 #endif // GUI_TASKVIEW_TASKAPPERANCE_H