X-Git-Url: http://Server1/repobrowser/?a=blobdiff_plain;ds=sidebyside;f=source%2Fcontacteditor%2FfrmContactEditorKey.cpp;h=01de31813e355750aa363850a11a3ea08a13efd3;hb=ba3ba5de4e84a8c3ddeb65549d0b46998e5ebdf5;hp=7234bbeb0821847ca6570dead178eb3d2802c34b;hpb=45729fca56479bd9158486e0cda0c4a94b4dd1dc;p=xestiaab%2F.git
diff --git a/source/contacteditor/frmContactEditorKey.cpp b/source/contacteditor/frmContactEditorKey.cpp
index 7234bbe..01de318 100644
--- a/source/contacteditor/frmContactEditorKey.cpp
+++ b/source/contacteditor/frmContactEditorKey.cpp
@@ -1,3 +1,21 @@
+// frmContactEditorKey.cpp - frmContactEditorKey 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 "frmContactEditorKey.h"
#include
#include "../common/textprocessing.h"
@@ -7,8 +25,13 @@ frmContactEditorKey::frmContactEditorKey( wxWindow* parent )
:
frmContactEditorKeyADT( parent )
{
+
+ // Setup the window.
+
EditorMode = FALSE;
- sliPriority->Disable();
+ priorityCtrl = new XABPriorityCtrl(tabGeneral);
+ szrGeneral->Add(priorityCtrl, 1, wxEXPAND, 5);
+ szrGeneral->Layout();
// Setup the control boxes and hide tabs unless they are
// needed.
@@ -19,26 +42,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
@@ -92,7 +112,8 @@ void frmContactEditorKey::SetEditorMode(bool EditMode)
striter = KeyListDataTypePtr->find(KeyListIndex);
- if (striter->first == KeyListIndex){
+ if (striter->first == KeyListIndex &&
+ striter != KeyListDataTypePtr->end()){
strValue = striter->second;
@@ -131,7 +152,8 @@ void frmContactEditorKey::SetEditorMode(bool EditMode)
striter = KeyListDataTypePtr->find(KeyListIndex);
- if (striter->first == KeyListIndex){
+ if (striter->first == KeyListIndex &&
+ striter != KeyListDataTypePtr->end()){
strValue = striter->second;
@@ -147,7 +169,8 @@ void frmContactEditorKey::SetEditorMode(bool EditMode)
striter = KeyListTypePtr->find(KeyListIndex);
- if (striter->first == KeyListIndex){
+ if (striter->first == KeyListIndex &&
+ striter != KeyListTypePtr->end()){
strValue = striter->second;
@@ -171,11 +194,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);
}
@@ -185,6 +208,9 @@ void frmContactEditorKey::SetEditorMode(bool EditMode)
void frmContactEditorKey::ProcessAction( wxCommandEvent& event )
{
+
+ // Process action.
+
long ListCtrlIndex;
int intKeyType = 0;
@@ -225,7 +251,7 @@ void frmContactEditorKey::ProcessAction( wxCommandEvent& event )
wxString wxSb64orig = txtKeyData->GetValue();
std::string base64new = std::string(wxSb64orig.mb_str());
- std::string base64enc = base64_encode(reinterpret_cast(base64new.c_str()), base64new.length());
+ std::string base64enc = base64_encode(reinterpret_cast(base64new.c_str()), (int)base64new.length());
wxString wxSb64key(base64enc.c_str(), wxConvUTF8);
KeyListPtr->insert(std::make_pair(KeyListIndex, wxSb64key));
@@ -258,10 +284,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 {
@@ -269,10 +295,6 @@ void frmContactEditorKey::ProcessAction( wxCommandEvent& event )
}
- if (chkUsePref->IsChecked()){
-
- }
-
this->Close();
} else if (EditorMode == TRUE){
@@ -307,7 +329,7 @@ void frmContactEditorKey::ProcessAction( wxCommandEvent& event )
wxString wxSb64orig = txtKeyData->GetValue();
std::string base64new = std::string(wxSb64orig.mb_str());
- std::string base64enc = base64_encode(reinterpret_cast(base64new.c_str()), base64new.length());
+ std::string base64enc = base64_encode(reinterpret_cast(base64new.c_str()), (int)base64new.length());
wxString wxSb64key(base64enc.c_str(), wxConvUTF8);
KeyListPtr->erase(KeyListIndex);
@@ -350,10 +372,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 {
@@ -369,27 +391,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();
@@ -411,6 +423,8 @@ void frmContactEditorKey::ProcessKeyType()
void frmContactEditorKey::ConvertURLType( wxCommandEvent& event )
{
+ // Convert the URL type.
+
wxString strValue;
strValue = cmbURL->GetString(cmbURL->GetCurrentSelection());
@@ -426,6 +440,8 @@ void frmContactEditorKey::ConvertURLType( wxCommandEvent& event )
void frmContactEditorKey::ConvertKeyType( wxCommandEvent& event )
{
+ // Convert the key type.
+
wxString strValue;
strValue = cmbKeyType->GetString(cmbKeyType->GetCurrentSelection());
@@ -440,7 +456,11 @@ void frmContactEditorKey::ConvertKeyType( wxCommandEvent& event )
void frmContactEditorKey::CloseWindow( wxCommandEvent& event )
{
+
+ // Close this window.
+
this->Close();
+
}
void frmContactEditorKey::SetupPointers(std::map *KeyList,
@@ -455,6 +475,8 @@ void frmContactEditorKey::SetupPointers(std::map *KeyList,
int KeyIndex )
{
+ // Setup the pointers.
+
KeyListPtr = KeyList;
KeyListAltIDPtr = KeyListAltID;
KeyListPIDPtr = KeyListPID;