File indexing completed on 2024-05-19 14:57:48

0001 /*
0002     SPDX-FileCopyrightText: 2002 Jason Harris <kstars@30doradus.org>
0003 
0004     SPDX-License-Identifier: GPL-2.0-or-later
0005 */
0006 
0007 #pragma once
0008 
0009 #include "ui_addcatdialog.h"
0010 
0011 class AddCatDialogUI : public QFrame, public Ui::AddCatDialog
0012 {
0013     Q_OBJECT
0014 
0015   public:
0016     explicit AddCatDialogUI(QWidget *parent = nullptr);
0017 };
0018 
0019 /**
0020  * @class AddCatDialog
0021  * @short Dialog for adding custom object catalogs to KStars
0022  *
0023  * @author Jason Harris
0024  * @version 1.0
0025  */
0026 class AddCatDialog : public QDialog
0027 {
0028     Q_OBJECT
0029 
0030   public:
0031     explicit AddCatDialog(QWidget *parent);
0032 
0033     /** @return the name for the custom catalog. */
0034     QString name() const { return acd->CatalogName->text(); }
0035 
0036     /** @return the filename of the custom catalog. */
0037     QString filename() const { return acd->CatalogURL->url().toLocalFile(); }
0038 
0039   private slots:
0040     /** Display contents of the import file. */
0041     void slotShowDataFile();
0042 
0043     /** Create the object catalog file, populate the objectList, and close the dialog. */
0044     void slotCreateCatalog();
0045 
0046     /** Preview the catalog file as constructed by the current parameters */
0047     void slotPreviewCatalog();
0048 
0049     /** Overridden from QDialog to show short help in a dialog rather than launch KHelpCenter. */
0050     void slotHelp();
0051 
0052   private:
0053     /**
0054      * Attempt to parse the user's data file according to the fields
0055      * specified in the Catalog fields list.
0056      */
0057     bool validateDataFile();
0058 
0059     /**
0060      * Write a header line describing the data fields in the catalog, and
0061      * defining the catalog name, ID prefix, and coordinate epoch.
0062      */
0063     QString writeCatalogHeader();
0064 
0065     AddCatDialogUI *acd { nullptr };
0066     QString CatalogContents;
0067 };