Tulip  4.1.0
Better Visualization Through Research
 All Classes 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 <string>
25 #include <vector>
26 
27 #include <tulip/tulipconf.h>
28 #include <tulip/Iterator.h>
29 
30 #include <QtCore/QString>
31 #include <QtGui/QDialog>
32 #include <QtGui/QWidget>
33 
34 #ifdef _WIN32
35 // compilation pb workaround
36 #include <windows.h>
37 #endif
38 
39 
40 
41 namespace Ui {
42 class CopyPropertyDialogData;
43 }
44 
45 namespace tlp {
46 class Graph;
47 class PropertyInterface;
48 
49 /**
50  * @brief Provide a dialog that allow user to copy a property in an existing property or in a new one.
51  *
52  * The easiest way to use this class is to use the copyProperty static function.
53  * @code
54  * Graph* g;
55  * PropertyInterface* source = g->getLocalProperty<BooleanProperty>("viewSelection");
56  * QWidget* parent;
57  * PropertyInterface* clonedProperty = PropertyCreationDialog::createNewProperty(g,souce,parent);
58  * @endcode
59  *
60  *
61  **/
62 
63 class TLP_QT_SCOPE CopyPropertyDialog : public QDialog {
64  Q_OBJECT
65 public:
66  CopyPropertyDialog(QWidget *parent = NULL);
67 
68  /**
69  * @brief Init dialog with required parameters. To make the copy this dialog need to have a valid source property and destination graph.
70  **/
71  void init(tlp::Graph* graph,tlp::PropertyInterface* toCopy);
72 
73  /**
74  * @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.
75  *
76  * 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.
77  **/
78  tlp::PropertyInterface* copyProperty(QString& errorMsg);
79 
80  /**
81  * @brief Get the name of the destintation property.
82  **/
83  QString destinationPropertyName()const;
84 
85  enum PropertyScope {
86  NEW,
87  LOCAL,
88  INHERITED
89  };
90 
91  /**
92  * @brief Return the scope where the new property will be created.
93  **/
94  PropertyScope destinationPropertyScope()const;
95 
96  /**
97  * @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.
98  *
99  * The function creates a modal property copy dialog with the given source property, graph and parent widget.
100  *
101  * @param graph The graph to use as parent for the properties to create.
102  * @param source The property to copy.
103  * @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.
104  **/
105  static PropertyInterface* copyProperty(tlp::Graph* graph,tlp::PropertyInterface* source,bool askBeforePropertyOverwriting=false,QWidget* parent=NULL);
106 
107 private:
108  Ui::CopyPropertyDialogData *ui;
109  tlp::Graph* _graph;
110  tlp::PropertyInterface* _source;
111 
112 private slots:
113  void checkValidity();
114 };
115 }
116 #endif // COPYPROPERTYDIALOG_H
117 ///@endcond