Kstars

finderchart.cpp
1/*
2 SPDX-FileCopyrightText: 2011 Rafał Kułaga <rl.kulaga@gmail.com>
3
4 SPDX-License-Identifier: GPL-2.0-or-later
5*/
6
7#include "finderchart.h"
8
9#include "detailstable.h"
10#include "geolocation.h"
11#include "kstarsdatetime.h"
12#include "loggingform.h"
13
14#include <QLocale>
15#include <QTextDocument>
16#include <QTextDocumentFragment>
17#include <QTextDocumentWriter>
18#include <QTextTable>
19
23
24void FinderChart::insertTitleSubtitle(const QString &title, const QString &subtitle)
25{
26 QTextCursor cursor(m_Document.get());
28
30 titleBlockFmt.setAlignment(Qt::AlignCenter);
31
32 if (!title.isEmpty())
33 {
35 QFont titleFont("Times", 20, QFont::Bold);
36 titleCharFmt.setFont(titleFont);
37
39 cursor.insertText(title);
40 }
41
42 if (!subtitle.isEmpty())
43 {
45 QFont subtitleFont("Times", 14);
46 subtitleCharFmt.setFont(subtitleFont);
47
49 cursor.insertText(subtitle);
50
52 }
53}
54
56{
57 QTextCursor cursor = m_Document->rootFrame()->lastCursorPosition();
58
60 descrBlockFmt.setAlignment(Qt::AlignJustify);
62 QFont descrFont("Times", 10);
63 descrCharFmt.setFont(descrFont);
64
66 cursor.insertText(description);
67
69}
70
72{
73 QTextCursor cursor = m_Document->rootFrame()->lastCursorPosition();
74
76 geoBlockFmt.setAlignment(Qt::AlignLeft);
78 QFont geoFont("Times", 10, QFont::Bold);
79 geoCharFmt.setFont(geoFont);
80
82 cursor.insertText(i18n("Date, time and location: "), geoCharFmt);
83
84 QString geoStr = geo->translatedName();
85 if (!geo->translatedProvince().isEmpty())
86 {
87 if (!geoStr.isEmpty())
88 {
89 geoStr.append(", ");
90 }
91 geoStr.append(geo->translatedProvince());
92 }
93 if (!geo->translatedCountry().isEmpty())
94 {
95 if (!geoStr.isEmpty())
96 {
97 geoStr.append(", ");
98 }
99 geoStr.append(geo->translatedCountry());
100 }
101
102 geoFont.setBold(false);
103 geoCharFmt.setFont(geoFont);
104 //cursor.insertText(QLocale().toString(ut.dateTime()) + ", " + geoStr, geoCharFmt);
105 cursor.insertText(QLocale().toString(ut) + ", " + geoStr, geoCharFmt);
106
108}
109
111{
112 QTextCursor cursor = m_Document->rootFrame()->lastCursorPosition();
114
117}
118
119void FinderChart::insertImage(const QImage &img, const QString &description, bool descriptionBelow)
120{
121 QTextCursor cursor = m_Document->rootFrame()->lastCursorPosition();
124 blockFmt.setAlignment(Qt::AlignHCenter);
125
127 {
129 cursor.insertImage(img);
131 cursor.insertText(description);
132 }
133
134 else
135 {
137 cursor.insertText(description);
139 cursor.insertImage(img);
140 }
141
144}
145
147{
148 QTextCursor cursor = m_Document->rootFrame()->lastCursorPosition();
150
153}
154
156{
157 QTextCursor cursor = m_Document->rootFrame()->lastCursorPosition();
158
160 titleBlockFmt.setAlignment(Qt::AlignLeft);
162 QFont titleFont("Times", 16, QFont::Bold);
163 titleFont.setCapitalization(QFont::AllUppercase);
164 titleCharFmt.setFont(titleFont);
165
167 cursor.insertText(title);
168}
Represents details tables that can be inserted to finder charts and logging forms.
QTextDocument * getDocument()
Get table document.
void insertDetailsTable(DetailsTable *table)
Insert details table to the finder chart.
void insertDescription(const QString &description)
Insert description to the finder chart.
void insertSectionTitle(const QString &title)
Insert section title to the finder chart.
FinderChart()
Constructor.
void insertLoggingForm(LoggingForm *log)
Insert logging form to the finder chart.
void insertTitleSubtitle(const QString &title, const QString &subtitle)
Insert title and subtitle to the finder chart.
void insertImage(const QImage &img, const QString &description, bool descriptionBelow=true)
Insert image to the finder chart.
void insertGeoTimeInfo(const KStarsDateTime &ut, GeoLocation *geo)
Insert details about date&time and geographic location.
Contains all relevant information for specifying a location on Earth: City Name, State/Province name,...
Definition geolocation.h:28
Extension of QDateTime for KStars KStarsDateTime can represent the date/time as a Julian Day,...
Base class for KStars documents.
Class that represents logging form.
Definition loggingform.h:21
QTextDocument * getDocument()
Get logging form internal QTextDocument.
QString i18n(const char *text, const TYPE &arg...)
bool isEmpty() const const
AlignCenter
void insertBlock()
void insertFragment(const QTextDocumentFragment &fragment)
void insertImage(const QImage &image, const QString &name)
void insertText(const QString &text)
bool movePosition(MoveOperation operation, MoveMode mode, int n)
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri May 24 2024 11:49:23 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.