Commit 926fed97 authored by Laurent Montel's avatar Laurent Montel 😁
Browse files

Modernize code

parent a0bc656e
Pipeline #48545 canceled with stage
......@@ -1683,7 +1683,7 @@ QPoint Agenda::contentsToGrid(const QPoint &pos) const
? d->mColumns - pos.x() / d->mGridSpacingX
: pos.x() / d->mGridSpacingX);
int gy = int(pos.y() / d->mGridSpacingY);
return QPoint(gx, gy);
return {gx, gy};
}
/*
......@@ -1695,7 +1695,7 @@ QPoint Agenda::gridToContents(const QPoint &gpos) const
? (d->mColumns - gpos.x()) * d->mGridSpacingX
: gpos.x() * d->mGridSpacingX);
int y = int(gpos.y() * d->mGridSpacingY);
return QPoint(x, y);
return {x, y};
}
/*
......@@ -2328,7 +2328,7 @@ QSize Agenda::sizeHint() const
if (d->mAllDayMode) {
return QWidget::sizeHint();
} else {
return QSize(parentWidget()->width(), d->mGridSpacingY * d->mRows);
return {parentWidget()->width(), d->mGridSpacingY * d->mRows};
}
}
......
......@@ -62,8 +62,8 @@ class AgendaItem : public QWidget, public CalendarSupport::CellItem
{
Q_OBJECT
public:
typedef QPointer<AgendaItem> QPtr;
typedef QList<QPtr> List;
using QPtr = QPointer<AgendaItem>;
using List = QList<QPtr>;
AgendaItem(EventView *eventView, const MultiViewCalendar::Ptr &calendar, const KCalendarCore::Incidence::Ptr &incidence, int itemPos, int itemCount, const QDateTime &qd, bool isSelected,
QWidget *parent);
......
......@@ -755,7 +755,7 @@ void AgendaView::init(QDate start, QDate end)
d->mAllDayAgenda = allDayScrollArea->agenda();
/* Create the main agenda widget and the related widgets */
QWidget *agendaFrame = new QWidget(d->mSplitterAgenda);
auto *agendaFrame = new QWidget(d->mSplitterAgenda);
auto agendaLayout = new QHBoxLayout(agendaFrame);
agendaLayout->setContentsMargins(0, 0, 0, 0);
agendaLayout->setSpacing(SPACING);
......@@ -1240,7 +1240,7 @@ void AgendaView::createDayLabels(bool force)
for (const QString &text : texts) {
// Compute a small version of the holiday string for AlternateLabel
const KWordWrap ww = KWordWrap::formatText(fm, topDayLabelBox->rect(), 0, text, -1);
AlternateLabel *label = new AlternateLabel(
auto *label = new AlternateLabel(
ww.truncatedString(), text, text, topDayLabelBox);
topDayLabelBoxLayout->addWidget(label);
label->setAlignment(Qt::AlignCenter);
......@@ -1421,7 +1421,7 @@ void AgendaView::createTimeBarHeaders()
const auto lst = d->mTimeLabelsZone->timeLabels();
for (QScrollArea *area : lst) {
auto timeLabel = static_cast<TimeLabels *>(area->widget());
QLabel *label
auto *label
= new QLabel(timeLabel->header().replace(QLatin1Char('/'), QStringLiteral("/ ")),
d->mTimeBarHeaderFrame);
d->mTimeBarHeaderFrame->layout()->addWidget(label);
......@@ -1628,7 +1628,7 @@ void AgendaView::updateEventDates(AgendaItem *item, bool addIncidence, Akonadi::
QDate AgendaView::startDate() const
{
if (d->mSelectedDates.isEmpty()) {
return QDate();
return {};
}
return d->mSelectedDates.first();
}
......@@ -1636,7 +1636,7 @@ QDate AgendaView::startDate() const
QDate AgendaView::endDate() const
{
if (d->mSelectedDates.isEmpty()) {
return QDate();
return {};
}
return d->mSelectedDates.last();
}
......
......@@ -230,7 +230,7 @@ private:
bool displayIncidence(const KCalendarCore::Incidence::Ptr &incidence, bool createSelected);
#ifndef EVENTVIEWS_NODECOS
typedef QList<EventViews::CalendarDecoration::Decoration *> DecorationList;
using DecorationList = QList<EventViews::CalendarDecoration::Decoration *>;
bool loadDecorations(const QStringList &decorations, DecorationList &decoList);
void placeDecorationsFrame(QFrame *frame, bool decorationsFound, bool isTop);
void placeDecorations(EventViews::AgendaView::DecorationList &decoList, const QDate &date, QWidget *labelBox, bool forWeek);
......
......@@ -266,10 +266,10 @@ QDate Decoration::weekDate(const QDate &date)
QDate Decoration::monthDate(const QDate &date)
{
return QDate(date.year(), date.month(), 1);
return {date.year(), date.month(), 1};
}
QDate Decoration::yearDate(const QDate &date)
{
return QDate(date.year(), 1, 1);
return {date.year(), 1, 1};
}
......@@ -30,7 +30,7 @@ class EVENTVIEWS_EXPORT Element : public QObject
Q_OBJECT
public:
typedef QList<Element *> List;
using List = QList<Element *>;
explicit Element(const QString &id);
~Element() override;
......@@ -149,7 +149,7 @@ public:
return QStringLiteral("Calendar/Decoration");
}
typedef QList<Decoration *> List;
using List = QList<Decoration *>;
Decoration();
~Decoration() override;
......
......@@ -323,7 +323,7 @@ void TimeLabels::paintEvent(QPaintEvent *)
QSize TimeLabels::sizeHint() const
{
return QSize(mMiniWidth, mRows * mCellHeight);
return {mMiniWidth, mRows * mCellHeight};
}
void TimeLabels::contextMenuEvent(QContextMenuEvent *event)
......
......@@ -17,13 +17,13 @@ class Agenda;
class TimeLabelsZone;
class Prefs;
typedef QSharedPointer<Prefs> PrefsPtr;
using PrefsPtr = QSharedPointer<Prefs>;
class TimeLabels : public QFrame
{
Q_OBJECT
public:
typedef QList<TimeLabels *> List;
using List = QList<TimeLabels *>;
TimeLabels(const QTimeZone &zone, int rows, TimeLabelsZone *parent = nullptr, Qt::WindowFlags f = {});
......
......@@ -17,7 +17,7 @@ class Agenda;
class AgendaView;
class Prefs;
typedef QSharedPointer<Prefs> PrefsPtr;
using PrefsPtr = QSharedPointer<Prefs>;
class TimeLabelsZone : public QWidget
{
......
......@@ -36,7 +36,7 @@ enum {
TimeZoneNameRole = Qt::UserRole
};
typedef QPair<QString, QByteArray> TimeZoneNamePair;
using TimeZoneNamePair = QPair<QString, QByteArray>;
static QString tzWithUTC(const QByteArray &zoneId)
{
......
......@@ -12,7 +12,7 @@
namespace EventViews {
class Prefs;
typedef QSharedPointer<Prefs> PrefsPtr;
using PrefsPtr = QSharedPointer<Prefs>;
class TimeScaleConfigDialog : public QDialog, private Ui::TimeScaleEditWidget
{
......
......@@ -115,7 +115,7 @@ QColor MultiViewCalendar::resourceColor(const KCalendarCore::Incidence::Ptr &inc
if (cal) {
return cal->resourceColor(incidence);
}
return QColor();
return {};
}
Akonadi::Item MultiViewCalendar::item(const KCalendarCore::Incidence::Ptr &incidence) const
......
......@@ -22,7 +22,7 @@ class AgendaView;
class EVENTVIEWS_EXPORT ViewCalendar
{
public:
typedef QSharedPointer<ViewCalendar> Ptr;
using Ptr = QSharedPointer<ViewCalendar>;
virtual ~ViewCalendar();
virtual bool isValid(const KCalendarCore::Incidence::Ptr &incidence) const = 0;
......@@ -38,7 +38,7 @@ public:
class AkonadiViewCalendar : public ViewCalendar
{
public:
typedef QSharedPointer<AkonadiViewCalendar> Ptr;
using Ptr = QSharedPointer<AkonadiViewCalendar>;
~AkonadiViewCalendar() override;
bool isValid(const KCalendarCore::Incidence::Ptr &incidence) const override;
......@@ -59,7 +59,7 @@ public:
class MultiViewCalendar : public ViewCalendar
{
public:
typedef QSharedPointer<MultiViewCalendar> Ptr;
using Ptr = QSharedPointer<MultiViewCalendar>;
~MultiViewCalendar() override;
ViewCalendar::Ptr findCalendar(const KCalendarCore::Incidence::Ptr &incidence) const;
......
......@@ -43,8 +43,8 @@ enum {
class EventViewPrivate;
class Prefs;
typedef QSharedPointer<Prefs> PrefsPtr;
typedef QSharedPointer<CalendarSupport::KCalPrefs> KCalPrefsPtr;
using PrefsPtr = QSharedPointer<Prefs>;
using KCalPrefsPtr = QSharedPointer<CalendarSupport::KCalPrefs>;
/**
EventView is the abstract base class from which all other calendar views
......
......@@ -55,7 +55,7 @@ void EventViews::setResourceColor(const Akonadi::Collection &coll, const QColor
QColor EventViews::resourceColor(const Akonadi::Collection &coll, const PrefsPtr &preferences)
{
if (!coll.isValid()) {
return QColor();
return {};
}
const QString id = QString::number(coll.id());
// Color stored in eventviewsrc (and in memory)
......@@ -78,7 +78,7 @@ QColor EventViews::resourceColor(const Akonadi::Collection &coll, const PrefsPtr
QColor EventViews::resourceColor(const Akonadi::Item &item, const PrefsPtr &preferences)
{
if (!item.isValid()) {
return QColor();
return {};
}
return resourceColor(item.parentCollection(), preferences);
}
......
......@@ -26,7 +26,7 @@ class QDate;
*/
namespace EventViews {
class Prefs;
typedef QSharedPointer<Prefs> PrefsPtr;
using PrefsPtr = QSharedPointer<Prefs>;
/**
Returns a nice QColor for text, give the input color &c.
......
......@@ -62,7 +62,7 @@ void JournalDateView::addJournal(const Akonadi::Item &j)
return;
}
QWidget *container = new QWidget(this);
auto *container = new QWidget(this);
layout()->addWidget(container);
auto layout = new QHBoxLayout(container);
layout->addStretch(1);
......
......@@ -26,7 +26,7 @@ class JournalFrame : public QFrame
{
Q_OBJECT
public:
typedef QList<JournalFrame *> List;
using List = QList<JournalFrame *>;
JournalFrame(const Akonadi::Item &journal, const Akonadi::ETMCalendar::Ptr &calendar, QWidget *parent);
......@@ -92,7 +92,7 @@ class JournalDateView : public QFrame
{
Q_OBJECT
public:
typedef QList<JournalDateView *> List;
using List = QList<JournalDateView *>;
JournalDateView(const Akonadi::ETMCalendar::Ptr &, QWidget *parent);
~JournalDateView();
......
......@@ -603,6 +603,6 @@ void ListView::clear()
QSize ListView::sizeHint() const
{
const QSize s = EventView::sizeHint();
return QSize(s.width() + style()->pixelMetric(QStyle::PM_ScrollBarExtent) + 1,
s.height());
return {s.width() + style()->pixelMetric(QStyle::PM_ScrollBarExtent) + 1,
s.height()};
}
......@@ -27,7 +27,7 @@ ScrollIndicator::ScrollIndicator(ScrollIndicator::ArrowDirection dir)
QRectF ScrollIndicator::boundingRect() const
{
return QRectF(-mWidth / 2, -mHeight / 2, mWidth, mHeight);
return {-mWidth / 2, -mHeight / 2, mWidth, mHeight};
}
void ScrollIndicator::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
......@@ -205,8 +205,8 @@ QPainterPath MonthGraphicsItem::widgetPath(bool border) const
QRectF MonthGraphicsItem::boundingRect() const
{
// width - 2 because of the cell-dividing line with width == 1 at beginning and end
return QRectF(0, 0, (daySpan() + 1) * mMonthItem->monthScene()->columnWidth() - 2,
mMonthItem->monthScene()->itemHeight());
return {0, 0, (daySpan() + 1) * mMonthItem->monthScene()->columnWidth() - 2,
mMonthItem->monthScene()->itemHeight()};
}
void MonthGraphicsItem::paint(QPainter *p, const QStyleOptionGraphicsItem *, QWidget *)
......
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