Commit 7ee680e9 authored by Laurent Montel's avatar Laurent Montel 😁

Fix warning + use nullptr + override + make it compiles with strict

compile flags
parent f11fb296
......@@ -34,9 +34,10 @@ find_package(KF5 REQUIRED COMPONENTS
find_package(KHotKeysDBusInterface QUIET)
feature_summary(WHAT ALL INCLUDE_QUIET_PACKAGES FATAL_ON_MISSING_REQUIRED_PACKAGES)
remove_definitions(-DQT_NO_CAST_FROM_ASCII -DQT_STRICT_ITERATORS -DQT_NO_CAST_FROM_BYTEARRAY -DQT_NO_KEYWORDS)
#add_definitions(-DQT_NO_CAST_FROM_ASCII -DQT_STRICT_ITERATORS -DQT_NO_CAST_FROM_BYTEARRAY)
add_definitions(-DQT_STRICT_ITERATORS -DQT_NO_CAST_FROM_ASCII -DQT_NO_CAST_FROM_BYTEARRAY)
add_subdirectory( pixmaps )
add_subdirectory( doc )
......@@ -85,3 +86,4 @@ install( PROGRAMS org.kde.kmenuedit.desktop DESTINATION ${KDE_INSTALL_APPDIR}
install( FILES kmenueditui.rc DESTINATION ${KDE_INSTALL_KXMLGUI5DIR}/kmenuedit )
ecm_install_icons( ICONS 16-apps-kmenuedit.png 22-apps-kmenuedit.png 32-apps-kmenuedit.png 48-apps-kmenuedit.png DESTINATION ${KDE_INSTALL_ICONDIR} THEME hicolor )
feature_summary(WHAT ALL INCLUDE_QUIET_PACKAGES FATAL_ON_MISSING_REQUIRED_PACKAGES)
......@@ -45,8 +45,6 @@
BasicTab::BasicTab( QWidget *parent )
: QTabWidget(parent)
{
_menuFolderInfo = 0;
_menuEntryInfo = 0;
initGeneralTab();
initAdvancedTab();
......@@ -492,7 +490,7 @@ void BasicTab::uidcb_clicked()
void BasicTab::slotExecSelected()
{
QString path = _execEdit->lineEdit()->text();
if (!path.startsWith('\''))
if (!path.startsWith(QLatin1Char('\'')))
_execEdit->lineEdit()->setText(KShell::quoteArg(path));
}
......
......@@ -85,20 +85,34 @@ protected:
void enableWidgets(bool isDF, bool isDeleted);
protected:
KLineEdit *_nameEdit;
KLineSpellChecking*_commentEdit;
KLineSpellChecking *_descriptionEdit;
KKeySequenceWidget *_keyBindingEdit;
KUrlRequester *_execEdit, *_pathEdit;
KLineEdit *_terminalOptionsEdit, *_userNameEdit;
QCheckBox *_terminalCB, *_userCB, *_launchCB, *_onlyShowInKdeCB, *_hiddenEntryCB;
KIconButton *_iconButton;
QGroupBox *_workPathGroup, *_terminalGroup, *_userGroup, *_keyBindingGroup;
QLabel *_terminalOptionsLabel, *_userNameLabel, *_pathLabel, *_nameLabel, *_commentLabel, *_execLabel, *_keyBindingLabel;
QLabel *_descriptionLabel;
MenuFolderInfo *_menuFolderInfo;
MenuEntryInfo *_menuEntryInfo;
KLineEdit *_nameEdit = nullptr;
KLineSpellChecking*_commentEdit = nullptr;
KLineSpellChecking *_descriptionEdit = nullptr;
KKeySequenceWidget *_keyBindingEdit = nullptr;
KUrlRequester *_execEdit, *_pathEdit = nullptr;
KLineEdit *_terminalOptionsEdit = nullptr;
KLineEdit *_userNameEdit = nullptr;
QCheckBox *_terminalCB = nullptr;
QCheckBox *_userCB = nullptr;
QCheckBox *_launchCB = nullptr;
QCheckBox *_onlyShowInKdeCB = nullptr;
QCheckBox *_hiddenEntryCB = nullptr;
KIconButton *_iconButton = nullptr;
QGroupBox *_workPathGroup = nullptr;
QGroupBox *_terminalGroup = nullptr;
QGroupBox *_userGroup = nullptr;
QGroupBox *_keyBindingGroup = nullptr;
QLabel *_terminalOptionsLabel = nullptr;
QLabel *_userNameLabel = nullptr;
QLabel *_pathLabel = nullptr;
QLabel *_nameLabel = nullptr;
QLabel *_commentLabel = nullptr;
QLabel *_execLabel = nullptr;
QLabel *_keyBindingLabel = nullptr;
QLabel *_descriptionLabel = nullptr;
MenuFolderInfo *_menuFolderInfo = nullptr;
MenuEntryInfo *_menuEntryInfo = nullptr;
};
#endif
......@@ -24,7 +24,7 @@ const QString ConfigurationManager::GENERAL_CONFIG_GROUP = QStringLiteral("Gener
const QString ConfigurationManager::SHOW_HIDDEN_ENTRIES_PROPERTY_NAME = QStringLiteral("ShowHidden");
const QString ConfigurationManager::SPLITTER_SIZES_PROPERTY_NAME = QStringLiteral("SplitterSizes");
ConfigurationManager* ConfigurationManager::m_instance = 0;
ConfigurationManager* ConfigurationManager::m_instance = nullptr;
ConfigurationManager::ConfigurationManager() :
m_configGroup(KSharedConfig::openConfig(), GENERAL_CONFIG_GROUP)
......
......@@ -29,7 +29,7 @@
static bool khotkeys_present = false;
static bool khotkeys_inited = false;
static OrgKdeKhotkeysInterface *khotkeysInterface = NULL;
static OrgKdeKhotkeysInterface *khotkeysInterface = nullptr;
bool KHotKeys::init()
......@@ -51,7 +51,7 @@ bool KHotKeys::init()
}
KMessageBox::error(
NULL,
"<qt>" + i18n("Unable to contact khotkeys. Your changes are saved, but they could not be activated.") + "</qt>" );
QStringLiteral("<qt>") + i18n("Unable to contact khotkeys. Your changes are saved, but they could not be activated.") + QStringLiteral("</qt>") );
}
khotkeys_present = khotkeysInterface->isValid();
......@@ -71,7 +71,7 @@ void KHotKeys::cleanup()
bool KHotKeys::present()
{
qDebug() << khotkeys_inited;
qDebug() << khotkeys_inited;
if( !khotkeys_inited )
init();
......
......@@ -43,7 +43,7 @@ void KLineSpellChecking::slotCheckSpelling()
if ( text().isEmpty() ) {
return;
}
Sonnet::Dialog *spellDialog = new Sonnet::Dialog(new Sonnet::BackgroundChecker(this), 0);
Sonnet::Dialog *spellDialog = new Sonnet::Dialog(new Sonnet::BackgroundChecker(this), nullptr);
connect(spellDialog, &Sonnet::Dialog::replace, this, &KLineSpellChecking::spellCheckerCorrected);
connect(spellDialog, &Sonnet::Dialog::misspelling, this, &KLineSpellChecking::spellCheckerMisspelling);
connect(spellDialog, SIGNAL(done(QString)), this, SLOT(slotSpellCheckDone(QString)));
......@@ -58,7 +58,7 @@ void KLineSpellChecking::spellCheckerMisspelling( const QString &_text, int pos)
highLightWord( _text.length(),pos );
}
void KLineSpellChecking::highLightWord( unsigned int length, unsigned int pos )
void KLineSpellChecking::highLightWord( int length, int pos )
{
setSelection ( pos, length );
}
......
......@@ -30,7 +30,7 @@ public:
explicit KLineSpellChecking( QWidget *parent = nullptr );
~KLineSpellChecking() override;
void highLightWord( unsigned int length, unsigned int pos );
void highLightWord(int length, int pos );
protected:
void contextMenuEvent(QContextMenuEvent *e) override;
......
......@@ -188,7 +188,7 @@ void KMenuEdit::slotChangeView()
m_actionDelete->setText(i18n("&Delete"));
actionCollection()->setDefaultShortcut(m_actionDelete, QKeySequence(Qt::Key_Delete));
if (m_splitter == 0) {
if (!m_splitter) {
setupView();
}
setupGUI(KXmlGuiWindow::ToolBar|Keys|Save|Create, QStringLiteral("kmenueditui.rc"));
......
......@@ -53,11 +53,11 @@ protected Q_SLOTS:
void slotConfigure();
protected:
TreeView *m_tree;
BasicTab *m_basicTab;
QSplitter *m_splitter;
TreeView *m_tree = nullptr;
BasicTab *m_basicTab = nullptr;
QSplitter *m_splitter = nullptr;
QAction *m_actionDelete;
QAction *m_actionDelete = nullptr;
bool m_showHidden;
};
......
......@@ -33,7 +33,7 @@
static const char description[] = I18N_NOOP("KDE menu editor");
static KMenuEdit *menuEdit = 0;
static KMenuEdit *menuEdit = nullptr;
class KMenuApplication : public QApplication
{
......@@ -42,7 +42,7 @@ public:
: QApplication(argc, argv)
{
QCoreApplication::setApplicationName(QStringLiteral("kmenuedit"));
QCoreApplication::setApplicationVersion(PROJECT_VERSION);
QCoreApplication::setApplicationVersion(QLatin1String(PROJECT_VERSION));
QCoreApplication::setOrganizationDomain(QStringLiteral("kde.org"));
QApplication::setApplicationDisplayName(i18n("KDE Menu Editor"));
}
......@@ -64,7 +64,7 @@ extern "C" int Q_DECL_EXPORT kdemain( int argc, char **argv )
KLocalizedString::setApplicationDomain("kmenuedit");
KAboutData aboutData(QStringLiteral("kmenuedit"), i18n("KDE Menu Editor"),
PROJECT_VERSION, i18n(description), KAboutLicense::GPL,
QLatin1String(PROJECT_VERSION), i18n(description), KAboutLicense::GPL,
i18n("(C) 2000-2003, Waldo Bastian, Raffaele Sandrini, Matthias Elter"));
aboutData.addAuthor(i18n("Waldo Bastian"), i18n("Maintainer"), QStringLiteral("bastian@kde.org"));
aboutData.addAuthor(i18n("Raffaele Sandrini"), i18n("Previous Maintainer"), QStringLiteral("sandrini@kde.org"));
......
......@@ -124,7 +124,7 @@ QDomElement MenuFile::findMenu(QDomElement elem, const QString &menuName, bool c
{
QString menuNodeName;
QString subMenuName;
int i = menuName.indexOf('/');
int i = menuName.indexOf(QLatin1Char('/'));
if (i >= 0)
{
menuNodeName = menuName.left(i);
......@@ -198,10 +198,10 @@ static QString entryToDirId(const QString &path)
local = KGlobal::dirs()->relativeLocation("xdgdata-dirs", path);
}
if (local.isEmpty() || local.startsWith('/'))
if (local.isEmpty() || local.startsWith(QLatin1Char('/')))
{
// What now? Use filename only and hope for the best.
local = path.mid(path.lastIndexOf('/')+1);
local = path.mid(path.lastIndexOf(QLatin1Char('/'))+1);
}
return local;
}
......@@ -335,7 +335,7 @@ void MenuFile::setLayout(const QString &menuName, const QStringList &layout)
mergeNode.setAttribute(QStringLiteral("type"), QStringLiteral("all"));
layoutNode.appendChild(mergeNode);
}
else if (li.endsWith('/'))
else if (li.endsWith(QLatin1Char('/')))
{
li.truncate(li.length()-1);
QDomElement menuNode = m_doc.createElement(MF_MENUNAME);
......@@ -395,8 +395,8 @@ void MenuFile::moveMenu(const QString &oldMenu, const QString &newMenu)
// TODO: GET RID OF COMMON PART, IT BREAKS STUFF
// Find common part
QStringList oldMenuParts = oldMenu.split( '/');
QStringList newMenuParts = newMenu.split( '/');
QStringList oldMenuParts = oldMenu.split(QLatin1Char('/'));
QStringList newMenuParts = newMenu.split(QLatin1Char('/'));
QString commonMenuName;
int max = qMin(oldMenuParts.count(), newMenuParts.count());
int i = 0;
......@@ -404,20 +404,20 @@ void MenuFile::moveMenu(const QString &oldMenu, const QString &newMenu)
{
if (oldMenuParts[i] != newMenuParts[i])
break;
commonMenuName += '/' + oldMenuParts[i];
commonMenuName += QLatin1Char('/') + oldMenuParts[i];
}
QString oldMenuName;
for(int j = i; j < oldMenuParts.count()-1; j++)
{
if (i != j)
oldMenuName += '/';
oldMenuName += QLatin1Char('/');
oldMenuName += oldMenuParts[j];
}
QString newMenuName;
for(int j = i; j < newMenuParts.count()-1; j++)
{
if (i != j)
newMenuName += '/';
newMenuName += QLatin1Char('/');
newMenuName += newMenuParts[j];
}
......@@ -455,7 +455,7 @@ QString MenuFile::uniqueMenuName(const QString &menuName, const QString &newMenu
QDomElement elem = findMenu(m_doc.documentElement(), menuName, false);
QString result = newMenu;
if (result.endsWith('/'))
if (result.endsWith(QLatin1Char('/')))
result.truncate(result.length()-1);
QRegExp r(QStringLiteral("(.*)(?=-\\d+)"));
......@@ -463,7 +463,7 @@ QString MenuFile::uniqueMenuName(const QString &menuName, const QString &newMenu
int trunc = result.length(); // Position of trailing '/'
result.append("/");
result.append(QLatin1Char('/'));
for(int n = 1; ++n; )
{
......
......@@ -34,9 +34,9 @@
// MenuFolderInfo
//
static QStringList *s_newShortcuts = 0;
static QStringList *s_freeShortcuts = 0;
static QStringList *s_deletedApps = 0;
static QStringList *s_newShortcuts = nullptr;
static QStringList *s_freeShortcuts = nullptr;
static QStringList *s_deletedApps = nullptr;
// Add separator
void MenuFolderInfo::add(MenuSeparatorInfo *info, bool initial)
......@@ -187,14 +187,14 @@ void MenuFolderInfo::save(MenuFile *menuFile)
}
#endif
delete s_deletedApps;
s_deletedApps = 0;
s_deletedApps = nullptr;
}
if (dirty)
{
QString local = KDesktopFile::locateLocal(directoryFile);
KDesktopFile *df = 0;
KDesktopFile *df = nullptr;
if (directoryFile != local)
{
KDesktopFile orig(QStandardPaths::ApplicationsLocation, directoryFile);
......@@ -320,7 +320,7 @@ void MenuEntryInfo::setDirty()
bool MenuEntryInfo::needInsertion()
{
// If entry is dirty and previously stored under applnk, then we need to be added explicitly
return dirty && !service->entryPath().startsWith('/');
return dirty && !service->entryPath().startsWith(QLatin1Char('/'));
}
void MenuEntryInfo::save()
......
......@@ -143,7 +143,7 @@ public:
class MenuEntryInfo : public MenuInfo
{
public:
explicit MenuEntryInfo(const KService::Ptr &_service, KDesktopFile *_df = 0)
explicit MenuEntryInfo(const KService::Ptr &_service, KDesktopFile *_df = nullptr)
: service(_service), m_desktopFile(_df),
shortcutLoaded(false), shortcutDirty(false), dirty(_df != 0), hidden(false)
{
......
......@@ -40,8 +40,8 @@ protected Q_SLOTS:
void slotSave();
private:
SpellCheckingPage *m_pageSpellChecking;
MiscPage *m_pageMisc;
SpellCheckingPage *m_pageSpellChecking = nullptr;
MiscPage *m_pageMisc = nullptr;
};
class SpellCheckingPage : public QWidget
......@@ -51,7 +51,7 @@ public:
explicit SpellCheckingPage( QWidget * );
void saveOptions();
private:
Sonnet::ConfigWidget *m_confPage;
Sonnet::ConfigWidget *m_confPage = nullptr;
};
class MiscPage : public QWidget
......@@ -61,7 +61,7 @@ public:
explicit MiscPage( QWidget * );
void saveOptions();
private:
QCheckBox *m_showHiddenEntries;
QCheckBox *m_showHiddenEntries = nullptr;
};
......
This diff is collapsed.
......@@ -204,28 +204,28 @@ protected:
void sendReloadMenu();
private:
KActionCollection *m_ac;
QMenu *m_popupMenu;
KActionCollection *m_ac = nullptr;
QMenu *m_popupMenu = nullptr;
int m_clipboard;
MenuFolderInfo *m_clipboardFolderInfo;
MenuEntryInfo *m_clipboardEntryInfo;
MenuFolderInfo *m_clipboardFolderInfo = nullptr;
MenuEntryInfo *m_clipboardEntryInfo = nullptr;
bool m_showHidden;
MenuFile *m_menuFile;
MenuFolderInfo *m_rootFolder;
MenuSeparatorInfo *m_separator;
MenuFile *m_menuFile = nullptr;
MenuFolderInfo *m_rootFolder = nullptr;
MenuSeparatorInfo *m_separator = nullptr;
QStringList m_newMenuIds;
QStringList m_newDirectoryList;
bool m_layoutDirty;
bool m_detailedMenuEntries;
bool m_detailedEntriesNamesFirst;
QStringList m_dropMimeTypes;
QSignalMapper *m_sortSignalMapper;
QSignalMapper *m_sortSignalMapper = nullptr;
};
class MenuItemMimeData : public QMimeData
{
public:
MenuItemMimeData(TreeItem *item);
explicit MenuItemMimeData(TreeItem *item);
QStringList formats() const override;
bool hasFormat(const QString &mimeType) const override;
TreeItem *item() const;
......@@ -234,7 +234,7 @@ protected:
QVariant retrieveData(const QString &mimeType, QVariant::Type type) const override;
private:
TreeItem *m_item;
TreeItem *m_item = nullptr;
};
Q_DECLARE_METATYPE(TreeItem *)
......
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