ORE Studio 0.0.4
Loading...
Searching...
No Matches
PaginationWidget.hpp
1/* -*- mode: c++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
2 *
3 * Copyright (C) 2025 Marco Craveiro <marco.craveiro@gmail.com>
4 *
5 * This program is free software; you can redistribute it and/or modify it under
6 * the terms of the GNU General Public License as published by the Free Software
7 * Foundation; either version 3 of the License, or (at your option) any later
8 * version.
9 *
10 * This program is distributed in the hope that it will be useful, but WITHOUT
11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
12 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
13 * details.
14 *
15 * You should have received a copy of the GNU General Public License along with
16 * this program; if not, write to the Free Software Foundation, Inc., 51
17 * Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 *
19 */
20#ifndef ORES_QT_PAGINATION_WIDGET_HPP
21#define ORES_QT_PAGINATION_WIDGET_HPP
22
23#include <QWidget>
24#include <QLabel>
25#include <QPushButton>
26#include <QComboBox>
27#include <QHBoxLayout>
28#include "ores.utility/log/make_logger.hpp"
29
30namespace ores::qt {
31
38class PaginationWidget : public QWidget {
39 Q_OBJECT
40
41private:
42 inline static std::string_view logger_name =
43 "ores.qt.pagination_widget";
44
45 [[nodiscard]] static auto& lg() {
46 using namespace ores::utility::log;
47 static auto instance = make_logger(logger_name);
48 return instance;
49 }
50
51public:
52 explicit PaginationWidget(QWidget* parent = nullptr);
53
60 void update_state(std::uint32_t loaded_count, std::uint32_t total_count);
61
67 std::uint32_t page_size() const;
68
74 void set_load_all_enabled(bool enabled);
75
76signals:
82 void page_size_changed(std::uint32_t page_size);
83
88
89private slots:
90 void on_page_size_changed(int index);
91 void on_load_all_clicked();
92
93private:
94 QLabel* info_label_;
95 QComboBox* page_size_combo_;
96 QPushButton* first_button_;
97 QPushButton* prev_button_;
98 QPushButton* next_button_;
99 QPushButton* last_button_;
100 QPushButton* load_all_button_;
101 QHBoxLayout* layout_;
102
103 std::uint32_t loaded_count_{0};
104 std::uint32_t total_count_{0};
105};
106
107}
108
109#endif
Qt-based graphical user interface for ORE Studio.
Definition AboutDialog.hpp:35
Implements logging for ORE Studio.
Definition lifecycle_manager.hpp:30
Widget providing pagination controls for data tables.
Definition PaginationWidget.hpp:38
void update_state(std::uint32_t loaded_count, std::uint32_t total_count)
Update the pagination display with current state.
Definition PaginationWidget.cpp:112
void page_size_changed(std::uint32_t page_size)
Emitted when user changes the page size selection.
void set_load_all_enabled(bool enabled)
Enable or disable the Load All button.
Definition PaginationWidget.cpp:150
void load_all_requested()
Emitted when user requests to load all remaining data.
std::uint32_t page_size() const
Get the selected page size.
Definition PaginationWidget.cpp:134