Home | News | Projects | Releases
Bugs | RFE | Repositories | Help
frmContactEditorKey: Implemented priority control
[xestiaab/.git] / source / contacteditor / frmContactEditorKey.cpp
index bcac1f5..78ee77a 100644 (file)
@@ -25,8 +25,12 @@ frmContactEditorKey::frmContactEditorKey( wxWindow* parent )
 :
 frmContactEditorKeyADT( parent )
 {
+       
+       // Setup the window.
+       
        EditorMode = FALSE;
-       sliPriority->Disable();
+       priorityCtrl = new XABPriorityCtrl(tabGeneral);
+       szrGeneral->Add(priorityCtrl, 1, wxEXPAND, 5);
        
        // Setup the control boxes and hide tabs unless they are
        // needed.
@@ -37,26 +41,23 @@ frmContactEditorKeyADT( parent )
        cmbKeyMainType->Append(_("URL"));
        cmbKeyMainType->Append(_("Key"));
        
+       cmbType->Append("");
        cmbType->Append(_("Home"));
        cmbType->Append(_("Work"));
        
        cmbURL->Append(_("PGP Key"));
        
        cmbKeyType->Append(_("PGP Key"));
+       
+       cmbType->SetSelection(0);
 
 }
 
-void frmContactEditorKey::EnablePriority( wxCommandEvent& event )
-{
-       if (chkUsePref->IsChecked()){
-               sliPriority->Enable();
-       } else {
-               sliPriority->Disable();
-       }
-}
-
 void frmContactEditorKey::SetEditorMode(bool EditMode)
 {
+       
+       // Set the editor mode.
+       
        // Set if the editor is adding or editing an address.
        // FALSE = Add
        // TRUE = Edit
@@ -110,7 +111,8 @@ void frmContactEditorKey::SetEditorMode(bool EditMode)
                        
                        striter = KeyListDataTypePtr->find(KeyListIndex);
                        
-                       if (striter->first == KeyListIndex){
+                       if (striter->first == KeyListIndex &&
+                               striter != KeyListDataTypePtr->end()){
                        
                                strValue = striter->second;
                        
@@ -149,7 +151,8 @@ void frmContactEditorKey::SetEditorMode(bool EditMode)
                        
                        striter = KeyListDataTypePtr->find(KeyListIndex);
                        
-                       if (striter->first == KeyListIndex){
+                       if (striter->first == KeyListIndex &&
+                               striter != KeyListDataTypePtr->end()){
                        
                                strValue = striter->second;
                        
@@ -165,7 +168,8 @@ void frmContactEditorKey::SetEditorMode(bool EditMode)
                
                striter = KeyListTypePtr->find(KeyListIndex);   
                
-               if (striter->first == KeyListIndex){
+               if (striter->first == KeyListIndex &&
+                       striter != KeyListTypePtr->end()){
                
                        strValue = striter->second;
                
@@ -189,11 +193,11 @@ void frmContactEditorKey::SetEditorMode(bool EditMode)
                
                intiter = KeyListPrefPtr->find(KeyListIndex);
                
-               if (intiter->first == KeyListIndex && intiter->second > 0){
+               if (intiter->first == KeyListIndex && intiter->second > 0 &&
+                       intiter != KeyListPrefPtr->end()){
                
-                       sliPriority->SetValue(intiter->second);
-                       sliPriority->Enable();
-                       chkUsePref->SetValue(TRUE);
+                       priorityCtrl->SetValue(intiter->second);
+                       priorityCtrl->EnablePriority(true);
                
                }
                
@@ -203,6 +207,9 @@ void frmContactEditorKey::SetEditorMode(bool EditMode)
 
 void frmContactEditorKey::ProcessAction( wxCommandEvent& event )
 {
+       
+       // Process action.
+       
        long ListCtrlIndex;
        int intKeyType = 0;
        
@@ -276,10 +283,10 @@ void frmContactEditorKey::ProcessAction( wxCommandEvent& event )
                
                // Get Key priority.
                
-               if (chkUsePref->IsChecked()){
+               if (priorityCtrl->IsPriorityChecked()){
                
-                       KeyListPrefPtr->insert(std::make_pair(KeyListIndex, sliPriority->GetValue()));
-                       KeyListCtrlPtr->SetItem(ListCtrlIndex, 2, wxString::Format(wxT("%i"), sliPriority->GetValue()));                        
+                       KeyListPrefPtr->insert(std::make_pair(KeyListIndex, priorityCtrl->GetValue()));
+                       KeyListCtrlPtr->SetItem(ListCtrlIndex, 2, wxString::Format(wxT("%i"), priorityCtrl->GetValue()));                       
                
                } else {
                
@@ -287,10 +294,6 @@ void frmContactEditorKey::ProcessAction( wxCommandEvent& event )
                
                }
                
-               if (chkUsePref->IsChecked()){
-               
-               }
-               
                this->Close();
                
        } else if (EditorMode == TRUE){
@@ -368,10 +371,10 @@ void frmContactEditorKey::ProcessAction( wxCommandEvent& event )
                
                KeyListPrefPtr->erase(KeyListIndex);            
                
-               if (chkUsePref->IsChecked()){
+               if (priorityCtrl->IsPriorityChecked()){
                
-                       KeyListPrefPtr->insert(std::make_pair(KeyListIndex, sliPriority->GetValue()));
-                       KeyListCtrlPtr->SetItem(longSelected, 2, wxString::Format(wxT("%i"), sliPriority->GetValue()));
+                       KeyListPrefPtr->insert(std::make_pair(KeyListIndex, priorityCtrl->GetValue()));
+                       KeyListCtrlPtr->SetItem(longSelected, 2, wxString::Format(wxT("%i"), priorityCtrl->GetValue()));
                
                } else {
                
@@ -387,27 +390,17 @@ void frmContactEditorKey::ProcessAction( wxCommandEvent& event )
 void frmContactEditorKey::ProcessKeyType( wxCommandEvent& event )
 {
 
-       int intKeyType = 0;
-       
-       intKeyType = cmbKeyMainType->GetCurrentSelection();
-       
-       if (intKeyType == 0){
-       
-               tabURL->Show();
-               tabKey->Hide();
-       
-       } else if (intKeyType == 1){
-       
-               tabURL->Hide();
-               tabKey->Show();
-       
-       }
+       // Process the key type (via wxCommandEvent).
 
+       ProcessKeyType();
+       
 }
 
 void frmContactEditorKey::ProcessKeyType()
 {
 
+       // Process the key type.
+       
        int intKeyType = 0;
        
        intKeyType = cmbKeyMainType->GetCurrentSelection();
@@ -429,6 +422,8 @@ void frmContactEditorKey::ProcessKeyType()
 void frmContactEditorKey::ConvertURLType( wxCommandEvent& event )
 {
 
+       // Convert the URL type.
+       
        wxString strValue;
 
        strValue = cmbURL->GetString(cmbURL->GetCurrentSelection());
@@ -444,6 +439,8 @@ void frmContactEditorKey::ConvertURLType( wxCommandEvent& event )
 void frmContactEditorKey::ConvertKeyType( wxCommandEvent& event )
 {
 
+       // Convert the key type.
+       
        wxString strValue;
 
        strValue = cmbKeyType->GetString(cmbKeyType->GetCurrentSelection());
@@ -458,7 +455,11 @@ void frmContactEditorKey::ConvertKeyType( wxCommandEvent& event )
 
 void frmContactEditorKey::CloseWindow( wxCommandEvent& event )
 {
+       
+       // Close this window.
+       
        this->Close();
+       
 }
 
 void frmContactEditorKey::SetupPointers(std::map<int, wxString> *KeyList,
@@ -473,6 +474,8 @@ void frmContactEditorKey::SetupPointers(std::map<int, wxString> *KeyList,
        int KeyIndex )
 {
 
+       // Setup the pointers.
+       
        KeyListPtr = KeyList;
        KeyListAltIDPtr = KeyListAltID;
        KeyListPIDPtr = KeyListPID;
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