X-Git-Url: http://Server1/repobrowser/?a=blobdiff_plain;f=source%2Fforms%2Fpreferences%2FfrmPreferences.cpp;h=b9919c73f8e0338b08127c52c0c9f576c5a46ef8;hb=49789773e2797383c866dca470fb99e80cb49e41;hp=b7c629b3a710b2425da45ee63e7641ea5a5cd502;hpb=66ebed13414439cd56161faa2abcff7744ab4588;p=xestiacalendar%2F.git diff --git a/source/forms/preferences/frmPreferences.cpp b/source/forms/preferences/frmPreferences.cpp index b7c629b..b9919c7 100644 --- a/source/forms/preferences/frmPreferences.cpp +++ b/source/forms/preferences/frmPreferences.cpp @@ -41,6 +41,7 @@ frmPreferencesADT( parent ) NbtPreferences->RemovePage(1); btnAccountAdd->Show(false); + NbtPreferences->ChangeSelection(0); } @@ -208,8 +209,8 @@ void frmPreferences::ModifyAccount( wxCommandEvent& event ) accType = preferences->accounts.GetAccountType((int)lstAccountsIndex); - if (accType != "CardDAV" && AccType != "carddav" && - accType != "Local" && AccType != "local"){ + if (accType != "CardDAV" && accType != "carddav" && + accType != "Local" && accType != "local"){ wxMessageBox(_("Cannot modify the selected account settings as the account type is unsupported."), _("Unsupported account type"), wxICON_ERROR); return; @@ -323,11 +324,9 @@ void frmPreferences::DeleteAccount( wxCommandEvent& event ) if (!accountDirFull.IsEmpty()){ - accountDirDelFull.Append(wxString::FromUTF8(getenv("HOME"))); - accountDirDelFull.Append(wxT("/.xestiacal/accounts/")); - accountDirDelFull.Append(accountDirFull); + accountDirDelFull.Append(GetAccountDir(accountDirFull, false)); - wxRmDir(accountDirDelFull); + DeleteDirectory(accountDirDelFull); } @@ -424,4 +423,37 @@ void frmPreferences::SetupPointers(bool *reloadAccountInc){ reloadAccountConfig = reloadAccountInc; -} \ No newline at end of file +} + +void frmPreferences::DeleteDirectory(wxString directoryPath) +{ + + // Open the directory and look for files and directories + // to delete. + + wxDir directoryHandle(directoryPath); + + if (!directoryHandle.IsOpened()) + { + return; + } + + wxString directoryFilename; + + bool continueProcessing = directoryHandle.GetFirst(&directoryFilename, wxEmptyString, wxDIR_FILES|wxDIR_DIRS|wxDIR_HIDDEN); + while (continueProcessing) + { + wxString directoryFilenameFull = directoryPath + "/" + directoryFilename; + if (wxDir::Exists(directoryFilenameFull)) + { + DeleteDirectory(directoryFilenameFull); + continueProcessing = directoryHandle.GetNext(&directoryFilename); + continue; + } + wxRemoveFile(directoryFilenameFull); + continueProcessing = directoryHandle.GetNext(&directoryFilename); + } + directoryHandle.Close(); + + wxRmDir(directoryPath); +}