![]() |
Tulip
4.6.0
Better Visualization Through Research
|
00001 /* 00002 * 00003 * This file is part of Tulip (www.tulip-software.org) 00004 * 00005 * Authors: David Auber and the Tulip development Team 00006 * from LaBRI, University of Bordeaux 00007 * 00008 * Tulip is free software; you can redistribute it and/or modify 00009 * it under the terms of the GNU Lesser General Public License 00010 * as published by the Free Software Foundation, either version 3 00011 * of the License, or (at your option) any later version. 00012 * 00013 * Tulip is distributed in the hope that it will be useful, 00014 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00015 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 00016 * See the GNU General Public License for more details. 00017 * 00018 */ 00019 ///@cond DOXYGEN_HIDDEN 00020 00021 #ifndef COPYPROPERTYDIALOG_H 00022 #define COPYPROPERTYDIALOG_H 00023 00024 #include <tulip/tulipconf.h> 00025 00026 #include <QDialog> 00027 00028 namespace Ui { 00029 class CopyPropertyDialogData; 00030 } 00031 00032 namespace tlp { 00033 class Graph; 00034 class PropertyInterface; 00035 00036 /** 00037 * @brief Provide a dialog that allow user to copy a property in an existing property or in a new one. 00038 * 00039 * The easiest way to use this class is to use the copyProperty static function. 00040 * @code 00041 * Graph* g; 00042 * PropertyInterface* source = g->getLocalProperty<BooleanProperty>("viewSelection"); 00043 * PropertyInterface* clonedProperty = CopyPropertyDialog::copyProperty(g, source); 00044 * @endcode 00045 * 00046 * 00047 **/ 00048 00049 class TLP_QT_SCOPE CopyPropertyDialog : public QDialog { 00050 Q_OBJECT 00051 public: 00052 CopyPropertyDialog(QWidget *parent = NULL); 00053 ~CopyPropertyDialog(); 00054 00055 /** 00056 * @brief Init dialog with required parameters. To make the copy this dialog need to have a valid source property and destination graph. 00057 **/ 00058 void init(tlp::Graph* graph,tlp::PropertyInterface* toCopy); 00059 00060 /** 00061 * @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. 00062 * 00063 * 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. 00064 **/ 00065 tlp::PropertyInterface* copyProperty(QString& errorMsg); 00066 00067 /** 00068 * @brief Get the name of the destintation property. 00069 **/ 00070 QString destinationPropertyName()const; 00071 00072 enum PropertyScope { 00073 NEW, 00074 LOCAL, 00075 INHERITED 00076 }; 00077 00078 /** 00079 * @brief Return the scope where the new property will be created. 00080 **/ 00081 PropertyScope destinationPropertyScope()const; 00082 00083 /** 00084 * @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. 00085 * 00086 * The function creates a modal property copy dialog with the given source property, graph and parent widget. 00087 * 00088 * @param graph The graph to use as parent for the properties to create. 00089 * @param source The property to copy. 00090 * @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. 00091 **/ 00092 static PropertyInterface* copyProperty(tlp::Graph* graph,tlp::PropertyInterface* source,bool askBeforePropertyOverwriting=false,QWidget* parent=NULL); 00093 00094 private: 00095 Ui::CopyPropertyDialogData *ui; 00096 tlp::Graph* _graph; 00097 tlp::PropertyInterface* _source; 00098 00099 private slots: 00100 void checkValidity(); 00101 }; 00102 } 00103 #endif // COPYPROPERTYDIALOG_H 00104 ///@endcond