• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

Stellarium / stellarium / 6685397774

29 Oct 2023 07:37PM UTC coverage: 11.735% (-0.002%) from 11.737%
6685397774

push

github

10110111
Deduplicate title bar implementation

131 of 131 new or added lines in 56 files covered. (100.0%)

14842 of 126472 relevant lines covered (11.74%)

21617.74 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/plugins/TelescopeControl/src/gui/StoredPointsDialog.cpp
1
/*
2
 * Stellarium Telescope Control Plug-in
3
 *
4
 * Copyright (C) 2015 Pavel Klimenko aka rich <dzy4@mail.ru> (this file)
5
 *
6
 * This program is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU General Public License
8
 * as published by the Free Software Foundation; either version 2
9
 * of the License, or (at your option) any later version.
10
 *
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with this program; if not, write to the Free Software
18
 * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA  02110-1335, USA.
19
*/
20

21
#include "StoredPointsDialog.hpp"
22
#include "ui_storedPointsDialog.h"
23

24
#include "StelApp.hpp"
25
#include "StelCore.hpp"
26
#include "StelModuleMgr.hpp"
27
#include "StelObjectMgr.hpp"
28
#include "StelUtils.hpp"
29
#include "StelTranslator.hpp"
30

31
StoredPointsDialog::StoredPointsDialog(const QString &dialogName, QObject* parent):
×
32
        StelDialog(dialogName, parent)
×
33
{
34
        ui = new Ui_StoredPoints;
×
35
        storedPointsListModel = new QStandardItemModel(0, ColumnCount);
×
36
}
×
37

38
StoredPointsDialog::~StoredPointsDialog()
×
39
{
40
        delete ui;
×
41
        delete storedPointsListModel;
×
42
}
×
43

44
void StoredPointsDialog::retranslate()
×
45
{
46
        if (dialog)
×
47
                ui->retranslateUi(dialog);
×
48
}
×
49

50
void StoredPointsDialog::createDialogContent()
×
51
{
52
        ui->setupUi(dialog);
×
53
        //Inherited connect
54
        connect(&StelApp::getInstance(), SIGNAL(languageChanged()), this, SLOT(retranslate()));
×
55
        connect(ui->titleBar, &TitleBar::closeClicked, this, &StelDialog::close);
×
56
        connect(ui->titleBar, SIGNAL(movedTo(QPoint)), this, SLOT(handleMovedTo(QPoint)));
×
57

58
        connect(ui->pushButtonAddPoint,   SIGNAL(clicked()), this, SLOT(buttonAddPressed()));
×
59
        connect(ui->pushButtonRemovePoint,SIGNAL(clicked()), this, SLOT(buttonRemovePressed()));
×
60
        connect(ui->pushButtonClearList,  SIGNAL(clicked()), this, SLOT(buttonClearPressed()));
×
61

62
        connect(ui->pushButtonCurrent, SIGNAL(clicked()), this, SLOT(getCurrentObjectInfo()));
×
63
        connect(ui->pushButtonCenter, SIGNAL(clicked()), this, SLOT(getCenterInfo()));
×
64

65
        //Initializing the list of telescopes
66
        storedPointsListModel->setColumnCount(ColumnCount);
×
67
        setHeaderNames();
×
68

69
        ui->treeViewStoredPoints->setModel(storedPointsListModel);
×
70
        ui->treeViewStoredPoints->header()->setSectionsMovable(false);
×
71
        ui->treeViewStoredPoints->header()->setSectionResizeMode(ColumnSlot, QHeaderView::ResizeToContents);
×
72
        ui->treeViewStoredPoints->header()->setStretchLastSection(true);
×
73

74
        ui->spinBoxRA->setDisplayFormat(AngleSpinBox::HMSLetters);
×
75
        ui->spinBoxDec->setDisplayFormat(AngleSpinBox::DMSSymbols);
×
76
}
×
77

78
void StoredPointsDialog::populatePointsList(QVariantList list)
×
79
{
80
        for (int i = 0; i < list.count(); i++ )
×
81
        {
82
                QVariant var = list.at(i);
×
83
                storedPoint sp = var.value<storedPoint>();
×
84
                // convert double to DisplayFormat
85
                AngleSpinBox tmpRA;
×
86
                AngleSpinBox tmpDec;
×
87

88
                tmpRA.setDisplayFormat(AngleSpinBox::HMSLetters);
×
89
                tmpDec.setDisplayFormat(AngleSpinBox::DMSSymbols);
×
90

91
                tmpRA.setRadians(sp.radiansRA);
×
92
                tmpDec.setRadians(sp.radiansDec);
×
93

94
                addModelRow(sp.number, sp.name, tmpRA.text(), tmpDec.text());
×
95
        }
×
96
}
×
97

