///////////////////////////////////////////////////////////////////////////// // $Header: $ // $Log: $ #include "stdwx.h" #include "DlgSearch.h" #include "DlgConfig.h" #include // WDR: class implementations //---------------------------------------------------------------------------- // scDlgSearch //---------------------------------------------------------------------------- // WDR: event table for scDlgSearch BEGIN_EVENT_TABLE(scDlgSearch,wxDialog) EVT_BUTTON( ID_SEARCH, scDlgSearch::OnSearch ) EVT_LIST_ITEM_RIGHT_CLICK( ID_LISTE, scDlgSearch::OnClick ) EVT_CLOSE(scDlgSearch::OnCloseWindow) EVT_BUTTON( ID_OPEN, scDlgSearch::OnOpen ) EVT_BUTTON( ID_CLOSE, scDlgSearch::OnClose ) EVT_BUTTON( ID_CONFIG, scDlgSearch::OnConfig ) EVT_LIST_ITEM_ACTIVATED( ID_LISTE, scDlgSearch::OnActivated ) END_EVENT_TABLE() scDlgSearch::scDlgSearch( wxWindow *parent, wxWindowID id, const wxString &title, const wxPoint &position, const wxSize& size, long style ) : wxDialog( parent, id, title, position, size, style ) { // WDR: dialog function createDlgSearch for scDlgSearch createDlgSearch( this, TRUE ); getListe()->InsertColumn (0, "Rang"); getListe()->InsertColumn (1, "Titel"); getListe()->InsertColumn (2, "Pfad"); } // WDR: handler implementations for scDlgSearch void scDlgSearch::OnActivated( wxListEvent &event ) { Open(); } void scDlgSearch::OnConfig( wxCommandEvent &event ) { int i; scDlgConfig dlgConfig (this, -1, "Konfiguration"); dlgConfig.m_strPath = wxGetApp().m_pConfig->Read ("executable", ""); long n = wxGetApp().m_pConfig->Read ("count", long(0)); for (i=0; iRead (s, ""); wxLogDebug (s); dlgConfig.m_astrIndex.Add (s); s.Printf ("active-%d", i); s = wxGetApp().m_pConfig->Read (s, ""); dlgConfig.m_astrAktiv.Add (s); } if (dlgConfig.ShowModal() != wxID_OK) return ; wxGetApp().m_pConfig->Write ("executable", dlgConfig.m_strPath); wxGetApp().m_pConfig->Write ("count", (long)dlgConfig.m_astrIndex.Count()); wxString s; for (i=0; iWrite (s, dlgConfig.m_astrIndex[i]); s.Printf ("active-%d", i); wxGetApp().m_pConfig->Write (s, dlgConfig.m_astrAktiv[i]); } } void scDlgSearch::OnClose( wxCommandEvent &event ) { EndModal (wxID_OK); } void scDlgSearch::OnOpen( wxCommandEvent &event ) { Open(); } void scDlgSearch::Open( ) { long nSel = -1; for (long i = 0 ; i< getListe()->GetItemCount(); i++) { if (( getListe()->GetItemState(i, wxLIST_STATE_SELECTED) & wxLIST_STATE_SELECTED) == wxLIST_STATE_SELECTED) nSel = i; } if (-1 == nSel) return; wxFileName FileName (m_File[nSel]); wxMimeTypesManager MimeTypes; wxFileType* Type = MimeTypes.GetFileTypeFromExtension(FileName.GetExt()); if (Type != NULL) { wxExecute (Type->GetOpenCommand(FileName.GetFullPath())); } } void scDlgSearch::OnClick( wxListEvent &event ) { if (event.GetIndex() < 0) return; wxFileName FileName (m_File[event.GetIndex()]); wxMimeTypesManager MimeTypes; wxFileType* Type = MimeTypes.GetFileTypeFromExtension(FileName.GetExt()); if (Type != NULL) { // wxMessageBox (Type->GetOpenCommand(FileName.GetFullPath())); wxExecute (Type->GetOpenCommand(FileName.GetFullPath())); } } void scDlgSearch::OnCloseWindow(wxCloseEvent& event) { Destroy(); } void scDlgSearch::OnSearch( wxCommandEvent &event ) { wxArrayString output; int i; wxString command; command = wxGetApp().m_pConfig->Read ("executable", ""); command += wxString (" -w \"") + getMuster()->GetValue() + wxString ("\" "); long n = wxGetApp().m_pConfig->Read ("count", long(0)); for (i=0; iRead (s, ""); if (s == "1") { s.Printf ("index-%d", i); s = wxGetApp().m_pConfig->Read (s, ""); command += " -f " + s; } } command += wxString (" -x \"°°\n\""); wxExecute(command, output); wxString s; getListe()->DeleteAllItems(); m_File.Empty(); int nLine = 0; for (int i=0; iInsertItem (nLine, token); else if (j == 1) getListe()->SetItem (nLine, j, token); else if (j == 2) { wxFileName FileName (token); m_File.Add (FileName.GetFullPath()); getListe()->SetItem (nLine, j, FileName.GetFullPath()); } j++; } nLine ++; } } getListe()->SetItemState(0,wxLIST_STATE_SELECTED, wxLIST_STATE_SELECTED); }