File indexing completed on 2024-12-01 03:30:00
0001 /* 0002 SPDX-FileCopyrightText: 2021 Valentin Boettcher <hiro at protagon.space; @hiro98:tchncs.de> 0003 0004 SPDX-License-Identifier: GPL-2.0-or-later 0005 */ 0006 0007 #ifndef CATALOGDETAILS_H 0008 #define CATALOGDETAILS_H 0009 0010 #include <QDialog> 0011 #include "catalogsdb.h" 0012 #include "catalogobject.h" 0013 #include "catalogobjectlistmodel.h" 0014 0015 class QTimer; 0016 class QListWidgetItem; 0017 namespace Ui 0018 { 0019 class CatalogDetails; 0020 } 0021 0022 /** 0023 * A dialog that shows catalog information and provides facilities to 0024 * edit catalog meta information and manage its contents (if the catalog 0025 * is mutable). It holds its own instance of `CatalogsDB::DBManager` and 0026 * can thus be instanciated with minimal dependencies on other parts of 0027 * KStars. 0028 * 0029 * The dialog displays the 100 most visible objects matching the 0030 * search query. 0031 * 0032 * Supported operations are insertion, deletion and editing of catalog 0033 * entries. 0034 * 0035 * Dedublication for custom catalogs still has to be implemented. 0036 */ 0037 class CatalogDetails : public QDialog 0038 { 0039 Q_OBJECT 0040 0041 public: 0042 /** 0043 * How many catalog entries to show in the list. 0044 */ 0045 static constexpr int list_size{ 10000 }; 0046 0047 /** 0048 * \param parent the parent widget, `nullptr` allowed 0049 * \param db_path the path to the catalog database to be used 0050 * \param catalog_id the id of the catalog to be edited 0051 * 0052 * If the catalog is not found, an error message will be displayed 0053 * and the dialog will be closed. 0054 */ 0055 explicit CatalogDetails(QWidget *parent, const QString &db_path, 0056 const int catalog_id); 0057 ~CatalogDetails(); 0058 0059 private: 0060 Ui::CatalogDetails *ui; 0061 0062 /** 0063 * The database instance for accessing a catalog database. 0064 */ 0065 CatalogsDB::DBManager m_manager; 0066 0067 /** 0068 * The id of the backing catalog. 0069 */ 0070 const int m_catalog_id; 0071 0072 /** 0073 * The backing catalog. 0074 */ 0075 CatalogsDB::Catalog m_catalog; 0076 0077 /** 0078 * A timer to check for idle in the filter input. 0079 */ 0080 QTimer *m_timer; 0081 0082 /** 0083 * A model that holds all the objects which are being viewed in a 0084 * `DetailDialog`. 0085 */ 0086 CatalogObjectListModel m_model; 0087 0088 private slots: 0089 /** Reload the catalog meta info display. */ 0090 void reload_catalog(); 0091 0092 /** Reload the displayed list of objects. */ 0093 void reload_objects(); 0094 0095 /** Shows a `DetailDialog` for the double clicked list item. */ 0096 void show_object_details(const QModelIndex &index); 0097 0098 /** Opens a `CatalogEditForm` to edit the currently selected catalog. */ 0099 void edit_catalog_meta(); 0100 0101 /** Opens an `AddCatalogObject` dialog to add an object to the catalog. */ 0102 void add_object(); 0103 0104 /** Removes the selected objects from the catalog. */ 0105 void remove_objects(); 0106 0107 /** Opens an `AddCatalogObject` dialog to edit the selected objects in the catalog. */ 0108 void edit_objects(); 0109 0110 /** Opens a `CatalogCSVImport` dialog and imports objects from a csv. */ 0111 void import_csv(); 0112 }; 0113 0114 #endif // CATALOGDETAILS_H