Tulip 5.7.1
Large graphs analysis and drawing
Loading...
Searching...
No Matches
CopyPropertyDialog.h
1/*
2 *
3 * This file is part of Tulip (https://tulip.labri.fr)
4 *
5 * Authors: David Auber and the Tulip development Team
6 * from LaBRI, University of Bordeaux
7 *
8 * Tulip is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU Lesser General Public License
10 * as published by the Free Software Foundation, either version 3
11 * of the License, or (at your option) any later version.
12 *
13 * Tulip is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
16 * See the GNU General Public License for more details.
17 *
18 */
19///@cond DOXYGEN_HIDDEN
20
21#ifndef COPYPROPERTYDIALOG_H
22#define COPYPROPERTYDIALOG_H
23
24#include <tulip/tulipconf.h>
25
26#include <QDialog>
27
28namespace Ui {
29class CopyPropertyDialogData;
30}
31
32namespace tlp {
33class Graph;
34class PropertyInterface;
35
36/**
37 * @brief Provide a dialog that allow user to copy a property in an existing property or in a new
38 *one.
39 *
40 * The easiest way to use this class is to use the copyProperty static function.
41 * @code
42 * Graph* g;
43 * PropertyInterface* source = g->getLocalProperty<BooleanProperty>("viewSelection");
44 * PropertyInterface* clonedProperty = CopyPropertyDialog::copyProperty(g, source);
45 * @endcode
46 *
47 *
48 **/
49
50class TLP_QT_SCOPE CopyPropertyDialog : public QDialog {
51 Q_OBJECT
52public:
53 CopyPropertyDialog(QWidget *parent = nullptr);
54 ~CopyPropertyDialog() override;
55
56 /**
57 * @brief Init dialog with required parameters. To make the copy this dialog need to have a valid
58 *source property and destination graph.
59 **/
60 void init(tlp::Graph *graph, tlp::PropertyInterface *toCopy);
61
62 /**
63 * @brief Perform the copy of the property in function of the parameters given by user. If
64 *parameters are invalid return a null pointer and fill the errorMsg with the description of the
65 *error.
66 *
67 * This function don't hold observers during the copy process. It's up to user to call
68 *Observable::holdObserver and Observable::unholdObserver before and after calling this function.
69 **/
70 tlp::PropertyInterface *copyProperty(QString &errorMsg);
71
72 /**
73 * @brief Get the name of the destintation property.
74 **/
75 QString destinationPropertyName() const;
76
77 enum PropertyScope { NEW, LOCAL, INHERITED };
78
79 /**
80 * @brief Return the scope where the new property will be created.
81 **/
82 PropertyScope destinationPropertyScope() const;
83
84 /**
85 * @brief This is a convenience static function that copy property in function of user
86 *parameters. If the user presses Cancel or an error occur, it returns a null pointer.
87 *
88 * The function creates a modal property copy dialog with the given source property, graph and
89 *parent widget.
90 *
91 * @param graph The graph to use as parent for the properties to create.
92 * @param source The property to copy.
93 * @param askBeforePropertyOverwriting If set to true and user try to create a new property with
94 *the same name than another existing ask user before overwriting them.
95 **/
96 static PropertyInterface *copyProperty(tlp::Graph *graph, tlp::PropertyInterface *source,
97 bool askBeforePropertyOverwriting = false,
98 QWidget *parent = nullptr);
99
100private:
101 Ui::CopyPropertyDialogData *ui;
102 tlp::Graph *_graph;
103 tlp::PropertyInterface *_source;
104
105private slots:
106 void checkValidity();
107};
108} // namespace tlp
109#endif // COPYPROPERTYDIALOG_H
110///@endcond
PropertyInterface describes the interface of a graph property.