• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdeedu API Reference
  • KDE Home
  • Contact Us
 

kstars

  • sources
  • kde-4.12
  • kdeedu
  • kstars
  • kstars
  • printing
finderchart.cpp
Go to the documentation of this file.
1 /***************************************************************************
2  finderchart.cpp - K Desktop Planetarium
3  -------------------
4  begin : Wed Jul 20 2011
5  copyright : (C) 2011 by Rafał Kułaga
6  email : rl.kulaga@gmail.com
7  ***************************************************************************/
8 
9 /***************************************************************************
10  * *
11  * This program is free software; you can redistribute it and/or modify *
12  * it under the terms of the GNU General Public License as published by *
13  * the Free Software Foundation; either version 2 of the License, or *
14  * (at your option) any later version. *
15  * *
16  ***************************************************************************/
17 
18 #include "finderchart.h"
19 
20 #include "QTextDocument"
21 #include "QTextDocumentFragment"
22 #include "QTextTable"
23 #include "QTextDocumentWriter"
24 #include "QSvgGenerator"
25 #include "QPainter"
26 #include "kstars.h"
27 #include "loggingform.h"
28 #include "detailstable.h"
29 #include "kstarsdatetime.h"
30 #include "geolocation.h"
31 
32 FinderChart::FinderChart() : KStarsDocument()
33 {}
34 
35 void FinderChart::insertTitleSubtitle(const QString &title, const QString &subtitle)
36 {
37  QTextCursor cursor(m_Document);
38  cursor.movePosition(QTextCursor::Start);
39 
40  QTextBlockFormat titleBlockFmt;
41  titleBlockFmt.setAlignment(Qt::AlignCenter);
42 
43  if(!title.isEmpty())
44  {
45  QTextCharFormat titleCharFmt;
46  QFont titleFont("Times", 20, QFont::Bold);
47  titleCharFmt.setFont(titleFont);
48 
49  cursor.insertBlock(titleBlockFmt, titleCharFmt);
50  cursor.insertText(title);
51  }
52 
53  if(!subtitle.isEmpty())
54  {
55  QTextCharFormat subtitleCharFmt;
56  QFont subtitleFont("Times", 14);
57  subtitleCharFmt.setFont(subtitleFont);
58 
59  cursor.insertBlock(titleBlockFmt, subtitleCharFmt);
60  cursor.insertText(subtitle);
61 
62  cursor.insertBlock(QTextBlockFormat(), QTextCharFormat());
63  }
64 }
65 
66 void FinderChart::insertDescription(const QString &description)
67 {
68  QTextCursor cursor = m_Document->rootFrame()->lastCursorPosition();
69 
70  QTextBlockFormat descrBlockFmt;
71  descrBlockFmt.setAlignment(Qt::AlignJustify);
72  QTextCharFormat descrCharFmt;
73  QFont descrFont("Times", 10);
74  descrCharFmt.setFont(descrFont);
75 
76  cursor.insertBlock(descrBlockFmt, descrCharFmt);
77  cursor.insertText(description);
78 
79  cursor.insertBlock(QTextBlockFormat(), QTextCharFormat());
80 }
81 
82 void FinderChart::insertGeoTimeInfo(const KStarsDateTime &ut, GeoLocation *geo)
83 {
84  QTextCursor cursor = m_Document->rootFrame()->lastCursorPosition();
85 
86  QTextBlockFormat geoBlockFmt;
87  geoBlockFmt.setAlignment(Qt::AlignLeft);
88  QTextCharFormat geoCharFmt;
89  QFont geoFont("Times", 10, QFont::Bold);
90  geoCharFmt.setFont(geoFont);
91 
92  cursor.insertBlock(geoBlockFmt);
93  cursor.insertText(i18n("Date, time and location: "), geoCharFmt);
94 
95  QString geoStr = geo->translatedName();
96  if(!geo->translatedProvince().isEmpty()) {
97  if(!geoStr.isEmpty()) {
98  geoStr.append(", ");
99  }
100  geoStr.append(geo->translatedProvince());
101  }
102  if(!geo->translatedCountry().isEmpty()) {
103  if(!geoStr.isEmpty()) {
104  geoStr.append(", ");
105  }
106  geoStr.append(geo->translatedCountry());
107  }
108 
109  geoFont.setBold(false);
110  geoCharFmt.setFont(geoFont);
111  cursor.insertText(KGlobal::locale()->formatDateTime(ut) + ", " + geoStr, geoCharFmt);
112 
113  cursor.insertBlock(QTextBlockFormat(), QTextCharFormat());
114 }
115 
116 void FinderChart::insertLoggingForm(LoggingForm *log)
117 {
118  QTextCursor cursor = m_Document->rootFrame()->lastCursorPosition();
119  cursor.insertFragment(QTextDocumentFragment(log->getDocument()));
120 
121  cursor.insertBlock(QTextBlockFormat(), QTextCharFormat());
122  cursor.insertBlock(QTextBlockFormat(), QTextCharFormat());
123 }
124 
125 void FinderChart::insertImage(const QImage &img, const QString &description, bool descriptionBelow)
126 {
127  QTextCursor cursor = m_Document->rootFrame()->lastCursorPosition();
128  QTextCharFormat textFmt;
129  QTextBlockFormat blockFmt;
130  blockFmt.setAlignment(Qt::AlignHCenter);
131 
132  if(descriptionBelow)
133  {
134  cursor.insertBlock(blockFmt, textFmt);
135  cursor.insertImage(img);
136  cursor.insertBlock(blockFmt, textFmt);
137  cursor.insertText(description);
138  }
139 
140  else
141  {
142  cursor.insertBlock(blockFmt, textFmt);
143  cursor.insertText(description);
144  cursor.insertBlock(blockFmt, textFmt);
145  cursor.insertImage(img);
146  }
147 
148  cursor.insertBlock(QTextBlockFormat(), QTextCharFormat());
149  cursor.insertBlock(QTextBlockFormat(), QTextCharFormat());
150 }
151 
152 void FinderChart::insertDetailsTable(DetailsTable *table)
153 {
154  QTextCursor cursor = m_Document->rootFrame()->lastCursorPosition();
155  cursor.insertFragment(QTextDocumentFragment(table->getDocument()));
156 
157  cursor.insertBlock(QTextBlockFormat(), QTextCharFormat());
158  cursor.insertBlock(QTextBlockFormat(), QTextCharFormat());
159 }
160 
161 void FinderChart::insertSectionTitle(const QString &title)
162 {
163  QTextCursor cursor = m_Document->rootFrame()->lastCursorPosition();
164 
165  QTextBlockFormat titleBlockFmt;
166  titleBlockFmt.setAlignment(Qt::AlignLeft);
167  QTextCharFormat titleCharFmt;
168  QFont titleFont("Times", 16, QFont::Bold);
169  titleFont.setCapitalization(QFont::AllUppercase);
170  titleCharFmt.setFont(titleFont);
171 
172  cursor.insertBlock(titleBlockFmt, titleCharFmt);
173  cursor.insertText(title);
174 }
DetailsTable::getDocument
QTextDocument * getDocument()
Get table document.
Definition: detailstable.h:137
GeoLocation::translatedName
QString translatedName() const
Definition: geolocation.cpp:78
FinderChart::insertImage
void insertImage(const QImage &img, const QString &description, bool descriptionBelow=true)
Insert image to the finder chart.
Definition: finderchart.cpp:125
geolocation.h
LoggingForm::getDocument
QTextDocument * getDocument()
Get logging form internal QTextDocument.
Definition: loggingform.cpp:72
FinderChart::FinderChart
FinderChart()
Constructor.
Definition: finderchart.cpp:32
LoggingForm
Class that represents logging form.
Definition: loggingform.h:32
GeoLocation::translatedProvince
QString translatedProvince() const
Definition: geolocation.cpp:88
FinderChart::insertDescription
void insertDescription(const QString &description)
Insert description to the finder chart.
Definition: finderchart.cpp:66
FinderChart::insertDetailsTable
void insertDetailsTable(DetailsTable *table)
Insert details table to the finder chart.
Definition: finderchart.cpp:152
GeoLocation
Contains all relevant information for specifying a location on Earth: City Name, State/Province name...
Definition: geolocation.h:39
loggingform.h
detailstable.h
KStarsDateTime
Extension of KDateTime for KStars KStarsDateTime can represent the date/time as a Julian Day...
Definition: kstarsdatetime.h:45
FinderChart::insertLoggingForm
void insertLoggingForm(LoggingForm *log)
Insert logging form to the finder chart.
Definition: finderchart.cpp:116
KStarsDocument::m_Document
QTextDocument * m_Document
Definition: kstarsdocument.h:73
FinderChart::insertSectionTitle
void insertSectionTitle(const QString &title)
Insert section title to the finder chart.
Definition: finderchart.cpp:161
FinderChart::insertGeoTimeInfo
void insertGeoTimeInfo(const KStarsDateTime &ut, GeoLocation *geo)
Insert details about date&time and geographic location.
Definition: finderchart.cpp:82
description
static const char description[]
Definition: main.cpp:37
finderchart.h
kstarsdatetime.h
GeoLocation::translatedCountry
QString translatedCountry() const
Definition: geolocation.cpp:92
DetailsTable
Represents details tables that can be inserted to finder charts and logging forms.
Definition: detailstable.h:39
kstars.h
KStarsDocument
Base class for KStars documents.
Definition: kstarsdocument.h:35
FinderChart::insertTitleSubtitle
void insertTitleSubtitle(const QString &title, const QString &subtitle)
Insert title and subtitle to the finder chart.
Definition: finderchart.cpp:35
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 22:36:19 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

kstars

Skip menu "kstars"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Related Pages

kdeedu API Reference

Skip menu "kdeedu API Reference"
  • Analitza
  •     lib
  • kalgebra
  • kalzium
  •   libscience
  • kanagram
  • kig
  •   lib
  • klettres
  • kstars
  • libkdeedu
  •   keduvocdocument
  • marble
  • parley
  • rocs
  •   App
  •   RocsCore
  •   VisualEditor
  •   stepcore

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal