Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | File Members

lvwSums.hpp

Go to the documentation of this file.
00001 /* 00002 * wxChecksums 00003 * Copyright (C) 2003-2004 Julien Couot 00004 * 00005 * This program is free software; you can redistribute it and/or 00006 * modify it under the terms of the GNU General Public License 00007 * as published by the Free Software Foundation; either version 2 00008 * of the License, or (at your option) any later version. 00009 * 00010 * This program is distributed in the hope that it will be useful, 00011 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00013 * GNU General Public License for more details. 00014 * 00015 * You should have received a copy of the GNU General Public License 00016 * along with this program; if not, write to the Free Software 00017 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 00018 */ 00019 00020 /** 00021 * \file lvwSums.hpp 00022 * A personalized listview to display information about checksums. 00023 */ 00024 00025 #ifndef INC_LVWSUMS_HPP 00026 #define INC_LVWSUMS_HPP 00027 00028 //--------------------------------------------------------------------------- 00029 // For compilers that support precompilation, includes "wx.h". 00030 #include <wx/wxprec.h> 00031 00032 #ifdef __BORLANDC__ 00033 #pragma hdrstop 00034 #endif 00035 00036 #ifndef WX_PRECOMP 00037 // Include your minimal set of headers here, or wx.h 00038 #include <wx/wx.h> 00039 #endif 00040 #include <wx/listctrl.h> 00041 #include "sumfile.hpp" 00042 //--------------------------------------------------------------------------- 00043 00044 /// Number of columns in the list of checksums. 00045 #define LVW_SUMS_NBCOLS 4 00046 00047 /** 00048 * The list that will display information about checksums. 00049 */ 00050 class ChecksumsListView : public wxListView 00051 { 00052 public: 00053 // Default constructor 00054 ChecksumsListView(); 00055 00056 // Creates a new list 00057 ChecksumsListView(wxWindow* parent, wxWindowID id, 00058 SumFile* checksumFile, 00059 const wxPoint& pos = wxDefaultPosition, 00060 const wxSize& size = wxDefaultSize, 00061 long style = wxLC_REPORT, 00062 const wxValidator& validator = wxDefaultValidator, 00063 const wxString& name = wxT("checksumslistview")); 00064 00065 // Destructor 00066 virtual ~ChecksumsListView(); 00067 00068 // Initializes the list parameters 00069 void init(); 00070 00071 00072 //------------------------------------------ 00073 // Operations on columns 00074 00075 /// Sort order of the column 00076 enum SortOrder 00077 { 00078 NONE, 00079 ASCENDING, 00080 DESCENDING, 00081 }; 00082 00083 /// Columns enumeration. 00084 enum Columns 00085 { 00086 FILE_NAME = 0, 00087 DIRECTORY, 00088 CHECKSUM_VALUE, 00089 STATE 00090 }; 00091 00092 // Gets to sort order 00093 SortOrder getSortOrder() const; 00094 00095 // Sets the sort order 00096 void setSortOrder(const SortOrder newSortOrder); 00097 00098 // Gets the column to be sorted 00099 int getColumnToSort() const; 00100 00101 // Sets the column to be sorted 00102 void setColumnToSort(const int col); 00103 00104 // Sets the column to be sorted 00105 void setColumnToSort(const int col, const SortOrder newSortOrder); 00106 00107 // Sort the list 00108 void sort(); 00109 00110 protected: 00111 /** 00112 * List of the columns (size = nb elements of enum Columns). 00113 * 00114 * Must contain once one of the elements of enum Columns. 00115 */ 00116 Columns columns[LVW_SUMS_NBCOLS]; 00117 00118 // Reformats the list. 00119 void reformat(Columns oldColumns[LVW_SUMS_NBCOLS]); 00120 00121 public: 00122 // Gets the name of a column. 00123 static wxString getColumnName(const Columns col); 00124 00125 // Gets the columns. 00126 void getColumns(Columns cols[LVW_SUMS_NBCOLS]); 00127 00128 // Sets the columns. 00129 bool setColumns(Columns newColumns[LVW_SUMS_NBCOLS]); 00130 00131 00132 //------------------------------------------ 00133 // Operations on the list 00134 00135 // Selects all the items 00136 void selectAll(); 00137 00138 // Inverts the selection 00139 void invertSelection(); 00140 00141 // Reformats the list. 00142 void reformat(); 00143 00144 00145 //------------------------------------------ 00146 // Operations on the checksums 00147 00148 // Gets a pointer on the checksum file. 00149 SumFile* getSumFile() const; 00150 00151 // Sets the checksum file. 00152 void setSumFile(SumFile* pSumFile); 00153 00154 // Checks the files. 00155 void check(); 00156 00157 // Recompute the checksums 00158 void recompute(); 00159 00160 protected: 00161 // Adds a checksum in the list 00162 long addChecksum(const long key, const wxString& stateMsg); 00163 00164 // Sets an item. 00165 void setChecksum(long item, const wxString& stateMsg); 00166 00167 // Sets the state of a checksum 00168 void setChecksumState(long item, const ChecksumData::State state, const wxString& msg); 00169 00170 // Indicates if the specified file is present in the list of checksums. 00171 bool isInList(const wxString& fileName); 00172 00173 // Removes the files that are already in the list 00174 bool removeFilesInList(wxArrayString& files, wxArrayString* in = NULL); 00175 00176 public: 00177 // Removes selected chechsum from the list 00178 void removeSelectedChecksums(); 00179 00180 // Gets the total of each state in the list of checksums. 00181 wxArrayInt getStates(const bool onlySelected = false) const; 00182 00183 // Sums up the total of each state in the list of checksums. 00184 wxString sumUpStates(const bool onlySelected = false) const; 00185 00186 //------------------------------------------ 00187 // Other operations 00188 00189 // Open a dialog to select the files to add to the list 00190 void selectFilesToAdd(); 00191 00192 // Open a dialog to select the directories to add to the list 00193 void selectDirectoriesToAdd(); 00194 00195 // Open a dialog to select files to add from matching patterns 00196 void selectMatchingFilesToAdd(); 00197 00198 // Adds files to the list of checksums. 00199 void addFiles(const wxArrayString& files); 00200 00201 // Processes a drop of files on the list. 00202 void DnDFiles(wxCommandEvent& event); 00203 00204 // Open a checksum file 00205 bool openChecksumFile(const wxFileName& fileName); 00206 00207 protected: 00208 SumFile* sumFile; ///< Checksums file linked with the list. 00209 SortOrder sortOrder; ///< Sort order 00210 int colToSort; ///< Column to sort 00211 00212 #if defined(__WXMSW__) 00213 // Event handler for the context menu demand. 00214 void OnContextMenu(wxContextMenuEvent& event); 00215 #else 00216 // Event handler for the context menu demand. 00217 void OnRightUp(wxMouseEvent& event); 00218 #endif // defined(__WXMSW__) 00219 // Shows the context menu. 00220 void ShowContextMenu(const wxPoint& p); 00221 00222 // Event handler for a key pressed. 00223 //void KeyPressed(wxKeyEvent& event); 00224 00225 // Event handler a pop-up menu click on 'Add files...'. 00226 void itpAddFilesClick(wxCommandEvent& event); 00227 // Event handler a pop-up menu click on 'Add directories...'. 00228 void itpAddDirectoriesClick(wxCommandEvent& event); 00229 // Event handler a pop-up menu click on 'Add matching files...'. 00230 void itpAddMatchingFilesClick(wxCommandEvent& event); 00231 // Event handler a pop-up menu click on 'Remove'. 00232 void itpRemoveClick(wxCommandEvent& event); 00233 00234 enum 00235 { 00236 ITP_FILESADD = wxID_HIGHEST + 1000, 00237 ITP_DIRECTORIESADD, 00238 ITP_ADDMATCHINGFILES, 00239 ITP_REMOVE 00240 }; 00241 00242 DECLARE_EVENT_TABLE() 00243 00244 private: 00245 DECLARE_DYNAMIC_CLASS(ChecksumsListView) 00246 00247 // Progress updater 00248 class ChecksumProgress; 00249 }; 00250 //--------------------------------------------------------------------------- 00251 00252 00253 /* 00254 * Defines a custom event for updating the dialog title. 00255 * Use this event when a child want the dialog title to be updated. 00256 */ 00257 BEGIN_DECLARE_EVENT_TYPES() 00258 DECLARE_LOCAL_EVENT_TYPE(EVENT_UPDATE_SUMS_FRAME_TITLE_COMMAND, 11001) 00259 END_DECLARE_EVENT_TYPES() 00260 00261 /* 00262 * Defines a custom event for updating the status bar. 00263 * Use this event when a child want the dialog status bar to be updated. 00264 */ 00265 BEGIN_DECLARE_EVENT_TYPES() 00266 DECLARE_LOCAL_EVENT_TYPE(EVENT_UPDATE_SUMS_FRAME_STATUSBAR_COMMAND, 11002) 00267 END_DECLARE_EVENT_TYPES() 00268 00269 /* 00270 * Defines a custom event for adding a file in the open recently file list. 00271 */ 00272 BEGIN_DECLARE_EVENT_TYPES() 00273 DECLARE_LOCAL_EVENT_TYPE(EVENT_OPEN_RECENT_ADD_FILE, 11003) 00274 END_DECLARE_EVENT_TYPES() 00275 00276 00277 #endif // INC_LVWSUMS_HPP

Generated on Sun May 30 13:37:45 2004 for wxChecksums by doxygen 1.3.7