Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Graphics
Gwenview
Commits
2272b304
Commit
2272b304
authored
Feb 14, 2022
by
Laurent Montel
Browse files
const'ify variables
parent
ff6cc853
Pipeline
#137127
passed with stage
in 3 minutes and 24 seconds
Changes
15
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
lib/about.cpp
View file @
2272b304
...
...
@@ -35,7 +35,7 @@ KAboutData *createAboutData(const QString &appName, const QString &programName)
{
auto
data
=
new
KAboutData
(
appName
,
programName
,
QStringLiteral
(
GWENVIEW_VERSION_STRING
));
data
->
setLicense
(
KAboutLicense
::
GPL
);
data
->
setCopyrightStatement
(
i18n
(
"Copyright 2000-20
19
Gwenview authors"
));
data
->
setCopyrightStatement
(
i18n
(
"Copyright 2000-20
22
Gwenview authors"
));
data
->
setProductName
(
"gwenview"
);
data
->
addAuthor
(
QStringLiteral
(
"Lukáš Tinkl"
),
i18n
(
"Current Maintainer"
),
QStringLiteral
(
"ltinkl@redhat.com"
));
data
->
addAuthor
(
QStringLiteral
(
"Aurélien Gâteau"
),
i18n
(
"Developer"
),
QStringLiteral
(
"agateau@kde.org"
));
...
...
lib/contextmanager.cpp
View file @
2272b304
...
...
@@ -37,8 +37,8 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
namespace
Gwenview
{
struct
ContextManagerPrivate
{
SortedDirModel
*
mDirModel
;
QItemSelectionModel
*
mSelectionModel
;
SortedDirModel
*
mDirModel
=
nullptr
;
QItemSelectionModel
*
mSelectionModel
=
nullptr
;
QUrl
mCurrentDirUrl
;
QUrl
mCurrentUrl
;
...
...
@@ -51,7 +51,7 @@ struct ContextManagerPrivate {
KFileItemList
mSelectedFileItemList
;
bool
mDirListerFinished
=
false
;
QTimer
*
mQueuedSignalsTimer
;
QTimer
*
mQueuedSignalsTimer
=
nullptr
;
void
queueSignal
(
Signal
signal
)
{
...
...
@@ -263,7 +263,7 @@ void ContextManager::slotSelectionChanged()
void
Gwenview
::
ContextManager
::
slotCurrentChanged
(
const
QModelIndex
&
index
)
{
QUrl
url
=
d
->
mDirModel
->
urlForIndex
(
index
);
const
QUrl
url
=
d
->
mDirModel
->
urlForIndex
(
index
);
setCurrentUrl
(
url
);
}
...
...
@@ -277,7 +277,7 @@ void ContextManager::emitQueuedSignals()
void
Gwenview
::
ContextManager
::
slotRowsAboutToBeRemoved
(
const
QModelIndex
&
/*parent*/
,
int
start
,
int
end
)
{
QModelIndex
oldCurrent
=
d
->
mSelectionModel
->
currentIndex
();
const
QModelIndex
oldCurrent
=
d
->
mSelectionModel
->
currentIndex
();
if
(
oldCurrent
.
row
()
<
start
||
oldCurrent
.
row
()
>
end
)
{
// currentIndex has not been removed
return
;
...
...
lib/fullscreenbar.cpp
View file @
2272b304
...
...
@@ -55,12 +55,12 @@ static const int INITIAL_HIDE_TIMEOUT = 2000;
static
const
int
EXTRA_BAR_HEIGHT
=
20
;
struct
FullScreenBarPrivate
{
FullScreenBar
*
q
;
QTimeLine
*
mTimeLine
;
QTimer
*
mAutoHideCursorTimer
;
FullScreenBar
*
q
=
nullptr
;
QTimeLine
*
mTimeLine
=
nullptr
;
QTimer
*
mAutoHideCursorTimer
=
nullptr
;
bool
mAutoHidingEnabled
;
bool
mEdgeTriggerEnabled
;
QTimer
*
mInitialHideTimer
;
QTimer
*
mInitialHideTimer
=
nullptr
;
void
startTimeLine
()
{
...
...
lib/historymodel.cpp
View file @
2272b304
...
...
@@ -139,7 +139,7 @@ private:
setData
(
mUrl
,
KFilePlacesModel
::
UrlRole
);
KFileItem
fileItem
(
mUrl
);
const
KFileItem
fileItem
(
mUrl
);
setData
(
QVariant
(
fileItem
),
KDirModel
::
FileItemRole
);
const
QString
date
=
KFormat
().
formatRelativeDateTime
(
mDateTime
,
QLocale
::
LongFormat
);
...
...
@@ -172,7 +172,7 @@ struct HistoryModelPrivate {
continue
;
}
QUrl
itemUrl
=
item
->
url
();
const
QUrl
itemUrl
=
item
->
url
();
if
(
UrlUtils
::
urlIsFastLocalFile
(
itemUrl
))
{
if
(
!
QFile
::
exists
(
itemUrl
.
path
()))
{
qCDebug
(
GWENVIEW_LIB_LOG
)
<<
"Removing"
<<
itemUrl
.
path
()
<<
"from recent folders. It does not exist anymore"
;
...
...
@@ -227,7 +227,7 @@ HistoryModel::~HistoryModel()
void
HistoryModel
::
addUrl
(
const
QUrl
&
url
,
const
QDateTime
&
_dateTime
)
{
QDateTime
dateTime
=
_dateTime
.
isValid
()
?
_dateTime
:
QDateTime
::
currentDateTime
();
const
QDateTime
dateTime
=
_dateTime
.
isValid
()
?
_dateTime
:
QDateTime
::
currentDateTime
();
HistoryItem
*
historyItem
=
d
->
mHistoryItemForUrl
.
value
(
url
);
if
(
historyItem
)
{
historyItem
->
setDateTime
(
dateTime
);
...
...
lib/imagemetainfomodel.cpp
View file @
2272b304
...
...
@@ -216,14 +216,14 @@ struct ImageMetaInfoModelPrivate {
void
setGroupEntryValue
(
GroupRow
groupRow
,
const
QString
&
key
,
const
QString
&
value
)
{
MetaInfoGroup
*
group
=
mMetaInfoGroupVector
[
groupRow
];
int
entryRow
=
group
->
getRowForKey
(
key
);
const
int
entryRow
=
group
->
getRowForKey
(
key
);
if
(
entryRow
==
MetaInfoGroup
::
InvalidRow
)
{
qCWarning
(
GWENVIEW_LIB_LOG
)
<<
"No row for key"
<<
key
;
return
;
}
group
->
setValueForKeyAt
(
entryRow
,
value
);
QModelIndex
groupIndex
=
q
->
index
(
groupRow
,
0
);
QModelIndex
entryIndex
=
q
->
index
(
entryRow
,
1
,
groupIndex
);
const
QModelIndex
groupIndex
=
q
->
index
(
groupRow
,
0
);
const
QModelIndex
entryIndex
=
q
->
index
(
entryRow
,
1
,
groupIndex
);
Q_EMIT
q
->
dataChanged
(
entryIndex
,
entryIndex
);
}
...
...
@@ -233,7 +233,7 @@ struct ImageMetaInfoModelPrivate {
if
(
index
.
column
()
!=
0
)
{
return
{};
}
QString
label
=
mMetaInfoGroupVector
[
index
.
row
()]
->
label
();
const
QString
label
=
mMetaInfoGroupVector
[
index
.
row
()]
->
label
();
return
QVariant
(
label
);
}
...
...
@@ -277,11 +277,11 @@ struct ImageMetaInfoModelPrivate {
if
(
it
->
tagName
().
substr
(
0
,
2
)
==
"0x"
)
{
continue
;
}
QString
key
=
QString
::
fromUtf8
(
it
->
key
().
c_str
());
QString
label
=
QString
::
fromLocal8Bit
(
it
->
tagLabel
().
c_str
());
const
QString
key
=
QString
::
fromUtf8
(
it
->
key
().
c_str
());
const
QString
label
=
QString
::
fromLocal8Bit
(
it
->
tagLabel
().
c_str
());
std
::
ostringstream
stream
;
stream
<<
*
it
;
QString
value
=
QString
::
fromLocal8Bit
(
stream
.
str
().
c_str
());
const
QString
value
=
QString
::
fromLocal8Bit
(
stream
.
str
().
c_str
());
EntryHash
::
iterator
hashIt
=
hash
.
find
(
key
);
if
(
hashIt
!=
hash
.
end
())
{
...
...
lib/kindproxymodel.cpp
View file @
2272b304
...
...
@@ -64,12 +64,12 @@ bool KindProxyModel::filterAcceptsRow(int sourceRow, const QModelIndex &sourcePa
if
(
d
->
mKindFilter
==
MimeTypeUtils
::
Kinds
())
{
return
true
;
}
QModelIndex
index
=
sourceModel
()
->
index
(
sourceRow
,
0
,
sourceParent
);
KFileItem
fileItem
=
index
.
data
(
KDirModel
::
FileItemRole
).
value
<
KFileItem
>
();
const
QModelIndex
index
=
sourceModel
()
->
index
(
sourceRow
,
0
,
sourceParent
);
const
KFileItem
fileItem
=
index
.
data
(
KDirModel
::
FileItemRole
).
value
<
KFileItem
>
();
if
(
fileItem
.
isNull
())
{
return
false
;
}
MimeTypeUtils
::
Kinds
kind
=
MimeTypeUtils
::
fileItemKind
(
fileItem
);
const
MimeTypeUtils
::
Kinds
kind
=
MimeTypeUtils
::
fileItemKind
(
fileItem
);
return
d
->
mKindFilter
&
kind
;
}
...
...
lib/memoryutils.cpp
View file @
2272b304
...
...
@@ -100,11 +100,11 @@ qulonglong getFreeMemory()
QString
entry
;
QTextStream
readStream
(
&
memFile
);
static
const
int
nElems
=
5
;
QString
names
[
nElems
]
=
{
QStringLiteral
(
"MemFree:"
),
QStringLiteral
(
"Buffers:"
),
QStringLiteral
(
"Cached:"
),
QStringLiteral
(
"SwapFree:"
),
QStringLiteral
(
"SwapTotal:"
)};
const
QString
names
[
nElems
]
=
{
QStringLiteral
(
"MemFree:"
),
QStringLiteral
(
"Buffers:"
),
QStringLiteral
(
"Cached:"
),
QStringLiteral
(
"SwapFree:"
),
QStringLiteral
(
"SwapTotal:"
)};
qulonglong
values
[
nElems
]
=
{
0
,
0
,
0
,
0
,
0
};
bool
foundValues
[
nElems
]
=
{
false
,
false
,
false
,
false
,
false
};
while
(
true
)
{
...
...
lib/placetreemodel.cpp
View file @
2272b304
...
...
@@ -107,8 +107,8 @@ struct PlaceTreeModelPrivate {
QModelIndex
createIndexForDir
(
SortedDirModel
*
dirModel
,
const
QUrl
&
url
)
const
{
QModelIndex
dirIndex
=
dirModel
->
indexForUrl
(
url
);
QModelIndex
parentDirIndex
=
dirIndex
.
parent
();
const
QModelIndex
dirIndex
=
dirModel
->
indexForUrl
(
url
);
const
QModelIndex
parentDirIndex
=
dirIndex
.
parent
();
QUrl
parentUrl
;
if
(
parentDirIndex
.
isValid
())
{
parentUrl
=
dirModel
->
urlForIndex
(
parentDirIndex
);
...
...
lib/preferredimagemetainfomodel.cpp
View file @
2272b304
...
...
@@ -35,8 +35,8 @@ struct PreferredImageMetaInfoModelPrivate {
QVariant
checkStateData
(
const
QModelIndex
&
sourceIndex
)
const
{
if
(
sourceIndex
.
parent
().
isValid
()
&&
sourceIndex
.
column
()
==
0
)
{
QString
key
=
mModel
->
keyForIndex
(
sourceIndex
);
bool
checked
=
mPreferredMetaInfoKeyList
.
contains
(
key
);
const
QString
key
=
mModel
->
keyForIndex
(
sourceIndex
);
const
bool
checked
=
mPreferredMetaInfoKeyList
.
contains
(
key
);
return
QVariant
(
checked
?
Qt
::
Checked
:
Qt
::
Unchecked
);
}
else
{
return
QVariant
();
...
...
@@ -48,11 +48,11 @@ struct PreferredImageMetaInfoModelPrivate {
QStringList
sortedList
;
int
groupCount
=
mModel
->
rowCount
();
for
(
int
groupRow
=
0
;
groupRow
<
groupCount
;
++
groupRow
)
{
QModelIndex
groupIndex
=
mModel
->
index
(
groupRow
,
0
);
int
keyCount
=
mModel
->
rowCount
(
groupIndex
);
const
QModelIndex
groupIndex
=
mModel
->
index
(
groupRow
,
0
);
const
int
keyCount
=
mModel
->
rowCount
(
groupIndex
);
for
(
int
keyRow
=
0
;
keyRow
<
keyCount
;
++
keyRow
)
{
QModelIndex
keyIndex
=
mModel
->
index
(
keyRow
,
0
,
groupIndex
);
QString
key
=
mModel
->
keyForIndex
(
keyIndex
);
const
QModelIndex
keyIndex
=
mModel
->
index
(
keyRow
,
0
,
groupIndex
);
const
QString
key
=
mModel
->
keyForIndex
(
keyIndex
);
if
(
mPreferredMetaInfoKeyList
.
contains
(
key
))
{
sortedList
<<
key
;
}
...
...
@@ -79,7 +79,7 @@ PreferredImageMetaInfoModel::~PreferredImageMetaInfoModel()
Qt
::
ItemFlags
PreferredImageMetaInfoModel
::
flags
(
const
QModelIndex
&
index
)
const
{
QModelIndex
sourceIndex
=
mapToSource
(
index
);
const
QModelIndex
sourceIndex
=
mapToSource
(
index
);
Qt
::
ItemFlags
fl
=
d
->
mModel
->
flags
(
sourceIndex
);
if
(
sourceIndex
.
parent
().
isValid
()
&&
sourceIndex
.
column
()
==
0
)
{
fl
|=
Qt
::
ItemIsUserCheckable
;
...
...
@@ -89,7 +89,7 @@ Qt::ItemFlags PreferredImageMetaInfoModel::flags(const QModelIndex &index) const
QVariant
PreferredImageMetaInfoModel
::
data
(
const
QModelIndex
&
index
,
int
role
)
const
{
QModelIndex
sourceIndex
=
mapToSource
(
index
);
const
QModelIndex
sourceIndex
=
mapToSource
(
index
);
if
(
!
sourceIndex
.
isValid
())
{
return
{};
}
...
...
lib/recentfilesmodel.cpp
View file @
2272b304
...
...
@@ -61,7 +61,7 @@ struct RecentFilesItem : public QStandardItem {
setData
(
mUrl
,
KFilePlacesModel
::
UrlRole
);
KFileItem
fileItem
(
mUrl
);
const
KFileItem
fileItem
(
mUrl
);
setData
(
QVariant
(
fileItem
),
KDirModel
::
FileItemRole
);
}
...
...
lib/shadowfilter.cpp
View file @
2272b304
...
...
@@ -56,7 +56,7 @@ struct ShadowFilterPrivate {
void
paint
()
{
QPainter
painter
(
mWidget
);
QRect
rect
=
mWidget
->
rect
();
const
QRect
rect
=
mWidget
->
rect
();
QColor
color
;
color
=
mShadows
.
value
(
ShadowFilter
::
LeftEdge
,
Qt
::
transparent
);
...
...
lib/slideshow.cpp
View file @
2272b304
...
...
@@ -74,7 +74,7 @@ private:
};
struct
SlideShowPrivate
{
QTimer
*
mTimer
;
QTimer
*
mTimer
=
nullptr
;
State
mState
;
QVector
<
QUrl
>
mUrls
;
QVector
<
QUrl
>
mShuffledUrls
;
...
...
@@ -143,7 +143,7 @@ struct SlideShowPrivate {
}
}
QUrl
url
=
mShuffledUrls
.
last
();
const
QUrl
url
=
mShuffledUrls
.
last
();
mShuffledUrls
.
pop_back
();
return
url
;
...
...
@@ -279,7 +279,7 @@ void SlideShow::resumeAndGoToNextUrl()
void
SlideShow
::
goToNextUrl
()
{
LOG
(
""
);
QUrl
url
=
d
->
findNextUrl
();
const
QUrl
url
=
d
->
findNextUrl
();
LOG
(
"url:"
<<
url
);
if
(
!
url
.
isValid
())
{
pause
();
...
...
lib/timeutils.cpp
View file @
2272b304
...
...
@@ -82,7 +82,7 @@ struct CacheItem {
if
(
!
UrlUtils
::
urlIsFastLocalFile
(
url
))
{
return
false
;
}
QString
path
=
url
.
path
();
const
QString
path
=
url
.
path
();
Exiv2ImageLoader
loader
;
if
(
!
loader
.
load
(
path
))
{
...
...
@@ -102,9 +102,9 @@ struct CacheItem {
std
::
ostringstream
stream
;
stream
<<
*
it
;
QString
value
=
QString
::
fromLocal8Bit
(
stream
.
str
().
c_str
());
const
QString
value
=
QString
::
fromLocal8Bit
(
stream
.
str
().
c_str
());
QDateTime
dt
=
QDateTime
::
fromString
(
value
,
QStringLiteral
(
"yyyy:MM:dd hh:mm:ss"
));
const
QDateTime
dt
=
QDateTime
::
fromString
(
value
,
QStringLiteral
(
"yyyy:MM:dd hh:mm:ss"
));
if
(
!
dt
.
isValid
())
{
qCWarning
(
GWENVIEW_LIB_LOG
)
<<
"Invalid date in exif header of"
<<
path
;
return
false
;
...
...
lib/urlutils.cpp
View file @
2272b304
...
...
@@ -52,7 +52,7 @@ bool urlIsFastLocalFile(const QUrl &url)
static
KMountPoint
::
Ptr
lastMountPoint
;
const
QString
fileName
=
url
.
toLocalFile
();
QString
currentFolder
=
fileName
.
left
(
fileName
.
lastIndexOf
(
QLatin1Char
(
'/'
)));
const
QString
currentFolder
=
fileName
.
left
(
fileName
.
lastIndexOf
(
QLatin1Char
(
'/'
)));
if
(
currentFolder
!=
lastFolder
)
{
lastFolder
=
currentFolder
;
...
...
@@ -80,7 +80,7 @@ bool urlIsDirectory(const QUrl &url)
return
QFileInfo
(
url
.
toLocalFile
()).
isDir
();
}
QWidgetList
list
=
QApplication
::
topLevelWidgets
();
const
QWidgetList
list
=
QApplication
::
topLevelWidgets
();
QWidget
*
parent
;
if
(
!
list
.
isEmpty
())
{
parent
=
list
[
0
];
...
...
@@ -101,11 +101,11 @@ QUrl fixUserEnteredUrl(const QUrl &in)
return
in
;
}
QFileInfo
info
(
in
.
toLocalFile
());
QString
path
=
info
.
absoluteFilePath
();
const
QFileInfo
info
(
in
.
toLocalFile
());
const
QString
path
=
info
.
absoluteFilePath
();
QUrl
out
=
QUrl
::
fromLocalFile
(
path
);
QString
mimeType
=
MimeTypeUtils
::
urlMimeType
(
out
);
const
QString
mimeType
=
MimeTypeUtils
::
urlMimeType
(
out
);
const
QString
protocol
=
ArchiveUtils
::
protocolForMimeType
(
mimeType
);
...
...
lib/zoomcombobox/zoomcombobox.cpp
View file @
2272b304
...
...
@@ -101,7 +101,7 @@ ZoomComboBox::ZoomComboBox(QWidget *parent)
setInsertPolicy
(
QComboBox
::
NoInsert
);
// QLocale::percent() will return a QString in Qt 6.
// Qt encourages using QString(locale().percent()) in QLocale documentation.
int
percentLength
=
QString
(
locale
().
percent
()).
length
();
const
int
percentLength
=
QString
(
locale
().
percent
()).
length
();
setMinimumContentsLength
(
locale
().
toString
(
9999
).
length
()
+
percentLength
);
connect
(
lineEdit
(),
&
QLineEdit
::
textEdited
,
this
,
[
this
,
d
](
const
QString
&
text
)
{
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment