Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
System
KCron
Commits
b8b5a51b
Commit
b8b5a51b
authored
Jan 15, 2021
by
Laurent Montel
😁
Browse files
const'ify method + port some foreach(...)
parent
cfc703d5
Changes
7
Hide whitespace changes
Inline
Side-by-side
src/crontablib/ctGlobalCron.cpp
View file @
b8b5a51b
...
...
@@ -40,12 +40,15 @@ QList<CTTask *> CTGlobalCron::tasks() const
logDebug
()
<<
"Global Cron Tasks"
;
QList
<
CTTask
*>
tasks
;
foreach
(
CTCron
*
cron
,
mCtHost
->
crons
)
{
const
auto
crons
=
mCtHost
->
crons
;
for
(
CTCron
*
cron
:
crons
)
{
if
(
cron
->
isSystemCron
())
{
continue
;
}
foreach
(
CTTask
*
task
,
cron
->
tasks
())
{
const
auto
ctasks
=
cron
->
tasks
();
for
(
CTTask
*
task
:
ctasks
)
{
tasks
.
append
(
task
);
}
}
...
...
@@ -57,12 +60,13 @@ QList<CTVariable *> CTGlobalCron::variables() const
logDebug
()
<<
"Global Cron Variables"
;
QList
<
CTVariable
*>
variables
;
foreach
(
CTCron
*
cron
,
mCtHost
->
crons
)
{
const
auto
crons
=
mCtHost
->
crons
;
for
(
CTCron
*
cron
:
crons
)
{
if
(
cron
->
isSystemCron
())
{
continue
;
}
for
each
(
CTVariable
*
variable
,
cron
->
variables
()
)
{
const
auto
cvariables
=
cron
->
variables
();
for
(
CTVariable
*
variable
:
c
variables
)
{
variables
.
append
(
variable
);
}
}
...
...
@@ -96,8 +100,8 @@ void CTGlobalCron::modifyTask(CTTask *task)
* actualCron could be NULL is the task came from clipboard because those tasks are never
* linked to an existing CTCron* object
*/
if
(
actualCron
==
nullptr
||
actualCron
->
userLogin
()
!=
task
->
userLogin
)
{
if
(
actualCron
!=
nullptr
)
{
if
(
!
actualCron
||
actualCron
->
userLogin
()
!=
task
->
userLogin
)
{
if
(
actualCron
)
{
actualCron
->
removeTask
(
task
);
}
...
...
@@ -116,8 +120,8 @@ void CTGlobalCron::modifyVariable(CTVariable *variable)
* actualCron could be NULL is the task came from clipboard because those tasks are never
* linked to an existing CTCron* object
*/
if
(
actualCron
==
nullptr
||
actualCron
->
userLogin
()
!=
variable
->
userLogin
)
{
if
(
actualCron
!=
nullptr
)
{
if
(
!
actualCron
||
actualCron
->
userLogin
()
!=
variable
->
userLogin
)
{
if
(
actualCron
)
{
actualCron
->
removeVariable
(
variable
);
}
...
...
src/crontablib/ctHelper.cpp
View file @
b8b5a51b
...
...
@@ -17,7 +17,7 @@ QString CTHelper::exportComment(const QString &comment)
QString
exportComment
;
if
(
comment
.
isEmpty
())
{
QString
noComment
=
i18n
(
"No comment"
);
const
QString
noComment
=
i18n
(
"No comment"
);
exportComment
+=
QLatin1String
(
"#"
)
+
noComment
+
QLatin1String
(
"
\n
"
);
return
exportComment
;
}
...
...
src/crontablib/ctInitializationError.cpp
View file @
b8b5a51b
...
...
@@ -7,3 +7,22 @@
*/
#include "ctInitializationError.h"
QString
CTInitializationError
::
errorMessage
()
const
{
return
mError
;
}
void
CTInitializationError
::
setErrorMessage
(
const
QString
&
errorMessage
)
{
this
->
mError
=
errorMessage
;
}
bool
CTInitializationError
::
hasErrorMessage
()
const
{
if
(
mError
.
isEmpty
())
{
return
false
;
}
return
true
;
}
src/crontablib/ctInitializationError.h
View file @
b8b5a51b
...
...
@@ -15,24 +15,11 @@ class CTInitializationError
{
public:
QString
errorMessage
()
const
{
return
mError
;
}
void
setErrorMessage
(
const
QString
&
errorMessage
)
{
this
->
mError
=
errorMessage
;
}
bool
hasErrorMessage
()
{
if
(
mError
.
isEmpty
())
{
return
false
;
}
return
true
;
}
QString
errorMessage
()
const
;
void
setErrorMessage
(
const
QString
&
errorMessage
);
bool
hasErrorMessage
()
const
;
private:
QString
mError
;
...
...
src/crontablib/cthour.cpp
View file @
b8b5a51b
...
...
@@ -27,7 +27,7 @@ int CTHour::findPeriod() const
QString
CTHour
::
exportUnit
()
const
{
int
period
=
findPeriod
();
const
int
period
=
findPeriod
();
if
(
period
!=
0
&&
period
!=
1
)
{
return
QStringLiteral
(
"*/%1"
).
arg
(
QString
::
number
(
period
));
}
...
...
src/kcronHelper.cpp
View file @
b8b5a51b
...
...
@@ -24,7 +24,8 @@ void KCronHelper::initUserCombo(QComboBox *userCombo, CrontabWidget *crontabWidg
QStringList
users
;
int
selectedIndex
=
0
;
foreach
(
CTCron
*
ctCron
,
crontabWidget
->
ctHost
()
->
crons
)
{
const
auto
crons
=
crontabWidget
->
ctHost
()
->
crons
;
for
(
CTCron
*
ctCron
:
crons
)
{
if
(
ctCron
->
isSystemCron
())
{
continue
;
}
...
...
@@ -52,7 +53,7 @@ QTextEdit *KCronHelper::createCommentEdit(QWidget *parent)
edit
->
setSizePolicy
(
QSizePolicy
(
QSizePolicy
::
Expanding
,
QSizePolicy
::
Minimum
));
edit
->
setTabChangesFocus
(
true
);
QFontMetrics
fontMetrics
(
edit
->
currentFont
());
const
QFontMetrics
fontMetrics
(
edit
->
currentFont
());
edit
->
setMaximumHeight
(
fontMetrics
.
lineSpacing
()
*
3
);
//TODO Choose a smarter value
return
edit
;
...
...
src/tasksWidget.cpp
View file @
b8b5a51b
...
...
@@ -110,7 +110,7 @@ void TasksWidget::runTaskNow() const
QStringList
parameters
;
parameters
<<
QStringLiteral
(
"-e"
)
<<
QStringLiteral
(
"bash"
)
<<
QStringLiteral
(
"-c"
);
parameters
<<
commandList
.
join
(
QLatin1
String
(
";"
));
parameters
<<
commandList
.
join
(
QLatin1
Char
(
';'
));
QProcess
process
;
process
.
startDetached
(
QStringLiteral
(
"konsole"
),
parameters
);
...
...
@@ -149,7 +149,7 @@ void TasksWidget::modifySelection()
void
TasksWidget
::
modifySelection
(
QTreeWidgetItem
*
item
,
int
position
)
{
TaskWidget
*
taskWidget
=
static_cast
<
TaskWidget
*>
(
item
);
if
(
taskWidget
!=
nullptr
)
{
if
(
taskWidget
)
{
if
(
position
==
statusColumnIndex
())
{
taskWidget
->
toggleEnable
();
Q_EMIT
taskModified
(
true
);
...
...
@@ -202,7 +202,8 @@ void TasksWidget::refreshTasks(CTCron *cron)
refreshHeaders
();
//Add new items
foreach
(
CTTask
*
ctTask
,
cron
->
tasks
())
{
const
auto
tasks
=
cron
->
tasks
();
for
(
CTTask
*
ctTask
:
tasks
)
{
new
TaskWidget
(
this
,
ctTask
);
}
...
...
@@ -285,8 +286,9 @@ void TasksWidget::prepareContextualMenu()
treeWidget
()
->
addAction
(
mDeleteAction
);
treeWidget
()
->
addAction
(
createSeparator
());
const
auto
cutCopyPasteActions
=
crontabWidget
()
->
cutCopyPasteActions
();
for
each
(
QAction
*
action
,
crontabWidget
()
->
cutCopyPasteActions
()
)
{
for
(
QAction
*
action
:
cutCopyPasteActions
)
{
treeWidget
()
->
addAction
(
action
);
}
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment