File indexing completed on 2024-03-24 15:17:40

0001 /*
0002     SPDX-FileCopyrightText: 2011 Rafał Kułaga <rl.kulaga@gmail.com>
0003 
0004     SPDX-License-Identifier: GPL-2.0-or-later
0005 */
0006 
0007 #include "loggingform.h"
0008 
0009 #include <KLocalizedString>
0010 
0011 #include <QTextDocument>
0012 #include <QTextTable>
0013 
0014 void LoggingForm::createFinderChartLogger()
0015 {
0016     QTextCursor cursor(m_Document.get());
0017     cursor.movePosition(QTextCursor::Start);
0018 
0019     QTextTableFormat tableFormat;
0020     tableFormat.setAlignment(Qt::AlignHCenter);
0021     tableFormat.setBorder(2);
0022     tableFormat.setCellPadding(2);
0023     tableFormat.setCellSpacing(4);
0024 
0025     QTextCharFormat fieldCharFmt;
0026     QFont font("Times", 10);
0027     fieldCharFmt.setFont(font);
0028 
0029     QVector<QTextLength> constraints;
0030     constraints << QTextLength(QTextLength::PercentageLength, 25) << QTextLength(QTextLength::PercentageLength, 25)
0031                 << QTextLength(QTextLength::PercentageLength, 25) << QTextLength(QTextLength::PercentageLength, 25);
0032     tableFormat.setColumnWidthConstraints(constraints);
0033 
0034     QTextTable *table = cursor.insertTable(5, 4, tableFormat);
0035     table->mergeCells(0, 0, 1, 4);
0036     table->cellAt(0, 0).firstCursorPosition().insertText(i18n("Observer:"), fieldCharFmt);
0037 
0038     table->mergeCells(1, 0, 1, 2);
0039     table->cellAt(1, 0).firstCursorPosition().insertText(i18n("Date:"), fieldCharFmt);
0040     table->mergeCells(1, 2, 1, 2);
0041     table->cellAt(1, 2).firstCursorPosition().insertText(i18n("Time:"), fieldCharFmt);
0042 
0043     table->mergeCells(2, 0, 1, 2);
0044     table->cellAt(2, 0).firstCursorPosition().insertText(i18n("Site:"), fieldCharFmt);
0045     table->cellAt(2, 2).firstCursorPosition().insertText(i18n("Seeing:"), fieldCharFmt);
0046     table->cellAt(2, 3).firstCursorPosition().insertText(i18n("Trans:"), fieldCharFmt);
0047 
0048     table->mergeCells(3, 0, 1, 4);
0049     table->cellAt(3, 0).firstCursorPosition().insertText(i18n("Telescope:"), fieldCharFmt);
0050 
0051     table->mergeCells(4, 0, 1, 3);
0052     table->cellAt(4, 0).firstCursorPosition().insertText(i18n("Eyepiece:"), fieldCharFmt);
0053     table->cellAt(4, 3).firstCursorPosition().insertText(i18n("Power:"), fieldCharFmt);
0054 }
0055 
0056 QTextDocument *LoggingForm::getDocument()
0057 {
0058     return m_Document.get();
0059 }