Commit 63a0b25c authored by Laurent Montel's avatar Laurent Montel 😁
Browse files

const'ify variable + initialize variable + use isEmpty()

parent eb678845
Pipeline #136691 passed with stage
in 1 minute and 51 seconds
......@@ -68,20 +68,20 @@ inline Sorting::Enum sortingFromSortAction(const QAction *action)
}
struct BrowseMainPagePrivate : public Ui_BrowseMainPage {
BrowseMainPage *q;
GvCore *mGvCore;
KFilePlacesModel *mFilePlacesModel;
KUrlNavigator *mUrlNavigator;
SortedDirModel *mDirModel;
BrowseMainPage *q = nullptr;
GvCore *mGvCore = nullptr;
KFilePlacesModel *mFilePlacesModel = nullptr;
KUrlNavigator *mUrlNavigator = nullptr;
SortedDirModel *mDirModel = nullptr;
int mDocumentCountImages;
int mDocumentCountVideos;
KFileItemList *mSelectedMediaItems;
KActionCollection *mActionCollection;
FilterController *mFilterController;
QActionGroup *mSortAction;
KToggleAction *mSortDescendingAction;
QActionGroup *mThumbnailDetailsActionGroup;
PreviewItemDelegate *mDelegate;
KFileItemList *mSelectedMediaItems = nullptr;
KActionCollection *mActionCollection = nullptr;
FilterController *mFilterController = nullptr;
QActionGroup *mSortAction = nullptr;
KToggleAction *mSortDescendingAction = nullptr;
QActionGroup *mThumbnailDetailsActionGroup = nullptr;
PreviewItemDelegate *mDelegate = nullptr;
void setupWidgets()
{
......
......@@ -102,7 +102,7 @@ QUrl FileOpsContextManagerItem::pasteTargetUrl() const
{
// If only one folder is selected, paste inside it, otherwise paste in
// current
KFileItemList list = contextManager()->selectedFileItemList();
const KFileItemList list = contextManager()->selectedFileItemList();
if (list.count() == 1 && list.first().isDir()) {
return list.first().url();
} else {
......@@ -271,11 +271,11 @@ void FileOpsContextManagerItem::updateSideBarContent()
void FileOpsContextManagerItem::showProperties()
{
KFileItemList list = contextManager()->selectedFileItemList();
if (list.count() > 0) {
const KFileItemList list = contextManager()->selectedFileItemList();
if (!list.isEmpty()) {
KPropertiesDialog::showDialog(list, mGroup);
} else {
QUrl url = contextManager()->currentDirUrl();
const QUrl url = contextManager()->currentDirUrl();
KPropertiesDialog::showDialog(url, mGroup);
}
}
......@@ -345,7 +345,7 @@ void FileOpsContextManagerItem::rename()
void FileOpsContextManagerItem::createFolder()
{
QUrl url = contextManager()->currentDirUrl();
const QUrl url = contextManager()->currentDirUrl();
mNewFileMenu->setParentWidget(mGroup);
mNewFileMenu->setPopupFiles(QList<QUrl>() << url);
mNewFileMenu->createDirectory();
......@@ -376,7 +376,7 @@ void FileOpsContextManagerItem::openWith(QAction *action)
{
Q_ASSERT(action);
KService::Ptr service;
QList<QUrl> list = urlList();
const QList<QUrl> list = urlList();
bool ok;
int idx = action->data().toInt(&ok);
......
......@@ -87,7 +87,7 @@ NameFilterWidget::~NameFilterWidget()
void NameFilterWidget::applyNameFilter()
{
QVariant data = mModeComboBox->itemData(mModeComboBox->currentIndex());
const QVariant data = mModeComboBox->itemData(mModeComboBox->currentIndex());
mFilter->setMode(NameFilter::Mode(data.toInt()));
mFilter->setText(mLineEdit->text());
}
......@@ -121,7 +121,7 @@ DateFilterWidget::~DateFilterWidget()
void DateFilterWidget::applyDateFilter()
{
QVariant data = mModeComboBox->itemData(mModeComboBox->currentIndex());
const QVariant data = mModeComboBox->itemData(mModeComboBox->currentIndex());
mFilter->setMode(DateFilter::Mode(data.toInt()));
mFilter->setDate(mDateWidget->date());
}
......@@ -164,7 +164,7 @@ void RatingFilterWidget::slotRatingChanged(int value)
void RatingFilterWidget::updateFilterMode()
{
QVariant data = mModeComboBox->itemData(mModeComboBox->currentIndex());
const QVariant data = mModeComboBox->itemData(mModeComboBox->currentIndex());
mFilter->setMode(RatingFilter::Mode(data.toInt()));
}
......@@ -257,9 +257,9 @@ protected:
{
QPainter painter(this);
painter.setRenderHint(QPainter::Antialiasing);
QPainterPath path = PaintUtils::roundedRectangle(QRectF(rect()).adjusted(0.5, 0.5, -0.5, -0.5), 6);
const QPainterPath path = PaintUtils::roundedRectangle(QRectF(rect()).adjusted(0.5, 0.5, -0.5, -0.5), 6);
QColor color = palette().color(QPalette::Highlight);
const QColor color = palette().color(QPalette::Highlight);
painter.fillPath(path, PaintUtils::alphaAdjustedF(color, 0.5));
painter.setPen(color);
painter.drawPath(path);
......
......@@ -236,7 +236,7 @@ void FullScreenContent::updateInformationLabel()
valueList << value;
}
}
QString text = valueList.join(i18nc("@item:intext fullscreen meta info separator", ", "));
const QString text = valueList.join(i18nc("@item:intext fullscreen meta info separator", ", "));
mInformationLabel->setText(text);
}
......@@ -405,8 +405,8 @@ void FullScreenContent::createOptionsAction()
void FullScreenContent::updateSlideShowIntervalLabel()
{
Q_ASSERT(mConfigWidget);
int value = mConfigWidget->mSlideShowIntervalSlider->value();
QString text = formatSlideShowIntervalText(value);
const int value = mConfigWidget->mSlideShowIntervalSlider->value();
const QString text = formatSlideShowIntervalText(value);
mConfigWidget->mSlideShowIntervalLabel->setText(text);
}
......
......@@ -61,11 +61,11 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Cambridge, MA 02110-1301, USA
namespace Gwenview
{
struct GvCorePrivate {
GvCore *q;
MainWindow *mMainWindow;
SortedDirModel *mDirModel;
HistoryModel *mRecentFoldersModel;
RecentFilesModel *mRecentFilesModel;
GvCore *q = nullptr;
MainWindow *mMainWindow = nullptr;
SortedDirModel *mDirModel = nullptr;
HistoryModel *mRecentFoldersModel = nullptr;
RecentFilesModel *mRecentFilesModel = nullptr;
QPalette mPalettes[4];
QString mFullScreenPaletteName;
int configFileJPEGQualityValue = GwenviewConfig::jPEGQuality();
......
......@@ -63,18 +63,18 @@ namespace Gwenview
#endif
struct ImageOpsContextManagerItem::Private {
ImageOpsContextManagerItem *q;
MainWindow *mMainWindow;
SideBarGroup *mGroup;
QRect *mCropStateRect;
QAction *mRotateLeftAction;
QAction *mRotateRightAction;
QAction *mMirrorAction;
QAction *mFlipAction;
QAction *mResizeAction;
QAction *mCropAction;
QAction *mRedEyeReductionAction;
ImageOpsContextManagerItem *q = nullptr;
MainWindow *mMainWindow = nullptr;
SideBarGroup *mGroup = nullptr;
QRect *mCropStateRect = nullptr;
QAction *mRotateLeftAction = nullptr;
QAction *mRotateRightAction = nullptr;
QAction *mMirrorAction = nullptr;
QAction *mFlipAction = nullptr;
QAction *mResizeAction = nullptr;
QAction *mCropAction = nullptr;
QAction *mRedEyeReductionAction = nullptr;
QList<QAction *> mActionList;
void setupActions()
......@@ -122,7 +122,7 @@ struct ImageOpsContextManagerItem::Private {
bool ensureEditable()
{
QUrl url = q->contextManager()->currentUrl();
const QUrl url = q->contextManager()->currentUrl();
Document::Ptr doc = DocumentFactory::instance()->load(url);
doc->waitUntilLoaded();
if (doc->isEditable()) {
......
......@@ -104,8 +104,8 @@ class KeyValueWidget : public QWidget
label->setTextInteractionFlags(Qt::TextSelectableByMouse | Qt::LinksAccessibleByMouse);
}
QLabel *keyLabel;
QLabel *valueLabel;
QLabel *const keyLabel;
QLabel *const valueLabel;
};
public:
......
......@@ -167,58 +167,58 @@ Layout of the main window looks like this:
*/
struct MainWindow::Private {
GvCore *mGvCore;
MainWindow *q;
QSplitter *mCentralSplitter;
QWidget *mContentWidget;
ViewMainPage *mViewMainPage;
KUrlNavigator *mUrlNavigator;
ThumbnailView *mThumbnailView;
ThumbnailView *mActiveThumbnailView;
DocumentInfoProvider *mDocumentInfoProvider;
ThumbnailViewHelper *mThumbnailViewHelper;
GvCore *mGvCore = nullptr;
MainWindow *q = nullptr;
QSplitter *mCentralSplitter = nullptr;
QWidget *mContentWidget = nullptr;
ViewMainPage *mViewMainPage = nullptr;
KUrlNavigator *mUrlNavigator = nullptr;
ThumbnailView *mThumbnailView = nullptr;
ThumbnailView *mActiveThumbnailView = nullptr;
DocumentInfoProvider *mDocumentInfoProvider = nullptr;
ThumbnailViewHelper *mThumbnailViewHelper = nullptr;
QPointer<ThumbnailProvider> mThumbnailProvider;
BrowseMainPage *mBrowseMainPage;
StartMainPage *mStartMainPage;
SideBar *mSideBar;
KMessageWidget *mSharedMessage;
QStackedWidget *mViewStackedWidget;
FullScreenContent *mFullScreenContent;
SaveBar *mSaveBar;
BrowseMainPage *mBrowseMainPage = nullptr;
StartMainPage *mStartMainPage = nullptr;
SideBar *mSideBar = nullptr;
KMessageWidget *mSharedMessage = nullptr;
QStackedWidget *mViewStackedWidget = nullptr;
FullScreenContent *mFullScreenContent = nullptr;
SaveBar *mSaveBar = nullptr;
bool mStartSlideShowWhenDirListerCompleted;
SlideShow *mSlideShow;
SlideShow *mSlideShow = nullptr;
#ifdef HAVE_QTDBUS
Mpris2Service *mMpris2Service;
Mpris2Service *mMpris2Service = nullptr;
#endif
Preloader *mPreloader;
Preloader *mPreloader = nullptr;
bool mPreloadDirectionIsForward;
QActionGroup *mViewModeActionGroup;
KRecentFilesAction *mFileOpenRecentAction;
QAction *mBrowseAction;
QAction *mViewAction;
QAction *mGoUpAction;
QAction *mGoToPreviousAction;
QAction *mGoToNextAction;
QAction *mGoToFirstAction;
QAction *mGoToLastAction;
KToggleAction *mToggleSideBarAction;
KToggleAction *mToggleOperationsSideBarAction;
QAction *mFullScreenAction;
QAction *mToggleSlideShowAction;
KToggleAction *mShowMenuBarAction;
KToggleAction *mShowStatusBarAction;
QPointer<HudButtonBox> hudButtonBox;
QActionGroup *mViewModeActionGroup = nullptr;
KRecentFilesAction *mFileOpenRecentAction = nullptr;
QAction *mBrowseAction = nullptr;
QAction *mViewAction = nullptr;
QAction *mGoUpAction = nullptr;
QAction *mGoToPreviousAction = nullptr;
QAction *mGoToNextAction = nullptr;
QAction *mGoToFirstAction = nullptr;
QAction *mGoToLastAction = nullptr;
KToggleAction *mToggleSideBarAction = nullptr;
KToggleAction *mToggleOperationsSideBarAction = nullptr;
QAction *mFullScreenAction = nullptr;
QAction *mToggleSlideShowAction = nullptr;
KToggleAction *mShowMenuBarAction = nullptr;
KToggleAction *mShowStatusBarAction = nullptr;
QPointer<HudButtonBox> hudButtonBox = nullptr;
#ifdef KF5Purpose_FOUND
Purpose::Menu *mShareMenu;
KToolBarPopupAction *mShareAction;
Purpose::Menu *mShareMenu = nullptr;
KToolBarPopupAction *mShareAction = nullptr;
#endif
KHamburgerMenu *mHamburgerMenu;
KHamburgerMenu *mHamburgerMenu = nullptr;
SortedDirModel *mDirModel;
DocumentOnlyProxyModel *mThumbnailBarModel;
KLinkItemSelectionModel *mThumbnailBarSelectionModel;
ContextManager *mContextManager;
SortedDirModel *mDirModel = nullptr;
DocumentOnlyProxyModel *mThumbnailBarModel = nullptr;
KLinkItemSelectionModel *mThumbnailBarSelectionModel = nullptr;
ContextManager *mContextManager = nullptr;
MainWindowState mStateBeforeFullScreen;
......@@ -227,7 +227,7 @@ struct MainWindow::Private {
MainPageId mCurrentMainPageId;
QDateTime mFullScreenLeftAt;
KNotificationRestrictions *mNotificationRestrictions;
KNotificationRestrictions *mNotificationRestrictions = nullptr;
void setupContextManager()
{
......
......@@ -41,7 +41,7 @@ namespace Gwenview
#endif
struct PreloaderPrivate {
Preloader *q;
Preloader *q = nullptr;
Document::Ptr mDocument;
QSize mSize;
......
......@@ -41,8 +41,8 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Cambridge, MA 02110-1301, USA
namespace Gwenview
{
struct SaveAllHelperPrivate {
QWidget *mParent;
QProgressDialog *mProgressDialog;
QWidget *mParent = nullptr;
QProgressDialog *mProgressDialog = nullptr;
QSet<DocumentJob *> mJobSet;
QStringList mErrorList;
};
......@@ -78,7 +78,7 @@ void SaveAllHelper::save()
d->mProgressDialog->exec();
// Done, show message if necessary
if (d->mErrorList.count() > 0) {
if (!d->mErrorList.isEmpty()) {
QString msg = i18ncp("@info", "One document could not be saved:", "%1 documents could not be saved:", d->mErrorList.count());
msg += QLatin1String("<ul>");
for (const QString &item : qAsConst(d->mErrorList)) {
......@@ -100,8 +100,8 @@ void SaveAllHelper::slotResult(KJob *_job)
{
auto job = static_cast<DocumentJob *>(_job);
if (job->error()) {
QUrl url = job->document()->url();
QString name = url.fileName().isEmpty() ? url.toDisplayString() : url.fileName();
const QUrl url = job->document()->url();
const QString name = url.fileName().isEmpty() ? url.toDisplayString() : url.fileName();
d->mErrorList << xi18nc("@info %1 is the name of the document which failed to save, %2 is the reason for the failure",
"<filename>%1</filename>: %2",
name,
......
......@@ -53,19 +53,19 @@ QToolButton *createToolButton()
}
struct SaveBarPrivate {
SaveBar *q;
KActionCollection *mActionCollection;
QWidget *mSaveBarWidget;
QWidget *mTopRowWidget;
QToolButton *mUndoButton;
QToolButton *mRedoButton;
QToolButton *mSaveCurrentUrlButton;
QToolButton *mSaveAsButton;
QToolButton *mSaveAllButton;
QToolButton *mSaveAllFullScreenButton;
QLabel *mMessageLabel;
QLabel *mActionsLabel;
QFrame *mTooManyChangesFrame;
SaveBar *q = nullptr;
KActionCollection *mActionCollection = nullptr;
QWidget *mSaveBarWidget = nullptr;
QWidget *mTopRowWidget = nullptr;
QToolButton *mUndoButton = nullptr;
QToolButton *mRedoButton = nullptr;
QToolButton *mSaveCurrentUrlButton = nullptr;
QToolButton *mSaveAsButton = nullptr;
QToolButton *mSaveAllButton = nullptr;
QToolButton *mSaveAllFullScreenButton = nullptr;
QLabel *mMessageLabel = nullptr;
QLabel *mActionsLabel = nullptr;
QFrame *mTooManyChangesFrame = nullptr;
QUrl mCurrentUrl;
void createTooManyChangesFrame()
......@@ -113,9 +113,9 @@ struct SaveBarPrivate {
void applyNormalStyleSheet()
{
QColor bgColor = QToolTip::palette().base().color();
QColor borderColor = PaintUtils::adjustedHsv(bgColor, 0, 150, 0);
QColor fgColor = QToolTip::palette().text().color();
const QColor bgColor = QToolTip::palette().base().color();
const QColor borderColor = PaintUtils::adjustedHsv(bgColor, 0, 150, 0);
const QColor fgColor = QToolTip::palette().text().color();
QString css =
"#saveBarWidget {"
......@@ -131,7 +131,7 @@ struct SaveBarPrivate {
void applyFullScreenStyleSheet()
{
QString css =
const QString css =
"#saveBarWidget {"
" background-color: #333;"
"}";
......
......@@ -135,8 +135,8 @@ public:
}
private:
GraphicsPixmapWidget *mPixmapWidget;
QTimer *mDeleteTimer;
GraphicsPixmapWidget *mPixmapWidget = nullptr;
QTimer *mDeleteTimer = nullptr;
void updatePixmap(int rating)
{
......
......@@ -81,8 +81,8 @@ private:
//- SideBarGroup ---------------------------------------------------------------
struct SideBarGroupPrivate {
QFrame *mContainer;
QLabel *mTitleLabel;
QFrame *mContainer = nullptr;
QLabel *mTitleLabel = nullptr;
};
SideBarGroup::SideBarGroup(const QString &title)
......@@ -149,7 +149,7 @@ void SideBarGroup::addAction(QAction *action)
struct SideBarPagePrivate {
QIcon mIcon;
QString mTitle;
QVBoxLayout *mLayout;
QVBoxLayout *mLayout = nullptr;
};
SideBarPage::SideBarPage(const QIcon &icon, const QString &title)
......
......@@ -78,10 +78,10 @@ public:
};
struct StartMainPagePrivate : public Ui_StartMainPage {
StartMainPage *q;
GvCore *mGvCore;
KFilePlacesModel *mBookmarksModel;
ThumbnailProvider *mRecentFilesThumbnailProvider;
StartMainPage *q = nullptr;
GvCore *mGvCore = nullptr;
KFilePlacesModel *mBookmarksModel = nullptr;
ThumbnailProvider *mRecentFilesThumbnailProvider = nullptr;
bool mSearchUiInitialized;
void setupSearchUi()
......
......@@ -39,7 +39,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
namespace Gwenview
{
struct ThumbnailViewHelperPrivate {
KActionCollection *mActionCollection;
KActionCollection *mActionCollection = nullptr;
QUrl mCurrentDirUrl;
void addActionToMenu(QMenu &popup, const char *name)
......
......@@ -107,27 +107,27 @@ const int ViewMainPage::MaxViewCount = 6;
* +-------------------------------------------------------------------+
*/
struct ViewMainPagePrivate {
ViewMainPage *q;
SlideShow *mSlideShow;
KActionCollection *mActionCollection;
GvCore *mGvCore;
KModelIndexProxyMapper *mDirModelToBarModelProxyMapper;
QSplitter *mThumbnailSplitter;
QWidget *mAdapterContainer;
DocumentViewController *mDocumentViewController;
ViewMainPage *q = nullptr;
SlideShow *mSlideShow = nullptr;
KActionCollection *mActionCollection = nullptr;
GvCore *mGvCore = nullptr;
KModelIndexProxyMapper *mDirModelToBarModelProxyMapper = nullptr;
QSplitter *mThumbnailSplitter = nullptr;
QWidget *mAdapterContainer = nullptr;
DocumentViewController *mDocumentViewController = nullptr;
QList<DocumentView *> mDocumentViews;
DocumentViewSynchronizer *mSynchronizer;
QToolButton *mToggleSideBarButton;
QToolButton *mToggleThumbnailBarButton;
ZoomWidget *mZoomWidget;
DocumentViewContainer *mDocumentViewContainer;
SlideContainer *mToolContainer;
QWidget *mStatusBarContainer;
ThumbnailBarView *mThumbnailBar;
KToggleAction *mToggleThumbnailBarAction;
KToggleAction *mSynchronizeAction;
QCheckBox *mSynchronizeCheckBox;
KSqueezedTextLabel *mDocumentCountLabel;
DocumentViewSynchronizer *mSynchronizer = nullptr;
QToolButton *mToggleSideBarButton = nullptr;
QToolButton *mToggleThumbnailBarButton = nullptr;
ZoomWidget *mZoomWidget = nullptr;
DocumentViewContainer *mDocumentViewContainer = nullptr;
SlideContainer *mToolContainer = nullptr;
QWidget *mStatusBarContainer = nullptr;
ThumbnailBarView *mThumbnailBar = nullptr;
KToggleAction *mToggleThumbnailBarAction = nullptr;
KToggleAction *mSynchronizeAction = nullptr;
QCheckBox *mSynchronizeCheckBox = nullptr;
KSqueezedTextLabel *mDocumentCountLabel = nullptr;
// Activity Resource events reporting needs to be above KPart,
// in the shell itself, to avoid problems with other MDI applications
......
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