Kstars

catalogeditform.cpp
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#include "catalogeditform.h"
8#include "dialogs/catalogcoloreditor.h"
9#include "kstarsdata.h"
10#include "ui_catalogeditform.h"
11#include "catalogsdb.h"
12#include <QColorDialog>
13
14CatalogEditForm::CatalogEditForm(QWidget *parent, const CatalogsDB::Catalog &catalog,
15 const int min_id, const bool allow_id_edit)
16 : QDialog(parent), ui(new Ui::CatalogEditForm), m_catalog{ catalog }
17{
18 ui->setupUi(this);
19 ui->id->setMinimum(min_id);
20 ui->id->setEnabled(allow_id_edit);
21
22 fill_form_from_catalog();
23 connect(ui->id, QOverload<int>::of(&QSpinBox::valueChanged),
24 [&](const int id) { m_catalog.id = id; });
25
27 [&](const QString &s) { m_catalog.name = s; });
28
30 [&](const QString &s) { m_catalog.author = s; });
31
33 [&](const QString &s) { m_catalog.source = s; });
34
35 connect(ui->description, &QTextEdit::textChanged,
36 [&]() { m_catalog.description = ui->description->toHtml(); });
37
38 connect(ui->license, &QLineEdit::textChanged,
39 [&](const QString &s) { m_catalog.license = s; });
40
41 connect(ui->maintainer, &QLineEdit::textChanged,
42 [&](const QString &s) { m_catalog.maintainer = s; });
43
44 connect(ui->color, &QPushButton::clicked, [&]() {
45 CatalogColorEditor editor{
46 m_catalog.color == "" ?
47 KStarsData::Instance()->colorScheme()->colorNamed("DSOColor").name() :
48 m_catalog.color
49 };
50
51 if (editor.exec() != QDialog::Accepted)
52 return;
53
54 m_catalog.color = editor.color_string();
55 });
56}
57
58CatalogEditForm::~CatalogEditForm()
59{
60 delete ui;
61}
62
63void CatalogEditForm::fill_form_from_catalog()
64{
65 ui->id->setValue(m_catalog.id);
66 ui->name->setText(m_catalog.name);
67 ui->author->setText(m_catalog.author);
68 ui->source->setText(m_catalog.source);
69 ui->description->setHtml(m_catalog.description);
70 ui->license->setText(m_catalog.license);
71 ui->maintainer->setText(m_catalog.maintainer);
72}
A simple data entry form for creating/editing catalog meta information.
void clicked(bool checked)
void textChanged(const QString &text)
void valueChanged(int i)
void textChanged()
QFuture< ArgsType< Signal > > connect(Sender *sender, Signal signal)
A simple struct to hold information about catalogs.
Definition catalogsdb.h:37
int id
The catalog id.
Definition catalogsdb.h:41
QString maintainer
The catalog maintainer.
Definition catalogsdb.h:101
QString name
The catalog mame.
Definition catalogsdb.h:46
QString license
The catalog license.
Definition catalogsdb.h:96
QString description
A (short) description for the catalog.
Definition catalogsdb.h:70
QString author
The author of the catalog.
Definition catalogsdb.h:59
QString source
The catalog source.
Definition catalogsdb.h:64
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri Dec 20 2024 11:52:59 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.