crontabPrinter.h 1.77 KB
Newer Older
1
2
3
4
5
6
7
8
/*
    --------------------------------------------------------------------
    KDE\QT Printing class
    --------------------------------------------------------------------
    SPDX-FileCopyrightText: 1999 Robert Berry <rjmber@ntlworld.com>
    --------------------------------------------------------------------
    SPDX-License-Identifier: GPL-2.0-or-later
*/
Robert Berry's avatar
Robert Berry committed
9

Yuri Chornoivan's avatar
Yuri Chornoivan committed
10
11
#ifndef CRONTABPRINTER_H
#define CRONTABPRINTER_H
Robert Berry's avatar
Robert Berry committed
12

13
#include <QList>
John Layt's avatar
John Layt committed
14

Nicolas Ternisien's avatar
Nicolas Ternisien committed
15
#include "crontabPrinterWidget.h"
Robert Berry's avatar
Robert Berry committed
16
17
18

class QString;

Nicolas Ternisien's avatar
Nicolas Ternisien committed
19
20
21
22
class CrontabWidget;

class CrontabPrinterPrivate;

Robert Berry's avatar
Robert Berry committed
23
/**
24
25
 *Provides a wrapper for simple printing of text.
 */
Nicolas Ternisien's avatar
   
Nicolas Ternisien committed
26
class CrontabPrinter {
Robert Berry's avatar
Robert Berry committed
27
28
public:

29
	/**
30
	 * Constructor
31
	 */
Yuri Chornoivan's avatar
Yuri Chornoivan committed
32
	explicit CrontabPrinter(CrontabWidget* crontabWidget);
33
34
35
36

	/**
	 * Destructor
	 */
Nicolas Ternisien's avatar
   
Nicolas Ternisien committed
37
	~CrontabPrinter();
Nicolas Ternisien's avatar
Nicolas Ternisien committed
38
	
39
	bool start();
Nicolas Ternisien's avatar
Nicolas Ternisien committed
40
41
42
	void finish();
	void printTasks();
	void printVariables();
43
44
45
46

	/**
	 * Whether crontab should be printed
	 */
Nicolas Ternisien's avatar
Nicolas Ternisien committed
47
48
	bool isPrintCrontab() const;
	
49
50
51
	/**  
	 * Whether all users should be printed (root only)
	 */
Nicolas Ternisien's avatar
Nicolas Ternisien committed
52
53
	bool isAllUsers() const;
	
Robert Berry's avatar
Robert Berry committed
54
55
private:

56
57
58
	/**
	 *Disable the copy constructor and the assignment operator
	 */
Nicolas Ternisien's avatar
   
Nicolas Ternisien committed
59
	CrontabPrinter& operator=(const CrontabPrinter&) {
60
61
		return *this;
	}
Nicolas Ternisien's avatar
Nicolas Ternisien committed
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
	
	void printPageNumber();
	
	void drawMainTitle();
	void drawTitle(const QString& title);
	
	void drawHeader(const QList<int>& columnWidths, const QStringList& headers);
	void drawContentRow(const QList<int>& columnWidths, const QStringList& contents);
	
	void drawTable(const QList<int>& columnWidths);
	
	void needNewPage();

	void changeRow(int x, int y);
	int computeMargin() const;
	int computeStringHeight(const QString& text) const;

	QList<int> findMaxWidths(const QList<QStringList>& tasksContent, int columnCount);
	QList<int> findColumnWidths(const QList<QStringList>& tasksContent, int columnCount);
	
	CrontabPrinterPrivate* const d;
Robert Berry's avatar
Robert Berry committed
83
84

};
85

Robert Berry's avatar
Robert Berry committed
86
#endif