Home | News | Projects | Releases
Bugs | RFE | Repositories | Help
frmContactEditorAddress: Implemented priority control
[xestiaab/.git] / source / contacteditor / frmContactEditorAddress.cpp
index f746895..a653d27 100644 (file)
@@ -26,8 +26,14 @@ frmContactEditorAddress::frmContactEditorAddress( wxWindow* parent )
 :
 frmContactEditorAddressADT( parent )
 {
+       
+       // Setup the window.
+       
        EditorMode = FALSE;
-       sliPriority->Disable();
+       priorityCtrl = new XABPriorityCtrl(tabGeneral);
+       szrGeneral->Add(priorityCtrl, 1, wxEXPAND, 5);
+       szrGeneral->Layout();
+       
 }
 
 void frmContactEditorAddress::InitAddressEditor( wxInitDialogEvent& event )
@@ -35,18 +41,11 @@ void frmContactEditorAddress::InitAddressEditor( wxInitDialogEvent& event )
        // Do nothing with this subroutine at this time.
 }
 
-void frmContactEditorAddress::EnablePriority( wxCommandEvent& event )
-{
-       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;
@@ -109,19 +108,14 @@ 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 (priorityCtrl->IsPriorityChecked()){
                
-               if (chkUsePref->IsChecked()){
-               
-                       AddressListPrefPtr->insert(std::make_pair(AddressListIndex, sliPriority->GetValue()));
+                       AddressListPrefPtr->insert(std::make_pair(AddressListIndex, priorityCtrl->GetValue()));
                
                } else {
                
@@ -142,9 +136,9 @@ void frmContactEditorAddress::ProcessData( wxCommandEvent& event )
                AddressListCtrlPtr->SetItem(ListCtrlIndex, 2, txtCounty->GetValue());
                AddressListCtrlPtr->SetItem(ListCtrlIndex, 3, txtPostCode->GetValue());
                
-               if (chkUsePref->IsChecked()){
+               if (priorityCtrl->IsPriorityChecked()){
                
-                       AddressListCtrlPtr->SetItem(ListCtrlIndex, 4, wxString::Format(wxT("%i"), sliPriority->GetValue()));
+                       AddressListCtrlPtr->SetItem(ListCtrlIndex, 4, wxString::Format(wxT("%i"), priorityCtrl->GetValue()));
                
                }
                
@@ -158,24 +152,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()));
 
@@ -191,8 +167,6 @@ 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);
@@ -204,8 +178,6 @@ void frmContactEditorAddress::ProcessData( wxCommandEvent& event )
                
                // Add the language to the list (maps).
                
-               //AddressListLangPtr = &AddressListLang;
-               
                AddressListLangPtr->erase(AddressListIndex);
                AddressListLangPtr->insert(std::make_pair(AddressListIndex, cmbLanguage->GetValue()));
                
@@ -227,24 +199,17 @@ 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()){
+               if (priorityCtrl->IsPriorityChecked()){
                
-                       AddressListPrefPtr->insert(std::make_pair(AddressListIndex, sliPriority->GetValue()));
+                       AddressListPrefPtr->insert(std::make_pair(AddressListIndex, priorityCtrl->GetValue()));
                
                } else {
                
@@ -267,9 +232,9 @@ void frmContactEditorAddress::ProcessData( wxCommandEvent& event )
                AddressListCtrlPtr->SetItem(longSelected, 2, txtCounty->GetValue());
                AddressListCtrlPtr->SetItem(longSelected, 3, txtPostCode->GetValue());
                
-               if (chkUsePref->IsChecked()){
+               if (priorityCtrl->IsPriorityChecked()){
                
-                       AddressListCtrlPtr->SetItem(longSelected, 4, wxString::Format(wxT("%i"), sliPriority->GetValue()));
+                       AddressListCtrlPtr->SetItem(longSelected, 4, wxString::Format(wxT("%i"), priorityCtrl->GetValue()));
                
                } else {
                
@@ -285,12 +250,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;
        
@@ -363,6 +334,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
@@ -388,7 +362,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);
                
@@ -396,7 +371,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);
                
@@ -404,7 +380,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);
                
@@ -412,7 +389,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);
                
@@ -420,24 +398,22 @@ 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();
-                       chkUsePref->SetValue(TRUE);
+                       priorityCtrl->SetValue(intiter->second);
+                       priorityCtrl->EnablePriority(true);
                
                }
                
@@ -445,9 +421,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();
+                       }
                
                }
 
@@ -457,17 +438,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;
                
@@ -477,7 +458,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;
                
@@ -509,6 +490,8 @@ void frmContactEditorAddress::SetupPointers( std::map<int, wxString> *AddressLis
        int AddressIndex )
 {
 
+       // Setup the pointers.
+       
        AddressListPtr = AddressList;
        AddressListTownPtr = AddressListTown;
        AddressListCountyPtr = AddressListCounty;
Xestia Software Development
Yn Maystri
© 2006 - 2019 Xestia Software Development
Software

Xestia Address Book
Xestia Calendar
Development

Xestia Gelforn
Everything else

About
News
Privacy Policy