File indexing completed on 2024-05-12 04:20:44
0001 /* 0002 * SPDX-FileCopyrightText: 2020 Dag Andersen <dag.andersen@kdemail.net> 0003 * 0004 * This file is part of the KGantt library. 0005 * 0006 * SPDX-License-Identifier: GPL-2.0-or-later 0007 */ 0008 0009 #include "kganttprintingcontext.h" 0010 0011 namespace KGantt 0012 { 0013 0014 class Q_DECL_HIDDEN PrintingContext::Private { 0015 public: 0016 PrintingContext::Fitting fitting; 0017 QRectF sceneRect; 0018 bool drawRowLabels; 0019 bool drawColumnLabels; 0020 }; 0021 0022 PrintingContext::PrintingContext() 0023 : d(new Private()) 0024 { 0025 d->fitting = NoFitting; 0026 d->drawRowLabels= true; 0027 d->drawColumnLabels = true; 0028 } 0029 0030 PrintingContext::PrintingContext(const PrintingContext &other) 0031 : d(new Private(*other.d)) 0032 { 0033 } 0034 0035 PrintingContext &PrintingContext::operator=(const PrintingContext &other) 0036 { 0037 *d = *other.d; 0038 return *this; 0039 } 0040 0041 PrintingContext::~PrintingContext() 0042 { 0043 delete d; d = nullptr; 0044 } 0045 0046 QRectF PrintingContext::sceneRect() const 0047 { 0048 return d->sceneRect; 0049 } 0050 0051 void PrintingContext::setSceneRect(const QRectF &rect) 0052 { 0053 d->sceneRect = rect; 0054 } 0055 0056 PrintingContext::Fitting PrintingContext::fitting() const 0057 { 0058 return d->fitting; 0059 } 0060 0061 void PrintingContext::setFitting(const PrintingContext::Fitting &value) 0062 { 0063 d->fitting = value; 0064 } 0065 0066 bool PrintingContext::drawRowLabels() const 0067 { 0068 return d->drawRowLabels; 0069 } 0070 0071 void PrintingContext::setDrawRowLabels(bool state) 0072 { 0073 d->drawRowLabels = state; 0074 } 0075 0076 bool PrintingContext::drawColumnLabels() const 0077 { 0078 return d->drawColumnLabels; 0079 } 0080 0081 void PrintingContext::setDrawColumnLabels(bool state) 0082 { 0083 d->drawColumnLabels = state; 0084 } 0085 0086 qreal PrintingContext::left() const 0087 { 0088 return d->sceneRect.left(); 0089 } 0090 0091 void PrintingContext::setLeft(qreal left) 0092 { 0093 d->sceneRect.setLeft(left); 0094 } 0095 0096 qreal PrintingContext::top() const 0097 { 0098 return d->sceneRect.top(); 0099 } 0100 0101 void PrintingContext::setTop(qreal top) 0102 { 0103 d->sceneRect.setTop(top); 0104 } 0105 0106 qreal PrintingContext::right() const 0107 { 0108 return d->sceneRect.right(); 0109 } 0110 0111 void PrintingContext::setRight(qreal right) 0112 { 0113 d->sceneRect.setRight(right); 0114 } 0115 0116 qreal PrintingContext::bottom() const 0117 { 0118 return d->sceneRect.bottom(); 0119 } 0120 0121 void PrintingContext::setBottom(qreal bottom) 0122 { 0123 d->sceneRect.setBottom(bottom); 0124 } 0125 0126 } 0127 0128 #ifndef QT_NO_DEBUG_STREAM 0129 QDebug operator<<( QDebug dbg, const KGantt::PrintingContext::Fitting &f) 0130 { 0131 switch (f) { 0132 case KGantt::PrintingContext::NoFitting: dbg << "Fitting::NoFitting"; break; 0133 case KGantt::PrintingContext::FitSinglePage: dbg << "Fitting::FitSinglePage"; break; 0134 case KGantt::PrintingContext::FitPageHeight: dbg << "Fitting::FitPageHeight"; break; 0135 default: break; 0136 } 0137 return dbg; 0138 } 0139 QDebug operator<<( QDebug dbg, const KGantt::PrintingContext &ctx) 0140 { 0141 dbg << "KGantt::PrintingContext["; 0142 dbg << ctx.fitting(); 0143 dbg << "Rows:" << ctx.drawRowLabels(); 0144 dbg << "Cols:" << ctx.drawColumnLabels(); 0145 dbg << ctx.sceneRect(); 0146 dbg << ']'; 0147 return dbg; 0148 } 0149 #endif