sptk2 logo
SPTK Home Page
CDBListView.h
1/*
2╔══════════════════════════════════════════════════════════════════════════════╗
3║ SIMPLY POWERFUL TOOLKIT (SPTK) ║
4╟──────────────────────────────────────────────────────────────────────────────╢
5║ copyright © 1999-2022 Alexey Parshin. All rights reserved. ║
6║ email alexeyp@gmail.com ║
7╚══════════════════════════════════════════════════════════════════════════════╝
8┌──────────────────────────────────────────────────────────────────────────────┐
9│ This library is free software; you can redistribute it and/or modify it │
10│ under the terms of the GNU Library General Public License as published by │
11│ the Free Software Foundation; either version 2 of the License, or (at your │
12│ option) any later version. │
13│ │
14│ This library is distributed in the hope that it will be useful, but │
15│ WITHOUT ANY WARRANTY; without even the implied warranty of │
16│ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library │
17│ General Public License for more details. │
18│ │
19│ You should have received a copy of the GNU Library General Public License │
20│ along with this library; if not, write to the Free Software Foundation, │
21│ Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. │
22│ │
23│ Please report all bugs and problems to alexeyp@gmail.com. │
24└──────────────────────────────────────────────────────────────────────────────┘
25*/
26
27#pragma once
28
29#include <sptk5/DateTime.h>
30#include <sptk5/db/Query.h>
31#include <sptk5/gui/CListView.h>
32
33namespace sptk {
34
43class SP_EXPORT CDBListView
44 : public CListView
45{
49 Query m_fullRefreshQuery;
50
54 Query m_fastRefreshQuery;
55
59 Query m_recordCountQuery;
60
64 String m_keyField;
65
69 bool m_fastRefreshEnabed;
70
74 DateTime m_lastRefresh;
75
79 uint32_t m_maxRecords;
80
84 bool m_recordsLimited;
85
86public:
93 CDBListView(const char* label = nullptr, int layoutSize = 20,
94 CLayoutAlign layoutAlign = CLayoutAlign::TOP);
95
96#ifdef __COMPATIBILITY_MODE__
105 CDBListView(int x, int y, int w, int h, const char* label = 0);
106#endif
107
111 ~CDBListView() override;
112
117
122
130 void sql(const String& sql, const String& recordCountSql = "", const String& fastRefreshSQL = "");
131
136
142 QueryParameter& param(const char* paramName, CRefreshKind refreshKind = CRefreshKind::LV_REFRESH_FULL);
143
149 void keyField(const String& fieldName);
150
155 {
156 return m_keyField;
157 }
158
165 void setup(PoolDatabaseConnection* db, const String& sql, const String& keyField);
166
172
177 {
178 return m_lastRefresh;
179 }
180
184 void maxRecords(uint32_t mr)
185 {
186 m_maxRecords = mr;
187 }
188
192 uint32_t maxRecords() const
193 {
194 return m_maxRecords;
195 }
196
201 bool recordsLimited() const
202 {
203 return m_recordsLimited;
204 }
205
210 static CLayoutClient* creator(const xdoc::SNode& node);
211};
215} // namespace sptk
List view widget with extended database support.
Definition: CDBListView.h:45
void setup(PoolDatabaseConnection *db, const String &sql, const String &keyField)
static CLayoutClient * creator(const xdoc::SNode &node)
Creates a widget based on the XML node information.
DateTime lastRefresh() const
Definition: CDBListView.h:176
void sql(const String &sql, const String &recordCountSql="", const String &fastRefreshSQL="")
void keyField(const String &fieldName)
uint32_t maxRecords() const
Definition: CDBListView.h:192
CDBListView(const char *label=nullptr, int layoutSize=20, CLayoutAlign layoutAlign=CLayoutAlign::TOP)
String keyField() const
Definition: CDBListView.h:154
bool recordsLimited() const
Definition: CDBListView.h:201
void refreshData(CRefreshKind refreshKind=CRefreshKind::LV_REFRESH_FULL)
void database(PoolDatabaseConnection *db)
QueryParameter & param(const char *paramName, CRefreshKind refreshKind=CRefreshKind::LV_REFRESH_FULL)
void maxRecords(uint32_t mr)
Definition: CDBListView.h:184
~CDBListView() override
PoolDatabaseConnection * database() const
Definition: CLayoutClient.h:82
List view widget.
Definition: CListView.h:108
Definition: DateTime.h:86
Definition: PoolDatabaseConnection.h:231
Definition: QueryParameter.h:44
Definition: Query.h:239
Definition: String.h:49
CLayoutAlign
Definition: CLayoutClient.h:44
CRefreshKind
The refersh kind.
Definition: CListView.h:54
@ TOP
Align to the right.

Fri Oct 14 2022 09:58:31: SPTK 5.4.1