Commit 652ed8f6 authored by Laurent Montel's avatar Laurent Montel 😁
Browse files

Modernize code

parent bb75452c
Pipeline #40762 canceled with stage
......@@ -26,7 +26,7 @@ bool LineEditCatchReturnKey::eventFilter(QObject *obj, QEvent *event)
{
if (obj == mLineEdit) {
if (event->type() == QEvent::KeyPress) {
QKeyEvent *e = static_cast<QKeyEvent *>(event);
auto *e = static_cast<QKeyEvent *>(event);
if (e->key() == Qt::Key_Return || e->key() == Qt::Key_Enter) {
const bool stopEvent = (e->modifiers() == Qt::NoButton ||
e->modifiers() == Qt::KeypadModifier);
......
......@@ -26,7 +26,7 @@ namespace KPIM {
class KDEPIM_EXPORT MultiplyingLineData
{
public:
typedef QSharedPointer<MultiplyingLineData> Ptr;
using Ptr = QSharedPointer<MultiplyingLineData>;
virtual ~MultiplyingLineData()
{
}
......
......@@ -227,7 +227,7 @@ void MultiplyingLineView::resizeEvent(QResizeEvent *ev)
QSize MultiplyingLineView::sizeHint() const
{
if (mDynamicSizeHint) {
return QSize(200, mLineHeight * mLines.count());
return {200, mLineHeight * mLines.count()};
} else {
return QScrollArea::sizeHint();
}
......@@ -243,7 +243,7 @@ QSize MultiplyingLineView::minimumSizeHint() const
} else {
height = mLineHeight * numLines;
}
return QSize(200, height);
return {200, height};
} else {
return QScrollArea::minimumSizeHint();
}
......
......@@ -22,11 +22,11 @@ void ProgressStatusBarWidgetTest::shouldHaveDefaultValue()
KPIM::ProgressStatusBarWidget w(widget, widget);
widget->show();
KPIM::ProgressDialog *progressDialog = widget->findChild<KPIM::ProgressDialog *>(QStringLiteral("progressDialog"));
auto *progressDialog = widget->findChild<KPIM::ProgressDialog *>(QStringLiteral("progressDialog"));
QVERIFY(progressDialog);
QVERIFY(progressDialog->isHidden());
KPIM::StatusbarProgressWidget *mLittleProgress = widget->findChild<KPIM::StatusbarProgressWidget *>(QStringLiteral("littleprogress"));
auto *mLittleProgress = widget->findChild<KPIM::StatusbarProgressWidget *>(QStringLiteral("littleprogress"));
QVERIFY(mLittleProgress);
QVERIFY(mLittleProgress->isVisible());
......
......@@ -26,27 +26,27 @@ StatusbarProgressWidgetTest::StatusbarProgressWidgetTest(QObject *parent)
void StatusbarProgressWidgetTest::shouldHaveDefaultValue()
{
QWidget *widget = new QWidget;
KPIM::ProgressDialog *progress = new KPIM::ProgressDialog(widget, widget);
auto *progress = new KPIM::ProgressDialog(widget, widget);
KPIM::StatusbarProgressWidget w(progress, widget);
QHBoxLayout *boxLayout = w.findChild<QHBoxLayout *>(QStringLiteral("boxLayout"));
auto *boxLayout = w.findChild<QHBoxLayout *>(QStringLiteral("boxLayout"));
QVERIFY(boxLayout);
QCOMPARE(boxLayout->contentsMargins(), QMargins(0, 0, 0, 0));
QCOMPARE(boxLayout->spacing(), 0);
QPushButton *mButton = w.findChild<QPushButton *>(QStringLiteral("button"));
auto *mButton = w.findChild<QPushButton *>(QStringLiteral("button"));
QVERIFY(mButton);
QVERIFY(mButton->text().isEmpty());
QStackedWidget *mStackedWidget = w.findChild<QStackedWidget *>(QStringLiteral("stackedwidget"));
auto *mStackedWidget = w.findChild<QStackedWidget *>(QStringLiteral("stackedwidget"));
QVERIFY(mStackedWidget);
KPIM::SSLLabel *mSslLabel = w.findChild<KPIM::SSLLabel *>(QStringLiteral("ssllabel"));
auto *mSslLabel = w.findChild<KPIM::SSLLabel *>(QStringLiteral("ssllabel"));
QVERIFY(mSslLabel);
QProgressBar *mProgressBar = w.findChild<QProgressBar *>(QStringLiteral("progressbar"));
auto *mProgressBar = w.findChild<QProgressBar *>(QStringLiteral("progressbar"));
QVERIFY(mProgressBar);
QLabel *mLabel = w.findChild<QLabel *>(QStringLiteral("emptylabel"));
auto *mLabel = w.findChild<QLabel *>(QStringLiteral("emptylabel"));
QVERIFY(mLabel);
}
......
......@@ -117,7 +117,7 @@ TransactionItemView::TransactionItemView(QWidget *parent, const QString &name)
setObjectName(name);
setFrameStyle(NoFrame);
mBigBox = new QWidget(this);
QVBoxLayout *mBigBoxVBoxLayout = new QVBoxLayout(mBigBox);
auto *mBigBoxVBoxLayout = new QVBoxLayout(mBigBox);
mBigBoxVBoxLayout->setContentsMargins(0, 0, 0, 0);
setWidget(mBigBox);
setWidgetResizable(true);
......@@ -126,7 +126,7 @@ TransactionItemView::TransactionItemView(QWidget *parent, const QString &name)
TransactionItem *TransactionItemView::addTransactionItem(ProgressItem *item, bool first)
{
TransactionItem *ti = new TransactionItem(mBigBox, item, first);
auto *ti = new TransactionItem(mBigBox, item, first);
mBigBox->layout()->addWidget(ti);
resize(mBigBox->width(), mBigBox->height());
......@@ -185,7 +185,7 @@ void TransactionItemView::slotLayoutFirstItem()
be the first item very shortly. That's the one we want to remove the
hline for.
*/
TransactionItem *ti = mBigBox->findChild<KPIM::TransactionItem *>(QStringLiteral("TransactionItem"));
auto *ti = mBigBox->findChild<KPIM::TransactionItem *>(QStringLiteral("TransactionItem"));
if (ti) {
ti->hideHLine();
}
......@@ -197,7 +197,7 @@ TransactionItem::TransactionItem(QWidget *parent, ProgressItem *item, bool first
: QWidget(parent)
, mItem(item)
{
QVBoxLayout *vboxLayout = new QVBoxLayout(this);
auto *vboxLayout = new QVBoxLayout(this);
vboxLayout->setSpacing(2);
vboxLayout->setContentsMargins(2, 2, 2, 2);
setSizePolicy(QSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed));
......@@ -209,7 +209,7 @@ TransactionItem::TransactionItem(QWidget *parent, ProgressItem *item, bool first
layout()->addWidget(mFrame);
QWidget *h = new QWidget(this);
QHBoxLayout *hHBoxLayout = new QHBoxLayout(h);
auto *hHBoxLayout = new QHBoxLayout(h);
hHBoxLayout->setContentsMargins(0, 0, 0, 0);
hHBoxLayout->setSpacing(5);
layout()->addWidget(h);
......
......@@ -23,7 +23,7 @@ ProgressStatusBarWidget::ProgressStatusBarWidget(QWidget *alignWidget, QWidget *
: QObject(parent)
, d(new KPIM::ProgressStatusBarWidgetPrivate)
{
KPIM::ProgressDialog *progressDialog = new KPIM::ProgressDialog(alignWidget, parent);
auto *progressDialog = new KPIM::ProgressDialog(alignWidget, parent);
progressDialog->setObjectName(QStringLiteral("progressDialog"));
progressDialog->setShowTypeProgressItem(showTypeProgressItem);
progressDialog->hide();
......
......@@ -39,7 +39,7 @@ StatusbarProgressWidget::StatusbarProgressWidget(ProgressDialog *progressDialog,
, mProgressDialog(progressDialog)
{
int w = fontMetrics().boundingRect(QStringLiteral(" 999.9 kB/s 00:00:01 ")).width() + 8;
QHBoxLayout *boxLayout = new QHBoxLayout(this);
auto *boxLayout = new QHBoxLayout(this);
boxLayout->setObjectName(QStringLiteral("boxLayout"));
boxLayout->setContentsMargins(0, 0, 0, 0);
boxLayout->setSpacing(0);
......@@ -256,7 +256,7 @@ void StatusbarProgressWidget::slotClean()
bool StatusbarProgressWidget::eventFilter(QObject *obj, QEvent *ev)
{
if (ev->type() == QEvent::MouseButtonPress) {
QMouseEvent *e = static_cast<QMouseEvent *>(ev);
auto *e = static_cast<QMouseEvent *>(ev);
if (e->button() == Qt::LeftButton && mMode == Progress) { // toggle view on left mouse button
// Consensus seems to be that we should show/hide the fancy dialog when the user
......
......@@ -23,7 +23,7 @@ int main(int argc, char **argv)
parser.addVersionOption();
parser.addHelpOption();
parser.process(app);
StatusbarProgressWidget_Gui *w = new StatusbarProgressWidget_Gui;
auto *w = new StatusbarProgressWidget_Gui;
w->resize(800, 600);
w->show();
app.exec();
......
......@@ -21,7 +21,7 @@ int main(int argc, char *argv[])
parser.addHelpOption();
parser.process(app);
KPIM::KCheckComboBox *combo = new KPIM::KCheckComboBox(nullptr);
auto *combo = new KPIM::KCheckComboBox(nullptr);
combo->addItems(QStringList() << QStringLiteral("KDE") << QStringLiteral("Mac OSX") << QStringLiteral("Windows") << QStringLiteral("XFCE") << QStringLiteral("FVWM") << QStringLiteral("TWM"));
combo->setCheckedItems(QStringList() << QStringLiteral("KDE") << QStringLiteral("Mac OSX") << QStringLiteral("Windows"));
combo->resize(400, 20);
......
......@@ -50,7 +50,7 @@ private:
void KCheckComboBox::Private::makeInsertedItemsCheckable(const QModelIndex &parent, int start, int end)
{
Q_UNUSED(parent);
QStandardItemModel *model = qobject_cast<QStandardItemModel *>(q->model());
auto *model = qobject_cast<QStandardItemModel *>(q->model());
if (model) {
for (int r = start; r <= end; ++r) {
QStandardItem *item = model->item(r, 0);
......@@ -106,7 +106,7 @@ void KCheckComboBox::Private::toggleCheckState()
const QModelIndex index = q->view()->currentIndex();
QVariant value = index.data(Qt::CheckStateRole);
if (value.isValid()) {
Qt::CheckState state = static_cast<Qt::CheckState>(value.toInt());
auto state = static_cast<Qt::CheckState>(value.toInt());
q->model()->setData(index, state == Qt::Unchecked ? Qt::Checked : Qt::Unchecked,
Qt::CheckStateRole);
}
......@@ -229,7 +229,7 @@ bool KCheckComboBox::itemEnabled(int index)
{
Q_ASSERT(index >= 0 && index <= count());
QStandardItemModel *itemModel = qobject_cast<QStandardItemModel *>(model());
auto *itemModel = qobject_cast<QStandardItemModel *>(model());
Q_ASSERT(itemModel);
QStandardItem *item = itemModel->item(index, 0);
......@@ -240,7 +240,7 @@ void KCheckComboBox::setItemEnabled(int index, bool enabled)
{
Q_ASSERT(index >= 0 && index <= count());
QStandardItemModel *itemModel = qobject_cast<QStandardItemModel *>(model());
auto *itemModel = qobject_cast<QStandardItemModel *>(model());
Q_ASSERT(itemModel);
QStandardItem *item = itemModel->item(index, 0);
......
......@@ -84,7 +84,7 @@ void KWidgetLister::init(bool fewerMoreButton)
d->mLayout->setSpacing(4);
d->mButtonBox = new QWidget(this);
QHBoxLayout *mButtonBoxHBoxLayout = new QHBoxLayout(d->mButtonBox);
auto *mButtonBoxHBoxLayout = new QHBoxLayout(d->mButtonBox);
mButtonBoxHBoxLayout->setContentsMargins(0, 0, 0, 0);
d->mLayout->addWidget(d->mButtonBox);
......
......@@ -18,7 +18,7 @@ public:
: labelStr(_label)
, q(qq)
{
QHBoxLayout *lay = new QHBoxLayout(q);
auto *lay = new QHBoxLayout(q);
lay->setContentsMargins(0, 0, 0, 0);
indicator = new KBusyIndicatorWidget;
lay->addWidget(indicator);
......
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