1 // frmContactEditor-LoadGroup.cpp - frmContactEditor load group subroutines.
3 // (c) 2012-2015 Xestia Software Development.
5 // This file is part of Xestia Address Book.
7 // Xestia Address Book is free software: you can redistribute it and/or modify
8 // it under the terms of the GNU General Public License as published by the
9 // Free Software Foundation, version 3 of the license.
11 // Xestia Address Book is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
16 // You should have received a copy of the GNU General Public License along
17 // with Xestia Address Book. If not, see <http://www.gnu.org/licenses/>
19 #include "frmContactEditor.h"
20 #include "../common/dirs.h"
23 void frmContactEditor::LoadKind(wxString KindType){
25 if (KindType == wxT("individual")){
27 cmbType->SetSelection(1);
29 } else if (KindType == wxT("group")){
31 cmbType->SetSelection(2);
34 } else if (KindType == wxT("org")){
36 cmbType->SetSelection(3);
38 } else if (KindType == wxT("location")){
40 cmbType->SetSelection(4);
44 cmbType->SetSelection(0);
48 wxCommandEvent nullevent;
50 UpdateMembersTab(nullevent);
54 void frmContactEditor::LoadMember(wxString MemberData, int *GroupCount){
56 // Go through the list of contacts for the account and find the matching UID.
57 // If contact with UID doesn't match then say (unknown contact).
60 if (StartupEditMode == FALSE){
61 XVMData = MainPtr->GetViewMode();
64 wxString AccountDirFinal = GetAccountDir(wxSContactAccount, FALSE);
66 //wxString vcardfilenamewxs;
67 wxString vCardFilename;
68 wxString vCardFilenameFull;
69 wxString vCardDataString;
70 //wxStringTokenizer vcardfileline;
72 wxString setname, setvalue;
73 //vCardNames = new std::map<wxString, wxString, std::greater<wxString>>;
74 std::multimap<wxString, wxString, std::greater<wxString>> vCardNamesAsc;
75 std::multimap<wxString, wxString, std::less<wxString>> vCardNamesDsc;
77 wxDir vcardaccdir(AccountDirFinal);
79 bool ProcFiles = vcardaccdir.GetFirst(&vCardFilename, wxEmptyString, wxDIR_FILES);
82 if (vCardFilename.Right(4) == wxT(".vcf") ||
83 vCardFilename.Right(4) == wxT(".VCF") ||
84 vCardFilename.Right(5) == wxT(".vcard") ||
85 vCardFilename.Right(5) == wxT(".VCARD")){
89 vCardFilenameFull.Append(AccountDirFinal);
90 vCardFilenameFull.Append(wxT("/"));
91 vCardFilenameFull.Append(vCardFilename);
93 Person.LoadFile(vCardFilenameFull);
95 if (MemberData.Left(9) == wxT("urn:uuid:")){
97 wxString NewPropValue;
98 NewPropValue = MemberData.Mid(9, wxString::npos);
99 MemberData = NewPropValue;
103 if (Person.MeetBaseSpecification()){
105 wxString KindStatus = Person.Get(wxT("KIND"));
107 if (KindStatus == wxT("group")){
109 vCardFilename.Clear();
110 vCardFilenameFull.Clear();
111 vCardDataString.Clear();
112 ProcFiles = vcardaccdir.GetNext(&vCardFilename);
117 wxString PersonName = Person.Get(wxT("N"));
118 wxString PersonUID = Person.Get(wxT("UID"));
119 wxString PersonFilename = vCardFilenameFull;
121 if (PersonUID != MemberData){
123 vCardFilename.Clear();
124 vCardFilenameFull.Clear();
125 vCardDataString.Clear();
126 ProcFiles = vcardaccdir.GetNext(&vCardFilename);
131 //ContactsNames.insert(std::make_pair(PersonName, ContactIndex));
132 //ContactsUIDs.insert(std::make_pair(ContactIndex, PersonUID));
134 if (XVMData.SortMode == 1){
136 // Split the name into sections.
138 vCardDataString = Person.Get(wxT("N"));
140 vCardName NameData = Person.GetName();
142 vCardDataString = NameData.Forename + wxT(" ") + NameData.Surname;
144 } else if (XVMData.SortMode == 2){
146 // Split the name into sections.
148 vCardName NameData = Person.GetName();
150 vCardDataString = NameData.Surname + wxT(", ") + NameData.Forename;
152 } else if (XVMData.SortMode == 3){
154 // Check and make sure that the top most nickname is used.
156 vCardDataString = Person.Get(wxT("NICKNAME"));
158 if (vCardDataString.IsEmpty()){
160 vCardDataString = wxT("(no nickname)");
164 } else if (XVMData.SortMode == 4){
166 vCardDataString = Person.Get(wxT("FN"));
170 if (XVMData.AscendingMode == TRUE){
171 vCardNamesAsc.insert(std::make_pair(vCardDataString, PersonUID));
173 vCardNamesDsc.insert(std::make_pair(vCardDataString, PersonUID));
184 vCardFilename.Clear();
185 vCardFilenameFull.Clear();
186 vCardDataString.Clear();
187 ProcFiles = vcardaccdir.GetNext(&vCardFilename);
191 if (XVMData.AscendingMode == TRUE){
193 for (std::map<wxString,wxString>::iterator iter = vCardNamesAsc.begin();
194 iter != vCardNamesAsc.end(); ++iter){
199 ItemData.SetText(iter->first);
201 lboGroups->InsertItem(ItemData);
203 GroupsList.insert(std::make_pair(intValueSeek, iter->second));
210 for (std::map<wxString,wxString>::iterator iter = vCardNamesDsc.begin();
211 iter != vCardNamesDsc.end(); ++iter){
216 ItemData.SetText(iter->first);
218 lboGroups->InsertItem(ItemData);
220 GroupsList.insert(std::make_pair(intValueSeek, iter->second));