OChess v0.0.2
Programmer's Manual
GameListManager.hpp
1#pragma once
2
3#include "ochess.hpp"
4#include <algorithm>
5#include <vector>
6
7#define TERMS_IN(COL) (row.COL.find(terms) != std::string::npos)
8#define BG_OPEN(INDEX) game_list->SetItemBackgroundColour(INDEX, *wxGREEN)
9#define BG_DELETE(INDEX) game_list->SetItemBackgroundColour(INDEX, *wxRED)
10#define BG_IMPORT(INDEX) game_list->SetItemBackgroundColour(INDEX, *wxBLUE)
11#define DISPLAY_ALL_ROWS() {for(std::size_t i=0;i<rows.size();i++){DisplayRow(i);}}
12
14typedef std::string CType;
15
17typedef struct Item {
18 long id;
19 CType White;
20 CType Black;
21 CType Event;
22 CType Round;
23 CType Result;
24 CType Eco;
25} RType;
26
32 long game_counter;
33 wxListCtrl *game_list;
34 std::vector<long> deleted_games, opened_games, imported_games;
35
36 void DisplayRow(long id);
37 void ClearDisplayedRow();
38public:
40 std::vector<RType> rows;
41
42 GameListManager(wxListCtrl *game_list);
44 long AddGame(CType White,CType Black,CType Event,CType Round, CType Result, CType Eco);
45 void MarkItemAsOpen(long item);
46 void MarkItemAsDeleted(long item);
47 void MarkItemAsImported(long item);
49 void Clear();
51 std::vector<long> GetSelectedItems();
53 long GetItemGameId(long item);
55 void Filter(std::string terms);
57 void ClearFilter();
59 void SortBy(short col);
60};
A helper class to manage a wxListCtrl that display games.
Definition: GameListManager.hpp:31
void ClearFilter()
Remove all filters.
Definition: GameListManager.cpp:133
void SortBy(short col)
Sort items by the given column.
Definition: GameListManager.cpp:71
long GetItemGameId(long item)
Get the game id from the item id.
Definition: GameListManager.cpp:109
void Filter(std::string terms)
Filter the rows given terms.
Definition: GameListManager.cpp:118
long AddGame(CType White, CType Black, CType Event, CType Round, CType Result, CType Eco)
Add a game to the list.
Definition: GameListManager.cpp:14
std::vector< RType > rows
Accessible outside (DO NOT MODIFY FROM OUTSIDE)
Definition: GameListManager.hpp:40
void Clear()
Clear the state of the GameListManager.
Definition: GameListManager.cpp:43
std::vector< long > GetSelectedItems()
Return the id of the selected items.
Definition: GameListManager.cpp:98
Row item content.
Definition: GameListManager.hpp:17