Commit 59e2aaaa authored by Laurent Montel's avatar Laurent Montel 😁
Browse files

const'ify more variables

parent a94fe7dd
Pipeline #137753 passed with stage
in 6 minutes and 33 seconds
......@@ -140,7 +140,7 @@ struct DocumentViewControllerPrivate {
const QColor &lightColor = usingLightTheme ? qApp->palette().base().color() : qApp->palette().text().color();
const QColor &darkColor = usingLightTheme ? qApp->palette().text().color() : qApp->palette().base().color();
QColor neutralColor = KColorUtils::mix(lightColor, darkColor, 0.5);
const QColor neutralColor = KColorUtils::mix(lightColor, darkColor, 0.5);
paintPixmap(lightPixmap, lightColor);
paintPixmap(neutralPixmap, neutralColor);
......
......@@ -37,8 +37,8 @@ namespace Gwenview
{
//// RasterImageViewAdapter ////
struct RasterImageViewAdapterPrivate {
RasterImageViewAdapter *q;
RasterImageView *mView;
RasterImageViewAdapter *q = nullptr;
RasterImageView *mView = nullptr;
};
RasterImageViewAdapter::RasterImageViewAdapter()
......
......@@ -73,7 +73,7 @@ struct FullScreenBarPrivate {
{
QBitmap empty(32, 32);
empty.clear();
QCursor blankCursor(empty, empty);
const QCursor blankCursor(empty, empty);
QApplication::setOverrideCursor(blankCursor);
}
......@@ -265,7 +265,7 @@ bool FullScreenBar::eventFilter(QObject *object, QEvent *event)
auto button = qobject_cast<QToolButton *>(object);
if (button && !button->actions().isEmpty()) {
QAction *action = button->actions().constFirst();
QString toolTip = KLocalizedString::removeAcceleratorMarker(action->toolTip());
const QString toolTip = KLocalizedString::removeAcceleratorMarker(action->toolTip());
// Filtering message requested by translators (scripting).
button->setToolTip(i18nc("@info:tooltip of custom toolbar button", "%1", toolTip));
}
......
......@@ -77,12 +77,12 @@ struct HistoryItem : public QStandardItem {
KConfig config(fileName, KConfig::SimpleConfig);
KConfigGroup group(&config, "general");
QUrl url(group.readEntry("url"));
const QUrl url(group.readEntry("url"));
if (!url.isValid()) {
qCCritical(GWENVIEW_LIB_LOG) << "Invalid url" << url;
return nullptr;
}
QDateTime dateTime = QDateTime::fromString(group.readEntry("dateTime"), Qt::ISODate);
const QDateTime dateTime = QDateTime::fromString(group.readEntry("dateTime"), Qt::ISODate);
if (!dateTime.isValid()) {
qCCritical(GWENVIEW_LIB_LOG) << "Invalid dateTime" << dateTime;
return nullptr;
......@@ -153,7 +153,7 @@ private:
};
struct HistoryModelPrivate {
HistoryModel *q;
HistoryModel *q = nullptr;
QString mStorageDir;
int mMaxCount;
......
......@@ -65,7 +65,7 @@ void HudLabel::setText(const QString &text)
void HudLabel::paint(QPainter *painter, const QStyleOptionGraphicsItem *, QWidget *)
{
HudTheme::RenderInfo info = HudTheme::renderInfo(HudTheme::FrameWidget);
const HudTheme::RenderInfo info = HudTheme::renderInfo(HudTheme::FrameWidget);
painter->setPen(info.textPen);
painter->drawText(boundingRect(), Qt::AlignCenter, d->mText);
}
......
......@@ -125,7 +125,7 @@ RenderInfo renderInfo(WidgetType widget, State state)
overSliderWidgetGroove.borderPen = QPen(QColor(0xcc, 0xcc, 0xcc));
renderInfoMap[SliderWidgetGroove].infos[MouseOverState] = overSliderWidgetGroove;
}
RenderInfo normalInfo = renderInfoMap[widget].infos.value(NormalState);
const RenderInfo normalInfo = renderInfoMap[widget].infos.value(NormalState);
if (state == NormalState) {
return normalInfo;
} else {
......
......@@ -207,7 +207,7 @@ QModelIndex PlaceTreeModel::index(int row, int column, const QModelIndex &parent
}
Node parentNode = d->nodeForIndex(parent);
QModelIndex parentDirIndex = d->dirIndexForNode(parentNode, parent);
const QModelIndex parentDirIndex = d->dirIndexForNode(parentNode, parent);
SortedDirModel *dirModel = parentNode.model;
QUrl parentUrl = dirModel->urlForIndex(parentDirIndex);
......@@ -285,8 +285,8 @@ void PlaceTreeModel::fetchMore(const QModelIndex &parent)
}
const Node node = d->nodeForIndex(parent);
if (!node.model->dirLister()->url().isValid()) {
QModelIndex placeIndex = d->mPlacesModel->index(parent.row(), parent.column());
QUrl url = KFilePlacesModel::convertedUrl(d->mPlacesModel->url(placeIndex));
const QModelIndex placeIndex = d->mPlacesModel->index(parent.row(), parent.column());
const QUrl url = KFilePlacesModel::convertedUrl(d->mPlacesModel->url(placeIndex));
node.model->dirLister()->openUrl(url, KDirLister::Keep);
return;
}
......@@ -327,7 +327,7 @@ void PlaceTreeModel::slotDirRowsAboutToBeInserted(const QModelIndex &parentDirIn
auto dirModel = static_cast<SortedDirModel *>(sender());
QModelIndex parentIndex;
if (parentDirIndex.isValid()) {
QUrl url = dirModel->urlForIndex(parentDirIndex);
const QUrl url = dirModel->urlForIndex(parentDirIndex);
parentIndex = d->createIndexForDir(dirModel, url);
} else {
parentIndex = d->createIndexForPlace(dirModel);
......@@ -345,7 +345,7 @@ void PlaceTreeModel::slotDirRowsAboutToBeRemoved(const QModelIndex &parentDirInd
auto dirModel = static_cast<SortedDirModel *>(sender());
QModelIndex parentIndex;
if (parentDirIndex.isValid()) {
QUrl url = dirModel->urlForIndex(parentDirIndex);
const QUrl url = dirModel->urlForIndex(parentDirIndex);
parentIndex = d->createIndexForDir(dirModel, url);
} else {
parentIndex = d->createIndexForPlace(dirModel);
......
......@@ -141,7 +141,7 @@ struct PrintHelperPrivate {
delete optionsPage;
}
QImage image = doc->image();
const QImage image = doc->image();
painter.setWindow(image.rect());
painter.drawImage(0, 0, image);
}
......
......@@ -52,7 +52,7 @@ struct PrintOptionsPagePrivate : public Ui_PrintOptionsPage {
QSize mImageSize;
QButtonGroup mScaleGroup;
QButtonGroup mPositionGroup;
KConfigDialogManager *mConfigDialogManager;
KConfigDialogManager *mConfigDialogManager = nullptr;
void initPositionFrame()
{
......
......@@ -39,7 +39,7 @@ int main(int argc, char **argv)
return 1;
}
QString fileName = QString::fromUtf8(argv[1]);
const QString fileName = QString::fromUtf8(argv[1]);
QFile file(fileName);
if (!file.open(QIODevice::ReadOnly)) {
......
......@@ -57,12 +57,12 @@ int main(int argc, char **argv)
aboutData->processCommandLine(&parser);
// Read cmdline options
QStringList args = parser.positionalArguments();
const QStringList args = parser.positionalArguments();
if (args.count() != 2) {
qFatal("Wrong number of arguments");
return 1;
}
QString imageDirName = args.first();
const QString imageDirName = args.first();
ThumbnailGroup::Enum group = ThumbnailGroup::Normal;
if (args.last() == "large") {
group = ThumbnailGroup::Large;
......@@ -75,7 +75,7 @@ int main(int argc, char **argv)
// Set up thumbnail base dir
if (!thumbnailBaseDirName.isEmpty()) {
QDir dir = QDir(thumbnailBaseDirName);
const QDir dir = QDir(thumbnailBaseDirName);
thumbnailBaseDirName = dir.absolutePath();
if (!dir.exists()) {
bool ok = QDir::root().mkpath(thumbnailBaseDirName);
......@@ -95,7 +95,7 @@ int main(int argc, char **argv)
KFileItemList list;
const auto entryList = dir.entryList();
for (const QString &name : entryList) {
QUrl url = QUrl::fromLocalFile(dir.absoluteFilePath(name));
const QUrl url = QUrl::fromLocalFile(dir.absoluteFilePath(name));
KFileItem item(url);
list << item;
}
......
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