File indexing completed on 2024-04-14 05:38:50
0001 /* 0002 -------------------------------------------------------------------- 0003 KDE\QT Printing class 0004 -------------------------------------------------------------------- 0005 SPDX-FileCopyrightText: 1999 Robert Berry <rjmber@ntlworld.com> 0006 -------------------------------------------------------------------- 0007 SPDX-License-Identifier: GPL-2.0-or-later 0008 */ 0009 0010 #pragma once 0011 0012 #include <QList> 0013 0014 #include "crontabPrinterWidget.h" 0015 0016 class QString; 0017 0018 class CrontabWidget; 0019 0020 class QPrinter; 0021 /** 0022 *Provides a wrapper for simple printing of text. 0023 */ 0024 class CrontabPrinter 0025 { 0026 public: 0027 /** 0028 * Constructor 0029 */ 0030 explicit CrontabPrinter(CrontabWidget *crontabWidget); 0031 0032 /** 0033 * Destructor 0034 */ 0035 ~CrontabPrinter(); 0036 0037 bool start(); 0038 void finish(); 0039 void printTasks(); 0040 void printVariables(); 0041 0042 /** 0043 * Whether crontab should be printed 0044 */ 0045 bool isPrintCrontab() const; 0046 0047 /** 0048 * Whether all users should be printed (root only) 0049 */ 0050 bool isAllUsers() const; 0051 0052 private: 0053 /** 0054 *Disable the copy constructor and the assignment operator 0055 */ 0056 CrontabPrinter &operator=(const CrontabPrinter &) 0057 { 0058 return *this; 0059 } 0060 0061 void printPageNumber(); 0062 0063 void drawMainTitle(); 0064 void drawTitle(const QString &title); 0065 0066 void drawHeader(const QList<int> &columnWidths, const QStringList &headers); 0067 void drawContentRow(const QList<int> &columnWidths, const QStringList &contents); 0068 0069 void drawTable(const QList<int> &columnWidths); 0070 0071 void needNewPage(); 0072 0073 void changeRow(int x, int y); 0074 int computeMargin() const; 0075 int computeStringHeight(const QString &text) const; 0076 0077 QList<int> findMaxWidths(const QList<QStringList> &tasksContent, int columnCount); 0078 QList<int> findColumnWidths(const QList<QStringList> &tasksContent, int columnCount); 0079 0080 /** 0081 * Pointer a printer options object 0082 */ 0083 CrontabPrinterWidget *mCrontabPrinterWidget = nullptr; 0084 0085 /** 0086 * Pointer to parent widget 0087 */ 0088 CrontabWidget *const mCrontabWidget; 0089 0090 QPainter *mPainter = nullptr; 0091 0092 QPrinter *mPrinter = nullptr; 0093 0094 QRect *mPrintView = nullptr; 0095 0096 int mPage = 0; 0097 int mCurrentRowPosition = 0; 0098 }; 0099