Commit a72fc7ec authored by Glen Ditchfield's avatar Glen Ditchfield 🐛
Browse files

Combine doLoadConfig()/loadConfig(), doSaveConfig()/saveConfig()

`doLoadConfig()`, virtual but never overridden, loaded some configuration
options and then called virtual `loadConfig()` to load the rest.  Combine
them into one virtual function.  The same applies to `doSaveConfig()` and
`saveConfig()`.
parent 6ddd070f
Pipeline #70896 failed with stage
in 4 minutes and 47 seconds
......@@ -73,20 +73,20 @@ void CalPrintIncidence::setSettingsWidget()
}
}
void CalPrintIncidence::loadConfig()
void CalPrintIncidence::doLoadConfig()
{
CalPrintPluginBase::doLoadConfig();
if (mConfig) {
KConfigGroup grp(mConfig, groupName());
mShowOptions = grp.readEntry("Show Options", false);
mShowSubitemsNotes = grp.readEntry("Show Subitems and Notes", false);
mShowAttendees = grp.readEntry("Use Attendees", false);
mShowAttachments = grp.readEntry("Use Attachments", false);
mShowNoteLines = grp.readEntry("Note Lines", false);
}
setSettingsWidget();
}
void CalPrintIncidence::saveConfig()
void CalPrintIncidence::doSaveConfig()
{
readSettingsWidget();
if (mConfig) {
......@@ -95,8 +95,8 @@ void CalPrintIncidence::saveConfig()
grp.writeEntry("Show Subitems and Notes", mShowSubitemsNotes);
grp.writeEntry("Use Attendees", mShowAttendees);
grp.writeEntry("Use Attachments", mShowAttachments);
grp.writeEntry("Note Lines", mShowNoteLines);
}
CalPrintPluginBase::doSaveConfig();
}
class TimePrintStringsVisitor : public KCalendarCore::Visitor
......@@ -710,8 +710,9 @@ void CalPrintDay::setSettingsWidget()
}
}
void CalPrintDay::loadConfig()
void CalPrintDay::doLoadConfig()
{
CalPrintPluginBase::doLoadConfig();
if (mConfig) {
KConfigGroup grp(mConfig, groupName());
QDate dt = QDate::currentDate(); // any valid QDate will do
......@@ -726,13 +727,12 @@ void CalPrintDay::loadConfig()
mIncludeAllEvents = grp.readEntry("Include all events", false);
mDayPrintType = static_cast<eDayPrintType>(grp.readEntry("Print type", static_cast<int>(Timetable)));
mSingleLineLimit = grp.readEntry("Single line limit", false);
mShowNoteLines = grp.readEntry("Note Lines", false);
mExcludeTime = grp.readEntry("Exclude time", false);
}
setSettingsWidget();
}
void CalPrintDay::saveConfig()
void CalPrintDay::doSaveConfig()
{
readSettingsWidget();
if (mConfig) {
......@@ -748,9 +748,9 @@ void CalPrintDay::saveConfig()
grp.writeEntry("Include all events", mIncludeAllEvents);
grp.writeEntry("Print type", int(mDayPrintType));
grp.writeEntry("Single line limit", mSingleLineLimit);
grp.writeEntry("Note Lines", mShowNoteLines);
grp.writeEntry("Exclude time", mExcludeTime);
}
CalPrintPluginBase::doSaveConfig();
}
void CalPrintDay::setDateRange(const QDate &from, const QDate &to)
......@@ -932,8 +932,9 @@ void CalPrintWeek::setSettingsWidget()
}
}
void CalPrintWeek::loadConfig()
void CalPrintWeek::doLoadConfig()
{
CalPrintPluginBase::doLoadConfig();
if (mConfig) {
KConfigGroup grp(mConfig, groupName());
QDate dt = QDate::currentDate(); // any valid QDate will do
......@@ -942,7 +943,6 @@ void CalPrintWeek::loadConfig()
QDateTime endTm(dt, tm1.addSecs(43200));
mStartTime = grp.readEntry("Start time", startTm).time();
mEndTime = grp.readEntry("End time", endTm).time();
mShowNoteLines = grp.readEntry("Note Lines", false);
mSingleLineLimit = grp.readEntry("Single line limit", false);
mIncludeTodos = grp.readEntry("Include todos", false);
mIncludeAllEvents = grp.readEntry("Include all events", false);
......@@ -954,7 +954,7 @@ void CalPrintWeek::loadConfig()
setSettingsWidget();
}
void CalPrintWeek::saveConfig()
void CalPrintWeek::doSaveConfig()
{
readSettingsWidget();
if (mConfig) {
......@@ -964,7 +964,6 @@ void CalPrintWeek::saveConfig()
grp.writeEntry("Start time", dt);
dt.setTime(mEndTime);
grp.writeEntry("End time", dt);
grp.writeEntry("Note Lines", mShowNoteLines);
grp.writeEntry("Single line limit", mSingleLineLimit);
grp.writeEntry("Include todos", mIncludeTodos);
grp.writeEntry("Include all events", mIncludeAllEvents);
......@@ -973,6 +972,7 @@ void CalPrintWeek::saveConfig()
grp.writeEntry("Include categories", mIncludeCategories);
grp.writeEntry("Exclude Time", mExcludeTime);
}
CalPrintPluginBase::doSaveConfig();
}
QPageLayout::Orientation CalPrintWeek::defaultOrientation() const
......@@ -1174,8 +1174,9 @@ void CalPrintMonth::setSettingsWidget()
}
}
void CalPrintMonth::loadConfig()
void CalPrintMonth::doLoadConfig()
{
CalPrintPluginBase::doLoadConfig();
if (mConfig) {
KConfigGroup grp(mConfig, groupName());
mWeekNumbers = grp.readEntry("Print week numbers", true);
......@@ -1183,14 +1184,13 @@ void CalPrintMonth::loadConfig()
mRecurWeekly = grp.readEntry("Print weekly incidences", true);
mIncludeTodos = grp.readEntry("Include todos", false);
mSingleLineLimit = grp.readEntry("Single line limit", false);
mShowNoteLines = grp.readEntry("Note Lines", false);
mIncludeDescription = grp.readEntry("Include description", false);
mIncludeCategories = grp.readEntry("Include categories", false);
}
setSettingsWidget();
}
void CalPrintMonth::saveConfig()
void CalPrintMonth::doSaveConfig()
{
readSettingsWidget();
if (mConfig) {
......@@ -1200,10 +1200,10 @@ void CalPrintMonth::saveConfig()
grp.writeEntry("Print weekly incidences", mRecurWeekly);
grp.writeEntry("Include todos", mIncludeTodos);
grp.writeEntry("Single line limit", mSingleLineLimit);
grp.writeEntry("Note Lines", mShowNoteLines);
grp.writeEntry("Include description", mIncludeDescription);
grp.writeEntry("Include categories", mIncludeCategories);
}
CalPrintPluginBase::doSaveConfig();
}
void CalPrintMonth::setDateRange(const QDate &from, const QDate &to)
......@@ -1376,8 +1376,9 @@ void CalPrintTodos::setSettingsWidget()
}
}
void CalPrintTodos::loadConfig()
void CalPrintTodos::doLoadConfig()
{
CalPrintPluginBase::doLoadConfig();
if (mConfig) {
KConfigGroup grp(mConfig, groupName());
mPageTitle = grp.readEntry("Page title", i18n("To-do list"));
......@@ -1396,7 +1397,7 @@ void CalPrintTodos::loadConfig()
setSettingsWidget();
}
void CalPrintTodos::saveConfig()
void CalPrintTodos::doSaveConfig()
{
readSettingsWidget();
if (mConfig) {
......@@ -1414,6 +1415,7 @@ void CalPrintTodos::saveConfig()
grp.writeEntry("Sort field", static_cast<int>(mTodoSortField));
grp.writeEntry("Sort direction", static_cast<int>(mTodoSortDirection));
}
CalPrintPluginBase::doSaveConfig();
}
void CalPrintTodos::print(QPainter &p, int width, int height)
......
......@@ -62,8 +62,8 @@ public:
void print(QPainter &p, int width, int height) override;
void readSettingsWidget() override;
void setSettingsWidget() override;
void loadConfig() override;
void saveConfig() override;
void doLoadConfig() override;
void doSaveConfig() override;
protected:
int printCaptionAndText(QPainter &p, QRect box, const QString &caption, const QString &text, const QFont &captionFont, const QFont &textFont);
......@@ -110,8 +110,8 @@ public:
void print(QPainter &p, int width, int height) override;
void readSettingsWidget() override;
void setSettingsWidget() override;
void loadConfig() override;
void saveConfig() override;
void doLoadConfig() override;
void doSaveConfig() override;
void setDateRange(const QDate &from, const QDate &to) override;
protected:
......@@ -167,8 +167,8 @@ public:
void print(QPainter &p, int width, int height) override;
void readSettingsWidget() override;
void setSettingsWidget() override;
void loadConfig() override;
void saveConfig() override;
void doLoadConfig() override;
void doSaveConfig() override;
void setDateRange(const QDate &from, const QDate &to) override;
protected:
......@@ -222,8 +222,8 @@ public:
void print(QPainter &p, int width, int height) override;
void readSettingsWidget() override;
void setSettingsWidget() override;
void loadConfig() override;
void saveConfig() override;
void doLoadConfig() override;
void doSaveConfig() override;
void setDateRange(const QDate &from, const QDate &to) override;
protected:
......@@ -273,8 +273,8 @@ public:
void print(QPainter &p, int width, int height) override;
void readSettingsWidget() override;
void setSettingsWidget() override;
void loadConfig() override;
void saveConfig() override;
void doLoadConfig() override;
void doSaveConfig() override;
protected:
QString mPageTitle;
......
......@@ -184,9 +184,9 @@ void CalPrintPluginBase::doLoadConfig()
mToDate = group.readEntry("ToDate", dt).date();
mUseColors = group.readEntry("UseColors", true);
mPrintFooter = group.readEntry("PrintFooter", true);
mShowNoteLines = group.readEntry("Note Lines", false);
mExcludeConfidential = group.readEntry("Exclude confidential", true);
mExcludePrivate = group.readEntry("Exclude private", true);
loadConfig();
} else {
qCDebug(CALENDARSUPPORT_LOG) << "No config available in loadConfig!!!!";
}
......@@ -196,7 +196,6 @@ void CalPrintPluginBase::doSaveConfig()
{
if (mConfig) {
KConfigGroup group(mConfig, groupName());
saveConfig();
QDateTime dt = QDateTime::currentDateTime(); // any valid QDateTime will do
dt.setDate(mFromDate);
group.writeEntry("FromDate", dt);
......@@ -204,6 +203,7 @@ void CalPrintPluginBase::doSaveConfig()
group.writeEntry("ToDate", dt);
group.writeEntry("UseColors", mUseColors);
group.writeEntry("PrintFooter", mPrintFooter);
group.writeEntry("Note Lines", mShowNoteLines);
group.writeEntry("Exclude confidential", mExcludeConfidential);
group.writeEntry("Exclude private", mExcludePrivate);
mConfig->sync();
......
......@@ -66,28 +66,15 @@ public:
@param width Width of printable area
@param height Height of printable area
*/
virtual void print(QPainter &p, int width, int height) = 0;
/**
Start printing.
*/
void doPrint(QPrinter *printer) override;
/**
Load print format configuration from config file.
*/
virtual void loadConfig() = 0;
/**
Write print format configuration to config file.
*/
virtual void saveConfig() = 0;
/**
Load complete config. This also calls loadConfig() of the derived class.
*/
void doLoadConfig() override;
/**
Save complete config. This also calls saveConfig() of the derived class.
*/
void doSaveConfig() override;
/** HELPER FUNCTIONS */
......
......@@ -59,8 +59,9 @@ void CalPrintJournal::setSettingsWidget()
}
}
void CalPrintJournal::loadConfig()
void CalPrintJournal::doLoadConfig()
{
CalPrintPluginBase::doLoadConfig();
if (mConfig) {
KConfigGroup config(mConfig, "Journalprint");
mUseDateRange = config.readEntry("JournalsInRange", false);
......@@ -68,7 +69,7 @@ void CalPrintJournal::loadConfig()
setSettingsWidget();
}
void CalPrintJournal::saveConfig()
void CalPrintJournal::doSaveConfig()
{
qCDebug(CALENDARSUPPORT_LOG);
......@@ -77,6 +78,7 @@ void CalPrintJournal::saveConfig()
KConfigGroup config(mConfig, "Journalprint");
config.writeEntry("JournalsInRange", mUseDateRange);
}
CalPrintPluginBase::doSaveConfig();
}
void CalPrintJournal::setDateRange(const QDate &from, const QDate &to)
......
......@@ -54,8 +54,8 @@ public:
void print(QPainter &p, int width, int height) override;
void readSettingsWidget() override;
void setSettingsWidget() override;
void loadConfig() override;
void saveConfig() override;
void doLoadConfig() override;
void doSaveConfig() override;
void setDateRange(const QDate &from, const QDate &to) override;
protected:
......
......@@ -135,14 +135,17 @@ public:
}
/**
Load complete config.
Load complete configuration. Each implementation calls its parent's
implementation to load parent configuration options, then loads its own.
*/
virtual void doLoadConfig()
{
}
/**
Save complete config.
Save complete configuration. Each implementation saves its own
configuration options, then calls its parent's implementation to save
parent options.
*/
virtual void doSaveConfig()
{
......
......@@ -60,8 +60,9 @@ void CalPrintYear::setSettingsWidget()
}
}
void CalPrintYear::loadConfig()
void CalPrintYear::doLoadConfig()
{
CalPrintPluginBase::doLoadConfig();
if (mConfig) {
KConfigGroup config(mConfig, "Yearprint");
mYear = config.readEntry("Year", QDate::currentDate().year());
......@@ -72,7 +73,7 @@ void CalPrintYear::loadConfig()
setSettingsWidget();
}
void CalPrintYear::saveConfig()
void CalPrintYear::doSaveConfig()
{
qCDebug(CALENDARSUPPORT_LOG);
......@@ -85,6 +86,7 @@ void CalPrintYear::saveConfig()
config.writeEntry("ShowSubDayEventsAs", mSubDaysEvents);
config.writeEntry("ShowHolidaysAs", mHolidaysEvents);
}
CalPrintPluginBase::doSaveConfig();
}
QPageLayout::Orientation CalPrintYear::defaultOrientation() const
......
......@@ -55,8 +55,8 @@ public:
void print(QPainter &p, int width, int height) override;
void readSettingsWidget() override;
void setSettingsWidget() override;
void loadConfig() override;
void saveConfig() override;
void doLoadConfig() override;
void doSaveConfig() override;
void setDateRange(const QDate &from, const QDate &to) override;
protected:
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment