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 00020 #ifndef GRAPHNEEDSSAVINGOBSERVER_H 00021 #define GRAPHNEEDSSAVINGOBSERVER_H 00022 00023 #include <tulip/Observable.h> 00024 00025 #include <QObject> 00026 00027 namespace tlp { 00028 00029 class Graph; 00030 00031 /** 00032 * @see Observable 00033 * 00034 * @brief The GraphNeedsSavingObserver class will observe a graph and tells if it has been modified. 00035 * 00036 * @li The constructor. Observe the graph given in parameter for modification 00037 * @li needsSaving. Returns true is the graph has been modified 00038 * @li saved. The graph has been saved, and the status of the class must be reset. needsSaving will return false if called after saved(). 00039 * @li savingNeeded. Signal send when the status of the graph evolves. 00040 * 00041 */ 00042 class TLP_QT_SCOPE GraphNeedsSavingObserver : public QObject, Observable { 00043 00044 Q_OBJECT 00045 00046 bool _needsSaving; 00047 Graph* _graph; 00048 00049 void addObserver(); 00050 void removeObservers(); 00051 00052 public : 00053 /** 00054 * @brief GraphNeedsSavingObserver Class constructor 00055 * @param graph the graph which needs to be observed for modifications 00056 */ 00057 GraphNeedsSavingObserver(Graph* graph); 00058 00059 /** 00060 * @brief saved If the graph has been saved, one has to call this method to reset the status of the graph (it does not need to be saved). 00061 * to indicate that the graph does not need to be saved until a new modification. 00062 */ 00063 void saved(); 00064 00065 /** 00066 * @brief needsSaving Indicates if the graph has been modified, and thus needs to be saved. 00067 * 00068 * @return true if the graph needs to be saved, false otherwise. 00069 */ 00070 bool needsSaving() const; 00071 00072 protected : 00073 /** 00074 * @see Listener 00075 * @see Observer 00076 * @see Observable 00077 * @see Observable::treatEvents(const std::vector<Event>&) 00078 * 00079 * @brief treatEvents This function is called when events are sent to Observers, and Observers only. 00080 * 00081 * @param events The events that happened since the last unHoldObservers(). 00082 */ 00083 virtual void treatEvents(const std::vector<Event>&); 00084 00085 signals: 00086 00087 /** 00088 * @brief savingNeeded This signal is sent when the graph needs to be saved (it has been modified). 00089 */ 00090 00091 void savingNeeded(); 00092 00093 }; 00094 } 00095 #endif //GRAPHNEEDSSAVINGOBSERVER_H