Members of the KDE Community are recommended to subscribe to the kde-community mailing list at https://mail.kde.org/mailman/listinfo/kde-community to allow them to participate in important discussions and receive other important announcements

Commit 7d68c1d6 authored by Daniel Nicoletti's avatar Daniel Nicoletti

Make use of C++11 auto

parent 13c6bc65
/***************************************************************************
* Copyright (C) 2010 by Daniel Nicoletti *
* Copyright (C) 2010-2018 by Daniel Nicoletti *
* dantti12@gmail.com *
* *
* This program is free software; you can redistribute it and/or modify *
......@@ -41,14 +41,14 @@ AddPrinter::~AddPrinter()
void AddPrinter::addPrinter(qulonglong wid)
{
AddPrinterAssistant *wizard = new AddPrinterAssistant();
auto wizard = new AddPrinterAssistant();
wizard->initAddPrinter();
show(wizard, wid);
}
void AddPrinter::addClass(qulonglong wid)
{
AddPrinterAssistant *wizard = new AddPrinterAssistant();
auto wizard = new AddPrinterAssistant();
wizard->initAddClass();
show(wizard, wid);
}
......@@ -69,7 +69,7 @@ void AddPrinter::changePPD(qulonglong wid, const QString &name)
if (printer.type() & CUPS_PRINTER_REMOTE) {
qWarning() << "Ignoring request, can not change PPD of remote printer" << name;
} else {
AddPrinterAssistant *wizard = new AddPrinterAssistant();
auto wizard = new AddPrinterAssistant();
wizard->initChangePPD(name, printer.deviceUri(), printer.makeAndModel());
show(wizard, wid);
}
......@@ -99,7 +99,7 @@ void AddPrinter::newPrinterFromDevice(qulonglong wid, const QString &name, const
// printer = "HP PSC 1400 series";
// deviceId = "MFG:HP;MDL:PSC 1400 series;DES:;CMD:LDL,MLC,PML,DYN;";
AddPrinterAssistant *wizard = new AddPrinterAssistant();
auto wizard = new AddPrinterAssistant();
wizard->initAddPrinter(name, device_id);
show(wizard, wid);
}
......
......@@ -145,8 +145,7 @@ void AddPrinterAssistant::initChangePPD(const QString &printer, const QString &d
void AddPrinterAssistant::back()
{
KAssistantDialog::back();
GenericPage *currPage;
currPage = qobject_cast<GenericPage*>(currentPage()->widget());
auto currPage = qobject_cast<GenericPage*>(currentPage()->widget());
enableNextButton(currPage->canProceed());
if (!qobject_cast<GenericPage*>(currentPage()->widget())->isValid()) {
back();
......@@ -181,8 +180,8 @@ void AddPrinterAssistant::setCurrentPage(KPageWidgetItem *page)
// it up, if not call next with it so we can find the next page
if (qobject_cast<GenericPage*>(page->widget())->isValid()) {
KAssistantDialog::setCurrentPage(page);
GenericPage *currPage = qobject_cast<GenericPage*>(currentPage()->widget());
GenericPage *nextPage = qobject_cast<GenericPage*>(page->widget());
auto currPage = qobject_cast<GenericPage*>(currentPage()->widget());
auto nextPage = qobject_cast<GenericPage*>(page->widget());
// Disconnect the current page slots
disconnect(currPage, &GenericPage::allowProceed, this, &AddPrinterAssistant::enableNextButton);
disconnect(currPage, &GenericPage::allowProceed, this, &AddPrinterAssistant::enableFinishButton);
......@@ -226,7 +225,7 @@ void AddPrinterAssistant::showEvent(QShowEvent *event)
void AddPrinterAssistant::slotFinishButtonClicked()
{
GenericPage *page = qobject_cast<GenericPage*>(currentPage()->widget());
auto page = qobject_cast<GenericPage*>(currentPage()->widget());
enableFinishButton(false);
if (page->finishClicked()) {
//KAssistantDialog::slotButtonClicked(button); // FIXME next() really?
......
/***************************************************************************
* Copyright (C) 2010 by Daniel Nicoletti *
* Copyright (C) 2010-2018 by Daniel Nicoletti *
* dantti12@gmail.com *
* *
* This program is free software; you can redistribute it and/or modify *
......@@ -115,8 +115,8 @@ void ChooseUri::findPrinters()
{
QUrl url = parsedURL(ui->addressLE->text());
KCupsConnection *conn = new KCupsConnection(url, this);
KCupsRequest *request = new KCupsRequest(conn);
auto conn = new KCupsConnection(url, this);
auto request = new KCupsRequest(conn);
connect(request, &KCupsRequest::finished, this, &ChooseUri::getPrintersFinished);
QStringList attr;
......@@ -136,7 +136,7 @@ void ChooseUri::findPrinters()
void ChooseUri::getPrintersFinished()
{
KCupsRequest *request = qobject_cast<KCupsRequest*>(sender());
auto request = qobject_cast<KCupsRequest*>(sender());
QUrl uri = request->property("URI").value<QUrl>();
QUrl url;
url.setScheme(QStringLiteral("ipp"));
......
/***************************************************************************
* Copyright (C) 2010 by Daniel Nicoletti *
* Copyright (C) 2010-2018 by Daniel Nicoletti *
* dantti12@gmail.com *
* *
* This program is free software; you can redistribute it and/or modify *
......@@ -275,7 +275,7 @@ QStandardItem *DevicesModel::createItem(const QString &device_class,
}
}
QStandardItem *stdItem = new QStandardItem;
auto stdItem = new QStandardItem;
stdItem->setText(text);
stdItem->setToolTip(toolTip);
stdItem->setData(device_class, DeviceClass);
......@@ -368,7 +368,7 @@ QStandardItem* DevicesModel::findCreateCategory(const QString &category)
}
}
QStandardItem *catItem = new QStandardItem(category);
auto catItem = new QStandardItem(category);
QFont font = catItem->font();
font.setBold(true);
catItem->setFont(font);
......
/***************************************************************************
* Copyright (C) 2010 by Daniel Nicoletti *
* Copyright (C) 2010-2018 by Daniel Nicoletti *
* dantti12@gmail.com *
* *
* This program is free software; you can redistribute it and/or modify *
......@@ -62,7 +62,7 @@ PageAddPrinter::PageAddPrinter(QWidget *parent) :
// May contain any printable characters except "/", "#", and space
QRegExp rx("[^/#\\ ]*");
QValidator *validator = new QRegExpValidator(rx, this);
auto validator = new QRegExpValidator(rx, this);
ui->nameLE->setValidator(validator);
// Hide the message widget
......
/***************************************************************************
* Copyright (C) 2010 by Daniel Nicoletti *
* Copyright (C) 2010-2018 by Daniel Nicoletti *
* dantti12@gmail.com *
* *
* This program is free software; you can redistribute it and/or modify *
......@@ -84,7 +84,7 @@ void PageChoosePPD::setValues(const QVariantHash &args)
// If
QUrl url(deviceURI % QStringLiteral(".ppd"));
if (url.scheme() == QStringLiteral("ipp")) {
QTemporaryFile *tempFile = new QTemporaryFile;
auto tempFile = new QTemporaryFile;
tempFile->setFileTemplate(QStringLiteral("print-manager-XXXXXX.ppd"));
tempFile->open();
url.setScheme(QStringLiteral("http"));
......@@ -189,7 +189,7 @@ void PageChoosePPD::selectDefault()
void PageChoosePPD::resultJob(KJob *job)
{
if (!job->error() && job->property("URI").toString() == m_args[KCUPS_DEVICE_URI].toString()) {
KIO::FileCopyJob *fileCopyJob = qobject_cast<KIO::FileCopyJob*>(job);
auto fileCopyJob = qobject_cast<KIO::FileCopyJob*>(job);
// Make sure this job is for the current device
m_ppdFile = fileCopyJob->destUrl().toLocalFile();
......
......@@ -136,7 +136,7 @@ bool PageDestinations::isValid() const
QVariantHash PageDestinations::values() const
{
QVariantHash ret = m_args;
GenericPage *page = qobject_cast<GenericPage*>(ui->stackedWidget->currentWidget());
auto page = qobject_cast<GenericPage*>(ui->stackedWidget->currentWidget());
if (page) {
ret = page->values();
} else if (canProceed()) {
......@@ -149,7 +149,7 @@ bool PageDestinations::canProceed() const
{
bool ret = ui->stackedWidget->currentIndex() != 0;
GenericPage *page = qobject_cast<GenericPage*>(ui->stackedWidget->currentWidget());
auto page = qobject_cast<GenericPage*>(ui->stackedWidget->currentWidget());
if (page) {
ret = page->canProceed();
}
......@@ -316,7 +316,7 @@ QVariantHash PageDestinations::selectedItemValues() const
void PageDestinations::setCurrentPage(QWidget *widget, const QVariantHash &args)
{
GenericPage *page = qobject_cast<GenericPage*>(widget);
auto page = qobject_cast<GenericPage*>(widget);
if (page) {
page->setValues(args);
if (ui->stackedWidget->currentWidget() != page) {;
......
......@@ -39,7 +39,7 @@ int main(int argc, char **argv)
PM_VERSION,
i18n("Tool for adding new printers"),
KAboutLicense::GPL,
i18n("(C) 2010-2013 Daniel Nicoletti"));
i18n("(C) 2010-2018 Daniel Nicoletti"));
about.addAuthor(i18n("Daniel Nicoletti"), QString(), "dantti12@gmail.com");
about.addAuthor(QStringLiteral("Lukáš Tinkl"), i18n("Port to Qt 5 / Plasma 5"), QStringLiteral("ltinkl@redhat.com"));
......
......@@ -56,7 +56,7 @@ ConfigureDialog::ConfigureDialog(const QString &destName, bool isClass, QWidget
KPageWidgetItem *page;
modifyPrinter = new ModifyPrinter(destName, isClass, this);
PrinterBehavior *printerBehavior = new PrinterBehavior(destName, isClass, this);
auto printerBehavior = new PrinterBehavior(destName, isClass, this);
attr << modifyPrinter->neededValues();
attr << printerBehavior->neededValues();
attr << KCUPS_PRINTER_TYPE; // needed to know if it's a remote printer
......@@ -150,8 +150,8 @@ ConfigureDialog::~ConfigureDialog()
void ConfigureDialog::currentPageChanged(KPageWidgetItem *current, KPageWidgetItem *before)
{
PrinterPage *currentPage = qobject_cast<PrinterPage*>(current->widget());
PrinterPage *beforePage = qobject_cast<PrinterPage*>(before->widget());
auto currentPage = qobject_cast<PrinterPage*>(current->widget());
auto beforePage = qobject_cast<PrinterPage*>(before->widget());
// Check if the before page has changes
savePage(beforePage);
......@@ -171,7 +171,7 @@ void ConfigureDialog::enableButtonApply(bool enable)
void ConfigureDialog::slotButtonClicked(QAbstractButton * pressedButton)
{
PrinterPage *page = qobject_cast<PrinterPage *>(currentPage()->widget());
auto page = qobject_cast<PrinterPage *>(currentPage()->widget());
if (pressedButton == button(QDialogButtonBox::Ok) ||
pressedButton == button(QDialogButtonBox::Apply)) {
page->save();
......@@ -180,7 +180,7 @@ void ConfigureDialog::slotButtonClicked(QAbstractButton * pressedButton)
void ConfigureDialog::closeEvent(QCloseEvent *event)
{
PrinterPage *page = qobject_cast<PrinterPage*>(currentPage()->widget());
auto page = qobject_cast<PrinterPage*>(currentPage()->widget());
if (savePage(page)) {
event->accept();
} else {
......
......@@ -86,7 +86,7 @@ void ConfigurePrinterInterface::ConfigurePrinter(const QString &destName)
request->deleteLater();
if (found) {
ConfigureDialog *ui = new ConfigureDialog(printer.name(), printer.isClass());
auto ui = new ConfigureDialog(printer.name(), printer.isClass());
connect(m_updateUi, &QTimer::timeout, ui, static_cast<void(ConfigureDialog::*)()>(&ConfigureDialog::update));
connect(ui, &ConfigureDialog::finished, this, &ConfigurePrinterInterface::RemovePrinter);
ui->show();
......@@ -112,7 +112,7 @@ void ConfigurePrinterInterface::ConfigurePrinter(const QString &destName)
void ConfigurePrinterInterface::RemovePrinter()
{
QWidget *ui = qobject_cast<QWidget*>(sender());
auto ui = qobject_cast<QWidget*>(sender());
if (ui) {
m_uis.remove(m_uis.key(ui));
}
......
......@@ -70,7 +70,7 @@ void ModifyPrinter::on_makeCB_activated(int index)
{
bool isDifferent = true;
if (ui->makeCB->itemData(index).toUInt() == PPDList) {
SelectMakeModelDialog * dialog = new SelectMakeModelDialog(m_make, m_makeAndModel, this);
auto dialog = new SelectMakeModelDialog(m_make, m_makeAndModel, this);
connect(dialog, &SelectMakeModelDialog::accepted, this, &ModifyPrinter::ppdSelectionAccepted);
connect(dialog, &SelectMakeModelDialog::rejected, this, &ModifyPrinter::ppdSelectionRejected);
dialog->show();
......@@ -100,8 +100,8 @@ void ModifyPrinter::on_makeCB_activated(int index)
void ModifyPrinter::ppdSelectionAccepted()
{
SelectMakeModelDialog *dialog = qobject_cast<SelectMakeModelDialog*>(sender());
SelectMakeModel *widget = qobject_cast<SelectMakeModel*>(dialog->mainWidget());
auto dialog = qobject_cast<SelectMakeModelDialog*>(sender());
auto widget = qobject_cast<SelectMakeModel*>(dialog->mainWidget());
if (widget->isFileSelected()) {
QString fileName = widget->selectedPPDFileName();
......@@ -124,7 +124,7 @@ void ModifyPrinter::ppdSelectionAccepted()
void ModifyPrinter::ppdSelectionRejected()
{
SelectMakeModelDialog *dialog = qobject_cast<SelectMakeModelDialog*>(sender());
auto dialog = qobject_cast<SelectMakeModelDialog*>(sender());
ui->makeCB->setCurrentIndex(ui->makeCB->property("lastIndex").toInt());
dialog->deleteLater();
}
......@@ -186,7 +186,7 @@ void ModifyPrinter::modelChanged()
void ModifyPrinter::textChanged(const QString &text)
{
QLineEdit *le = qobject_cast<QLineEdit *>(sender());
auto le = qobject_cast<QLineEdit *>(sender());
bool isDifferent = le->property("orig_text") != text;
if (isDifferent != le->property("different").toBool()) {
......
......@@ -171,7 +171,7 @@ void PrinterBehavior::userListChanged()
void PrinterBehavior::currentIndexChangedCB(int index)
{
QComboBox *comboBox = qobject_cast<QComboBox*>(sender());
auto comboBox = qobject_cast<QComboBox*>(sender());
bool isDifferent = comboBox->property("defaultChoice").toInt() != index;
if (isDifferent != comboBox->property("different").toBool()) {
......
......@@ -185,10 +185,10 @@ void PrinterOptions::createGroups()
QString text = m_codec->toUnicode(group->text);
// The group box were the options will be laid out
QGroupBox *groupBox = new QGroupBox(text, ui->scrollArea);
auto groupBox = new QGroupBox(text, ui->scrollArea);
// Create the form layout to put options in
QFormLayout *gFormLayout = new QFormLayout(groupBox);
auto gFormLayout = new QFormLayout(groupBox);
gFormLayout->setFormAlignment(Qt::AlignCenter);
groupBox->setLayout(gFormLayout);
ui->verticalLayout->addWidget(groupBox);
......@@ -239,9 +239,9 @@ void PrinterOptions::createGroups()
QWidget* PrinterOptions::pickBoolean(ppd_option_t *option, const QString &keyword, QWidget *parent) const
{
Q_UNUSED(keyword)
QWidget *widget = new QWidget(parent);
QHBoxLayout *layout = new QHBoxLayout(widget);
QButtonGroup *radioGroup = new QButtonGroup(widget);
auto widget = new QWidget(parent);
auto layout = new QHBoxLayout(widget);
auto radioGroup = new QButtonGroup(widget);
widget->setLayout(layout);
int i;
......@@ -254,7 +254,7 @@ QWidget* PrinterOptions::pickBoolean(ppd_option_t *option, const QString &keywor
QString choiceName = m_codec->toUnicode(choice->choice);
QString cText = m_codec->toUnicode(choice->text);
QRadioButton *button = new QRadioButton(cText, widget);
auto button = new QRadioButton(cText, widget);
button->setChecked(defChoice == choiceName);
button->setProperty("choice", choiceName);
// if we are in looking at a remote printer we can't save it
......@@ -302,8 +302,8 @@ void PrinterOptions::radioBtClicked(QAbstractButton *button)
QWidget* PrinterOptions::pickMany(ppd_option_t *option, const QString &keyword, QWidget *parent) const
{
Q_UNUSED(keyword)
QListView *listView = new QListView(parent);
QStandardItemModel *model = new QStandardItemModel(listView);
auto listView = new QListView(parent);
auto model = new QStandardItemModel(listView);
listView->setModel(model);
listView->setItemDelegate(new NoSelectionRectDelegate(listView));
......@@ -317,7 +317,7 @@ QWidget* PrinterOptions::pickMany(ppd_option_t *option, const QString &keyword,
QString cName = m_codec->toUnicode(choice->choice);
QString cText = m_codec->toUnicode(choice->text);
QStandardItem *item = new QStandardItem(cText);
auto item = new QStandardItem(cText);
item->setData(cName);
item->setCheckable(true);
item->setEditable(false);
......@@ -336,7 +336,7 @@ QWidget* PrinterOptions::pickOne(ppd_option_t *option, const QString &keyword, Q
int i;
ppd_choice_t *choice;
QString defChoice = m_codec->toUnicode(option->defchoice);
QComboBox *comboBox = new QComboBox(parent);
auto comboBox = new QComboBox(parent);
// Iterate over the choices in the option
for (i = 0, choice = option->choices;
i < option->num_choices;
......@@ -359,7 +359,7 @@ QWidget* PrinterOptions::pickOne(ppd_option_t *option, const QString &keyword, Q
void PrinterOptions::currentIndexChangedCB(int index)
{
QComboBox *comboBox = qobject_cast<QComboBox*>(sender());
auto comboBox = qobject_cast<QComboBox*>(sender());
bool isDifferent = comboBox->property(DEFAULT_CHOICE).toString() != comboBox->itemData(index);
if (isDifferent != comboBox->property("different").toBool()) {
......
/***************************************************************************
* Copyright (C) 2014 Lukáš Tinkl <ltinkl@redhat.com> *
* Copyright (C) 2018 by Daniel Nicoletti <dantti12@gmail.com> *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
......@@ -35,7 +36,7 @@ SelectMakeModelDialog::SelectMakeModelDialog(const QString &make, const QString
{
setWindowTitle(i18n("Select a Driver"));
QVBoxLayout * layout = new QVBoxLayout(this);
auto layout = new QVBoxLayout(this);
m_widget = new SelectMakeModel(this);
layout->addWidget(m_widget);
......@@ -50,14 +51,14 @@ SelectMakeModelDialog::SelectMakeModelDialog(const QString &make, const QString
m_bbox->button(QDialogButtonBox::Ok)->setEnabled(false);
// Configure the help button to be flat, disabled and empty
QPushButton *button = m_bbox->button(QDialogButtonBox::Help);
auto button = m_bbox->button(QDialogButtonBox::Help);
button->setFlat(true);
button->setEnabled(false);
button->setIcon(QIcon());
button->setText(QString());
// Setup the busy cursor
KPixmapSequenceOverlayPainter *busySeq = new KPixmapSequenceOverlayPainter(this);
auto busySeq = new KPixmapSequenceOverlayPainter(this);
busySeq->setSequence(KIconLoader::global()->loadPixmapSequence("process-working", KIconLoader::SizeSmallMedium));
busySeq->setAlignment(Qt::AlignHCenter | Qt::AlignBottom);
busySeq->setWidget(button);
......
/***************************************************************************
* Copyright (C) 2010-2012 by Daniel Nicoletti *
* Copyright (C) 2010-2018 by Daniel Nicoletti *
* dantti12@gmail.com *
* *
* This program is free software; you can redistribute it and/or modify *
......@@ -40,7 +40,7 @@ int main(int argc, char **argv)
PM_VERSION,
i18n("ConfigurePrinter"),
KAboutLicense::GPL,
i18n("(C) 2010-2013 Daniel Nicoletti"));
i18n("(C) 2010-2018 Daniel Nicoletti"));
aboutData.addAuthor(QStringLiteral("Daniel Nicoletti"), QString(), "dantti12@gmail.com");
aboutData.addAuthor(QStringLiteral("Jan Grulich"), i18n("Port to Qt 5 / Plasma 5"), QStringLiteral("jgrulich@redhat.com"));
......
/***************************************************************************
* Copyright (C) 2010 by Daniel Nicoletti *
* dantti12@gmail.com *
* Copyright (C) 2010-2018 by Daniel Nicoletti <dantti12@gmail.com> *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
......@@ -97,7 +96,7 @@ void ClassListWidget::loadFinished()
foreach (const KCupsPrinter &printer, printers) {
QString destName = printer.name();
if (destName != m_printerName) {
QStandardItem *item = new QStandardItem;
auto item = new QStandardItem;
item->setText(destName);
item->setCheckable(true);
item->setEditable(false);
......
/***************************************************************************
* Copyright (C) 2010-2018 by Daniel Nicoletti *
* dantti12@gmail.com *
* Copyright (C) 2010-2018 by Daniel Nicoletti <dantti12@gmail.com> *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
......@@ -182,7 +181,7 @@ void JobModel::getJobs()
void JobModel::getJobFinished()
{
KCupsRequest *request = static_cast<KCupsRequest *>(sender());
auto request = static_cast<KCupsRequest *>(sender());
if (request) {
if (request->hasError()) {
// clear the model after so that the proper widget can be shown
......@@ -291,7 +290,7 @@ void JobModel::insertJob(int pos, const KCupsJob &job)
// insert the first column which has the job state and id
QList<QStandardItem*> row;
ipp_jstate_e jobState = job.state();
QStandardItem *statusItem = new QStandardItem(jobStatus(jobState));
auto statusItem = new QStandardItem(jobStatus(jobState));
statusItem->setData(jobState, RoleJobState);
statusItem->setData(job.id(), RoleJobId);
statusItem->setData(job.name(), RoleJobName);
......@@ -448,7 +447,7 @@ Qt::DropActions JobModel::supportedDropActions() const
QMimeData* JobModel::mimeData(const QModelIndexList &indexes) const
{
QMimeData *mimeData = new QMimeData();
auto mimeData = new QMimeData();
QByteArray encodedData;
QDataStream stream(&encodedData, QIODevice::WriteOnly);
......@@ -537,7 +536,7 @@ KCupsRequest* JobModel::modifyJob(int row, JobAction action, const QString &newD
return 0;
}
KCupsRequest *request = new KCupsRequest;
auto request = new KCupsRequest;
switch (action) {
case Cancel:
request->cancelJob(destName, jobId);
......
......@@ -872,7 +872,7 @@ const char * password_cb(const char *prompt, http_t *http, const char *method, c
return NULL;
}
KCupsPasswordDialog *passwordDialog = static_cast<KCupsPasswordDialog *>(user_data);
auto passwordDialog = static_cast<KCupsPasswordDialog *>(user_data);
bool wrongPassword = password_retries > 1;
// This will block this thread until exec is not finished
......
......@@ -86,7 +86,7 @@ static void choose_device_cb(const char *device_class, /* I - Class */
/*
* Add the device to the array...
*/
KCupsRequest *request = static_cast<KCupsRequest*>(user_data);
auto request = static_cast<KCupsRequest*>(user_data);
QMetaObject::invokeMethod(request,
"device",
Qt::QueuedConnection,
......
/***************************************************************************
* Copyright (C) 2010-2012 by Daniel Nicoletti *
* dantti12@gmail.com *
* Copyright (C) 2010-2018 by Daniel Nicoletti <dantti12@gmail.com> *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
......@@ -74,7 +73,7 @@ QStandardItem* PPDModel::findCreateMake(const QString &make)
}
}
QStandardItem *makeItem = new QStandardItem(make);
auto makeItem = new QStandardItem(make);
appendRow(makeItem);
return makeItem;
}
......@@ -93,7 +92,7 @@ void PPDModel::clear()
QStandardItem *PPDModel::createPPDItem(const QVariantHash &ppd, bool recommended)
{
QStandardItem *ret = new QStandardItem;
auto ret = new QStandardItem;
QString make = ppd["ppd-make"].toString();
QString makeAndModel = ppd["ppd-make-and-model"].toString();
......
......@@ -116,7 +116,7 @@ PrinterModel::PrinterModel(QObject *parent) :
void PrinterModel::getDestsFinished()
{
KCupsRequest *request = qobject_cast<KCupsRequest *>(sender());
auto request = qobject_cast<KCupsRequest *>(sender());
// When there is no printer IPP_NOT_FOUND is returned
if (request->hasError() && request->error() != IPP_NOT_FOUND) {
// clear the model after so that the proper widget can be shown
......@@ -234,7 +234,7 @@ void PrinterModel::update()
{
// kcmshell(6331) PrinterModel::update: (QHash(("printer-type", QVariant(int, 75534348) ) ( "marker-names" , QVariant(QStringList, ("Cyan", "Yellow", "Magenta", "Black") ) ) ( "printer-name" , QVariant(QString, "EPSON_Stylus_TX105") ) ( "marker-colors" , QVariant(QStringList, ("#00ffff", "#ffff00", "#ff00ff", "#000000") ) ) ( "printer-location" , QVariant(QString, "Luiz Vitor’s MacBook Pro") ) ( "marker-levels" , QVariant(QList<int>, ) ) ( "marker-types" , QVariant(QStringList, ("inkCartridge", "inkCartridge", "inkCartridge", "inkCartridge") ) ) ( "printer-is-shared" , QVariant(bool, true) ) ( "printer-state-message" , QVariant(QString, "") ) ( "printer-commands" , QVariant(QStringList, ("Clean", "PrintSelfTestPage", "ReportLevels") ) ) ( "marker-change-time" , QVariant(int, 1267903160) ) ( "printer-state" , QVariant(int, 3) ) ( "printer-info" , QVariant(QString, "EPSON Stylus TX105") ) ( "printer-make-and-model" , QVariant(QString, "EPSON TX105 Series") ) ) )
// Get destinations with these attributes
KCupsRequest *request = new KCupsRequest;
auto request = new KCupsRequest;
connect(request, &KCupsRequest::finished, this, &PrinterModel::getDestsFinished);
request->getPrinters(m_attributes);
}
......@@ -242,7 +242,7 @@ void PrinterModel::update()
void PrinterModel::insertDest(int pos, const KCupsPrinter &printer)
{
// Create the printer item
QStandardItem *stdItem = new QStandardItem(printer.name());
auto stdItem = new QStandardItem(printer.name());
stdItem->setData(printer.name(), DestName);
stdItem->setIcon(printer.icon());
// update the item
......@@ -411,7 +411,7 @@ Qt::ItemFlags PrinterModel::flags(const QModelIndex &index) const
void PrinterModel::insertUpdatePrinterName(const QString &printerName)
{
KCupsRequest *request = new KCupsRequest;
auto request = new KCupsRequest;
connect(request, &KCupsRequest::finished, this, &PrinterModel::insertUpdatePrinterFinished);
// TODO how do we know if it's a class if this DBus signal
// does not tell us
......@@ -437,7 +437,7 @@ void PrinterModel::insertUpdatePrinter(const QString &text,
void PrinterModel::insertUpdatePrinterFinished()
{
KCupsRequest *request = qobject_cast<KCupsRequest *>(sender());
auto request = qobject_cast<KCupsRequest *>(sender());
if (!request->hasError()) {
foreach (const KCupsPrinter &printer, request->printers()) {
// If there is a printer and it's not the current one add it
......
......@@ -66,7 +66,7 @@ void NewPrinterNotification::GetReady()
{
qCDebug(PM_KDED);
// This method is all about telling the user a new printer was detected
KNotification *notify = new KNotification("GetReady");
auto notify = new KNotification("GetReady");
notify->setComponentName("printmanager");
notify->setPixmap(QIcon::fromTheme("printer").pixmap(64, 64));
notify->setTitle(i18n("A New Printer was detected"));
......@@ -93,7 +93,7 @@ void NewPrinterNotification::NewPrinter(int status,
// mfg "Samsung"
// mdl "SCX-3400 Series" "" "SPL,FWV,PIC,BDN,EXT"
// This method is all about telling the user a new printer was detected
KNotification *notify = new KNotification("NewPrinterNotification");
auto notify = new KNotification("NewPrinterNotification");
notify->setComponentName("printmanager");
notify->setPixmap(QIcon::fromTheme("printer").pixmap(64, 64));
notify->setFlags(KNotification::Persistent);
......@@ -203,11 +203,10 @@ void NewPrinterNotification::init()
if (!registerService()) {
// in case registration fails due to another user or application running
// keep an eye on it so we can register when available
QDBusServiceWatcher *watcher;
watcher = new QDBusServiceWatcher(QLatin1String("com.redhat.NewPrinterNotification"),
QDBusConnection::systemBus(),
QDBusServiceWatcher::WatchForUnregistration,
this);
auto watcher = new QDBusServiceWatcher(QLatin1String("com.redhat.NewPrinterNotification"),
QDBusConnection::systemBus(),
QDBusServiceWatcher::WatchForUnregistration,
this);
connect(watcher, &QDBusServiceWatcher::serviceUnregistered, this, &NewPrinterNotification::registerService);
}
}
......
......@@ -57,7 +57,7 @@ PrintKCM::PrintKCM(QWidget *parent, const QVariantList &args) :
PM_VERSION,
i18n("Print settings"),
KAboutLicense::GPL,
i18n("(C) 2010-2013 Daniel Nicoletti"));
i18n("(C) 2010-2018 Daniel Nicoletti"));
aboutData->addAuthor(QStringLiteral("Daniel Nicoletti"), QString(), "dantti12@gmail.com");
aboutData->addAuthor(QStringLiteral("Jan Grulich"), i18n("Port to Qt 5 / Plasma 5"), QStringLiteral("jgrulich@redhat.com"));
setAboutData(aboutData);
......@@ -71,7 +71,7 @@ PrintKCM::PrintKCM(QWidget *parent, const QVariantList &args) :
// default dialog icon size is 32, this times 6 is 192 which is roughly the original width
ui->printersTV->setMinimumWidth(IconSize(KIconLoader::Dialog) * 6);
QMenu *addMenu = new QMenu(this);
auto addMenu = new QMenu(this);
addMenu->addAction(i18nc("@action:intoolbar","Add a Printer Class"),
this, &PrintKCM::addClass);
ui->addTB->setIcon(QIcon::fromTheme("list-add"));
......@@ -81,7 +81,7 @@ PrintKCM::PrintKCM(QWidget *parent, const QVariantList &args) :
ui->removeTB->setIcon(QIcon::fromTheme("list-remove"));
ui->removeTB->setToolTip(i18n("Remove Printer"));
QMenu *systemMenu = new QMenu(this);
auto systemMenu = new QMenu(this);
connect(systemMenu, &QMenu::aboutToShow, this, &PrintKCM::getServerSettings);
connect(systemMenu, &QMenu::triggered, this, &PrintKCM::systemPreferencesTriggered);
#if CUPS_VERSION_MAJOR == 1 && CUPS_VERSION_MINOR < 6
......@@ -107,7 +107,7 @@ PrintKCM::PrintKCM(QWidget *parent, const QVariantList &args) :
ui->systemPreferencesTB->setMenu(systemMenu);
m_model = new PrinterModel(this);
PrinterSortFilterModel *sortModel = new PrinterSortFilterModel(this);
auto sortModel = new PrinterSortFilterModel(this);
sortModel->setSourceModel(m_model);
ui->printersTV->setModel(sortModel);
ui->printersTV->setItemDelegate(new NoSelectionRectDelegate(this));
......@@ -304,7 +304,7 @@ void PrintKCM::on_removeTB_clicked()
void PrintKCM::getServerSettings()
{
if (!m_serverRequest) {
QMenu *systemMenu = qobject_cast<QMenu*>(sender());
auto systemMenu = qobject_cast<QMenu*>(sender());
m_serverRequest = new KCupsRequest;
m_serverRequest->setProperty("interactive", static_cast<bool>(systemMenu));
connect(m_serverRequest, &KCupsRequest::finished, this, &PrintKCM::getServerSettingsFinished);
......@@ -314,7 +314,7 @@ void PrintKCM::getServerSettings()
void PrintKCM::getServerSettingsFinished()
{
KCupsRequest *request = qobject_cast<KCupsRequest *>(sender());
auto request = qobject_cast<KCupsRequest *>(sender());
// When we don't have any destinations error is set to IPP_NOT_FOUND
// we can safely ignore the error since it DOES bring the server settings
......@@ -353,7 +353,7 @@ void PrintKCM::getServerSettingsFinished()
void PrintKCM::updateServerFinished()
{
KCupsRequest *request = qobject_cast<KCupsRequest *>(sender());
auto request = qobject_cast<KCupsRequest *>(sender());
if (request->hasError()) {
if (request->error() == IPP_SERVICE_UNAVAILABLE ||