Upstream tarball 20080418
[amule.git] / src / SearchDlg.h
blob87236e9b024a3eba66a19072bb0b48711e3726f8
1 //
2 // This file is part of the aMule Project.
3 //
4 // Copyright (c) 2003-2008 aMule Team ( admin@amule.org / http://www.amule.org )
5 // Copyright (c) 2002 Merkur ( devs@emule-project.net / http://www.emule-project.net )
6 //
7 // Any parts of this program derived from the xMule, lMule or eMule project,
8 // or contributed by third-party developers are copyrighted by their
9 // respective authors.
11 // This program is free software; you can redistribute it and/or modify
12 // it under the terms of the GNU General Public License as published by
13 // the Free Software Foundation; either version 2 of the License, or
14 // (at your option) any later version.
16 // This program is distributed in the hope that it will be useful,
17 // but WITHOUT ANY WARRANTY; without even the implied warranty of
18 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 // GNU General Public License for more details.
20 //
21 // You should have received a copy of the GNU General Public License
22 // along with this program; if not, write to the Free Software
23 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
26 #ifndef SEARCHDLG_H
27 #define SEARCHDLG_H
29 #include <wx/panel.h> // Needed for wxPanel
31 #include "Types.h" // Needed for uint16 and uint32
34 class CMuleNotebook;
35 class CSearchListCtrl;
36 class CMuleNotebookEvent;
37 class wxListEvent;
38 class wxNotebookEvent;
39 class wxSpinEvent;
40 class wxGauge;
41 class CSearchFile;
44 /**
45 * This class represents the Search Dialog, which takes care of
46 * enabling the user to search and to display results in a readable
47 * manner.
49 class CSearchDlg : public wxPanel
51 public:
52 /**
53 * Constructor.
55 * @param pParent The parent widget passed to the wxPanel constructor.
57 CSearchDlg(wxWindow* pParent);
59 /**
60 * Destructor.
62 ~CSearchDlg();
65 /**
66 * Adds the provided result to the right result-list.
68 * Please note that there is no duplicates checking, so the files should
69 * indeed be a new result.
71 void AddResult(CSearchFile* toadd);
73 /**
74 * Updates a changed result.
76 * @param A pointer to the updated CSearchFile.
78 * This function will update the source-count and color of the result, and
79 * if needed, it will also move the result so that the current sorting
80 * is maintained.
82 void UpdateResult(CSearchFile* toupdate);
84 /**
85 * Checks if a result-page with the specified heading exists.
87 * @param searchString The heading to look for.
89 bool CheckTabNameExists(const wxString& searchString);
91 /**
92 * Creates a new tab and displays the specified results.
94 * @param searchString This will be the heading of the new page.
95 * @param nSearchID The results with this searchId will be displayed.
97 void CreateNewTab(const wxString& searchString, wxUIntPtr nSearchID);
101 * Call this function to signify that the local search is over.
103 void LocalSearchEnd();
107 * Call this function to signify that the kad search is over.
109 void KadSearchEnd(uint32 id);
113 * This function updates the category list according to existing categories.
115 void UpdateCatChoice();
119 * This function displays the the hit-count in the heading for the specified page.
121 * @param page The page to have its heading updated.
123 void UpdateHitCount(CSearchListCtrl* page);
126 * Helper function which resets the controls.
128 void ResetControls();
130 // Event handler and helper function
131 void OnBnClickedDownload(wxCommandEvent& ev);
133 CSearchListCtrl* GetSearchList( wxUIntPtr id );
135 void UpdateProgress(uint32 new_value);
137 void StartNewSearch();
139 private:
140 // Event handlers
141 void OnFieldChanged(wxEvent& evt);
143 void OnListItemSelected(wxListEvent& ev);
144 void OnBnClickedReset(wxCommandEvent& ev);
145 void OnBnClickedClear(wxCommandEvent& ev);
146 void OnExtendedSearchChange(wxCommandEvent& ev);
147 void OnFilterCheckChange(wxCommandEvent& ev);
148 void OnFilteringChange(wxCommandEvent& ev);
150 void OnSearchClosing(wxNotebookEvent& evt);
152 void OnBnClickedStart(wxCommandEvent& evt);
153 void OnBnClickedStop(wxCommandEvent& evt);
157 * Event-handler for page-chages which takes care of enabling/disabling the download button.
159 void OnSearchPageChanged(wxNotebookEvent& evt);
161 uint32 m_last_search_time;
163 wxGauge* m_progressbar;
165 CMuleNotebook* m_notebook;
167 DECLARE_EVENT_TABLE()
170 #endif
171 // File_checked_for_headers