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
29 QTextBlockFormat titleBlockFmt;
30 titleBlockFmt.setAlignment(Qt::AlignCenter);
31
32 if (!title.isEmpty())
33 {
34 QTextCharFormat titleCharFmt;
35 QFont titleFont("Times", 20, QFont::Bold);
36 titleCharFmt.setFont(titleFont);
37
38 cursor.insertBlock(titleBlockFmt, titleCharFmt);
39 cursor.insertText(title);
40 }
41
42 if (!subtitle.isEmpty())
43 {
44 QTextCharFormat subtitleCharFmt;
45 QFont subtitleFont("Times", 14);
46 subtitleCharFmt.setFont(subtitleFont);
47
48 cursor.insertBlock(titleBlockFmt, subtitleCharFmt);
49 cursor.insertText(subtitle);
50
52 }
53}
54
56{
57 QTextCursor cursor = m_Document->rootFrame()->lastCursorPosition();
58
59 QTextBlockFormat descrBlockFmt;
60 descrBlockFmt.setAlignment(Qt::AlignJustify);
61 QTextCharFormat descrCharFmt;
62 QFont descrFont("Times", 10);
63 descrCharFmt.setFont(descrFont);
64
65 cursor.insertBlock(descrBlockFmt, descrCharFmt);
66 cursor.insertText(description);
67
69}
70
72{
73 QTextCursor cursor = m_Document->rootFrame()->lastCursorPosition();
74
75 QTextBlockFormat geoBlockFmt;
76 geoBlockFmt.setAlignment(Qt::AlignLeft);
77 QTextCharFormat geoCharFmt;
78 QFont geoFont("Times", 10, QFont::Bold);
79 geoCharFmt.setFont(geoFont);
80
81 cursor.insertBlock(geoBlockFmt);
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();
122 QTextCharFormat textFmt;
123 QTextBlockFormat blockFmt;
125
126 if (descriptionBelow)
127 {
128 cursor.insertBlock(blockFmt, textFmt);
129 cursor.insertImage(img);
130 cursor.insertBlock(blockFmt, textFmt);
131 cursor.insertText(description);
132 }
133
134 else
135 {
136 cursor.insertBlock(blockFmt, textFmt);
137 cursor.insertText(description);
138 cursor.insertBlock(blockFmt, textFmt);
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
159 QTextBlockFormat titleBlockFmt;
160 titleBlockFmt.setAlignment(Qt::AlignLeft);
161 QTextCharFormat titleCharFmt;
162 QFont titleFont("Times", 16, QFont::Bold);
164 titleCharFmt.setFont(titleFont);
165
166 cursor.insertBlock(titleBlockFmt, titleCharFmt);
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...)
void setBold(bool enable)
void setCapitalization(Capitalization caps)
QString & append(QChar ch)
bool isEmpty() const const
AlignCenter
void setAlignment(Qt::Alignment alignment)
void setFont(const QFont &font, FontPropertiesInheritanceBehavior behavior)
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 Nov 29 2024 11:57:48 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.