Kstars

catalogsdbui.h
1/*
2 SPDX-FileCopyrightText: 2021 Valentin Boettcher <hiro at protagon.space; @hiro98:tchncs.de>
3
4 SPDX-License-Identifier: GPL-2.0-or-later
5*/
6
7#ifndef CATALOGSDBUI_H
8#define CATALOGSDBUI_H
9
10#include <QDialog>
11#include "catalogsdb.h"
12
13namespace Ui
14{
15class CatalogsDBUI;
16}
17
18/**
19 * A simple UI to manage downloaded and custom Catalogs.
20 *
21 * It holds it's own instance of `CatalogsDB::DBManager` and can import,
22 * export, delete, enable, disable and clone catalogs. On request it
23 * spawns a `CatalogDetails` dialog which can be be used to edit
24 * `mutable` catalogs.
25 */
26class CatalogsDBUI : public QDialog
27{
29 public:
30 explicit CatalogsDBUI(QWidget *parent, const QString &db_path);
32
33 private slots:
34 /**
35 * Activates the apropriate buttons.
36 */
37 void row_selected(int row, int);
38
39 /**
40 * Disables all catalog related buttons if no row is selected.c
41 */
42 void disable_buttons();
43
44 /**
45 * Enables or disables the currently selected catalog.
46 */
47 void enable_disable_catalog();
48
49 /**
50 * Opens a file selection dialog and exports the selected catalog.
51 */
52 void export_catalog();
53
54 /**
55 * Opens a file selection dialog and imports the selected catalog.
56 */
57 void import_catalog(bool force = false);
58
59 /**
60 * Removes the selected catalog.
61 */
62 void remove_catalog();
63
64 /**
65 * Creates a new catalog by prompting for the relevant details.
66 * The smallest available id for custom catalogs is proposed.
67 */
68 void create_new_catalog();
69
70 /**
71 * Creates a new catalog based on \p `catalog` by prompting for the
72 * relevant details.
73 *
74 * returns wether a catalog was created and the id of the created catalog
75 */
76 std::pair<bool, int> create_new_catalog(const CatalogsDB::Catalog &catalog);
77
78 /**
79 * Shows the `CatalogDetails` dialog for the currently selected
80 * catalog.
81 */
82 void show_more_dialog();
83
84 /**
85 * Shows the `CatalogColorEditor` dialog for the currently selected
86 * catalog.
87 */
88 void show_color_editor();
89
90 /**
91 * Dublicate the selected catalog, inserting it as a new catalog
92 * and prompt for meta-data edit.
93 */
94 void dublicate_catalog();
95
96 /**
97 * Refresh the table by reloading the catalogs from the database.
98 */
99 void refresh_db_table();
100
101 private:
102 Ui::CatalogsDBUI *ui;
103
104 /**
105 * The database instance for accessing a catalog database.
106 */
107 CatalogsDB::DBManager m_manager;
108
109 /**
110 * The currently loaded catalogs. Relates row number to catalog
111 * id.
112 */
113 std::vector<int> m_catalogs;
114
115 /**
116 * \returns if a catalog is selected and the catalog itself
117 */
118 const std::pair<bool, CatalogsDB::Catalog> get_selected_catalog();
119
120 /** Remeber the directory where we last loaded a catalog from */
121 QString m_last_dir;
122};
123
124#endif // CATALOGSDBUI_H
A simple UI to manage downloaded and custom Catalogs.
Manages the catalog database and provides an interface to provide an interface to query and modify th...
Definition catalogsdb.h:183
Q_OBJECTQ_OBJECT
QObject * parent() const const
A simple struct to hold information about catalogs.
Definition catalogsdb.h:37
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Mon Nov 18 2024 12:16:40 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.