Tulip  4.3.0
Better Visualization Through Research
 All Classes Namespaces Files Functions Variables Enumerations Enumerator Properties Groups Pages
CopyPropertyDialog.h
1 /*
2  *
3  * This file is part of Tulip (www.tulip-software.org)
4  *
5  * Authors: David Auber and the Tulip development Team
6  * from LaBRI, University of Bordeaux 1 and Inria Bordeaux - Sud Ouest
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 
28 namespace Ui {
29 class CopyPropertyDialogData;
30 }
31 
32 namespace tlp {
33 class Graph;
34 class PropertyInterface;
35 
36 /**
37  * @brief Provide a dialog that allow user to copy a property in an existing property or in a new one.
38  *
39  * The easiest way to use this class is to use the copyProperty static function.
40  * @code
41  * Graph* g;
42  * PropertyInterface* source = g->getLocalProperty<BooleanProperty>("viewSelection");
43  * QWidget* parent;
44  * PropertyInterface* clonedProperty = PropertyCreationDialog::createNewProperty(g,souce,parent);
45  * @endcode
46  *
47  *
48  **/
49 
50 class TLP_QT_SCOPE CopyPropertyDialog : public QDialog {
51  Q_OBJECT
52 public:
53  CopyPropertyDialog(QWidget *parent = NULL);
54  ~CopyPropertyDialog();
55 
56  /**
57  * @brief Init dialog with required parameters. To make the copy this dialog need to have a valid source property and destination graph.
58  **/
59  void init(tlp::Graph* graph,tlp::PropertyInterface* toCopy);
60 
61  /**
62  * @brief Perform the copy of the property in function of the parameters given by user. If parameters are invalid return a null pointer and fill the errorMsg with the description of the error.
63  *
64  * This function don't hold observers during the copy process. It's up to user to call Observable::holdObserver and Observable::unholdObserver before and after calling this funtion.
65  **/
66  tlp::PropertyInterface* copyProperty(QString& errorMsg);
67 
68  /**
69  * @brief Get the name of the destintation property.
70  **/
71  QString destinationPropertyName()const;
72 
73  enum PropertyScope {
74  NEW,
75  LOCAL,
76  INHERITED
77  };
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 parameters. If the user presses Cancel or an error occur, it returns a null pointer.
86  *
87  * The function creates a modal property copy dialog with the given source property, graph and parent widget.
88  *
89  * @param graph The graph to use as parent for the properties to create.
90  * @param source The property to copy.
91  * @param askBeforePropertyOverwriting If set to true and user try to create a new property with the same name than another existing ask user before overwriting them.
92  **/
93  static PropertyInterface* copyProperty(tlp::Graph* graph,tlp::PropertyInterface* source,bool askBeforePropertyOverwriting=false,QWidget* parent=NULL);
94 
95 private:
96  Ui::CopyPropertyDialogData *ui;
97  tlp::Graph* _graph;
98  tlp::PropertyInterface* _source;
99 
100 private slots:
101  void checkValidity();
102 };
103 }
104 #endif // COPYPROPERTYDIALOG_H
105 ///@endcond