Commit 43cb1a84 authored by Laurent Montel's avatar Laurent Montel 😁
Browse files

Rename private variables

parent 0f82a544
......@@ -30,24 +30,8 @@
K_PLUGIN_FACTORY(KCMCronFactory, registerPlugin<KCMCron>();
)
class KCMCronPrivate
{
public:
/**
* Main GUI view/working area.
*/
CrontabWidget *crontabWidget = nullptr;
/**
* Document object, here crotab entries.
*/
CTHost *ctHost = nullptr;
};
KCMCron::KCMCron(QWidget *parent, const QVariantList & /*args*/)
: KCModule(parent)
, d(new KCMCronPrivate())
{
KAboutData *aboutData = new KAboutData(QStringLiteral("kcm_cron"), i18n("Task Scheduler"),
QStringLiteral("5.0"), i18n("KDE Task Scheduler"), KAboutLicense::GPL, i18n("(c) 2008, Nicolas Ternisien\n(c) 1999-2000, Gary Meyer"));
......@@ -62,23 +46,23 @@ KCMCron::KCMCron(QWidget *parent, const QVariantList & /*args*/)
// Initialize document.
CTInitializationError ctInitializationError;
d->ctHost = new CTHost(findCrontabBinary(), ctInitializationError);
mCtHost = new CTHost(findCrontabBinary(), ctInitializationError);
if (ctInitializationError.hasErrorMessage()) {
KMessageBox::error(this, i18n("The following error occurred while initializing KCron:"
"\n\n%1\n\nKCron will now exit.\n", ctInitializationError.errorMessage()));
}
d->crontabWidget = new CrontabWidget(this, d->ctHost);
mCrontabWidget = new CrontabWidget(this, mCtHost);
logDebug() << "Crontab Widget initialized";
connect(d->crontabWidget->tasksWidget(), SIGNAL(taskModified(bool)), this, SIGNAL(changed(bool)));
connect(d->crontabWidget->variablesWidget(), SIGNAL(variableModified(bool)), this, SIGNAL(changed(bool)));
connect(mCrontabWidget->tasksWidget(), SIGNAL(taskModified(bool)), this, SIGNAL(changed(bool)));
connect(mCrontabWidget->variablesWidget(), SIGNAL(variableModified(bool)), this, SIGNAL(changed(bool)));
// Initialize view.
QVBoxLayout *layout = new QVBoxLayout(this);
layout->addWidget(d->crontabWidget);
layout->addWidget(mCrontabWidget);
init();
}
......@@ -90,24 +74,23 @@ QString KCMCron::findCrontabBinary()
KCMCron::~KCMCron()
{
delete d->crontabWidget;
delete d->ctHost;
delete mCrontabWidget;
delete mCtHost;
delete d;
}
void KCMCron::load()
{
logDebug() << "Calling load";
d->ctHost->cancel();
mCtHost->cancel();
}
void KCMCron::save()
{
logDebug() << "Saving crontab...";
CTSaveStatus saveStatus = d->ctHost->save();
CTSaveStatus saveStatus = mCtHost->save();
if (saveStatus.isError() == true) {
KMessageBox::detailedError(this, saveStatus.errorMessage(), saveStatus.detailErrorMessage());
}
......@@ -117,16 +100,16 @@ void KCMCron::defaults()
{
logDebug() << "Loading defaults";
d->ctHost->cancel();
mCtHost->cancel();
}
bool KCMCron::init()
{
// Display greeting screen.
// if there currently are no scheduled tasks...
if (!d->ctHost->isRootUser()) {
if (!mCtHost->isRootUser()) {
int taskCount = 0;
foreach (CTCron *ctCron, d->ctHost->crons) {
foreach (CTCron *ctCron, mCtHost->crons) {
taskCount += ctCron->tasks().count();
}
......@@ -142,7 +125,7 @@ bool KCMCron::init()
CTHost *KCMCron::ctHost() const
{
return d->ctHost;
return mCtHost;
}
#include "kcmCron.moc"
......@@ -23,8 +23,7 @@
#include <KSharedConfig>
class CTHost;
class KCMCronPrivate;
class CrontabWidget;
class KCMCron : public KCModule
{
......@@ -53,8 +52,15 @@ public:
QString findCrontabBinary();
private:
/**
* Main GUI view/working area.
*/
CrontabWidget *mCrontabWidget = nullptr;
KCMCronPrivate *const d;
/**
* Document object, here crotab entries.
*/
CTHost *mCtHost = nullptr;
};
#endif // KCM_CRON_H
This diff is collapsed.
......@@ -65,9 +65,9 @@ public:
void paintEvent(QPaintEvent *) override;
bool isDirty;
QPalette palSelected;
QPalette palNormal;
bool mIsDirty;
QPalette mPalSelected;
QPalette mPalNormal;
};
/**
......@@ -197,51 +197,51 @@ private:
/**
* Task.
*/
CTTask *ctTask;
CTTask *mCtTask = nullptr;
CrontabWidget *crontabWidget;
CrontabWidget *mCrontabWidget = nullptr;
// Widgets.
KTitleWidget *titleWidget;
QPushButton *okButton;
KTitleWidget *mTitleWidget = nullptr;
QPushButton *mOkButton = nullptr;
QComboBox *userCombo;
QComboBox *mUserCombo = nullptr;
QTextEdit *leComment;
QTextEdit *mLeComment = nullptr;
QLabel *commandIcon;
QPixmap missingCommandPixmap;
KUrlRequester *command;
QLabel *mCommandIcon = nullptr;
QPixmap mMissingCommandPixmap;
KUrlRequester *mCommand = nullptr;
QCheckBox *chkEnabled;
QCheckBox *chkReboot;
QCheckBox *cbEveryDay;
QCheckBox *mChkEnabled = nullptr;
QCheckBox *mChkReboot = nullptr;
QCheckBox *mCbEveryDay = nullptr;
QGroupBox *bgMonth;
NumberPushButton *monthButtons[13]; // The index 0 is not used
SetOrClearAllButton *allMonths;
QGroupBox *mBgMonth = nullptr;
NumberPushButton *mMonthButtons[13]; // The index 0 is not used
SetOrClearAllButton *mAllMonths = nullptr;
QGroupBox *bgDayOfMonth;
NumberPushButton *dayOfMonthButtons[32]; // The index 0 is not used
SetOrClearAllButton *allDaysOfMonth;
QGroupBox *mBgDayOfMonth;
NumberPushButton *mDayOfMonthButtons[32]; // The index 0 is not used
SetOrClearAllButton *mAllDaysOfMonth = nullptr;
QGroupBox *bgDayOfWeek;
NumberPushButton *dayOfWeekButtons[8]; // The index 0 is not used
SetOrClearAllButton *allDaysOfWeek;
QGroupBox *mBgDayOfWeek = nullptr;
NumberPushButton *mDayOfWeekButtons[8]; // The index 0 is not used
SetOrClearAllButton *mAllDaysOfWeek = nullptr;
QGroupBox *hoursGroup;
QLabel *morningLabel;
QLabel *afternoonLabel;
QPushButton *hourButtons[24];
SetOrClearAllButton *allHours;
QGroupBox *mHoursGroup = nullptr;
QLabel *mMorningLabel = nullptr;
QLabel *mAfternoonLabel = nullptr;
QPushButton *mHourButtons[24];
SetOrClearAllButton *mAllHours = nullptr;
QGroupBox *minutesGroup;
QGridLayout *minutesLayout;
QPushButton *minuteButtons[60];
QGroupBox *mMinutesGroup = nullptr;
QGridLayout *mMinutesLayout = nullptr;
QPushButton *mMinuteButtons[60];
QHBoxLayout *minutesPreselectionLayout;
QComboBox *minutesPreselection;
QHBoxLayout *mMinutesPreselectionLayout = nullptr;
QComboBox *mMinutesPreselection = nullptr;
static const int minuteTotal = 59; // or 55 or 59
......@@ -249,7 +249,7 @@ private:
static const int reducedMinuteStep = 5;
QStringList specialValidCommands;
QStringList mSpecialValidCommands;
};
#endif // TASK_EDITOR_DIALOG_H
......@@ -21,8 +21,8 @@
TaskWidget::TaskWidget(TasksWidget *_tasksWidget, CTTask *_cttask)
: QTreeWidgetItem(_tasksWidget->treeWidget())
{
ctTask = _cttask;
tasksWidget = _tasksWidget;
mCtTask = _cttask;
mTasksWidget = _tasksWidget;
refresh();
}
......@@ -31,16 +31,16 @@ void TaskWidget::refresh()
{
int column = 0;
if (tasksWidget->needUserColumn()) {
setText(column++, ctTask->userLogin);
if (mTasksWidget->needUserColumn()) {
setText(column++, mCtTask->userLogin);
}
setText(column++, ctTask->schedulingCronFormat());
setText(column++, mCtTask->schedulingCronFormat());
setText(column, ctTask->command);
setIcon(column++, ctTask->commandIcon());
setText(column, mCtTask->command);
setIcon(column++, mCtTask->commandIcon());
if (ctTask->enabled) {
if (mCtTask->enabled) {
setText(column, i18n("Enabled"));
setIcon(column++, QIcon::fromTheme(QStringLiteral("dialog-ok-apply")));
} else {
......@@ -48,17 +48,17 @@ void TaskWidget::refresh()
setIcon(column++, QIcon::fromTheme(QStringLiteral("dialog-cancel")));
}
setText(column++, ctTask->comment);
setText(column++, ctTask->describe());
setText(column++, mCtTask->comment);
setText(column++, mCtTask->describe());
}
void TaskWidget::toggleEnable()
{
ctTask->enabled = !ctTask->enabled;
mCtTask->enabled = !mCtTask->enabled;
refresh();
}
CTTask *TaskWidget::getCTTask() const
{
return ctTask;
return mCtTask;
}
......@@ -46,9 +46,9 @@ private:
/**
* Task.
*/
CTTask *ctTask;
CTTask *mCtTask = nullptr;
TasksWidget *tasksWidget;
TasksWidget *mTasksWidget = nullptr;
};
#endif // TASK_WIDGET_H
......@@ -25,27 +25,11 @@
#include "logging.h"
class TasksWidgetPrivate
{
public:
QAction *newTaskAction;
QAction *modifyAction;
QAction *deleteAction;
QAction *runNowAction;
QAction *printAction;
};
/**
* Construct tasks folder from branch.
*/
TasksWidget::TasksWidget(CrontabWidget *crontabWidget)
: GenericListWidget(crontabWidget, i18n("<b>Scheduled Tasks</b>"), QIcon::fromTheme(QStringLiteral("system-run")))
, d(new TasksWidgetPrivate())
{
refreshHeaders();
......@@ -61,7 +45,6 @@ TasksWidget::TasksWidget(CrontabWidget *crontabWidget)
TasksWidget::~TasksWidget()
{
delete d;
}
QList<TaskWidget *> TasksWidget::selectedTasksWidget() const
......@@ -261,44 +244,44 @@ bool TasksWidget::needUserColumn() const
void TasksWidget::setupActions(CrontabWidget *crontabWidget)
{
d->newTaskAction = new QAction(this);
d->newTaskAction->setIcon(QIcon::fromTheme(QStringLiteral("document-new")));
d->newTaskAction->setText(i18nc("Adds a new task", "New &Task..."));
d->newTaskAction->setToolTip(i18n("Create a new task."));
addRightAction(d->newTaskAction, this, SLOT(createTask()));
d->modifyAction = new QAction(this);
d->modifyAction->setText(i18n("M&odify..."));
d->modifyAction->setIcon(QIcon::fromTheme(QStringLiteral("document-open")));
d->modifyAction->setToolTip(i18n("Modify the selected task."));
addRightAction(d->modifyAction, this, SLOT(modifySelection()));
d->deleteAction = new QAction(this);
d->deleteAction->setText(i18n("&Delete"));
d->deleteAction->setIcon(QIcon::fromTheme(QStringLiteral("edit-delete")));
d->deleteAction->setToolTip(i18n("Delete the selected task."));
addRightAction(d->deleteAction, this, SLOT(deleteSelection()));
d->runNowAction = new QAction(this);
d->runNowAction->setText(i18n("&Run Now"));
d->runNowAction->setIcon(QIcon::fromTheme(QStringLiteral("system-run")));
d->runNowAction->setToolTip(i18n("Run the selected task now."));
addRightAction(d->runNowAction, this, SLOT(runTaskNow()));
d->printAction = KStandardAction::print(crontabWidget, SLOT(print()), this);
addRightAction(d->printAction, crontabWidget, SLOT(print()));
mNewTaskAction = new QAction(this);
mNewTaskAction->setIcon(QIcon::fromTheme(QStringLiteral("document-new")));
mNewTaskAction->setText(i18nc("Adds a new task", "New &Task..."));
mNewTaskAction->setToolTip(i18n("Create a new task."));
addRightAction(mNewTaskAction, this, SLOT(createTask()));
mModifyAction = new QAction(this);
mModifyAction->setText(i18n("M&odify..."));
mModifyAction->setIcon(QIcon::fromTheme(QStringLiteral("document-open")));
mModifyAction->setToolTip(i18n("Modify the selected task."));
addRightAction(mModifyAction, this, SLOT(modifySelection()));
mDeleteAction = new QAction(this);
mDeleteAction->setText(i18n("&Delete"));
mDeleteAction->setIcon(QIcon::fromTheme(QStringLiteral("edit-delete")));
mDeleteAction->setToolTip(i18n("Delete the selected task."));
addRightAction(mDeleteAction, this, SLOT(deleteSelection()));
mRunNowAction = new QAction(this);
mRunNowAction->setText(i18n("&Run Now"));
mRunNowAction->setIcon(QIcon::fromTheme(QStringLiteral("system-run")));
mRunNowAction->setToolTip(i18n("Run the selected task now."));
addRightAction(mRunNowAction, this, SLOT(runTaskNow()));
mPrintAction = KStandardAction::print(crontabWidget, SLOT(print()), this);
addRightAction(mPrintAction, crontabWidget, SLOT(print()));
addRightStretch();
}
void TasksWidget::prepareContextualMenu()
{
treeWidget()->addAction(d->newTaskAction);
treeWidget()->addAction(mNewTaskAction);
treeWidget()->addAction(createSeparator());
treeWidget()->addAction(d->modifyAction);
treeWidget()->addAction(d->deleteAction);
treeWidget()->addAction(mModifyAction);
treeWidget()->addAction(mDeleteAction);
treeWidget()->addAction(createSeparator());
......@@ -308,28 +291,28 @@ void TasksWidget::prepareContextualMenu()
treeWidget()->addAction(createSeparator());
treeWidget()->addAction(d->runNowAction);
treeWidget()->addAction(mRunNowAction);
}
void TasksWidget::toggleRunNowAction(bool state)
{
setActionEnabled(d->runNowAction, state);
setActionEnabled(mRunNowAction, state);
}
void TasksWidget::togglePrintAction(bool state)
{
setActionEnabled(d->printAction, state);
setActionEnabled(mPrintAction, state);
}
void TasksWidget::toggleModificationActions(bool state)
{
setActionEnabled(d->modifyAction, state);
setActionEnabled(d->deleteAction, state);
setActionEnabled(mModifyAction, state);
setActionEnabled(mDeleteAction, state);
}
void TasksWidget::toggleNewEntryAction(bool state)
{
setActionEnabled(d->newTaskAction, state);
setActionEnabled(mNewTaskAction, state);
}
void TasksWidget::changeCurrentSelection()
......
......@@ -16,8 +16,6 @@
class TaskWidget;
class TasksWidgetPrivate;
/**
* QTreeWidget of a "tasks" folder.
*/
......@@ -95,7 +93,15 @@ private:
void setupActions(CrontabWidget *crontabWidget);
void prepareContextualMenu();
TasksWidgetPrivate *const d;
QAction *mNewTaskAction = nullptr;
QAction *mModifyAction = nullptr;
QAction *mDeleteAction = nullptr;
QAction *mRunNowAction = nullptr;
QAction *mPrintAction = nullptr;
};
#endif // TASKS_WIDGET_H
......@@ -25,13 +25,13 @@
VariableEditorDialog::VariableEditorDialog(CTVariable *_ctVariable, const QString &_caption, CrontabWidget *_crontabWidget)
: QDialog(_crontabWidget)
{
ctVariable = _ctVariable;
crontabWidget = _crontabWidget;
mCtVariable = _ctVariable;
mCrontabWidget = _crontabWidget;
setModal(true);
setWindowTitle(_caption);
QDialogButtonBox *buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel, this);
okButton = buttonBox->button(QDialogButtonBox::Ok);
mOkButton = buttonBox->button(QDialogButtonBox::Ok);
QGridLayout *layout = new QGridLayout;
setLayout(layout);
......@@ -45,36 +45,36 @@ VariableEditorDialog::VariableEditorDialog(CTVariable *_ctVariable, const QStrin
int layoutPosition = 0;
// top title widget
titleWidget = new KTitleWidget(this);
titleWidget->setText(i18n("Add or modify a variable"));
layout->addWidget(titleWidget, layoutPosition, 0, 1, 2);
mTitleWidget = new KTitleWidget(this);
mTitleWidget->setText(i18n("Add or modify a variable"));
layout->addWidget(mTitleWidget, layoutPosition, 0, 1, 2);
// variable
QLabel *labVariable = new QLabel(i18nc("The environmental variable name ie HOME, MAILTO etc", "&Variable:"), this);
layout->addWidget(labVariable, ++layoutPosition, 0, Qt::AlignLeft);
cmbVariable = new QComboBox(this);
cmbVariable->setEditable(true);
layout->addWidget(cmbVariable, layoutPosition, 1);
mCmbVariable = new QComboBox(this);
mCmbVariable->setEditable(true);
layout->addWidget(mCmbVariable, layoutPosition, 1);
cmbVariable->addItem(QStringLiteral("HOME"));
cmbVariable->addItem(QStringLiteral("MAILTO"));
cmbVariable->addItem(QStringLiteral("PATH"));
cmbVariable->addItem(QStringLiteral("SHELL"));
cmbVariable->addItem(QStringLiteral("LD_CONFIG_PATH"));
mCmbVariable->addItem(QStringLiteral("HOME"));
mCmbVariable->addItem(QStringLiteral("MAILTO"));
mCmbVariable->addItem(QStringLiteral("PATH"));
mCmbVariable->addItem(QStringLiteral("SHELL"));
mCmbVariable->addItem(QStringLiteral("LD_CONFIG_PATH"));
labVariable->setBuddy(cmbVariable);
labVariable->setBuddy(mCmbVariable);
// details
QLabel *labDetails = new QLabel(QLatin1String(""), this);
layout->addWidget(labDetails, ++layoutPosition, 0, Qt::AlignLeft);
QHBoxLayout *detailsLayout = new QHBoxLayout;
detailsIcon = new QLabel(this);
detailsLayout->addWidget(detailsIcon);
mDetailsIcon = new QLabel(this);
detailsLayout->addWidget(mDetailsIcon);
details = new QLabel(this);
detailsLayout->addWidget(details);
mDetails = new QLabel(this);
detailsLayout->addWidget(mDetails);
layout->addLayout(detailsLayout, layoutPosition, 1, Qt::AlignLeft);
......@@ -82,58 +82,58 @@ VariableEditorDialog::VariableEditorDialog(CTVariable *_ctVariable, const QStrin
QLabel *labValue = new QLabel(i18n("Va&lue:"), this);
layout->addWidget(labValue, ++layoutPosition, 0, Qt::AlignLeft);
leValue = new QLineEdit(this);
layout->addWidget(leValue, layoutPosition, 1);
leValue->setMaxLength(255);
labValue->setBuddy(leValue);
mLeValue = new QLineEdit(this);
layout->addWidget(mLeValue, layoutPosition, 1);
mLeValue->setMaxLength(255);
labValue->setBuddy(mLeValue);
// User Combo
QLabel *userLabel = new QLabel(i18n("&Run as:"), this);
layout->addWidget(userLabel, ++layoutPosition, 0);
userCombo = new QComboBox(this);
mUserCombo = new QComboBox(this);
userLabel->setBuddy(userCombo);
layout->addWidget(userCombo, layoutPosition, 1);
userLabel->setBuddy(mUserCombo);
layout->addWidget(mUserCombo, layoutPosition, 1);
if (crontabWidget->variablesWidget()->needUserColumn()) {
KCronHelper::initUserCombo(userCombo, crontabWidget, ctVariable->userLogin);
if (mCrontabWidget->variablesWidget()->needUserColumn()) {
KCronHelper::initUserCombo(mUserCombo, mCrontabWidget, mCtVariable->userLogin);
} else {
userLabel->hide();
userCombo->hide();
mUserCombo->hide();
}
// comment
QLabel *labComment = new QLabel(i18n("Co&mment:"), this);
layout->addWidget(labComment, ++layoutPosition, 0, Qt::AlignLeft);
teComment = KCronHelper::createCommentEdit(this);
layout->addWidget(teComment, layoutPosition, 1);
labComment->setBuddy(teComment);
mTeComment = KCronHelper::createCommentEdit(this);
layout->addWidget(mTeComment, layoutPosition, 1);
labComment->setBuddy(mTeComment);
// enabled
chkEnabled = new QCheckBox(i18n("&Enable this variable"), this);
layout->addWidget(chkEnabled, ++layoutPosition, 0, 1, 2);
mChkEnabled = new QCheckBox(i18n("&Enable this variable"), this);