-
Notifications
You must be signed in to change notification settings - Fork 0
/
SaveButtonManager.h
79 lines (67 loc) · 2.79 KB
/
SaveButtonManager.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
/**
* GeoDa TM, Copyright (C) 2011-2014 by Luc Anselin - all rights reserved
*
* This file is part of GeoDa.
*
* GeoDa is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* GeoDa is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef __GEODA_CENTER_SAVE_MANAGER_H__
#define __GEODA_CENTER_SAVE_MANAGER_H__
#include "DataViewer/TableStateObserver.h"
class TableState;
/**
* SaveButtonManager is responsible for keeping keeping track of when there
* are changes that need to be saved to the Project meta-data file and
* also to the database. It determines this by observing TableState
* events.
*/
class SaveButtonManager : public TableStateObserver {
public:
SaveButtonManager(TableState* table_state);
virtual ~SaveButtonManager();
/** SetAllowEnableSave is used to notify the project that the Save
menu items can be enabled. It does not mean that save items should
be enabled, only that they can be when changes have been made to
the meta-data or db data. When a new project is opened, the project
file name has not been specified, and therefore only Save As should
be enabled until the project is saved for the first time. For the case of
data-only files such as dBase, CSV or Excel, if a point layer
is added, then only Save As should be enabled since it is not
possible to save the point layer in the data-only text file. */
void SetAllowEnableSave(bool enable);
bool IsAllowEnableSave();
bool IsSaveNeeded();
bool IsMetaDataSaveNeeded();
bool IsDbSaveNeeded();
void SetMetaDataSaveNeeded(bool save_needed);
/** This should only be called immedately after creating or opening
a new Project instance. After that, the SaveButtonManager will watch
for TableState events to determine when a change has been made. */
void SetDbSaveNeeded(bool save_needed);
void NotifyAllSaved();
void NotifyMetaDataSaved();
void NotifyDbSaved();
/** Implementation of TableStateObserver interface */
virtual void update(TableState* o);
virtual bool AllowTimelineChanges() { return true; }
virtual bool AllowGroupModify(const wxString& grp_nm) { return true; }
virtual bool AllowObservationAddDelete() { return true; }
private:
void UpdateSaveMenuItems();
TableState* table_state;
bool allow_enable_save;
bool metadata_chgs_since_last_save;
bool db_chgs_since_last_save;
};
#endif