7#ifndef CATALOGCSVIMPORT_H
8#define CATALOGCSVIMPORT_H
14#include "polyfills/qstring_hash.h"
15#include <unordered_map>
17#include "catalogobject.h"
19#include "catalogobjectlistmodel.h"
23class CatalogCSVImport;
38template <coord_unit unit_p>
48Converter<typed_dms<coord_unit::deg>>::ToVal(
const std::string &pStr,
49 typed_dms<coord_unit::deg> &pVal)
const
52 throw std::exception();
57Converter<typed_dms<coord_unit::hours>>::ToVal(
const std::string &pStr,
58 typed_dms<coord_unit::hours> &pVal)
const
61 throw std::exception();
71class CatalogCSVImport :
public QDialog
82 using type_map = std::unordered_map<std::string, SkyObject::TYPE>;
92 using column_pair = std::pair<int, QString>;
93 using column_map = std::unordered_map<QString, column_pair>;
95 inline const std::vector<CatalogObject> &get_objects()
const {
return m_objects; };
101 void init_mapping_selectors();
104 void type_table_add_map();
107 void type_table_remove_map();
110 inline void read_objects() { read_n_objects(); };
113 void init_column_mapping();
114 void init_type_table();
115 type_map get_type_mapping();
116 column_map get_column_mapping();
117 void read_n_objects(
size_t n = std::numeric_limits<int>::max());
120 SkyObject::TYPE parse_type(
const std::string &type,
const type_map &type_map);
122 template <
typename T>
123 T cell_or_default(
const column_pair &config,
const size_t row,
const T &default_val)
125 if (config.first < 0)
128 return m_doc.
GetCell<T>(config.first, row);
131 template <
typename T>
132 T get_default(
const column_pair &config,
const T &default_val)
134 if (config.first != -1)
140 converter.
ToVal(config.second.toStdString(), res);
145 Ui::CatalogCSVImport *ui;
148 void reset_mapping();
151 std::map<QString, QComboBox *> m_selectors{};
157 std::vector<CatalogObject> m_objects;
160 CatalogObjectListModel m_preview_model;
162 static const char default_separator =
',';
163 static const char default_comment =
'#';
164 static const int default_preview_size = 10;
TYPE
The type classification of the SkyObject.
An angle, stored as degrees, but expressible in many ways.
virtual bool setFromString(const QString &s, bool isDeg=true)
Attempt to parse the string argument as a dms value, and set the dms object accordingly.
Class providing conversion to/from numerical datatypes and strings.
void ToVal(const std::string &pStr, T &pVal) const
Converts string holding a numerical value to numerical datatype representation.
Class representing a CSV document.
T GetCell(const size_t pColumnIdx, const size_t pRowIdx) const
Get cell by index.
QObject * parent() const const
Datastructure holding parameters controlling how invalid numbers (including empty strings) should be ...