Commit 565d4e0a authored by Laurent Montel's avatar Laurent Montel 😁
Browse files

Const'ify

parent a33fc9ae
......@@ -73,7 +73,7 @@ void AgentConfiguration::edit(int index)
setupEdit(instance);
}
void AgentConfiguration::editIdentifier(QString resourceIdentifier)
void AgentConfiguration::editIdentifier(const QString &resourceIdentifier)
{
auto instance = Akonadi::AgentManager::self()->instance(resourceIdentifier);
setupEdit(instance);
......@@ -97,7 +97,7 @@ void AgentConfiguration::restart(int index)
setupRestart(instance);
}
void AgentConfiguration::restartIdentifier(QString resourceIdentifier)
void AgentConfiguration::restartIdentifier(const QString &resourceIdentifier)
{
auto instance = Akonadi::AgentManager::self()->instance(resourceIdentifier);
setupRestart(instance);
......@@ -118,13 +118,13 @@ void AgentConfiguration::remove(int index)
setupRemove(instance);
}
void AgentConfiguration::removeIdentifier(QString resourceIdentifier)
void AgentConfiguration::removeIdentifier(const QString &resourceIdentifier)
{
auto instance = Akonadi::AgentManager::self()->instance(resourceIdentifier);
setupRemove(instance);
}
void AgentConfiguration::setupRemove(Akonadi::AgentInstance instance)
void AgentConfiguration::setupRemove(const Akonadi::AgentInstance &instance)
{
if (instance.isValid()) {
Akonadi::AgentManager::self()->removeInstance(instance);
......
......@@ -30,11 +30,11 @@ public:
Q_INVOKABLE void createNew(int index);
Q_INVOKABLE void edit(int index);
Q_INVOKABLE void editIdentifier(QString resourceIdentifier);
Q_INVOKABLE void editIdentifier(const QString &resourceIdentifier);
Q_INVOKABLE void remove(int index);
Q_INVOKABLE void removeIdentifier(QString resourceIdentifier);
Q_INVOKABLE void removeIdentifier(const QString &resourceIdentifier);
Q_INVOKABLE void restart(int index);
Q_INVOKABLE void restartIdentifier(QString resourceIdentifier);
Q_INVOKABLE void restartIdentifier(const QString &resourceIdentifier);
public Q_SLOTS:
void processInstanceProgressChanged(const Akonadi::AgentInstance &instance);
......@@ -44,7 +44,7 @@ Q_SIGNALS:
private:
void setupEdit(Akonadi::AgentInstance instance);
void setupRemove(Akonadi::AgentInstance instance);
void setupRemove(const Akonadi::AgentInstance &instance);
void setupRestart(Akonadi::AgentInstance instance);
Akonadi::AgentFilterProxyModel *m_runningAgents = nullptr;
......
......@@ -911,7 +911,7 @@ QVariantMap CalendarManager::getCollectionDetails(QVariant collectionId)
return collectionDetails;
}
void CalendarManager::setCollectionColor(qint64 collectionId, QColor color)
void CalendarManager::setCollectionColor(qint64 collectionId, const QColor &color)
{
auto collection = m_calendar->collection(collectionId);
auto colorAttr = collection.attribute<Akonadi::CollectionColorAttribute>(Akonadi::Collection::AddIfMissing);
......
......@@ -89,7 +89,7 @@ public:
Q_INVOKABLE void changeIncidenceCollection(KCalendarCore::Incidence::Ptr incidence, qint64 collectionId);
void changeIncidenceCollection(Akonadi::Item item, qint64 collectionId);
Q_INVOKABLE QVariantMap getCollectionDetails(QVariant collectionId);
Q_INVOKABLE void setCollectionColor(qint64 collectionId, QColor color);
Q_INVOKABLE void setCollectionColor(qint64 collectionId, const QColor &color);
Q_INVOKABLE QVariant getIncidenceSubclassed(KCalendarCore::Incidence::Ptr incidencePtr);
Q_INVOKABLE void undoAction();
Q_INVOKABLE void redoAction();
......
......@@ -91,9 +91,9 @@ int AttachmentsModel::rowCount(const QModelIndex &) const
return m_incidence->attachments().size();
}
void AttachmentsModel::addAttachment(QString uri)
void AttachmentsModel::addAttachment(const QString &uri)
{
QMimeType type = m_mimeDb.mimeTypeForUrl(QUrl(uri));
const QMimeType type = m_mimeDb.mimeTypeForUrl(QUrl(uri));
KCalendarCore::Attachment attachment(uri);
attachment.setLabel(QUrl(uri).fileName());
......@@ -104,7 +104,7 @@ void AttachmentsModel::addAttachment(QString uri)
Q_EMIT layoutChanged();
}
void AttachmentsModel::deleteAttachment(QString uri)
void AttachmentsModel::deleteAttachment(const QString &uri)
{
KCalendarCore::Attachment::List attachments = m_incidence->attachments();
......
......@@ -38,8 +38,8 @@ public:
QHash<int, QByteArray> roleNames() const override;
int rowCount(const QModelIndex &parent = {}) const override;
Q_INVOKABLE void addAttachment(QString uri);
Q_INVOKABLE void deleteAttachment(QString uri);
Q_INVOKABLE void addAttachment(const QString &uri);
Q_INVOKABLE void deleteAttachment(const QString &uri);
Q_SIGNALS:
void incidencePtrChanged();
......
......@@ -37,7 +37,7 @@ AttendeeStatusModel::AttendeeStatusModel(QObject *parent)
// QLatin1String is a workaround for QT_NO_CAST_FROM_ASCII.
// Regular expression adds space between every lowercase and Capitalised character then does the same
// for capitalised letters together, e.g. ThisIsATest. Not a problem right now, but best to be safe.
QLatin1String enumName = QLatin1String(QMetaEnum::fromType<KCalendarCore::Attendee::PartStat>().key(i));
const QLatin1String enumName = QLatin1String(QMetaEnum::fromType<KCalendarCore::Attendee::PartStat>().key(i));
QString displayName = enumName;
displayName.replace(lowerToCapitalSep, QStringLiteral("\\1 \\2"));
displayName.replace(capitalToCapitalSep, QStringLiteral("\\1 \\2"));
......
......@@ -67,7 +67,7 @@ QVariant RecurrenceExceptionsModel::data(const QModelIndex &idx, int role) const
if (!hasIndex(idx.row(), idx.column())) {
return {};
}
QDate exception = m_exceptions[idx.row()];
const QDate exception = m_exceptions[idx.row()];
switch (role) {
case DateRole:
return exception;
......
......@@ -10,8 +10,8 @@ RemindersModel::RemindersModel(QObject *parent, KCalendarCore::Incidence::Ptr in
, m_incidence(incidencePtr)
{
for (int i = 0; i < QMetaEnum::fromType<RemindersModel::Roles>().keyCount(); i++) {
int value = QMetaEnum::fromType<RemindersModel::Roles>().value(i);
QString key = QLatin1String(roleNames().value(value));
const int value = QMetaEnum::fromType<RemindersModel::Roles>().value(i);
const QString key = QLatin1String(roleNames().value(value));
m_dataRoles[key] = value;
}
}
......
......@@ -230,7 +230,7 @@ bool TodoSortFilterProxyModel::filterAcceptsRowCheck(int row, const QModelIndex
}
if (m_filterMap.contains(QLatin1String("tags")) && !m_filterMap[QLatin1String("tags")].toStringList().isEmpty()) {
auto tags = m_filterMap[QLatin1String("tags")].toStringList();
const auto tags = m_filterMap[QLatin1String("tags")].toStringList();
bool containsTag = false;
for (const auto &tag : tags) {
const auto todoPtr = sourceIndex.data(TodoModel::TodoPtrRole).value<KCalendarCore::Todo::Ptr>();
......@@ -314,7 +314,7 @@ void TodoSortFilterProxyModel::loadColors()
Q_EMIT layoutChanged();
}
int TodoSortFilterProxyModel::showCompleted()
int TodoSortFilterProxyModel::showCompleted() const
{
return m_showCompleted;
}
......@@ -331,7 +331,7 @@ void TodoSortFilterProxyModel::setShowCompleted(int showCompleted)
sortTodoModel();
}
QVariantMap TodoSortFilterProxyModel::filterMap()
QVariantMap TodoSortFilterProxyModel::filterMap() const
{
return m_filterMap;
}
......@@ -345,7 +345,7 @@ void TodoSortFilterProxyModel::setFilterMap(const QVariantMap &filterMap)
Q_EMIT filterMapChanged();
if (m_filterMap.contains(QLatin1String("name"))) {
auto name = m_filterMap[QLatin1String("name")].toString();
const auto name = m_filterMap[QLatin1String("name")].toString();
setFilterFixedString(name);
}
invalidateFilter();
......@@ -356,7 +356,7 @@ void TodoSortFilterProxyModel::setFilterMap(const QVariantMap &filterMap)
void TodoSortFilterProxyModel::sortTodoModel()
{
auto order = m_sortAscending ? Qt::AscendingOrder : Qt::DescendingOrder;
const auto order = m_sortAscending ? Qt::AscendingOrder : Qt::DescendingOrder;
QSortFilterProxyModel::sort(m_sortColumn, order);
}
......@@ -609,7 +609,7 @@ bool TodoSortFilterProxyModel::lessThan(const QModelIndex &left, const QModelInd
}
}
int TodoSortFilterProxyModel::sortBy()
int TodoSortFilterProxyModel::sortBy() const
{
return m_sortColumn;
}
......@@ -621,7 +621,7 @@ void TodoSortFilterProxyModel::setSortBy(int sortBy)
sortTodoModel();
}
bool TodoSortFilterProxyModel::sortAscending()
bool TodoSortFilterProxyModel::sortAscending() const
{
return m_sortAscending;
}
......@@ -633,7 +633,7 @@ void TodoSortFilterProxyModel::setSortAscending(bool sortAscending)
sortTodoModel();
}
bool TodoSortFilterProxyModel::showCompletedSubtodosInIncomplete()
bool TodoSortFilterProxyModel::showCompletedSubtodosInIncomplete() const
{
return m_showCompletedSubtodosInIncomplete;
}
......
......@@ -102,16 +102,16 @@ public:
Akonadi::IncidenceChanger *incidenceChanger();
void setIncidenceChanger(Akonadi::IncidenceChanger *changer);
int showCompleted();
int showCompleted() const;
void setShowCompleted(int showCompleted);
QVariantMap filterMap();
QVariantMap filterMap() const;
void setFilterMap(const QVariantMap &filterMap);
int sortBy();
int sortBy() const;
void setSortBy(int sortBy);
bool sortAscending();
bool sortAscending() const;
void setSortAscending(bool sortAscending);
bool showCompletedSubtodosInIncomplete();
bool showCompletedSubtodosInIncomplete() const;
void setShowCompletedSubtodosInIncomplete(bool showCompletedSubtodosInIncomplete);
void sortTodoModel();
......
Supports Markdown
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