Changeset 2469
- Timestamp:
- Jul 23, 2007, 9:01:26 PM (16 years ago)
- Location:
- trunk/wx
- Files:
-
- 2 added
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wx/Makefile.am
r2465 r2469 5 5 bin_PROGRAMS = Xmission 6 6 7 Xmission_SOURCES = xmission.cc torrent-list.cc 7 Xmission_SOURCES = \ 8 xmission.cc \ 9 torrent-filter.cc \ 10 torrent-list.cc 8 11 9 12 Xmission_LDADD = ../libtransmission/libtransmission.a @WX_LIBS@ $(PTHREAD_LIBS) -lm -
trunk/wx/torrent-list.cc
r2466 r2469 166 166 167 167 BEGIN_EVENT_TABLE(TorrentListCtrl, wxListCtrl) 168 EVT_LIST_COL_CLICK(TORRENT_LIST_CTRL, TorrentListCtrl::OnSort) 168 EVT_LIST_COL_CLICK( TORRENT_LIST_CTRL, TorrentListCtrl::OnSort ) 169 EVT_LIST_ITEM_SELECTED( TORRENT_LIST_CTRL, TorrentListCtrl::OnItemSelected ) 170 EVT_LIST_ITEM_DESELECTED( TORRENT_LIST_CTRL, TorrentListCtrl::OnItemDeselected ) 169 171 END_EVENT_TABLE() 170 172 … … 174 176 const wxPoint & pos, 175 177 const wxSize & size): 176 wxListCtrl( parent, TORRENT_LIST_CTRL, pos, size, wxLC_REPORT |wxLC_SINGLE_SEL),178 wxListCtrl( parent, TORRENT_LIST_CTRL, pos, size, wxLC_REPORT ), 177 179 myHandle( handle ), 178 180 myConfig( config ) … … 318 320 } 319 321 322 /*** 323 **** 324 ***/ 325 326 void 327 TorrentListCtrl :: OnSort( wxListEvent& event ) 328 { 329 const int_v cols = getTorrentColumns( myConfig ); 330 const int key = cols[ event.GetColumn() ]; 331 Sort( key ); 332 } 333 334 void 335 TorrentListCtrl :: OnItemSelected( wxListEvent& event ) 336 { 337 std::set<tr_torrent_t*> sel; 338 long item = -1; 339 for ( ;; ) { 340 item = GetNextItem(item, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED); 341 if ( item == -1 ) 342 break; 343 sel.insert( myTorrents[GetItemData(item)] ); 344 } 345 fire_selection_changed( sel ); 346 } 347 348 void 349 TorrentListCtrl :: OnItemDeselected( wxListEvent& event ) 350 { 351 OnItemSelected( event ); 352 } 353 354 /*** 355 **** 356 ***/ 357 320 358 static torrents_t * uglyHack = NULL; 321 359 … … 414 452 415 453 return ret; 416 }417 418 void419 TorrentListCtrl :: OnSort( wxListEvent& event )420 {421 const int_v cols = getTorrentColumns( myConfig );422 const int key = cols[ event.GetColumn() ];423 Sort( key );424 454 } 425 455 … … 453 483 uglyHack = NULL; 454 484 } 485 486 /*** 487 **** 488 ***/ 455 489 456 490 void -
trunk/wx/torrent-list.h
r2465 r2469 30 30 31 31 public: 32 33 enum ShowMode 34 { 35 SHOW_ALL, 36 SHOW_DOWNLOADING, 37 SHOW_UPLOADING, 38 SHOW_COMPLETE, 39 SHOW_INCOMPLETE, 40 SHOW_ACTIVE, 41 SHOW_INACTIVE, 42 N_FILTERS 43 }; 44 45 void SetShowMode( ShowMode ); 46 47 int GetShowModeCounts( ShowMode ) const; 48 49 public: 50 51 struct Listener 52 { 53 Listener() {} 54 55 virtual ~Listener() {} 56 57 virtual void OnTorrentListSelectionChanged( 58 TorrentListCtrl*, 59 const std::set<tr_torrent_t*>& ) = 0; 60 }; 61 62 private: 63 typedef std::set<Listener*> listeners_t; 64 listeners_t myListeners; 65 void fire_selection_changed( const std::set<tr_torrent_t*>& t ) { 66 for( listeners_t::iterator it(myListeners.begin()), end(myListeners.end()); it!=end; ) 67 (*it++)->OnTorrentListSelectionChanged( this, t ); 68 } 69 public: 70 void AddListener( Listener* l ) { myListeners.insert(l); } 71 void RemoveListener( Listener* l ) { myListeners.erase(l); } 72 73 public: 32 74 void Rebuild (); 33 75 void Repopulate (); … … 41 83 void Sort( int column ); 42 84 void Resort( ); 43 void OnSort( wxListEvent& );44 85 void RefreshTorrent( tr_torrent_t*, int, const std::vector<int>& ); 45 86 static int Compare( long, long, long ); … … 48 89 typedef std::map<std::string,int> str2int_t; 49 90 str2int_t myHashToRow; 91 92 private: 93 void OnSort( wxListEvent& ); 94 void OnItemSelected( wxListEvent& ); 95 void OnItemDeselected( wxListEvent& ); 50 96 51 97 private: -
trunk/wx/xmission.cc
r2468 r2469 20 20 #include <wx/config.h> 21 21 #include <wx/image.h> 22 #include <wx/intl.h> 22 23 #include <wx/listctrl.h> 23 24 #include <wx/notebook.h> … … 43 44 } 44 45 46 #include "torrent-filter.h" 45 47 #include "torrent-list.h" 46 48 … … 56 58 tr_handle_t * handle = NULL; 57 59 58 typedef std::vector<tr_torrent_t*> torrents_ t;60 typedef std::vector<tr_torrent_t*> torrents_v; 59 61 } 60 62 … … 64 66 MyFrame(const wxString& title, const wxPoint& pos, const wxSize& size); 65 67 virtual ~MyFrame(); 68 69 public: 66 70 void OnQuit( wxCommandEvent& ); 67 71 void OnAbout( wxCommandEvent& ); … … 69 73 void OnTimer( wxTimerEvent& ); 70 74 75 private: 76 void RefreshFilterCounts( ); 77 71 78 protected: 72 79 wxConfig * myConfig; … … 75 82 private: 76 83 TorrentListCtrl * myTorrentList; 84 wxListCtrl * myFilters; 77 85 wxTaskBarIcon * myTaskBarIcon; 78 86 wxIcon * myLogoIcon; 79 87 wxIcon * myTrayLogo; 88 torrents_v myTorrents; 80 89 }; 81 90 … … 181 190 182 191 void 192 MyFrame :: RefreshFilterCounts( ) 193 { 194 for( int i=0; i<TorrentFilter::N_FILTERS; ++i ) 195 { 196 wxString xstr = TorrentFilter::getFilterName( i ); 197 const int count = TorrentFilter::CountHits( i, myTorrents ); 198 if( count ) 199 xstr += wxString::Format(_T(" (%d)"), count ); 200 myFilters->SetItem( i, 0, xstr ); 201 } 202 } 203 204 void 183 205 MyFrame :: OnTimer(wxTimerEvent& event) 184 206 { 185 myTorrentList->Refresh (); 207 RefreshFilterCounts( ); 208 209 myTorrentList->Refresh ( ); 186 210 187 211 float dl, ul; … … 287 311 /* Filters */ 288 312 289 wxListCtrl * filters = new wxListCtrl( row1, wxID_ANY, wxDefaultPosition, wxDefaultSize, 290 wxLC_REPORT|wxLC_SINGLE_SEL|wxLC_NO_HEADER ); 291 filters->InsertColumn( wxLIST_FORMAT_LEFT, _T("YYZ") ); 292 int i = 0; 293 filters->InsertItem( i++, _T("All") ); 294 filters->InsertItem( i++, _T("Downloading (1)") ); 295 filters->InsertItem( i++, _T("Completed") ); 296 filters->InsertItem( i++, _T("Active (1)") ); 297 filters->InsertItem( i++, _T("Inactive") ); 313 myFilters = new wxListCtrl( row1, wxID_ANY, wxDefaultPosition, wxSize(120,-1), 314 wxLC_REPORT|wxLC_SINGLE_SEL|wxLC_NO_HEADER ); 315 myFilters->InsertColumn( wxLIST_FORMAT_LEFT, _("Filters"), wxLIST_FORMAT_LEFT, 120 ); 316 for( int i=0; i<TorrentFilter::N_FILTERS; ++i ) 317 myFilters->InsertItem( i, TorrentFilter::getFilterName(i) ); 298 318 299 319 /* Torrent List */ … … 302 322 303 323 wxBoxSizer * boxSizer = new wxBoxSizer( wxHORIZONTAL ); 304 boxSizer->Add( filters, 0, wxEXPAND|wxRIGHT, 5 );324 boxSizer->Add( myFilters, 0, wxEXPAND|wxRIGHT, 5 ); 305 325 boxSizer->Add( myTorrentList, 1, wxEXPAND, 0 ); 306 326 row1->SetSizer( boxSizer ); 327 //boxSizer->SetSizeHints( row1 ); 307 328 308 329 … … 344 365 int count = 0; 345 366 tr_torrent_t ** torrents = tr_loadTorrents ( handle, destination, flags, &count ); 346 myTorrentList->Add( std::vector<tr_torrent_t*>( torrents, torrents+count ) ); 367 myTorrents.insert( myTorrents.end(), torrents, torrents+count ); 368 myTorrentList->Add( myTorrents ); 347 369 tr_free( torrents ); 348 370 }
Note: See TracChangeset
for help on using the changeset viewer.