X-Git-Url: http://Server1/repobrowser/?a=blobdiff_plain;f=source%2Fcontacteditor%2FfrmContactEditorAddress.cpp;h=6c6811793ac7658d218df60f3e0473e5a6e9b8a9;hb=bfe817b5bfae33a1eb666c463643ec119cd1d66d;hp=f613e0ae2c1a2a42cf4ef674bd3538ce352ccd33;hpb=45729fca56479bd9158486e0cda0c4a94b4dd1dc;p=xestiaab%2F.git diff --git a/source/contacteditor/frmContactEditorAddress.cpp b/source/contacteditor/frmContactEditorAddress.cpp index f613e0a..6c68117 100644 --- a/source/contacteditor/frmContactEditorAddress.cpp +++ b/source/contacteditor/frmContactEditorAddress.cpp @@ -1,3 +1,21 @@ +// frmContactEditorAddress.cpp - frmContactEditorAddress form. +// +// (c) 2012-2015 Xestia Software Development. +// +// This file is part of Xestia Address Book. +// +// Xestia Address Book 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, version 3 of the license. +// +// Xestia Address Book 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 Xestia Address Book. If not, see + #include "frmContactEditorAddress.h" #include #include @@ -8,8 +26,12 @@ frmContactEditorAddress::frmContactEditorAddress( wxWindow* parent ) : frmContactEditorAddressADT( parent ) { + + // Setup the window. + EditorMode = FALSE; sliPriority->Disable(); + } void frmContactEditorAddress::InitAddressEditor( wxInitDialogEvent& event ) @@ -19,16 +41,22 @@ void frmContactEditorAddress::InitAddressEditor( wxInitDialogEvent& event ) void frmContactEditorAddress::EnablePriority( wxCommandEvent& event ) { + + // Enable/disable the priority setting. + if (chkUsePref->IsChecked()){ sliPriority->Enable(); } else { sliPriority->Disable(); } + } void frmContactEditorAddress::ProcessData( wxCommandEvent& event ) { + // Process data. + // Check what edit mode we are in and go from there. long ListCtrlIndex; @@ -54,7 +82,10 @@ void frmContactEditorAddress::ProcessData( wxCommandEvent& event ) // Add the label to the list (maps). - AddressListLabelPtr->insert(std::make_pair(AddressListIndex, txtLabel->GetValue())); + wxString LabelData = txtLabel->GetValue(); + LabelData.Prepend("\""); + LabelData.Append("\""); + AddressListLabelPtr->insert(std::make_pair(AddressListIndex, LabelData)); // Add the language to the list (maps). @@ -88,16 +119,11 @@ void frmContactEditorAddress::ProcessData( wxCommandEvent& event ) AddressListTypePtr->insert(std::make_pair(AddressListIndex, wxT("work"))); } - - //AddressListTypePtr = &AddressListType; - + // Add the mediatype to the list (maps). AddressListMediatypePtr->insert(std::make_pair(AddressListIndex, wxT("text/plain"))); - //AddressListMediatypePtr = &AddressListMediatype; - //AddressListPrefPtr = &AddressListPref; - if (chkUsePref->IsChecked()){ AddressListPrefPtr->insert(std::make_pair(AddressListIndex, sliPriority->GetValue())); @@ -137,24 +163,6 @@ void frmContactEditorAddress::ProcessData( wxCommandEvent& event ) wxString strValue; long longSelected = -1; - /* - strAddress.Append(wxT(";;")); - - strAddress.Append(txtAddress->GetValue()); - strAddress.Append(wxT(";")); - - strAddress.Append(txtTownCity->GetValue()); - strAddress.Append(wxT(";")); - - strAddress.Append(txtCounty->GetValue()); - strAddress.Append(wxT(";")); - - strAddress.Append(txtPostCode->GetValue()); - strAddress.Append(wxT(";")); - - strAddress.Append(txtCountry->GetValue()); - */ - AddressListPtr->erase(AddressListIndex); AddressListPtr->insert(std::make_pair(AddressListIndex, txtAddress->GetValue())); @@ -170,16 +178,16 @@ void frmContactEditorAddress::ProcessData( wxCommandEvent& event ) AddressListCountryPtr->erase(AddressListIndex); AddressListCountryPtr->insert(std::make_pair(AddressListIndex, txtCountry->GetValue())); - //AddressListLabelPtr = &AddressListLabel; - // Add the label to the list (maps). AddressListLabelPtr->erase(AddressListIndex); - AddressListLabelPtr->insert(std::make_pair(AddressListIndex, txtLabel->GetValue())); - // Add the language to the list (maps). + wxString LabelData = txtLabel->GetValue(); + LabelData.Prepend("\""); + LabelData.Append("\""); + AddressListLabelPtr->insert(std::make_pair(AddressListIndex, LabelData)); - //AddressListLangPtr = &AddressListLang; + // Add the language to the list (maps). AddressListLangPtr->erase(AddressListIndex); AddressListLangPtr->insert(std::make_pair(AddressListIndex, cmbLanguage->GetValue())); @@ -202,19 +210,12 @@ void frmContactEditorAddress::ProcessData( wxCommandEvent& event ) AddressListTimezonePtr->erase(AddressListIndex); AddressListTimezonePtr->insert(std::make_pair(AddressListIndex, txtTimezone->GetValue())); - - // No need to update type since it will not have changed. - - //AddressListTypePtr = &AddressListType; // Add the mediatype to the list (maps). AddressListMediatypePtr->erase(AddressListIndex); AddressListMediatypePtr->insert(std::make_pair(AddressListIndex, wxT("text/plain"))); - //AddressListMediatypePtr = &AddressListMediatype; - //AddressListPrefPtr = &AddressListPref; - AddressListPrefPtr->erase(AddressListIndex); if (chkUsePref->IsChecked()){ @@ -260,12 +261,18 @@ void frmContactEditorAddress::ProcessData( wxCommandEvent& event ) void frmContactEditorAddress::CloseWindow( wxCommandEvent& event ) { + + // Close the window. + this->Close(); + } void frmContactEditorAddress::CopyAddress( wxCommandEvent& event ) { + // Copy the address. + wxString MailingLabel; bool AddComma = FALSE; @@ -338,6 +345,9 @@ void frmContactEditorAddress::CopyAddress( wxCommandEvent& event ) void frmContactEditorAddress::SetEditorMode( bool EditMode, SectionType SectType ) { + + // Set the editor mode. + // Set if the editor is adding or editing an address. // FALSE = Add // TRUE = Edit @@ -363,7 +373,8 @@ void frmContactEditorAddress::SetEditorMode( bool EditMode, SectionType SectType striter = AddressListPtr->find(AddressListIndex); - if (striter->first == AddressListIndex){ + if (striter->first == AddressListIndex && + striter != AddressListPtr->end()){ txtAddress->SetValue(striter->second); @@ -371,7 +382,8 @@ void frmContactEditorAddress::SetEditorMode( bool EditMode, SectionType SectType striter = AddressListTownPtr->find(AddressListIndex); - if (striter->first == AddressListIndex){ + if (striter->first == AddressListIndex && + striter != AddressListTownPtr->end()){ txtTownCity->SetValue(striter->second); @@ -379,7 +391,8 @@ void frmContactEditorAddress::SetEditorMode( bool EditMode, SectionType SectType striter = AddressListCountyPtr->find(AddressListIndex); - if (striter->first == AddressListIndex){ + if (striter->first == AddressListIndex && + striter != AddressListCountyPtr->end()){ txtCounty->SetValue(striter->second); @@ -387,7 +400,8 @@ void frmContactEditorAddress::SetEditorMode( bool EditMode, SectionType SectType striter = AddressListPostCodePtr->find(AddressListIndex); - if (striter->first == AddressListIndex){ + if (striter->first == AddressListIndex && + striter != AddressListPostCodePtr->end()){ txtPostCode->SetValue(striter->second); @@ -395,20 +409,19 @@ void frmContactEditorAddress::SetEditorMode( bool EditMode, SectionType SectType striter = AddressListCountryPtr->find(AddressListIndex); - if (striter->first == AddressListIndex){ + if (striter->first == AddressListIndex && + striter != AddressListCountryPtr->end()){ txtCountry->SetValue(striter->second); } - //CaptureString(&strValue, TRUE); - //->Replace(wxT("\;"), wxT("\;;"), TRUE); - // Setup the Slider. intiter = AddressListPrefPtr->find(AddressListIndex); - if (intiter->first == AddressListIndex && intiter->second > 0){ + if (intiter->first == AddressListIndex && intiter->second > 0 && intiter != AddressListPrefPtr->end() && + intiter != AddressListPrefPtr->end()){ sliPriority->SetValue(intiter->second); sliPriority->Enable(); @@ -420,9 +433,14 @@ void frmContactEditorAddress::SetEditorMode( bool EditMode, SectionType SectType striter = AddressListLabelPtr->find(AddressListIndex); - if (striter->first == AddressListIndex){ + if (striter->first == AddressListIndex && striter != AddressListLabelPtr->end() && + striter != AddressListLabelPtr->end()){ strValue = striter->second; + if (strValue.Left(1) == "\"" && strValue.Right(1) == "\""){ + strValue.erase(0, 1); + strValue.RemoveLast(); + } } @@ -432,17 +450,17 @@ void frmContactEditorAddress::SetEditorMode( bool EditMode, SectionType SectType striter = AddressListLangPtr->find(AddressListIndex); - if (striter->first == AddressListIndex){ + if (striter->first == AddressListIndex && striter != AddressListLangPtr->end()){ strValue = striter->second; - + } cmbLanguage->SetValue(strValue); striter = AddressListGeoPtr->find(AddressListIndex); - if (striter->first == AddressListIndex){ + if (striter->first == AddressListIndex && striter != AddressListGeoPtr->end()){ strValue = striter->second; @@ -452,7 +470,7 @@ void frmContactEditorAddress::SetEditorMode( bool EditMode, SectionType SectType striter = AddressListTimezonePtr->find(AddressListIndex); - if (striter->first == AddressListIndex){ + if (striter->first == AddressListIndex && striter != AddressListTimezonePtr->end()){ strValue = striter->second; @@ -484,6 +502,8 @@ void frmContactEditorAddress::SetupPointers( std::map *AddressLis int AddressIndex ) { + // Setup the pointers. + AddressListPtr = AddressList; AddressListTownPtr = AddressListTown; AddressListCountyPtr = AddressListCounty;