Commit 8ab0514d authored by Harald Sitter's avatar Harald Sitter 🏳🌈
Browse files

various stylistic improvements

- use override instead of virtual; it implies virtual
- use =default where possible
- reduce slot lambda signatures to only used arguments
- getUsersList is now static - it uses no members
- reboot is now static - it uses no member
- use auto when the right hand side of an assignment shows the type
- make sure pointer members are init'd to nullptr lest we forget to
declare them in the ctor
parent 01a6bda3
......@@ -38,7 +38,7 @@ QWidget *UserPermissionDelegate::createEditor(QWidget *parent,
return nullptr;
}
QComboBox *comboBox = new QComboBox(parent);
auto comboBox = new QComboBox(parent);
comboBox->addItem(i18n("---"));
comboBox->addItem(i18n("Full Control"), QLatin1String("F"));
comboBox->addItem(i18n("Read Only"), QLatin1String("R"));
......@@ -50,7 +50,7 @@ QWidget *UserPermissionDelegate::createEditor(QWidget *parent,
void UserPermissionDelegate::setEditorData(QWidget *editor,
const QModelIndex &index) const
{
QComboBox *comboBox = qobject_cast<QComboBox *>(editor);
auto comboBox = qobject_cast<QComboBox *>(editor);
if (!comboBox || (index.column() != UserPermissionModel::ColumnAccess)) {
return;
}
......@@ -66,7 +66,7 @@ void UserPermissionDelegate::setEditorData(QWidget *editor,
void UserPermissionDelegate::setModelData(QWidget *editor, QAbstractItemModel *model,
const QModelIndex &index) const
{
QComboBox *comboBox = qobject_cast<QComboBox *>(editor);
auto comboBox = qobject_cast<QComboBox *>(editor);
if (!comboBox || (index.column() != UserPermissionModel::ColumnAccess)) {
return;
}
......
......@@ -24,7 +24,6 @@
#include <QItemDelegate>
class UserPermissionDelegate : public QItemDelegate
{
Q_OBJECT
......
......@@ -56,7 +56,7 @@ void UserPermissionModel::setupData()
}
}
QStringList UserPermissionModel::getUsersList() const
QStringList UserPermissionModel::getUsersList()
{
uid_t defminuid = 1000;
uid_t defmaxuid = 65000;
......
......@@ -55,7 +55,7 @@ private:
QVariantMap m_usersAcl;
void setupData();
QStringList getUsersList() const;
static QStringList getUsersList();
};
#endif
......@@ -67,14 +67,14 @@ SambaUserSharePlugin::SambaUserSharePlugin(QObject *parent, const QList<QVariant
return;
}
QFrame *vbox = new QFrame();
auto vbox = new QFrame();
properties->addPage(vbox, i18n("&Share"));
properties->setFileSharingPage(vbox);
QVBoxLayout *vLayoutMaster = new QVBoxLayout(vbox);
auto vLayoutMaster = new QVBoxLayout(vbox);
m_failedSambaWidgets = new QWidget(vbox);
vLayoutMaster->addWidget(m_failedSambaWidgets);
QVBoxLayout *vFailedLayout = new QVBoxLayout(m_failedSambaWidgets);
auto vFailedLayout = new QVBoxLayout(m_failedSambaWidgets);
vFailedLayout->setAlignment(Qt::AlignJustify);
vFailedLayout->setContentsMargins(0, 0, 0, 0);
vFailedLayout->addWidget(new QLabel(i18n("The Samba package failed to install."), m_failedSambaWidgets));
......@@ -83,7 +83,7 @@ SambaUserSharePlugin::SambaUserSharePlugin(QObject *parent, const QList<QVariant
m_installSambaWidgets = new QWidget(vbox);
vLayoutMaster->addWidget(m_installSambaWidgets);
QVBoxLayout *vLayout = new QVBoxLayout(m_installSambaWidgets);
auto vLayout = new QVBoxLayout(m_installSambaWidgets);
vLayout->setAlignment(Qt::AlignJustify);
vLayout->setContentsMargins(0, 0, 0, 0);
......@@ -94,7 +94,7 @@ SambaUserSharePlugin::SambaUserSharePlugin(QObject *parent, const QList<QVariant
#ifdef SAMBA_INSTALL
m_justInstalledSambaWidgets = new QWidget(vbox);
vLayoutMaster->addWidget(m_justInstalledSambaWidgets);
QVBoxLayout *vJustInstalledLayout = new QVBoxLayout(m_justInstalledSambaWidgets);
auto vJustInstalledLayout = new QVBoxLayout(m_justInstalledSambaWidgets);
vJustInstalledLayout->setAlignment(Qt::AlignJustify);
vJustInstalledLayout->addWidget(new QLabel(i18n("Restart the computer to complete the installation."), m_justInstalledSambaWidgets));
m_restartButton = new QPushButton(i18n("Restart"), m_justInstalledSambaWidgets);
......@@ -137,7 +137,7 @@ SambaUserSharePlugin::SambaUserSharePlugin(QObject *parent, const QList<QVariant
connect(propertiesUi.sambaNameEdit, &QLineEdit::textChanged,
this, &SambaUserSharePlugin::checkShareName);
connect(propertiesUi.sambaAllowGuestChk, &QCheckBox::toggled,
this, [=] (bool checked) { setDirty(); });
this, [=] { setDirty(); });
connect(model, &UserPermissionModel::dataChanged,
this, [=] { setDirty(); });
connect(propertiesUi.sambaStatusMonitorButton, &QPushButton::clicked,
......@@ -157,10 +157,6 @@ SambaUserSharePlugin::SambaUserSharePlugin(QObject *parent, const QList<QVariant
}
}
SambaUserSharePlugin::~SambaUserSharePlugin()
{
}
#ifdef SAMBA_INSTALL
void SambaUserSharePlugin::installSamba()
{
......
......@@ -47,23 +47,23 @@ class SambaUserSharePlugin : public KPropertiesDialogPlugin
public:
SambaUserSharePlugin(QObject *parent, const QList<QVariant> &args);
virtual ~SambaUserSharePlugin();
~SambaUserSharePlugin() override = default;
void applyChanges() override;
private:
QString m_url;
KSambaShareData shareData;
UserPermissionModel *model;
UserPermissionModel *model = nullptr;
Ui::PropertiesPageGUI propertiesUi;
QWidget *m_failedSambaWidgets;
QWidget *m_installSambaWidgets;
QWidget *m_shareWidgets;
QLabel *m_sambaStatusMessage;
QProgressBar *m_installProgress;
QPushButton *m_installSambaButton;
QWidget *m_failedSambaWidgets = nullptr;
QWidget *m_installSambaWidgets = nullptr;
QWidget *m_shareWidgets = nullptr;
QLabel *m_sambaStatusMessage = nullptr;
QProgressBar *m_installProgress = nullptr;
QPushButton *m_installSambaButton = nullptr;
#ifdef SAMBA_INSTALL
QWidget *m_justInstalledSambaWidgets;
QPushButton *m_restartButton;
QWidget *m_justInstalledSambaWidgets = nullptr;
QPushButton *m_restartButton = nullptr;
#endif // SAMBA_INSTALL
void setupModel();
......@@ -77,10 +77,8 @@ private:
#ifdef SAMBA_INSTALL
void installSamba();
void packageFinished(PackageKit::Transaction::Exit status, uint runtime);
void reboot();
static void reboot();
#endif // SAMBA_INSTALL
};
#endif // SAMBAUSERSHAREPLUGIN_H
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