/*************************************************************** * Name: mainDialog.h * Purpose: Main Application Dialog * Author: ZenJu (zhnmju123@gmx.de) * Created: 2008-07-16 **************************************************************/ #ifndef MAINDIALOG_H #define MAINDIALOG_H #include "guiGenerated.h" #include #include "../library/processXml.h" #include #include class CompareStatusHandler; class CompareStatus; class MainFolderDragDrop; class FolderPairPanel; class CustomGrid; class FFSCheckRowsEvent; class FFSSyncDirectionEvent; class IconUpdater; class ManualDeletionHandler; namespace FreeFileSync { class CustomLocale; class GridView; } class MainDialog : public MainDialogGenerated { friend class CompareStatusHandler; friend class ManualDeletionHandler; friend class MainFolderDragDrop; //IDs for context menu items enum ContextIDRim //context menu for left and right grids { CONTEXT_FILTER_TEMP = 10, CONTEXT_EXCLUDE_EXT, CONTEXT_EXCLUDE_OBJ, CONTEXT_CLIPBOARD, CONTEXT_EXPLORER, CONTEXT_DELETE_FILES, CONTEXT_SYNC_DIR_LEFT, CONTEXT_SYNC_DIR_NONE, CONTEXT_SYNC_DIR_RIGHT }; enum ContextIDRimLabel//context menu for column settings { CONTEXT_CUSTOMIZE_COLUMN_LEFT, CONTEXT_CUSTOMIZE_COLUMN_RIGHT, CONTEXT_AUTO_ADJUST_COLUMN_LEFT, CONTEXT_AUTO_ADJUST_COLUMN_RIGHT }; enum ContextIDMiddle//context menu for middle grid { CONTEXT_CHECK_ALL = 20, CONTEXT_UNCHECK_ALL }; enum ContextIDMiddleLabel { CONTEXT_COMPARISON_RESULT = 30, CONTEXT_SYNC_PREVIEW }; public: MainDialog(wxFrame* frame, const wxString& cfgFileName, xmlAccess::XmlGlobalSettings& settings); ~MainDialog(); private: void cleanUp(); //configuration load/save bool readConfigurationFromXml(const wxString& filename, bool programStartup = false); bool writeConfigurationToXml(const wxString& filename); xmlAccess::XmlGuiConfig getCurrentConfiguration() const; static const wxString& lastConfigFileName(); xmlAccess::XmlGuiConfig lastConfigurationSaved; //support for: "Save changed configuration?" dialog void readGlobalSettings(); void writeGlobalSettings(); void updateViewFilterButtons(); void updateFilterButton(wxBitmapButton* filterButton, bool isActive); void addFileToCfgHistory(const wxString& filename); void addLeftFolderToHistory(const wxString& leftFolder); void addRightFolderToHistory(const wxString& rightFolder); void addFolderPair(const std::vector& newPairs, bool addFront = false); void removeAddFolderPair(const int pos); //keep it an int, allow negative values! void clearAddFolderPairs(); //main method for putting gridDataView on UI: updates data respecting current view settings void updateGuiGrid(); void updateGridViewData(); //context menu functions std::set getSelectedRows(const CustomGrid* grid) const; std::set getSelectedRows() const; void setSyncDirManually(const std::set& rowsToSetOnUiTable, const FreeFileSync::SyncDirection dir); void filterRangeManually(const std::set& rowsToFilterOnUiTable, const int leadingRow); void copySelectionToClipboard(const CustomGrid* selectedGrid); void openWithFileManager(const int rowNumber, const bool leftSide); void deleteSelectedFiles(); //work to be done in idle time void OnIdleEvent(wxEvent& event); //delayed status information restore void pushStatusInformation(const wxString& text); void clearStatusBar(); void disableAllElements(); //dis-/enables all elements (except abort button) that might receive user input during long-running processes: comparison, deletion void enableAllElements(); // //events void onGridLeftButtonEvent( wxKeyEvent& event); void onGridRightButtonEvent( wxKeyEvent& event); void onGridMiddleButtonEvent( wxKeyEvent& event); void OnContextRim( wxGridEvent& event); void OnContextRimSelection( wxCommandEvent& event); void OnContextRimLabelLeft( wxGridEvent& event); void OnContextRimLabelRight( wxGridEvent& event); void OnContextRimLabelSelection( wxCommandEvent& event); void OnContextMiddle( wxGridEvent& event); void OnContextMiddleSelection( wxCommandEvent& event); void OnContextMiddleLabel( wxGridEvent& event); void OnContextMiddleLabelSelection(wxCommandEvent& event); void OnDirSelected(wxFileDirPickerEvent& event); void requestShutdown(); //try to exit application void OnCheckRows(FFSCheckRowsEvent& event); void OnSetSyncDirection(FFSSyncDirectionEvent& event); void OnLeftGridDoubleClick( wxGridEvent& event); void OnRightGridDoubleClick(wxGridEvent& event); void OnSortLeftGrid( wxGridEvent& event); void OnSortMiddleGrid( wxGridEvent& event); void OnSortRightGrid( wxGridEvent& event); void OnLeftOnlyFiles( wxCommandEvent& event); void OnRightOnlyFiles( wxCommandEvent& event); void OnLeftNewerFiles( wxCommandEvent& event); void OnRightNewerFiles( wxCommandEvent& event); void OnEqualFiles( wxCommandEvent& event); void OnDifferentFiles( wxCommandEvent& event); void OnConflictFiles( wxCommandEvent& event); void OnSyncCreateLeft( wxCommandEvent& event); void OnSyncCreateRight( wxCommandEvent& event); void OnSyncDeleteLeft( wxCommandEvent& event); void OnSyncDeleteRight( wxCommandEvent& event); void OnSyncDirLeft( wxCommandEvent& event); void OnSyncDirRight( wxCommandEvent& event); void OnSyncDirNone( wxCommandEvent& event); void OnSaveConfig( wxCommandEvent& event); void OnLoadConfig( wxCommandEvent& event); void OnLoadFromHistory( wxCommandEvent& event); bool trySaveConfig(); //return true if saved successfully void loadConfiguration(const wxString& filename); void OnCfgHistoryKeyEvent( wxKeyEvent& event); void OnFolderHistoryKeyEvent(wxKeyEvent& event); void OnRegularUpdateCheck( wxIdleEvent& event); void OnLayoutWindowAsync( wxIdleEvent& event); void refreshGridAfterFilterChange(const int delay); void OnResize( wxSizeEvent& event); void OnResizeFolderPairs( wxSizeEvent& event); void OnFilterButton( wxCommandEvent& event); void OnHideFilteredButton( wxCommandEvent& event); void OnConfigureFilter( wxHyperlinkEvent& event); void OnSwapSides( wxCommandEvent& event); void OnCompare( wxCommandEvent& event); void OnSwitchView( wxCommandEvent& event); void OnSyncSettings( wxCommandEvent& event); void OnCmpSettings( wxCommandEvent& event); void OnStartSync( wxCommandEvent& event); void OnClose( wxCloseEvent& event); void OnQuit( wxCommandEvent& event); void calculatePreview(); void OnAddFolderPair( wxCommandEvent& event); void OnRemoveFolderPair( wxCommandEvent& event); void OnRemoveTopFolderPair( wxCommandEvent& event); //menu events void OnMenuGlobalSettings( wxCommandEvent& event); void OnMenuExportFileList( wxCommandEvent& event); void OnMenuBatchJob( wxCommandEvent& event); void OnMenuCheckVersion( wxCommandEvent& event); void OnMenuAbout( wxCommandEvent& event); void OnMenuQuit( wxCommandEvent& event); void OnMenuLanguageSwitch( wxCommandEvent& event); void switchProgramLanguage(const int langID); typedef int MenuItemID; typedef int LanguageID; std::map languageMenuItemMap; //needed to attach menu item events //*********************************************** //application variables are stored here: //global settings used by GUI and batch mode xmlAccess::XmlGlobalSettings& globalSettings; //technical representation of grid-data FreeFileSync::FolderComparison currentGridData; //UI view of currentGridData std::auto_ptr gridDataView; //------------------------------------- //functional configuration xmlAccess::XmlGuiConfig currentCfg; //folder pairs: //m_directoryLeft, m_directoryRight std::vector additionalFolderPairs; //additional pairs to the standard pair //gui settings int widthNotMaximized; int heightNotMaximized; int posXNotMaximized; int posYNotMaximized; //------------------------------------- //convenience method to get all folder pairs (unformatted) std::vector getFolderPairs() const; //*********************************************** std::auto_ptr contextMenu; //status information wxLongLong lastStatusChange; std::stack stackObjects; //compare status panel (hidden on start, shown when comparing) CompareStatus* compareStatus; //save the last used config filename history std::vector cfgFileNames; //used when saving configuration wxString currentConfigFileName; //temporal variables used by exclude via context menu wxString exFilterCandidateExtension; struct FilterObject { wxString relativeName; FreeFileSync::FileDescrLine::ObjectType type; }; std::vector exFilterCandidateObj; bool cleanedUp; //determines if destructor code was already executed //remember last sort executed (for determination of sort order) int lastSortColumn; const wxGrid* lastSortGrid; //support for drag and drop std::auto_ptr dragDropOnLeft; std::auto_ptr dragDropOnRight; #ifdef FFS_WIN //update icons periodically: one updater instance for both left and right grids std::auto_ptr updateFileIcons; #endif //encapsulation of handling of sync preview class SyncPreview //encapsulates MainDialog functionality for synchronization preview (friend class) { public: SyncPreview(MainDialog* mainDlg); void enablePreview(bool value); bool previewIsEnabled() const; void enableSynchronization(bool value); bool synchronizationIsEnabled() const; private: MainDialog* mainDlg_; bool syncPreviewEnabled; //toggle to display configuration preview instead of comparison result bool synchronizationEnabled; //determines whether synchronization should be allowed } syncPreview; }; #endif // MAINDIALOG_H