Commit 81934884 authored by Laurent Montel's avatar Laurent Montel 😁

Modernize code

parent 0c48f07b
......@@ -2,9 +2,10 @@ project(kinfocenter)
set(PROJECT_VERSION "5.11.90")
cmake_minimum_required(VERSION 2.8.12 FATAL_ERROR)
set(QT_MIN_VERSION "5.4.0")
set(QT_MIN_VERSION "5.7.0")
find_package(ECM 1.2.0 REQUIRED NO_MODULE)
set(KF5_MIN_VERSION "5.30")
find_package(ECM ${KF5_MIN_VERSION} REQUIRED NO_MODULE)
set(CMAKE_MODULE_PATH ${ECM_MODULE_PATH} ${ECM_KDE_MODULE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
include(KDEInstallDirs)
......@@ -14,7 +15,6 @@ include(FeatureSummary)
find_package(Qt5 ${QT_MIN_VERSION} CONFIG REQUIRED COMPONENTS Core Gui Widgets)
set(KF5_MIN_VERSION "5.30")
find_package(KF5 ${KF5_MIN_VERSION} REQUIRED COMPONENTS
Completion
Config
......
......@@ -24,11 +24,8 @@
#include <QIcon>
#include <QStandardPaths>
#include <kcoreaddons_version.h>
#include <KAboutData>
#if KCOREADDONS_VERSION >= QT_VERSION_CHECK(5,20,0)
#include <KCoreAddons>
#endif
#include <KConfig>
#include <KConfigGroup>
#include <KDesktopFile>
......@@ -182,12 +179,7 @@ void Module::loadSoftware()
ui->qtLabel->setText(qVersion());
#if KCOREADDONS_VERSION >= QT_VERSION_CHECK(5,20,0)
ui->frameworksLabel->setText(KCoreAddons::versionString());
#else
ui->frameworksLabelKey->setVisible(false);
ui->frameworksLabel->setVisible(false);
#endif
}
void Module::loadHardware()
......
......@@ -186,7 +186,7 @@ void DeviceListing::deviceAddedSlot(const QString udi)
void DeviceListing::deviceRemovedSlot(const QString udi)
{
const QTreeWidgetItem *item = getTreeWidgetItemFromUdi(this,udi);
if(item == NULL) return;
if(item == nullptr) return;
delete item;
}
......
......@@ -66,7 +66,7 @@ void InfoPanel::setDefaultText()
lay->addWidget(defaultText,0,Qt::AlignHCenter);
}
void InfoPanel::setTopWidgetLayout(const bool &isInit)
void InfoPanel::setTopWidgetLayout(bool isInit)
{
if(!isInit) delete top;
top = new QWidget(this);
......@@ -76,7 +76,7 @@ void InfoPanel::setTopWidgetLayout(const bool &isInit)
top->setLayout(setAlignedLayout(top));
}
QVBoxLayout *InfoPanel::setAlignedLayout(QWidget *parent, const int &spacingHeight)
QVBoxLayout *InfoPanel::setAlignedLayout(QWidget *parent, int spacingHeight)
{
QVBoxLayout *lay = new QVBoxLayout(parent);
lay->insertSpacing(0,spacingHeight);
......@@ -85,7 +85,7 @@ QVBoxLayout *InfoPanel::setAlignedLayout(QWidget *parent, const int &spacingHeig
return lay;
}
void InfoPanel::setBottomWidgetLayout(QVListLayout *lay, const bool &isInit)
void InfoPanel::setBottomWidgetLayout(QVListLayout *lay, bool isInit)
{
if(!isInit) delete bottom;
......@@ -136,7 +136,7 @@ QString InfoPanel::friendlyString(const QString &input, const QString &blankName
return input;
}
QString InfoPanel::convertTf(const bool &b)
QString InfoPanel::convertTf(bool b)
{
if(b) return i18n("Yes");
return i18n("No");
......
......@@ -54,17 +54,17 @@ class InfoPanel : public QGroupBox
void setTopInfo(const QIcon &, Solid::Device *);
void setBottomInfo(QVListLayout *lay);
static QString friendlyString(const QString &, const QString & = i18nc("name of something is not known", "Unknown"));
static QString convertTf(const bool &);
static QString convertTf(bool );
private:
void setTopWidgetLayout(const bool & = false);
void setBottomWidgetLayout(QVListLayout *, const bool & = false);
void setTopWidgetLayout(bool = false);
void setBottomWidgetLayout(QVListLayout *, bool = false);
void setInfoPanelLayout();
void removeItems(QWidget *);
void setDefaultText();
QLabel *setDevicesIcon(const QIcon &);
QVBoxLayout *setAlignedLayout(QWidget *parent, const int & = 0);
QVBoxLayout *setAlignedLayout(QWidget *parent, int = 0);
QWidget *top;
QWidget *bottom;
......
......@@ -103,6 +103,7 @@ void StatisticsProvider::componentComplete()
QVariantList StatisticsProvider::asPoints() const
{
QVariantList points;
points.reserve(m_values.count());
foreach (const HistoryReply &h, m_values) {
points.append(QPointF(h.time, h.value));
}
......
......@@ -48,7 +48,7 @@ USBDevice::~USBDevice() {
}
static QString catFile(QString fname) {
static QString catFile(const QString &fname) {
char buffer[256];
QString result;
int fd =:: open(QFile::encodeName(fname), O_RDONLY);
......
......@@ -37,18 +37,12 @@
class ToolTipManager::Private
{
public:
Private() :
view(0),
timer(0),
delay(50)
{ }
KToolTipWidget *tooltip;
QAbstractItemView* view;
QTimer* timer;
KToolTipWidget *tooltip = nullptr;
QAbstractItemView* view = nullptr;
QTimer* timer = nullptr;
QModelIndex item;
QRect itemRect;
int delay;
int delay = 50;
};
ToolTipManager::ToolTipManager(QAbstractItemView* parent)
......
......@@ -103,7 +103,7 @@ KInfoCenter::~KInfoCenter()
disconnect(m_searchAction, SIGNAL(triggered()),m_searchText, SLOT(setFocus()));
//Buttons
disconnect(m_moduleHelpAction, &QAction::triggered,this,&KInfoCenter::helpClickedSlot);
disconnect(m_moduleHelpAction, &QAction::triggered, this, &KInfoCenter::helpClickedSlot);
//Menu
disconnect(m_aboutKcm, &QAction::triggered, this, &KInfoCenter::aboutKcmSlot);
......@@ -229,7 +229,7 @@ void KInfoCenter::helpClickedSlot()
// Nicked from Ben, could not use KToolInvocation due to docpath.
QString docPath = m_contain->helpPath();
QUrl url("help:/" + docPath );
QUrl url(QStringLiteral("help:/") + docPath );
QProcess::startDetached(QStringLiteral("khelpcenter"), QStringList() << url.url());
}
......
......@@ -29,7 +29,9 @@
#include <QDebug>
#include <KLocalizedString>
InfoKcmModel::InfoKcmModel(QObject *parent) : QAbstractItemModel(parent), m_root(new KcmCategoryItem(i18n("Information Modules")))
InfoKcmModel::InfoKcmModel(QObject *parent)
: QAbstractItemModel(parent),
m_root(new KcmCategoryItem(i18n("Information Modules")))
{
createTreeItems();
}
......@@ -41,7 +43,7 @@ InfoKcmModel::~InfoKcmModel()
void InfoKcmModel::createTreeItems()
{
KService::List categoryList = KServiceTypeTrader::self()->query(QStringLiteral("KInfoCenterCategory"));
const KService::List categoryList = KServiceTypeTrader::self()->query(QStringLiteral("KInfoCenterCategory"));
foreach(const KService::Ptr &categoryModule, categoryList) {
m_root->addChild(new KcmCategoryItem(categoryModule,m_root));
......
......@@ -22,7 +22,7 @@
#include "kcmcategoryitem.h"
KcmCategoryItem::KcmCategoryItem(const KService::Ptr module, KcmTreeItem *parent) :
KcmCategoryItem::KcmCategoryItem(const KService::Ptr &module, KcmTreeItem *parent) :
KcmTreeItem(module, parent)
{
}
......
......@@ -39,7 +39,7 @@ class KcmCategoryItem : public KcmTreeItem
* @param module pointer to KCM module
* @param parent objects parent
*/
explicit KcmCategoryItem(const KService::Ptr module, KcmTreeItem *parent=0);
explicit KcmCategoryItem(const KService::Ptr &module, KcmTreeItem *parent=nullptr);
/**
* Category Tree Item for InfoKcmModel. Holds information about a Category
......
......@@ -29,8 +29,8 @@
#include <QVBoxLayout>
#include <QStyle>
KcmContainer::KcmContainer(QWidget *parent) : QScrollArea(parent), m_titleLabel(NULL),
m_centerWidget(NULL), m_mod(NULL), m_kcmTopEdge(-1)
KcmContainer::KcmContainer(QWidget *parent) : QScrollArea(parent), m_titleLabel(nullptr),
m_centerWidget(nullptr), m_mod(nullptr), m_kcmTopEdge(-1)
{
setWidgetResizable( true );
setFrameStyle( QFrame::NoFrame );
......@@ -51,7 +51,7 @@ void KcmContainer::setContainerLayout()
return;
}
m_mod = NULL; // will be deleted on the line below
m_mod = nullptr; // will be deleted on the line below
delete m_centerWidget;
m_centerWidget = new QWidget(this);
m_centerWidget->setContentsMargins(0,0,0,0);
......@@ -107,7 +107,7 @@ void KcmContainer::setKcmTitle(const KCModuleInfo &info)
QString KcmContainer::helpPath() const
{
if(m_mod == NULL) {
if(m_mod == nullptr) {
return QString();
}
return m_modInfo.docPath();
......
......@@ -28,7 +28,7 @@ KcmTreeItem::KcmTreeItem(const KService::Ptr module, KcmTreeItem *parent) : m_pa
{
}
KcmTreeItem::KcmTreeItem() : m_parent(NULL), m_moduleInfo(new KCModuleInfo())
KcmTreeItem::KcmTreeItem() : m_parent(nullptr), m_moduleInfo(new KCModuleInfo())
{
}
......
......@@ -41,7 +41,7 @@ KicApp::KicApp(int &argc, char **argv)
const auto displayName = i18n("Info Center");
KAboutData aboutData( QStringLiteral("kinfocenter"), displayName,
PROJECT_VERSION, displayName, KAboutLicense::GPL,
i18n("Copyright 2009-2016 KDE"));
i18n("Copyright 2009-2017 KDE"));
aboutData.addAuthor(i18n("David Hubner"),i18n("Current Maintainer"), QStringLiteral("hubnerd@ntlworld.com"));
aboutData.addAuthor(i18n("Helge Deller"), i18n("Previous Maintainer"), QStringLiteral("deller@kde.org"));
......@@ -63,7 +63,7 @@ KicApp::KicApp(int &argc, char **argv)
display = new KInfoCenter();
display->show();
KDBusService* service = new KDBusService(KDBusService::Unique, this);
(void)new KDBusService(KDBusService::Unique, this);
}
int main(int argc, char *argv[])
......
......@@ -31,7 +31,8 @@
#include <QRegExp>
#include <QMenu>
SidePanel::SidePanel(QWidget *parent) : QTreeView(parent)
SidePanel::SidePanel(QWidget *parent)
: QTreeView(parent)
{
setHeaderHidden(true);
setSortingEnabled(true);
......
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