98
void StoredPointsDialog::setHeaderNames()
×
99
{
100
        const QStringList headerStrings = {
101
                // TRANSLATORS: Symbol for "number"
102
                qc_("#", "numero sign"),
103
                q_("Name"),
104
                q_("Right Ascension (J2000)"),
105
                q_("Declination (J2000)")};
×
106
        storedPointsListModel->setHorizontalHeaderLabels(headerStrings);
×
107
}
×
108

109
void StoredPointsDialog::buttonAddPressed()
×
110
{
111
        double radiansRA  = ui->spinBoxRA->valueRadians();
×
112
        double radiansDec = ui->spinBoxDec->valueRadians();
×
113
        QString name      = ui->lineEditStoredPointName->text().trimmed();
×
114

115
        if (name.isEmpty())
×
116
                return;
×
117

118
        int lastRow = storedPointsListModel->rowCount();
×
119

120
        addModelRow(lastRow, name, ui->spinBoxRA->text(), ui->spinBoxDec->text());
×
121

122
        ui->lineEditStoredPointName->setText("");
×
123
        ui->lineEditStoredPointName->setFocus();
×
124

125
        emit addStoredPoint(lastRow, name, radiansRA, radiansDec);
×
126
}
×
127

128
void StoredPointsDialog::buttonRemovePressed()
×
129
{
130
        int number = ui->treeViewStoredPoints->currentIndex().row();
×
131
        storedPointsListModel->removeRow(number);
×
132

133
        emit removeStoredPoint(number);
×
134
}
×
135

136
void StoredPointsDialog::buttonClearPressed()
×
137
{
138
        storedPointsListModel->clear();
×
139

140
        emit clearStoredPoints();
×
141
}
×
142

143
void StoredPointsDialog::addModelRow(int number, QString name, QString RA, QString Dec)
×
144
{
145
        QStandardItem* tempItem = nullptr;
×
146

147
        tempItem = new QStandardItem(QString::number(number+1));
×
148
        tempItem->setEditable(false);
×
149
        storedPointsListModel->setItem(number, ColumnSlot, tempItem);
×
150

151
        tempItem = new QStandardItem(name);
×
152
        tempItem->setEditable(false);
×
153
        storedPointsListModel->setItem(number, ColumnName, tempItem);
×
154

155
        tempItem = new QStandardItem(RA);
×
156
        tempItem->setEditable(false);
×
157
        storedPointsListModel->setItem(number, ColumnRA, tempItem);
×
158

159
        tempItem = new QStandardItem(Dec);
×
160
        tempItem->setEditable(false);
×
161
        storedPointsListModel->setItem(number, ColumnDec, tempItem);
×
162
}
×
163

164
void StoredPointsDialog::getCurrentObjectInfo()
×
165
{
166
        const QList<StelObjectP>& selected = GETSTELMODULE(StelObjectMgr)->getSelectedObject();
×
167
        if (!selected.isEmpty())
×
168
        {
169
                double dec_j2000 = 0;
×
170
                double ra_j2000 = 0;
×
171
                StelUtils::rectToSphe(&ra_j2000,&dec_j2000, selected[0]->getJ2000EquatorialPos(StelApp::getInstance().getCore()));
×
172
                ui->spinBoxRA->setRadians(ra_j2000);
×
173
                ui->spinBoxDec->setRadians(dec_j2000);
×
174
                ui->lineEditStoredPointName->setText(selected[0]->getNameI18n());
×
175
        }
176
}
×
177

178
void StoredPointsDialog::getCenterInfo()
×
179
{
180
        StelCore *core = StelApp::getInstance().getCore();
×
181
        const StelProjectorP projector = core->getProjection(StelCore::FrameEquinoxEqu);
×
182
        Vec3d centerPosition;
×
183
        Vector2<qreal> center = projector->getViewportCenter();
×
184
        projector->unProject(center[0], center[1], centerPosition);
×
185
        double dec_j2000 = 0;
×
186
        double ra_j2000 = 0;
×
187
        StelUtils::rectToSphe(&ra_j2000,&dec_j2000,core->equinoxEquToJ2000(centerPosition, StelCore::RefractionOff)); // GZ for 0.15.2: Not sure about RefractionOff. This just keeps old behaviour.
×
188
        ui->spinBoxRA->setRadians(ra_j2000);
×
189
        ui->spinBoxDec->setRadians(dec_j2000);
×
190

191
        ui->lineEditStoredPointName->clear(); // if previous saved
×
192
        ui->lineEditStoredPointName->setFocus();
×
193
}
×
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc