2 // This file is part of the aMule Project.
4 // Copyright (c) 2003-2011 aMule Team ( admin@amule.org / http://www.amule.org )
5 // Copyright (c) 2002-2011 Merkur ( devs@emule-project.net / http://www.emule-project.net )
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
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.
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 #include "muuli_wdr.h" // Needed for ID_CLOSEWNDFD
27 #include "FileDetailListCtrl.h" // Interface declarations
29 #define wxLIST_STATE_DESELECTED 0x0000
31 BEGIN_EVENT_TABLE(CFileDetailListCtrl
, CMuleListCtrl
)
32 EVT_LIST_ITEM_SELECTED(IDC_LISTCTRLFILENAMES
, CFileDetailListCtrl::OnSelect
) // Care for single selection
36 CFileDetailListCtrl::CFileDetailListCtrl(wxWindow
* &parent
, int id
, const wxPoint
& pos
, wxSize siz
, int flags
):CMuleListCtrl(parent
, id
, pos
, siz
, flags
)
38 // Set sorter function
39 SetSortFunc(SortProc
);
41 // Initial sorting: Sources descending
42 InsertColumn(0, _("File Name"), wxLIST_FORMAT_LEFT
, 370);
43 InsertColumn(1, _("Sources"), wxLIST_FORMAT_LEFT
, 70);
45 SetSorting(1, CMuleListCtrl::SORT_DES
);
50 int CFileDetailListCtrl::SortProc(wxUIntPtr param1
, wxUIntPtr param2
, long sortData
)
52 // Comparison for different sortings
53 SourcenameItem
*item1
= (SourcenameItem
*)param1
;
54 SourcenameItem
*item2
= (SourcenameItem
*)param2
;
56 int mod
= (sortData
& CMuleListCtrl::SORT_DES
) ? -1 : 1;
58 switch (sortData
& CMuleListCtrl::COLUMN_MASK
) {
59 case 1: return mod
* (item1
->count
- item2
->count
); // Sources descending
60 case 0: return mod
* item1
->name
.CmpNoCase(item2
->name
); // Name descending
66 void CFileDetailListCtrl::OnSelect(wxListEvent
& event
)
68 // Damn wxLC_SINGLE_SEL does not work! So we have to care for single selection ourselfs:
69 long realpos
= event
.m_itemIndex
;
72 // Loop through all selected items
73 pos
= GetNextItem(pos
, wxLIST_NEXT_ALL
, wxLIST_STATE_SELECTED
);
74 if (pos
!= realpos
&& pos
!= -1) {
75 // Deselect all items except the one we have just clicked
76 SetItemState(pos
, wxLIST_STATE_DESELECTED
, wxLIST_STATE_SELECTED
);
82 // File_checked_for_headers