Commit efe57643 authored by Laurent Montel's avatar Laurent Montel 😁
Browse files

Modernize code

parent 5fae135f
Pipeline #100377 canceled with stage
......@@ -1763,7 +1763,7 @@ AgendaItem::QPtr Agenda::insertItem(const KCalendarCore::Incidence::Ptr &inciden
AgendaItem::QPtr agendaItem = createAgendaItem(incidence, itemPos, itemCount, recurrenceId, isSelected);
if (!agendaItem) {
return AgendaItem::QPtr();
return {};
}
if (YTop >= d->mRows) {
......@@ -1808,7 +1808,7 @@ AgendaItem::QPtr Agenda::insertAllDayItem(const KCalendarCore::Incidence::Ptr &i
AgendaItem::QPtr agendaItem = createAgendaItem(incidence, 1, 1, recurrenceId, isSelected);
if (!agendaItem) {
return AgendaItem::QPtr();
return {};
}
agendaItem->setCellXY(XBegin, 0, 0);
......@@ -1836,7 +1836,7 @@ Agenda::createAgendaItem(const KCalendarCore::Incidence::Ptr &incidence, int ite
{
if (!incidence) {
qCWarning(CALENDARVIEW_LOG) << "Agenda::createAgendaItem() item is invalid.";
return AgendaItem::QPtr();
return {};
}
AgendaItem::QPtr agendaItem = new AgendaItem(d->mAgendaView, d->mCalendar, incidence, itemPos, itemCount, recurrenceId, isSelected, this);
......@@ -2338,9 +2338,7 @@ AgendaScrollArea::AgendaScrollArea(bool isAllDay, AgendaView *agendaView, bool i
mAgenda->setStartTime(agendaView->preferences()->dayBegins().time());
}
AgendaScrollArea::~AgendaScrollArea()
{
}
AgendaScrollArea::~AgendaScrollArea() = default;
Agenda *AgendaScrollArea::agenda() const
{
......
......@@ -109,9 +109,7 @@ AgendaItem::AgendaItem(EventView *eventView,
setAcceptDrops(true);
}
AgendaItem::~AgendaItem()
{
}
AgendaItem::~AgendaItem() = default;
void AgendaItem::updateIcons()
{
......
......@@ -2281,7 +2281,7 @@ void AgendaView::writeSettings(KConfig *config)
QVector<bool> AgendaView::busyDayMask() const
{
if (d->mSelectedDates.isEmpty() || !d->mSelectedDates[0].isValid()) {
return QVector<bool>();
return {};
}
QVector<bool> busyDayMask;
......
......@@ -26,9 +26,7 @@ AlternateLabel::AlternateLabel(const QString &shortlabel, const QString &longlab
squeezeTextToLabel();
}
AlternateLabel::~AlternateLabel()
{
}
AlternateLabel::~AlternateLabel() = default;
void AlternateLabel::useShortText()
{
......
......@@ -12,9 +12,7 @@ Element::Element(const QString &id)
{
}
Element::~Element()
{
}
Element::~Element() = default;
QString Element::id() const
{
......@@ -23,32 +21,32 @@ QString Element::id() const
QString Element::elementInfo() const
{
return QString();
return {};
}
QString Element::shortText() const
{
return QString();
return {};
}
QString Element::longText() const
{
return QString();
return {};
}
QString Element::extensiveText() const
{
return QString();
return {};
}
QPixmap Element::newPixmap(const QSize &)
{
return QPixmap();
return {};
}
QUrl Element::url() const
{
return QUrl();
return {};
}
////////////////////////////////////////////////////////////////////////////////
......@@ -242,22 +240,22 @@ Element::List Decoration::registerYearElements(const Element::List &e, const QDa
Element::List Decoration::createDayElements(const QDate &)
{
return Element::List();
return {};
}
Element::List Decoration::createWeekElements(const QDate &)
{
return Element::List();
return {};
}
Element::List Decoration::createMonthElements(const QDate &)
{
return Element::List();
return {};
}
Element::List Decoration::createYearElements(const QDate &)
{
return Element::List();
return {};
}
QDate Decoration::weekDate(QDate date)
......
......@@ -13,17 +13,13 @@
using namespace EventViews;
ViewCalendar::~ViewCalendar()
{
}
ViewCalendar::~ViewCalendar() = default;
MultiViewCalendar::~MultiViewCalendar()
{
}
MultiViewCalendar::~MultiViewCalendar() = default;
KCalendarCore::Calendar::Ptr MultiViewCalendar::getCalendar() const
{
return KCalendarCore::Calendar::Ptr();
return {};
}
KCalendarCore::Incidence::List MultiViewCalendar::incidences() const
......@@ -49,7 +45,7 @@ ViewCalendar::Ptr MultiViewCalendar::findCalendar(const KCalendarCore::Incidence
return cal;
}
}
return ViewCalendar::Ptr();
return {};
}
ViewCalendar::Ptr MultiViewCalendar::findCalendar(const QString &incidenceIdentifier) const
......@@ -59,7 +55,7 @@ ViewCalendar::Ptr MultiViewCalendar::findCalendar(const QString &incidenceIdenti
return cal;
}
}
return ViewCalendar::Ptr();
return {};
}
void MultiViewCalendar::addCalendar(const ViewCalendar::Ptr &calendar)
......@@ -85,7 +81,7 @@ QString MultiViewCalendar::displayName(const KCalendarCore::Incidence::Ptr &inci
if (cal) {
return cal->displayName(incidence);
}
return QString();
return {};
}
QString MultiViewCalendar::iconForIncidence(const KCalendarCore::Incidence::Ptr &incidence) const
......@@ -94,7 +90,7 @@ QString MultiViewCalendar::iconForIncidence(const KCalendarCore::Incidence::Ptr
if (cal) {
return cal->iconForIncidence(incidence);
}
return QString();
return {};
}
bool MultiViewCalendar::isValid(const KCalendarCore::Incidence::Ptr &incidence) const
......@@ -124,12 +120,10 @@ Akonadi::Item MultiViewCalendar::item(const KCalendarCore::Incidence::Ptr &incid
return mETMCalendar->item(incidence);
}
return Akonadi::Item();
return {};
}
AkonadiViewCalendar::~AkonadiViewCalendar()
{
}
AkonadiViewCalendar::~AkonadiViewCalendar() = default;
bool AkonadiViewCalendar::isValid(const KCalendarCore::Incidence::Ptr &incidence) const
{
......@@ -155,7 +149,7 @@ bool AkonadiViewCalendar::isValid(const QString &incidenceIdentifier) const
Akonadi::Item AkonadiViewCalendar::item(const KCalendarCore::Incidence::Ptr &incidence) const
{
if (!mCalendar || !incidence) {
return Akonadi::Item();
return {};
}
bool ok = false;
Akonadi::Item::Id id = incidence->customProperty("VOLATILE", "AKONADI-ID").toLongLong(&ok);
......@@ -166,7 +160,7 @@ Akonadi::Item AkonadiViewCalendar::item(const KCalendarCore::Incidence::Ptr &inc
if (id == -1) {
// Ok, we really don't know the ID, give up.
qCWarning(CALENDARVIEW_LOG) << "Item is invalid. uid = " << incidence->instanceIdentifier();
return Akonadi::Item();
return {};
}
return mCalendar->item(incidence->instanceIdentifier());
}
......
......@@ -238,12 +238,12 @@ void EventView::updateConfig()
QDateTime EventView::selectionStart() const
{
return QDateTime();
return {};
}
QDateTime EventView::selectionEnd() const
{
return QDateTime();
return {};
}
bool EventView::dateRangeSelectionEnabled() const
......
......@@ -38,9 +38,7 @@ JournalDateView::JournalDateView(const Akonadi::ETMCalendar::Ptr &calendar, QWid
layout->setSpacing(0);
}
JournalDateView::~JournalDateView()
{
}
JournalDateView::~JournalDateView() = default;
void JournalDateView::setDate(QDate date)
{
......@@ -195,9 +193,7 @@ JournalFrame::JournalFrame(const Akonadi::Item &j, const Akonadi::ETMCalendar::P
mBrowser->setStyleSheet(QStringLiteral("QFrame { border: 0px solid white } "));
}
JournalFrame::~JournalFrame()
{
}
JournalFrame::~JournalFrame() = default;
bool JournalFrame::eventFilter(QObject *object, QEvent *event)
{
......
......@@ -38,9 +38,7 @@ JournalView::JournalView(QWidget *parent)
installEventFilter(this);
}
JournalView::~JournalView()
{
}
JournalView::~JournalView() = default;
void JournalView::appendJournal(const Akonadi::Item &journal, QDate dt)
{
......
......@@ -36,7 +36,7 @@ public:
Q_REQUIRED_RESULT Akonadi::Item::List selectedIncidences() const override;
Q_REQUIRED_RESULT KCalendarCore::DateList selectedIncidenceDates() const override
{
return KCalendarCore::DateList();
return {};
}
void appendJournal(const Akonadi::Item &journal, QDate dt);
......
......@@ -95,13 +95,9 @@ bool ListViewItem::operator<(const QTreeWidgetItem &other) const
class EventViews::ListViewPrivate
{
public:
ListViewPrivate()
{
}
ListViewPrivate() = default;
~ListViewPrivate()
{
}
~ListViewPrivate() = default;
void addIncidences(const Akonadi::ETMCalendar::Ptr &calendar, const KCalendarCore::Incidence::List &incidenceList, QDate date);
void addIncidence(const Akonadi::ETMCalendar::Ptr &calendar, const KCalendarCore::Incidence::Ptr &, QDate date);
......@@ -136,9 +132,7 @@ public:
{
}
~ListItemVisitor() override
{
}
~ListItemVisitor() override = default;
bool visit(const Event::Ptr &) override;
bool visit(const Todo::Ptr &) override;
......
......@@ -33,7 +33,7 @@ void MonthItemOrderTest::longerInstancesFirst()
{
QDate startDate(2000, 01, 01);
IncidenceMonthItem *longEvent = eventItem(startDate, startDate.addDays(1));
HolidayMonthItem *longHoliday = new HolidayMonthItem(nullptr, startDate, startDate.addDays(1), QStringLiteral(""));
auto *longHoliday = new HolidayMonthItem(nullptr, startDate, startDate.addDays(1), QStringLiteral(""));
for (int offset = -1; offset < 3; offset++) {
QDate d = startDate.addDays(offset);
......@@ -43,7 +43,7 @@ void MonthItemOrderTest::longerInstancesFirst()
QVERIFY( MonthItem::greaterThan(longHoliday, shortEvent));
QVERIFY( ! MonthItem::greaterThan(shortEvent, longHoliday));
HolidayMonthItem *shortHoliday = new HolidayMonthItem(nullptr, d, QStringLiteral(""));
auto *shortHoliday = new HolidayMonthItem(nullptr, d, QStringLiteral(""));
QVERIFY( MonthItem::greaterThan(longEvent, shortHoliday));
QVERIFY( ! MonthItem::greaterThan(shortHoliday, longEvent));
QVERIFY( MonthItem::greaterThan(longHoliday, shortHoliday));
......@@ -58,7 +58,7 @@ void MonthItemOrderTest::holidaysFirst()
{
QDate startDate(2000, 01, 01);
IncidenceMonthItem *event = eventItem(startDate, startDate);
HolidayMonthItem *holiday = new HolidayMonthItem(nullptr, startDate, QStringLiteral(""));
auto *holiday = new HolidayMonthItem(nullptr, startDate, QStringLiteral(""));
QVERIFY( ! MonthItem::greaterThan(event, holiday));
QVERIFY( MonthItem::greaterThan(holiday, event));
}
......@@ -71,8 +71,8 @@ void MonthItemOrderTest::stableOrder()
{
QDate startDate(2000, 01, 01);
HolidayMonthItem *holiday = new HolidayMonthItem(nullptr, startDate, QStringLiteral(""));
HolidayMonthItem *otherHoliday = new HolidayMonthItem(nullptr, startDate, QStringLiteral(""));
auto *holiday = new HolidayMonthItem(nullptr, startDate, QStringLiteral(""));
auto *otherHoliday = new HolidayMonthItem(nullptr, startDate, QStringLiteral(""));
QVERIFY( ! (MonthItem::greaterThan(otherHoliday, holiday) && MonthItem::greaterThan(holiday, otherHoliday)));
IncidenceMonthItem *event = eventItem(startDate, startDate);
......@@ -82,7 +82,7 @@ void MonthItemOrderTest::stableOrder()
IncidenceMonthItem *MonthItemOrderTest::eventItem(QDate start, QDate end)
{
KCalendarCore::Event *e = new KCalendarCore::Event;
auto *e = new KCalendarCore::Event;
e->setDtStart(QDateTime(start, QTime(00, 00, 00)));
e->setDtEnd(QDateTime(end, QTime(00, 00, 00)));
e->setAllDay(true);
......
......@@ -126,9 +126,7 @@ MonthGraphicsItem::MonthGraphicsItem(MonthItem *manager)
setTransform(transform);
}
MonthGraphicsItem::~MonthGraphicsItem()
{
}
MonthGraphicsItem::~MonthGraphicsItem() = default;
bool MonthGraphicsItem::isMoving() const
{
......@@ -205,7 +203,7 @@ 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 *)
......
......@@ -308,9 +308,7 @@ IncidenceMonthItem::IncidenceMonthItem(MonthScene *monthScene,
}
}
IncidenceMonthItem::~IncidenceMonthItem()
{
}
IncidenceMonthItem::~IncidenceMonthItem() = default;
bool IncidenceMonthItem::greaterThanFallback(const MonthItem *other) const
{
......@@ -613,7 +611,7 @@ Akonadi::Item IncidenceMonthItem::akonadiItem() const
if (mIncidence) {
return monthScene()->mMonthView->calendar()->item(mIncidence);
} else {
return Akonadi::Item();
return {};
}
}
......@@ -679,9 +677,7 @@ HolidayMonthItem::HolidayMonthItem(MonthScene *monthScene, QDate startDate, QDat
{
}
HolidayMonthItem::~HolidayMonthItem()
{
}
HolidayMonthItem::~HolidayMonthItem() = default;
bool HolidayMonthItem::greaterThanFallback(const MonthItem *other) const
{
......
......@@ -265,7 +265,7 @@ QDateTime MonthView::selectionStart() const
if (d->scene->selectedCell()) {
return QDateTime(d->scene->selectedCell()->date().startOfDay());
} else {
return QDateTime();
return {};
}
}
......
......@@ -14,9 +14,7 @@ namespace EventViews
class ConfigDialogInterface
{
public:
virtual ~ConfigDialogInterface()
{
}
virtual ~ConfigDialogInterface() = default;
virtual int numberOfColumns() const = 0;
virtual bool useCustomColumns() const = 0;
......
......@@ -107,9 +107,7 @@ TimelineSubItem::TimelineSubItem(const Akonadi::ETMCalendar::Ptr &calendar, cons
}
}
TimelineSubItem::~TimelineSubItem()
{
}
TimelineSubItem::~TimelineSubItem() = default;
void TimelineSubItem::setStartTime(const QDateTime &dt)
{
......
......@@ -75,7 +75,7 @@ public:
KGantt::Span rowGeometry(const QModelIndex &idx) const override
{
return KGantt::Span(idx.row() * mRowHeight, mRowHeight);
return {idx.row() * mRowHeight, mRowHeight};
}
int maximumItemHeight() const override
......@@ -273,7 +273,7 @@ Akonadi::Item::List TimelineView::selectedIncidences() const
KCalendarCore::DateList TimelineView::selectedIncidenceDates() const
{
return KCalendarCore::DateList();
return {};
}
int TimelineView::currentDateCount() const
......
......@@ -29,9 +29,7 @@ TimelineViewPrivate::TimelineViewPrivate(TimelineView *parent)
{
}
TimelineViewPrivate::~TimelineViewPrivate()
{
}
TimelineViewPrivate::~TimelineViewPrivate() = default;
void TimelineViewPrivate::itemSelected(const QModelIndex &index)
{
......
......@@ -272,7 +272,7 @@ PreNode::Ptr IncidenceTreeModelPrivate::prenodeFromSourceRow(int row) const
if (!item.isValid()) {
// It's a Collection, ignore that, we only want items.
return PreNode::Ptr();
return {};
}
node->item = item;
......@@ -645,7 +645,7 @@ QVariant IncidenceTreeModel::data(const QModelIndex &index, int role) const
{
Q_ASSERT(index.isValid());
if (!index.isValid() || !sourceModel()) {
return QVariant();
return {};
}
QModelIndex sourceIndex = mapToSource(index);
......@@ -694,14 +694,14 @@ QModelIndex IncidenceTreeModel::mapFromSource(const QModelIndex &sourceIndex) co
}
if (!sourceModel()) {
return QModelIndex();
return {};
}
Q_ASSERT(sourceIndex.column() < sourceModel()->columnCount());
Q_ASSERT(sourceModel() == sourceIndex.model());
const Akonadi::Item::Id id = sourceIndex.data(Akonadi::EntityTreeModel::ItemIdRole).toLongLong();
if (id == -1 || !d->m_nodeMap.contains(id)) {
return QModelIndex();
return {};
}
const Node::Ptr node = d->m_nodeMap.value(id);
......@@ -738,7 +738,7 @@ QModelIndex IncidenceTreeModel::mapToSource(const QModelIndex &proxyIndex) const
if (!index.isValid()) {
qCWarning(CALENDARVIEW_LOG) << "IncidenceTreeModel::mapToSource(): sourceModelIndex is invalid";
Q_ASSERT(false);
return QModelIndex();
return {};
}
Q_ASSERT(index.model() == sourceModel());
......@@ -758,11 +758,11 @@ QModelIndex IncidenceTreeModel::parent(const QModelIndex &child) const
Node *childNode = reinterpret_cast<Node *>(child.internalPointer());
if (d->m_removedNodes.contains(childNode)) {
qCWarning(CALENDARVIEW_LOG) << "IncidenceTreeModel::parent() Node already removed.";
return QModelIndex();
return {};
}
if (!childNode->parentNode) {
return QModelIndex();
return {};
}
const QModelIndex parentIndex = d->indexForNode(childNode->parentNode);
......@@ -770,7 +770,7 @@ QModelIndex IncidenceTreeModel::parent(const QModelIndex &child) const
if (!parentIndex.isValid()) {
qCWarning(CALENDARVIEW_LOG) << "IncidenceTreeModel::parent(): proxyModelIndex is invalid.";
Q_ASSERT(false);
return QModelIndex();
return {};
}
Q_ASSERT(parentIndex.model() == this);
......@@ -802,7 +802,7 @@ QModelIndex IncidenceTreeModel::index(int row, int column, const QModelIndex &pa
if (row >= parentNode->directChilds.count()) {
qCCritical(CALENDARVIEW_LOG) << "IncidenceTreeModel::index() row=" << row << "; column=" << column;
Q_ASSERT(false);
return QModelIndex();
return {};
}
return createIndex(row, column, parentNode->directChilds.at(row).data());
......
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