lib: added implicit ctor converter from DatabaseDatabase to DBListType
[barry/progweb.git] / desktop / src / Mode_Sync.h
blobc2eb7fcd8f4b38980226e67b0aedac4e9b44e525
1 ///
2 /// \file Mode_Sync.h
3 /// Mode derived class for syncing
4 ///
6 /*
7 Copyright (C) 2009-2012, Net Direct Inc. (http://www.netdirect.ca/)
9 This program is free software; you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation; either version 2 of the License, or
12 (at your option) any later version.
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
18 See the GNU General Public License in the COPYING file at the
19 root directory of this project for more details.
22 #ifndef __BARRYDESKTOP_MODE_SYNC_H__
23 #define __BARRYDESKTOP_MODE_SYNC_H__
25 #include "Mode.h"
26 #include "deviceset.h"
27 #include "configui.h"
29 class SyncMode : public wxEvtHandler, public Mode
31 private:
32 DECLARE_EVENT_TABLE() // sets to protected:
34 private:
35 wxWindow *m_parent;
37 std::auto_ptr<DeviceSet> m_device_set;
38 ConfigUI::ptr m_cui;
40 // window controls
41 std::auto_ptr<wxBoxSizer> m_topsizer;
42 std::auto_ptr<wxButton> m_sync_now_button;
43 std::auto_ptr<wxButton> m_configure_button;
44 std::auto_ptr<wxButton> m_run_app_button;
45 std::auto_ptr<wxButton> m_1way_reset_button;
46 std::auto_ptr<wxListCtrl> m_device_list;
47 std::auto_ptr<wxStaticText> m_label[4];
49 protected:
50 static std::string Timestamp(time_t last_sync);
52 int GetMaxTimestampWidth(wxWindow *win);
53 void FillDeviceList();
54 void UpdateButtons();
55 DeviceSet::subset_type GetSelectedDevices();
56 void ReselectDevices(const DeviceSet::subset_type &set);
57 void ConfigureDevice(int device_index);
58 void ConfigureDevice(DeviceEntry &entry);
59 void CheckConfigured(DeviceSet::subset_type &subset);
60 void RefillList();
61 int GetSelectedDevice(); // returns index, or -1 if none or
62 // more than one selected... also
63 // handles the message box
64 int GetAuthoritativeSide(int device_index);
65 bool ZapConflicts(int device_index, int authoritative_side);
66 void RewriteConfig(int device_index);
67 bool WarnAbout1WayReset();
69 public:
70 SyncMode(wxWindow *parent);
71 ~SyncMode();
73 // virtual override events (derived from Mode)
74 wxString GetTitleText() const { return _T("Barry Sync"); }
76 // window events
77 void OnSyncNow(wxCommandEvent &event);
78 void OnConfigure(wxCommandEvent &event);
79 void OnRunApp(wxCommandEvent &event);
80 void On1WayReset(wxCommandEvent &event);
81 void OnListSelChange(wxListEvent &event);//to keep track of button state
82 void OnConfigureDevice(wxListEvent &event);
85 #endif