diff options
Diffstat (limited to 'ui/folder_pair.h')
-rw-r--r-- | ui/folder_pair.h | 124 |
1 files changed, 82 insertions, 42 deletions
diff --git a/ui/folder_pair.h b/ui/folder_pair.h index 5ca8d92f..6c535664 100644 --- a/ui/folder_pair.h +++ b/ui/folder_pair.h @@ -27,49 +27,56 @@ template <class GuiPanel> class FolderPairPanelBasic : private wxEvtHandler { public: - typedef std::shared_ptr<const zen::AlternateSyncConfig> AltSyncCfgPtr; + typedef std::shared_ptr<const CompConfig> AltCompCfgPtr; + typedef std::shared_ptr<const SyncConfig> AltSyncCfgPtr; - AltSyncCfgPtr getAltSyncConfig() const - { - return altSyncConfig; - } - - FilterConfig getAltFilterConfig() const - { - return localFilter; - } + AltCompCfgPtr getAltCompConfig() const { return altCompConfig; } + AltSyncCfgPtr getAltSyncConfig() const { return altSyncConfig; } + FilterConfig getAltFilterConfig() const { return localFilter; } - void setConfig(AltSyncCfgPtr syncCfg, const FilterConfig& filter) + void setConfig(AltCompCfgPtr compConfig, AltSyncCfgPtr syncCfg, const FilterConfig& filter) { + altCompConfig = compConfig; altSyncConfig = syncCfg; localFilter = filter; refreshButtons(); } - void refreshButtons() { + if (altCompConfig.get()) + { + setBitmapLabel(*basicPanel_.m_bpButtonAltCompCfg, GlobalResources::getImage(wxT("cmpConfigSmall"))); + basicPanel_.m_bpButtonAltCompCfg->SetToolTip(wxString(_("Select alternate comparison settings")) + wxT(" \n") + + wxT("(") + getVariantName(altCompConfig->compareVar) + wxT(")")); + } + else + { + setBitmapLabel(*basicPanel_.m_bpButtonAltCompCfg, GlobalResources::getImage(wxT("cmpConfigSmallGrey"))); + basicPanel_.m_bpButtonAltCompCfg->SetToolTip(_("Select alternate comparison settings")); + } + if (altSyncConfig.get()) { - setBitmapLabel(*basicPanel_.m_bpButtonAltSyncCfg, GlobalResources::instance().getImage(wxT("syncConfigSmall"))); + setBitmapLabel(*basicPanel_.m_bpButtonAltSyncCfg, GlobalResources::getImage(wxT("syncConfigSmall"))); basicPanel_.m_bpButtonAltSyncCfg->SetToolTip(wxString(_("Select alternate synchronization settings")) + wxT(" \n") + - wxT("(") + getVariantName(altSyncConfig->syncConfiguration.var) + wxT(")")); + wxT("(") + getVariantName(altSyncConfig->directionCfg.var) + wxT(")")); } else { - setBitmapLabel(*basicPanel_.m_bpButtonAltSyncCfg, GlobalResources::instance().getImage(wxT("syncConfigSmallGrey"))); + setBitmapLabel(*basicPanel_.m_bpButtonAltSyncCfg, GlobalResources::getImage(wxT("syncConfigSmallGrey"))); basicPanel_.m_bpButtonAltSyncCfg->SetToolTip(_("Select alternate synchronization settings")); } //test for Null-filter if (isNullFilter(localFilter)) { - setBitmapLabel(*basicPanel_.m_bpButtonLocalFilter, GlobalResources::instance().getImage(wxT("filterSmallGrey"))); + setBitmapLabel(*basicPanel_.m_bpButtonLocalFilter, GlobalResources::getImage(wxT("filterSmallGrey"))); basicPanel_.m_bpButtonLocalFilter->SetToolTip(_("No filter selected")); } else { - setBitmapLabel(*basicPanel_.m_bpButtonLocalFilter, GlobalResources::instance().getImage(wxT("filterSmall"))); + setBitmapLabel(*basicPanel_.m_bpButtonLocalFilter, GlobalResources::getImage(wxT("filterSmall"))); basicPanel_.m_bpButtonLocalFilter->SetToolTip(_("Filter is active")); } } @@ -79,18 +86,20 @@ protected: basicPanel_(basicPanel) { //register events for removal of alternate configuration - basicPanel_.m_bpButtonAltSyncCfg->Connect(wxEVT_RIGHT_DOWN, wxCommandEventHandler(FolderPairPanelBasic::OnAltSyncCfgRemove), NULL, this); + basicPanel_.m_bpButtonAltCompCfg ->Connect(wxEVT_RIGHT_DOWN, wxCommandEventHandler(FolderPairPanelBasic::OnAltCompCfgRemove ), NULL, this); + basicPanel_.m_bpButtonAltSyncCfg ->Connect(wxEVT_RIGHT_DOWN, wxCommandEventHandler(FolderPairPanelBasic::OnAltSyncCfgRemove ), NULL, this); basicPanel_.m_bpButtonLocalFilter->Connect(wxEVT_RIGHT_DOWN, wxCommandEventHandler(FolderPairPanelBasic::OnLocalFilterCfgRemove), NULL, this); - basicPanel_.m_bpButtonAltSyncCfg-> Connect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(FolderPairPanelBasic::OnAltSyncCfg), NULL, this); + basicPanel_.m_bpButtonAltCompCfg-> Connect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(FolderPairPanelBasic::OnAltCompCfg ), NULL, this); + basicPanel_.m_bpButtonAltSyncCfg-> Connect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(FolderPairPanelBasic::OnAltSyncCfg ), NULL, this); basicPanel_.m_bpButtonLocalFilter->Connect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(FolderPairPanelBasic::OnLocalFilterCfg), NULL, this); - basicPanel_.m_bpButtonRemovePair->SetBitmapLabel(GlobalResources::instance().getImage(wxT("removeFolderPair"))); + basicPanel_.m_bpButtonRemovePair->SetBitmapLabel(GlobalResources::getImage(wxT("removeFolderPair"))); } - virtual void OnLocalFilterCfgRemoveConfirm(wxCommandEvent& event) + virtual void OnAltCompCfgRemoveConfirm(wxCommandEvent& event) { - localFilter = FilterConfig(); + altCompConfig.reset(); refreshButtons(); } @@ -100,18 +109,23 @@ protected: refreshButtons(); } + virtual void OnLocalFilterCfgRemoveConfirm(wxCommandEvent& event) + { + localFilter = FilterConfig(); + refreshButtons(); + } private: - void OnLocalFilterCfgRemove(wxCommandEvent& event) + void OnAltCompCfgRemove(wxCommandEvent& event) { contextMenu.reset(new wxMenu); //re-create context menu - wxMenuItem* itemClear = new wxMenuItem(contextMenu.get(), wxID_ANY, _("Clear filter settings")); - contextMenu->Append(itemClear); - contextMenu->Connect(itemClear->GetId(), wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(FolderPairPanelBasic::OnLocalFilterCfgRemoveConfirm), NULL, this); + wxMenuItem* itemRemove = new wxMenuItem(contextMenu.get(), wxID_ANY, _("Remove alternate settings")); + contextMenu->Append(itemRemove); + contextMenu->Connect(itemRemove->GetId(), wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(FolderPairPanelBasic::OnAltCompCfgRemoveConfirm), NULL, this); - if (isNullFilter(localFilter)) - contextMenu->Enable(itemClear->GetId(), false); //disable menu item, if clicking wouldn't make sense anyway + if (!altCompConfig.get()) + contextMenu->Enable(itemRemove->GetId(), false); //disable menu item, if clicking wouldn't make sense anyway basicPanel_.PopupMenu(contextMenu.get()); //show context menu } @@ -130,36 +144,61 @@ private: basicPanel_.PopupMenu(contextMenu.get()); //show context menu } + void OnLocalFilterCfgRemove(wxCommandEvent& event) + { + contextMenu.reset(new wxMenu); //re-create context menu + + wxMenuItem* itemClear = new wxMenuItem(contextMenu.get(), wxID_ANY, _("Clear filter settings")); + contextMenu->Append(itemClear); + contextMenu->Connect(itemClear->GetId(), wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(FolderPairPanelBasic::OnLocalFilterCfgRemoveConfirm), NULL, this); + + if (isNullFilter(localFilter)) + contextMenu->Enable(itemClear->GetId(), false); //disable menu item, if clicking wouldn't make sense anyway + + basicPanel_.PopupMenu(contextMenu.get()); //show context menu + } + + virtual MainConfiguration getMainConfig() const = 0; virtual wxWindow* getParentWindow() = 0; - virtual void OnAltSyncCfgChange() {}; + virtual void OnAltCompCfgChange() = 0; + virtual void OnAltSyncCfgChange() = 0; + virtual void OnLocalFilterCfgChange() {}; - void OnAltSyncCfg(wxCommandEvent& event) + void OnAltCompCfg(wxCommandEvent& event) { const MainConfiguration mainCfg = getMainConfig(); - const AlternateSyncConfig syncConfigMain(mainCfg.syncConfiguration, - mainCfg.handleDeletion, - mainCfg.customDeletionDirectory); - AlternateSyncConfig altSyncCfg = altSyncConfig.get() ? *altSyncConfig : syncConfigMain; + CompConfig cmpCfg = altCompConfig.get() ? *altCompConfig : mainCfg.cmpConfig; + + if (showCompareCfgDialog(cmpCfg) == ReturnSmallDlg::BUTTON_OKAY) + { + altCompConfig = std::make_shared<CompConfig>(cmpCfg); + refreshButtons(); + + OnAltCompCfgChange(); + } + } + + void OnAltSyncCfg(wxCommandEvent& event) + { + const MainConfiguration mainCfg = getMainConfig(); + CompConfig cmpCfg = altCompConfig.get() ? *altCompConfig : mainCfg.cmpConfig; + SyncConfig syncCfg = altSyncConfig.get() ? *altSyncConfig : mainCfg.syncCfg; - if (showSyncConfigDlg(mainCfg.compareVar, - altSyncCfg.syncConfiguration, - altSyncCfg.handleDeletion, - altSyncCfg.customDeletionDirectory, + if (showSyncConfigDlg(cmpCfg.compareVar, + syncCfg, NULL) == ReturnSyncConfig::BUTTON_OKAY) //optional input parameter { - altSyncConfig.reset(new AlternateSyncConfig(altSyncCfg)); + altSyncConfig = std::make_shared<SyncConfig>(syncCfg); refreshButtons(); OnAltSyncCfgChange(); } } - virtual void OnLocalFilterCfgChange() {}; - void OnLocalFilterCfg(wxCommandEvent& event) { FilterConfig localFiltTmp = localFilter; @@ -177,7 +216,8 @@ private: GuiPanel& basicPanel_; //panel to be enhanced by this template //alternate configuration attached to it - AltSyncCfgPtr altSyncConfig; //optional: present if non-NULL + AltCompCfgPtr altCompConfig; //optional: present if non-NULL + AltSyncCfgPtr altSyncConfig; // FilterConfig localFilter; std::unique_ptr<wxMenu> contextMenu; |