X-Git-Url: http://Server1/repobrowser/?a=blobdiff_plain;f=source%2FfrmMain.cpp;h=150e7f976c4d5e1d16fae6db882e7c26d36fcd58;hb=f4990ff8fd11ee3a231e93bd9ce0a1c4851d6ebb;hp=d49a44d0c4d1943676e93cc7b151143e0a911867;hpb=a217e7366f768d671fa325ebe8546d57ce9524e6;p=xestiaab%2F.git diff --git a/source/frmMain.cpp b/source/frmMain.cpp index d49a44d..150e7f9 100644 --- a/source/frmMain.cpp +++ b/source/frmMain.cpp @@ -1,3 +1,21 @@ +// frmMain.cpp - Main window 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 #include #include @@ -13,7 +31,7 @@ #include #include #include -//#include +#include // Include the forms. @@ -21,11 +39,11 @@ #include "frmAbout.h" #include "frmPreferences.h" #include "frmNewAccount.h" -#include "frmActivityMgr.h" +#include "actmgr/frmActivityMgr.h" #include "frmContact.h" #include "frmConflictResolution.h" #include "frmInvalidSSLCertificate.h" -#include "frmSearch.h" +#include "search/frmSearch.h" #include "frmSSLCertificate.h" #include "frmUpdate.h" #include "import/frmImportResults.h" @@ -40,6 +58,7 @@ #include "contacteditor/frmContactEditor.h" #include "import/import.h" #include "export/export.h" +#include "widgets/XABContactMenu.h" #include "widgets/XABAccountView.h" #include "version.h" @@ -53,7 +72,10 @@ DEFINE_EVENT_TYPE(CE_UPDATECONTACTLIST); DEFINE_EVENT_TYPE(CE_UPDATEACCOUNTLIST); DEFINE_EVENT_TYPE(SE_UPDATECONTACTNOTIF); DEFINE_EVENT_TYPE(CE_OPENCONTACT); +DEFINE_EVENT_TYPE(CE_OPENCONTACTLIST); +DEFINE_EVENT_TYPE(CE_NEWCONTACT); DEFINE_EVENT_TYPE(CE_EDITCONTACT); +DEFINE_EVENT_TYPE(CE_DELETECONTACT); DEFINE_EVENT_TYPE(CE_REVEALCONTACT); DEFINE_EVENT_TYPE(CE_REMOVECONTACT); DEFINE_EVENT_TYPE(CE_REMOVESEARCH); @@ -63,13 +85,14 @@ DEFINE_EVENT_TYPE(ACTMGR_SHUFFLE); DEFINE_EVENT_TYPE(ACTMGR_STOP); DEFINE_EVENT_TYPE(WINDOW_ADD); DEFINE_EVENT_TYPE(WINDOW_EDIT); -//DEFINE_EVENT_TYPE(WINDOW_DELETE); DEFINE_EVENT_TYPE(WINDOW_CLOSE); DEFINE_EVENT_TYPE(CONNSTAT_UPDATE); DEFINE_EVENT_TYPE(INVALIDSSLCERT); DEFINE_EVENT_TYPE(GETSELECTEDLIST); DEFINE_EVENT_TYPE(SYNCACCOUNT); DEFINE_EVENT_TYPE(IMPORT_RESULTSSHOW); +DEFINE_EVENT_TYPE(RELOADCONTACTLIST); +DEFINE_EVENT_TYPE(REFRESHADDRESSBOOK); BEGIN_EVENT_TABLE(frmMain, wxFrame) EVT_COMMAND(wxID_ANY, wxEVT_COMMAND_BUTTON_CLICKED, frmMain::ConflictResolution) @@ -77,7 +100,10 @@ EVT_COMMAND(wxID_ANY, CE_UPDATECONTACTLIST, frmMain::UpdateContactList) EVT_COMMAND(wxID_ANY, CE_UPDATEACCOUNTLIST, frmMain::UpdateAccountList) EVT_COMMAND(wxID_ANY, SE_UPDATECONTACTNOTIF, frmMain::UpdateSearchContactLists) EVT_COMMAND(wxID_ANY, CE_OPENCONTACT, frmMain::OpenContactInfo) +EVT_COMMAND(wxID_ANY, CE_OPENCONTACTLIST, frmMain::OpenContactInfoList) +EVT_COMMAND(wxID_ANY, CE_NEWCONTACT, frmMain::ShowContactEditorNew) EVT_COMMAND(wxID_ANY, CE_EDITCONTACT, frmMain::ShowContactEditorEdit) +EVT_COMMAND(wxID_ANY, CE_DELETECONTACT, frmMain::DeleteContact) EVT_COMMAND(wxID_ANY, CE_REVEALCONTACT, frmMain::RevealContact) EVT_COMMAND(wxID_ANY, CE_REMOVESEARCH, frmMain::RemoveContactsWindowPointer) EVT_COMMAND(wxID_ANY, SYNC_EMPTYSERVER, frmMain::EmptyServerDialog) @@ -92,6 +118,8 @@ EVT_COMMAND(wxID_ANY, INVALIDSSLCERT, frmMain::InvalidSSLCertificate) EVT_COMMAND(wxID_ANY, GETSELECTEDLIST, frmMain::GetSelectedList) EVT_COMMAND(wxID_ANY, SYNCACCOUNT, frmMain::SyncAccount) EVT_COMMAND(wxID_ANY, IMPORT_RESULTSSHOW, frmMain::ShowImportResults) +EVT_COMMAND(wxID_ANY, RELOADCONTACTLIST, frmMain::ReloadContactList) +EVT_COMMAND(wxID_ANY, REFRESHADDRESSBOOK, frmMain::RefreshAddressBook) END_EVENT_TABLE() frmMain::frmMain( wxWindow* parent ) @@ -198,29 +226,6 @@ frmMainADT( parent ) AccCtrl->SetPopupMaxHeight(175); AccCtrl->SetPopupMinWidth(250); treAccounts->AssignImageList(AccImgList); - //bmpIcon->Hide(); - - /*wxStaticBitmap* BeepBoop = new wxStaticBitmap(AccCtrl, wxID_ANY, wxNullBitmap, wxPoint(AccTextCtrlSize.GetX() + 3, AccTextCtrlSize.GetY() + 2), wxDefaultSize, 0); - - icons_accgroup_png.SetMask(new wxMask(icons_accgroup_png, wxSystemSettings::GetColour(wxSYS_COLOUR_BACKGROUND))); - - BeepBoop->SetBackgroundColour(AccCtrl->GetBackgroundColour()); - BeepBoop->SetBitmap(icons_accgroup_png);*/ - - //szrContactList->Insert(0, XABV2, 1, wxEXPAND | wxALL, 0); - - /*AccControl->UseAltPopupWindow(); - AccControl->SetPopupControl(treAccounts); - AccControl->SetPopupMaxHeight(175); - - treAccounts->AssignImageList(AccImgList); - szrContactList->Insert(0, AccControl, 1, wxEXPAND|wxALL, 0); - szrAccList->Add(AccIcon, 0, wxLEFT|wxTOP|wxEXPAND, 3); - - */ - - //szrContactList->Layout(); - //szrContactList->RecalcSizes(); wxListItem ColumnData; ColumnData.SetId(0); @@ -228,14 +233,6 @@ frmMainADT( parent ) ColumnData.SetWidth(320); lstContacts->InsertColumn(0, ColumnData); - //Connect(wxID_ANY, ContactConflictCmdEnv, - // ContactConflictEventHandler(frmMain::ConflictResolution), NULL, this); - - //Connect(wxID_ANY, MyFooCommandEvent, - // MyFooEventHandler(frmMain::DoSomething), NULL, this); - - //Bind(ContactConflictCmdEnv, ContactConflictEventHandler(frmMain::ConflictResolution), this, wxID_ANY); - treAccounts->Connect(wxEVT_LEFT_DCLICK, wxTreeEventHandler(frmMain::LoadContactList), NULL, this); treAccounts->Connect(wxEVT_TREE_SEL_CHANGED, wxTreeEventHandler(frmMain::LoadContactList), NULL, this); @@ -325,9 +322,30 @@ frmMainADT( parent ) } +void frmMain::QuitApp( wxCloseEvent& event ) +{ + + QuitApp(); + +} + void frmMain::QuitApp( wxCommandEvent& event ) { + + QuitApp(); + +} + +void frmMain::QuitApp() +{ + //------------------------------------------------------------------- + // frmMain::QuitApp: Quits the application by simply closing this + // window which causes the exit as frmMain is the main window. + // + // wxCommandEvent Accepts a referenced event command. //------------------------------------------------------------------- + + //------------------------------------------------------------------- // frmMain::QuitApp: Quits the application by simply closing this // window which causes the exit as frmMain is the main window. // @@ -396,17 +414,6 @@ void frmMain::QuitApp( wxCommandEvent& event ) std::exit(0); -} - -void frmMain::QuitApp() -{ - //------------------------------------------------------------------- - // frmMain::QuitApp: Quits the application by simply closing this - // window which causes the exit as frmMain is the main window. - // - // wxCommandEvent Accepts a referenced event command. - //------------------------------------------------------------------- - Close(); } @@ -605,14 +612,12 @@ void frmMain::LoadContactList( wxTreeEvent& event ) ContactsFileIndex.Clear(); - //wxString vcardfilenamewxs; wxString vCardFilename; wxString vCardFilenameFull; wxString vCardDataString; wxStringTokenizer vcardfileline; wxString lwxs; wxString setname, setvalue; - //vCardNames = new std::map>; std::multimap> vCardNamesAsc; std::multimap> vCardNamesDsc; long ContactIndex = 1; @@ -632,8 +637,7 @@ void frmMain::LoadContactList( wxTreeEvent& event ) std::multimap::iterator AGTiter = AccountGroupTreeId.find(ActiveItemId); std::multimap::iterator AGFiter = AccountGroupFilename.find(AGTiter->second); - //std::multimap::iterator AGFiter = AccountGroupTreeId.find(ActiveItemId); - + Group.LoadFile(AGFiter->second); ArrayvCardOutData vCardMember = Group.GetByPartial(wxT("MEMBER")); @@ -760,7 +764,6 @@ void frmMain::LoadContactList( wxTreeEvent& event ) vCard Person; vCardFilenameFull.Append(AccountDirFinal); - vCardFilenameFull.Append(wxT("/")); vCardFilenameFull.Append(vCardFilename); Person.LoadFile(vCardFilenameFull); @@ -872,8 +875,6 @@ void frmMain::ShowContactInfo( wxListEvent& event ) long intSelected = -1; long ContactSeekNum = -1; - // intSelected = lstContacts->GetSelection(); - // Check if several contacts have been selected. int ContactTotal = 0; @@ -995,8 +996,6 @@ void frmMain::ShowContactInfo( wxListEvent& event ) if (wxSPropertyNextLine.Mid(0, 1) == wxT(" ") || wxSPropertyNextLine.Mid(0, 1) == wxT("\t")){ wxSPropertyNextLine.Remove(0, 1); - //wxSPropertyNextLine.Trim(FALSE); - //ContactLine.Trim(); ContactLine.Append(wxSPropertyNextLine); } else { @@ -1143,9 +1142,7 @@ void frmMain::ShowContactEditorEdit( wxCommandEvent& event ) long intSelected = -1; long intContactSeekNum = -1; - - // intSelected = lstContacts->GetSelection(); - + intSelected = lstContacts->GetNextItem(intSelected, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED); @@ -1237,7 +1234,7 @@ void frmMain::RefreshAddressBook( wxCommandEvent& event ){ } -void frmMain::OpenContactInfo( wxListEvent& event ) +void frmMain::OpenContactInfoList( wxListEvent& event ) { wxStringTokenizer vcardfileline; @@ -1294,6 +1291,13 @@ void frmMain::OpenContactInfo( wxListEvent& event ) } +void frmMain::OpenContactInfoList( wxCommandEvent& event ){ + + wxListEvent pevent; + OpenContactInfoList(pevent); + +} + void frmMain::OpenContactInfo( wxCommandEvent& event ) { @@ -1305,7 +1309,6 @@ void frmMain::OpenContactInfo( wxCommandEvent& event ) wxString setname, setvalue; vCard Person; wxString nextchar; - //std::fstream vcardfile; Person.LoadFile(uc->ContactFilename); @@ -1385,12 +1388,6 @@ void frmMain::LoadPreferences(){ AccountSyncTimers.clear(); - /* - for (int i = (preferences.accounts.GetCount() - 1); i > 0; --i){ - treAccounts->AppendItem(RootNode, preferences.accounts.GetAccountName(i)); - } - */ - wxString AccDir; wxString AccDirFull; wxString AccDirFullSfx; @@ -1434,7 +1431,7 @@ void frmMain::LoadPreferences(){ if (preferences.accounts.GetAccountType(i) == wxT("CardDAV") || preferences.accounts.GetAccountType(i) == wxT("carddav")){ - // Check if the directory exists before doing anything. + // TODO: Check if the directory exists before doing anything. @@ -1470,8 +1467,7 @@ void frmMain::LoadPreferences(){ wxString vCardFilename; wxString vCardDataString; wxString vCardFilenameFull; - //bool ProcFiles = FALSE; - + bool ProcFiles = vcardaccdir.GetFirst(&vCardFilename, wxEmptyString, wxDIR_FILES); while(ProcFiles){ @@ -1542,11 +1538,7 @@ void frmMain::ConflictResolution(wxCommandEvent& event){ vCardConflictObj *vCardConfObj = (vCardConflictObj*)event.GetClientData(); vCard *ClientDataPtr = vCardConfObj->vCardLocalData; vCard *ServerDataPtr = vCardConfObj->vCardServerData; - //vCard *ServerDataPtr = vCardConfObj->vCardServerData; - //wxString Moo = ClientDataPtr->WriteString(); - //vCard *ServerDataPtr = vCardConfObj->vCardServerData; frameCR->LoadData(ClientDataPtr, ServerDataPtr, &MemoryFileList); - //frameCR->LoadData(vCardConfObj->vCardLocalData, vCardConfObj->vCardServerData, &MemoryFileList); frameCR->ShowModal(); int FinalConflictResult = frameCR->GetResult(); @@ -1798,7 +1790,6 @@ void frmMain::OpenFindContactsWindow(wxCommandEvent& event){ void frmMain::RemoveContactsWindowPointer(wxCommandEvent& event){ - //frmSearch *frameSCH = static_cast(ActMgrPtr); void *frameSCH = (void*)event.GetClientData(); SearchWindowList.erase(frameSCH); @@ -1817,20 +1808,6 @@ void frmMain::RemoveContactEditorWindowPointer(wxCommandEvent& event){ } -void frmMain::UpdateWindowList(wxCommandEvent& event){ - - // Update the Window List. - - // Delete the existing items in the window menu. - - // Get the list of contacts. - - // Insert a separator. - - // Get the list of search windows. - -} - void frmMain::RevealContact(wxCommandEvent& event){ UCNotif *uc = (UCNotif*)event.GetClientData(); @@ -1884,15 +1861,17 @@ void frmMain::RevealContact(wxCommandEvent& event){ // If they match then select it. if (ContactsFileIndex[intSelectedData] == uc->ContactFilename){ - + // Select. lstContacts->SetItemState(longSelected, wxLIST_STATE_SELECTED, wxLIST_STATE_SELECTED); lstContacts->EnsureVisible(longSelected); - break; - - } + } else { + + lstContacts->SetItemState(longSelected, 0, wxLIST_STATE_SELECTED); + + } } @@ -2341,15 +2320,7 @@ void frmMain::WindowEdit( wxCommandEvent &event ){ std::map::iterator MenuIter = WindowListPointersMenu.find(WData->WindowID); MenuIter->second->SetItemLabel(WindowTitle); - - //mnuWindow->FindChildItem(intID, &pos); - //wxMenuItem *mnuNewItem = new wxMenuItem(NULL, WData->WindowID, WindowTitle, WData->WindowID), wxEmptyString, wxITEM_NORMAL, NULL); - //mnuNewItem->SetId(WData->WindowID); - //ContactWindowListPointersMenu.insert(std::make_pair(WData->WindowID, mnuNewItem)); - //ContactWindowListPointers.insert(std::make_pair(WData->WindowID, WData->WindowPointer)); - //mnuWindow->Insert((pos + 1), mnuNewItem); - //this->Connect(mnuNewItem->GetId(), wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(frmMain::ShowContactWindow)); - + } else if (WData->DataType == 1){ // Get the window title and use that. @@ -2370,14 +2341,6 @@ void frmMain::WindowEdit( wxCommandEvent &event ){ } - //mnuWindow->FindChildItem(intID, &pos); - //wxMenuItem *mnuNewItem = new wxMenuItem(NULL, WData->WindowID, WindowTitle, WData->WindowID), wxEmptyString, wxITEM_NORMAL, NULL); - //mnuNewItem->SetId(WData->WindowID); - //ContactEditorWindowListPointersMenu.insert(std::make_pair(WData->WindowID, mnuNewItem)); - //ContactEditorWindowListPointers.insert(std::make_pair(WData->WindowID, WData->WindowPointer)); - //mnuWindow->Insert((pos + 1), mnuNewItem); - //this->Connect(mnuNewItem->GetId(), wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(frmMain::ShowContactEditorWindow)); - } delete WData; @@ -2760,10 +2723,10 @@ void frmMain::GetSelectedList( wxCommandEvent& event ){ void frmMain::SyncAccount( wxCommandEvent& event ){ - wxString *AccNameInc = (wxString*)event.GetClientData(); + wxString AccNameInc = event.GetString(); frmActivityMgr *frameActMgr = static_cast(ActMgrPtr); - frameActMgr->AddTask(3, wxT(""), *AccNameInc, + frameActMgr->AddTask(3, wxT(""), AccNameInc, wxT(""), wxT(""), wxT(""), wxT("")); } @@ -2827,4 +2790,34 @@ void frmMain::ShowImportResults( wxCommandEvent &event ){ delete ResultData; ResultData = NULL; +} + +void frmMain::ReloadContactList( wxCommandEvent &event ){ + + // Check if the account name given is the current + // account selected. + + if (ActiveAccount == event.GetString()){ + + wxTreeEvent NullEvent; + LoadContactList(NullEvent); + + } + +} + +void frmMain::ShowContactMenu( wxMouseEvent& event ){ + + bool EnableRefresh = FALSE; + + if (!ActiveAccount.IsEmpty()){ + + EnableRefresh = TRUE; + + } + + ContactMenu->SetupPointers(this, lstContacts, EnableRefresh); + + this->PopupMenu(ContactMenu->MenuPointer(), wxDefaultPosition); + } \ No newline at end of file