Commit c9f6cd5a authored by Laurent Montel's avatar Laurent Montel 😁

Minor optimization

parent f45a9c62
......@@ -27,7 +27,8 @@
#include <QTimer>
DateChecker::DateChecker(QObject *parent) : QObject(parent), mUpdateTimer(nullptr)
DateChecker::DateChecker(QObject *parent)
: QObject(parent), mUpdateTimer(nullptr)
{
enableRollover(FollowMonth);
}
......@@ -55,6 +56,7 @@ void DateChecker::enableRollover(RolloverType r)
mUpdateTimer->setSingleShot(true);
mUpdateTimer->start(0);
mLastDayChecked = QDate::currentDate();
break;
}
mUpdateRollover = r;
}
......@@ -82,7 +84,7 @@ void DateChecker::possiblyPastMidnight()
if (mUpdateTimer) {
QTime now = QTime::currentTime();
QTime midnight = QTime(23, 59, 59);
int msecsWait = qMin(480000, now.msecsTo(midnight) + 2000);
const int msecsWait = qMin(480000, now.msecsTo(midnight) + 2000);
mUpdateTimer->stop();
mUpdateTimer->start(msecsWait);
......
......@@ -98,7 +98,7 @@ void DateNavigatorContainer::setCalendar(const Akonadi::ETMCalendar::Ptr &calend
{
mCalendar = calendar;
mNavigatorView->setCalendar(calendar);
foreach (KDateNavigator *n, mExtraViews) {
for (KDateNavigator *n : qAsConst(mExtraViews)) {
if (n) {
n->setCalendar(calendar);
}
......@@ -111,7 +111,7 @@ void DateNavigatorContainer::setCalendar(const Akonadi::ETMCalendar::Ptr &calend
void DateNavigatorContainer::updateDayMatrix()
{
mNavigatorView->updateDayMatrix();
foreach (KDateNavigator *n, mExtraViews) {
for (KDateNavigator *n : qAsConst(mExtraViews)) {
if (n) {
n->updateDayMatrix();
}
......@@ -121,7 +121,7 @@ void DateNavigatorContainer::updateDayMatrix()
void DateNavigatorContainer::updateToday()
{
mNavigatorView->updateToday();
foreach (KDateNavigator *n, mExtraViews) {
for (KDateNavigator *n : qAsConst(mExtraViews)) {
if (n) {
n->updateToday();
}
......@@ -131,7 +131,7 @@ void DateNavigatorContainer::updateToday()
void DateNavigatorContainer::setUpdateNeeded()
{
mNavigatorView->setUpdateNeeded();
foreach (KDateNavigator *n, mExtraViews) {
for (KDateNavigator *n : qAsConst(mExtraViews)) {
if (n) {
n->setUpdateNeeded();
}
......@@ -141,7 +141,7 @@ void DateNavigatorContainer::setUpdateNeeded()
void DateNavigatorContainer::updateView()
{
mNavigatorView->updateView();
foreach (KDateNavigator *n, mExtraViews) {
for (KDateNavigator *n : qAsConst(mExtraViews)) {
if (n) {
n->setUpdateNeeded();
}
......@@ -151,7 +151,7 @@ void DateNavigatorContainer::updateView()
void DateNavigatorContainer::updateConfig()
{
mNavigatorView->updateConfig();
foreach (KDateNavigator *n, mExtraViews) {
for (KDateNavigator *n : qAsConst(mExtraViews)) {
if (n) {
n->updateConfig();
}
......@@ -193,7 +193,7 @@ void DateNavigatorContainer::selectDates(const KCalCore::DateList &dateList,
if (!mIgnoreNavigatorUpdates) {
mNavigatorView->selectDates(dateList);
foreach (KDateNavigator *n, mExtraViews) {
for (KDateNavigator *n : qAsConst(mExtraViews)) {
if (n) {
n->selectDates(dateList);
}
......@@ -209,7 +209,7 @@ void DateNavigatorContainer::setBaseDates(const QDate &start)
mNavigatorView->setBaseDate(baseDate);
}
foreach (KDateNavigator *n, mExtraViews) {
for (KDateNavigator *n : qAsConst(mExtraViews)) {
baseDate = baseDate.addMonths(1);
if (!mIgnoreNavigatorUpdates) {
n->setBaseDate(baseDate);
......@@ -260,7 +260,7 @@ void DateNavigatorContainer::resizeAllContents()
mVerticalCount = verticalCount;
setBaseDates(mNavigatorView->selectedDates().first());
selectDates(mNavigatorView->selectedDates());
foreach (KDateNavigator *n, mExtraViews) {
for (KDateNavigator *n : qAsConst(mExtraViews)) {
if (n) {
n->show();
}
......@@ -319,7 +319,7 @@ void DateNavigatorContainer::setHighlightMode(bool highlightEvents,
mNavigatorView->setHighlightMode(highlightEvents, highlightTodos, highlightJournals);
foreach (KDateNavigator *n, mExtraViews) {
for (KDateNavigator *n : qAsConst(mExtraViews)) {
if (n) {
n->setHighlightMode(highlightEvents, highlightTodos, highlightJournals);
}
......@@ -409,7 +409,7 @@ KDateNavigator *DateNavigatorContainer::firstNavigatorForDate(const QDate &date)
// The date is in the first navigator
navigator = mNavigatorView;
} else {
foreach (KDateNavigator *nav, mExtraViews) {
for (KDateNavigator *nav : qAsConst(mExtraViews)) {
if (nav) {
limits = KODayMatrix::matrixLimits(nav->month());
if (date >= limits.first && date <= limits.second) {
......
......@@ -181,7 +181,7 @@ void KOEventView::focusChanged(QWidget *, QWidget *now)
void KOEventView::finishTypeAhead()
{
if (mTypeAheadReceiver) {
foreach (QEvent *e, mTypeAheadEvents) {
for (QEvent *e : qAsConst(mTypeAheadEvents)) {
QApplication::sendEvent(mTypeAheadReceiver, e);
}
}
......
......@@ -161,7 +161,7 @@ void KOViewManager::writeSettings(KConfig *config)
}
// write out custom view configuration
Q_FOREACH (KOrg::BaseView *const view, mViews) {
for (KOrg::BaseView *const view : qAsConst(mViews)) {
KConfigGroup group = KSharedConfig::openConfig()->group(view->identifier());
view->saveConfig(group);
}
......@@ -199,14 +199,11 @@ void KOViewManager::showView(KOrg::BaseView *view)
action->setEnabled(view->hasConfigurationDialog());
}
QStringList zoomActions;
QStringList rangeActions;
zoomActions << QStringLiteral("zoom_in_horizontally")
const QStringList zoomActions = QStringList() << QStringLiteral("zoom_in_horizontally")
<< QStringLiteral("zoom_out_horizontally")
<< QStringLiteral("zoom_in_vertically")
<< QStringLiteral("zoom_out_vertically");
rangeActions << QStringLiteral("select_workweek")
const QStringList rangeActions = QStringList() << QStringLiteral("select_workweek")
<< QStringLiteral("select_week")
<< QStringLiteral("select_day")
<< QStringLiteral("select_nextx");
......
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