ochess/src/base_tab/GameListManager.hpp

44 lines
1.1 KiB
C++
Raw Normal View History

2022-12-25 19:43:05 +01:00
#pragma once
2022-12-25 15:26:16 +01:00
#include "ochess.hpp"
2022-12-26 06:48:11 +01:00
#include <algorithm>
#include <vector>
2022-12-25 15:26:16 +01:00
2022-12-25 18:30:56 +01:00
#define TERMS_IN(COL) (row.COL.find(terms) != std::string::npos)
2022-12-26 08:26:02 +01:00
#define BG_OPEN(INDEX) game_list->SetItemBackgroundColour(INDEX, *wxGREEN)
#define BG_DELETE(INDEX) game_list->SetItemBackgroundColour(INDEX, *wxRED)
#define DISPLAY_ALL_ROWS() {for(int i=0;i<rows.size();i++){DisplayRow(i);}}
2022-12-25 18:30:56 +01:00
2022-12-25 15:26:16 +01:00
typedef std::string CType;
2022-12-25 16:29:17 +01:00
typedef struct Item {
2022-12-26 08:26:02 +01:00
long id;
2022-12-25 16:29:17 +01:00
CType White;
CType Black;
CType Event;
CType Round;
CType Result;
CType Eco;
} RType;
2022-12-25 15:26:16 +01:00
class GameListManager {
long game_counter;
2022-12-26 12:51:48 +01:00
wxListCtrl *game_list;
2022-12-26 08:26:02 +01:00
std::vector<long> deleted_games, opened_games;
2022-12-25 16:29:17 +01:00
void DisplayRow(long id);
2022-12-25 16:39:54 +01:00
void ClearDisplayedRow();
2022-12-25 15:26:16 +01:00
public:
2022-12-26 12:51:48 +01:00
std::vector<RType> rows;
2022-12-25 15:26:16 +01:00
GameListManager(wxListCtrl *game_list);
2022-12-25 16:29:17 +01:00
void AddGame(CType White,CType Black,CType Event,CType Round, CType Result, CType Eco);
2022-12-25 15:51:00 +01:00
void Clear();
2022-12-25 17:30:22 +01:00
void MarkItemAsOpen(long item);
void MarkItemAsDeleted(long item);
std::vector<long> GetSelectedItems();
long GetItemGameId(long item);
2022-12-25 18:30:56 +01:00
void Filter(std::string terms);
void ClearFilter();
2022-12-26 08:26:02 +01:00
void SortBy(short col);
2022-12-25 15:26:16 +01:00
};