blob: 7ba25c674a42896c266d92972fdc387aa31e7b9d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
|
#include "FbGenrTree.h"
#include "FbBookEvent.h"
#include "FbDatabase.h"
#include "FbConst.h"
#include "FbMasterTypes.h"
//-----------------------------------------------------------------------------
// FbGenrParentData
//-----------------------------------------------------------------------------
IMPLEMENT_CLASS(FbGenrParentData, FbParentData)
//-----------------------------------------------------------------------------
// FbGenrChildData
//-----------------------------------------------------------------------------
IMPLEMENT_CLASS(FbGenrChildData, FbChildData)
wxString FbGenrChildData::GetValue(FbModel & model, size_t col) const
{
switch (col) {
case 0:
return m_name;
case 1:
return m_count ? Format(m_count) : wxString();
default:
return wxEmptyString ;
}
}
bool FbGenrChildData::operator==(const FbMasterInfo & info) const
{
FbMasterGenrInfo * data = wxDynamicCast(&info, FbMasterGenrInfo);
return data && data->GetId() == m_code;
}
//-----------------------------------------------------------------------------
// FbGenrListData
//-----------------------------------------------------------------------------
IMPLEMENT_CLASS(FbGenrListData, FbModelData)
FbGenrListData::FbGenrListData(FbSQLite3ResultSet &result)
: m_code(result.GetString(0)), m_count(result.GetInt(1))
{
}
//-----------------------------------------------------------------------------
// FbGenrChildData
//-----------------------------------------------------------------------------
void * FbGenrListThread::Entry()
{
FbCommonDatabase database;
database.JoinThread(this);
FbSQLite3ResultSet result = database.ExecuteQuery(m_sql);
if (!result.IsOk()) return NULL;
if (IsClosed()) return NULL;
FbModel * model = new FbListStore;
while (result.NextRow()) model->Append(new FbGenrListData(result));
if (IsClosed()) {
delete model;
} else {
FbModelEvent(ID_MODEL_CREATE, model).Post(m_frame);
}
return NULL;
}
|