Use 'auto' to avoid duplicating the type name

This commit is contained in:
thalieht 2019-02-13 17:12:02 +02:00
parent 947c7e1d64
commit d8cbc9266a
25 changed files with 68 additions and 68 deletions

View File

@ -345,7 +345,7 @@ void Application::sendNotificationEmail(const BitTorrent::TorrentHandle *torrent
// Send the notification email
const Preferences *pref = Preferences::instance();
Net::Smtp *smtp = new Net::Smtp(this);
auto *smtp = new Net::Smtp(this);
smtp->sendMail(pref->getMailNotificationSender(),
pref->getMailNotificationEmail(),
tr("[qBittorrent] '%1' has finished downloading").arg(torrent->name()),

View File

@ -74,7 +74,7 @@ Server::Server(IRequestHandler *requestHandler, QObject *parent)
setProxy(QNetworkProxy::NoProxy);
QSslSocket::setDefaultCiphers(safeCipherList());
QTimer *dropConnectionTimer = new QTimer(this);
auto *dropConnectionTimer = new QTimer(this);
connect(dropConnectionTimer, &QTimer::timeout, this, &Server::dropTimedOutConnection);
dropConnectionTimer->start(CONNECTIONS_SCAN_INTERVAL * 1000);
}
@ -102,7 +102,7 @@ void Server::incomingConnection(qintptr socketDescriptor)
static_cast<QSslSocket *>(serverSocket)->startServerEncryption();
}
Connection *c = new Connection(serverSocket, m_requestHandler, this);
auto *c = new Connection(serverSocket, m_requestHandler, this);
m_connections.append(c);
}

View File

@ -171,7 +171,7 @@ QString GeoIPDatabase::lookup(const QHostAddress &hostAddr) const
ptr += m_recordBytes;
quint32 id = 0;
uchar *idPtr = reinterpret_cast<uchar *>(&id);
auto *idPtr = reinterpret_cast<uchar *>(&id);
memcpy(&idPtr[4 - m_recordBytes], ptr, m_recordBytes);
fromBigEndian(idPtr, 4);
@ -298,7 +298,7 @@ QVariantHash GeoIPDatabase::readMetadata() const
if (index >= 0) {
if (m_size > MAX_METADATA_SIZE)
index += (m_size - MAX_METADATA_SIZE); // from begin of all data
quint32 offset = static_cast<quint32>(index + strlen(METADATA_BEGIN_MARK));
auto offset = static_cast<quint32>(index + strlen(METADATA_BEGIN_MARK));
QVariant metadata = readDataField(offset);
if (metadata.userType() == QMetaType::QVariantHash)
return metadata.toHash();

View File

@ -183,7 +183,7 @@ bool ScanFoldersModel::setData(const QModelIndex &index, const QVariant &value,
return false;
if (role == Qt::UserRole) {
PathType type = static_cast<PathType>(value.toInt());
auto type = static_cast<PathType>(value.toInt());
if (type == CUSTOM_LOCATION)
return false;

View File

@ -97,7 +97,7 @@ namespace
if (sizeInBytes < 0) return false;
int i = 0;
qreal rawVal = static_cast<qreal>(sizeInBytes);
auto rawVal = static_cast<qreal>(sizeInBytes);
while ((rawVal >= 1024.) && (i <= static_cast<int>(Utils::Misc::SizeUnit::ExbiByte))) {
rawVal /= 1024.;

View File

@ -59,7 +59,7 @@ namespace
CategoryFilterWidget::CategoryFilterWidget(QWidget *parent)
: QTreeView(parent)
{
CategoryFilterProxyModel *proxyModel = new CategoryFilterProxyModel(this);
auto *proxyModel = new CategoryFilterProxyModel(this);
proxyModel->setSortCaseSensitivity(Qt::CaseInsensitive);
proxyModel->setSourceModel(new CategoryFilterModel(this));
setModel(proxyModel);

View File

@ -184,7 +184,7 @@ FileSystemPathEdit::FileSystemPathEdit(Private::FileEditorWithCompletion *editor
Q_D(FileSystemPathEdit);
editor->widget()->setParent(this);
QHBoxLayout *layout = new QHBoxLayout(this);
auto *layout = new QHBoxLayout(this);
layout->setContentsMargins(0, 0, 0, 0);
layout->addWidget(editor->widget());
layout->addWidget(d->m_browseBtn);

View File

@ -251,8 +251,7 @@ void Private::FileLineEdit::keyPressEvent(QKeyEvent *e)
showCompletionPopup();
}
const FileSystemPathValidator *validator =
qobject_cast<const FileSystemPathValidator *>(this->validator());
auto *validator = qobject_cast<const FileSystemPathValidator *>(this->validator());
if (validator) {
FileSystemPathValidator::TestResult lastTestResult = validator->lastTestResult();
QValidator::State lastState = validator->lastValidationState();

View File

@ -78,7 +78,7 @@ void LogListWidget::keyPressEvent(QKeyEvent *event)
void LogListWidget::appendLine(const QString &line, const Log::MsgType &type)
{
QListWidgetItem *item = new QListWidgetItem;
auto *item = new QListWidgetItem;
// We need to use QLabel here to support rich text
QLabel *lbl = new QLabel(line);
lbl->setContentsMargins(4, 2, 4, 2);

View File

@ -199,7 +199,7 @@ MainWindow::MainWindow(QWidget *parent)
m_ui->menuAutoShutdownOnDownloadsCompletion->setIcon(GuiIconProvider::instance()->getIcon("application-exit"));
m_ui->actionManageCookies->setIcon(GuiIconProvider::instance()->getIcon("preferences-web-browser-cookies"));
QMenu *lockMenu = new QMenu(this);
auto *lockMenu = new QMenu(this);
QAction *defineUiLockPasswdAct = lockMenu->addAction(tr("&Set Password"));
connect(defineUiLockPasswdAct, &QAction::triggered, this, &MainWindow::defineUILockPassword);
QAction *clearUiLockPasswdAct = lockMenu->addAction(tr("&Clear Password"));
@ -222,7 +222,7 @@ MainWindow::MainWindow(QWidget *parent)
m_splitter = new QSplitter(Qt::Horizontal, this);
// vSplitter->setChildrenCollapsible(false);
QSplitter *hSplitter = new QSplitter(Qt::Vertical, this);
auto *hSplitter = new QSplitter(Qt::Vertical, this);
hSplitter->setChildrenCollapsible(false);
hSplitter->setFrameShape(QFrame::NoFrame);
@ -380,7 +380,7 @@ MainWindow::MainWindow(QWidget *parent)
QTimer::singleShot(0, this, &MainWindow::on_actionSearchWidget_triggered);
// Auto shutdown actions
QActionGroup *autoShutdownGroup = new QActionGroup(this);
auto *autoShutdownGroup = new QActionGroup(this);
autoShutdownGroup->setExclusive(true);
autoShutdownGroup->addAction(m_ui->actionAutoShutdownDisabled);
autoShutdownGroup->addAction(m_ui->actionAutoExit);
@ -555,7 +555,7 @@ void MainWindow::addToolbarContextMenu()
m_toolbarMenu->addAction(textBesideIcons);
m_toolbarMenu->addAction(textUnderIcons);
m_toolbarMenu->addAction(followSystemStyle);
QActionGroup *textPositionGroup = new QActionGroup(m_toolbarMenu);
auto *textPositionGroup = new QActionGroup(m_toolbarMenu);
textPositionGroup->addAction(iconsOnly);
iconsOnly->setCheckable(true);
textPositionGroup->addAction(textOnly);
@ -567,7 +567,7 @@ void MainWindow::addToolbarContextMenu()
textPositionGroup->addAction(followSystemStyle);
followSystemStyle->setCheckable(true);
const Qt::ToolButtonStyle buttonStyle = static_cast<Qt::ToolButtonStyle>(pref->getToolbarTextPosition());
const auto buttonStyle = static_cast<Qt::ToolButtonStyle>(pref->getToolbarTextPosition());
if ((buttonStyle >= Qt::ToolButtonIconOnly) && (buttonStyle <= Qt::ToolButtonFollowStyle))
m_ui->toolBar->setToolButtonStyle(buttonStyle);
switch (buttonStyle) {
@ -795,7 +795,7 @@ void MainWindow::cleanup()
#endif
// remove all child widgets
while (QWidget *w = findChild<QWidget * >())
while (auto *w = findChild<QWidget *>())
delete w;
}

View File

@ -454,7 +454,7 @@ OptionsDialog::OptionsDialog(QWidget *parent)
m_ui->textTempPath->setMode(FileSystemPathEdit::Mode::DirectorySave);
// disable mouse wheel event on widgets to avoid mis-selection
WheelEventEater *wheelEventEater = new WheelEventEater(this);
auto *wheelEventEater = new WheelEventEater(this);
for (QComboBox *widget : asConst(findChildren<QComboBox *>()))
widget->installEventFilter(wheelEventEater);
for (QSpinBox *widget : asConst(findChildren<QSpinBox *>()))
@ -548,7 +548,7 @@ void OptionsDialog::saveOptions()
// Load the translation
QString locale = getLocale();
if (pref->getLocale() != locale) {
QTranslator *translator = new QTranslator;
auto *translator = new QTranslator;
if (translator->load(QLatin1String(":/lang/qbittorrent_") + locale))
qDebug("%s locale recognized, using translation.", qUtf8Printable(locale));
else
@ -592,7 +592,7 @@ void OptionsDialog::saveOptions()
m_ui->checkAssociateMagnetLinks->setEnabled(!m_ui->checkAssociateMagnetLinks->isChecked());
}
#endif
Application *const app = static_cast<Application*>(QCoreApplication::instance());
auto *const app = static_cast<Application *>(QCoreApplication::instance());
app->setFileLoggerPath(m_ui->textFileLogPath->selectedPath());
app->setFileLoggerBackup(m_ui->checkFileLogBackup->isChecked());
app->setFileLoggerMaxSize(m_ui->spinFileLogSize->value() * 1024);

View File

@ -82,7 +82,7 @@ void PowerManagementInhibitor::requestIdle()
call.setArguments(args);
QDBusPendingCall pcall = QDBusConnection::sessionBus().asyncCall(call, 1000);
QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(pcall, this);
auto *watcher = new QDBusPendingCallWatcher(pcall, this);
connect(watcher, &QDBusPendingCallWatcher::finished, this, &PowerManagementInhibitor::onAsyncReply);
}
@ -119,7 +119,7 @@ void PowerManagementInhibitor::requestBusy()
call.setArguments(args);
QDBusPendingCall pcall = QDBusConnection::sessionBus().asyncCall(call, 1000);
QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(pcall, this);
auto *watcher = new QDBusPendingCallWatcher(pcall, this);
connect(watcher, &QDBusPendingCallWatcher::finished, this, &PowerManagementInhibitor::onAsyncReply);
}

View File

@ -198,7 +198,7 @@ void PropertiesWidget::showPiecesDownloaded(bool show)
void PropertiesWidget::setVisibility(bool visible)
{
if (!visible && (m_state == VISIBLE)) {
QSplitter *hSplitter = static_cast<QSplitter *>(parentWidget());
auto *hSplitter = static_cast<QSplitter *>(parentWidget());
m_ui->stackedProperties->setVisible(false);
m_slideSizes = hSplitter->sizes();
hSplitter->handle(1)->setVisible(false);
@ -211,7 +211,7 @@ void PropertiesWidget::setVisibility(bool visible)
if (visible && (m_state == REDUCED)) {
m_ui->stackedProperties->setVisible(true);
QSplitter *hSplitter = static_cast<QSplitter *>(parentWidget());
auto *hSplitter = static_cast<QSplitter *>(parentWidget());
hSplitter->handle(1)->setDisabled(false);
hSplitter->handle(1)->setVisible(true);
hSplitter->setSizes(m_slideSizes);
@ -344,7 +344,7 @@ void PropertiesWidget::readSettings()
if (sizesStr.size() == 2) {
m_slideSizes << sizesStr.first().toInt();
m_slideSizes << sizesStr.last().toInt();
QSplitter *hSplitter = static_cast<QSplitter *>(parentWidget());
auto *hSplitter = static_cast<QSplitter *>(parentWidget());
hSplitter->setSizes(m_slideSizes);
}
const int currentTab = pref->getPropCurTab();
@ -360,7 +360,7 @@ void PropertiesWidget::saveSettings()
Preferences *const pref = Preferences::instance();
pref->setPropVisible(m_state == VISIBLE);
// Splitter sizes
QSplitter *hSplitter = static_cast<QSplitter *>(parentWidget());
auto *hSplitter = static_cast<QSplitter *>(parentWidget());
QList<int> sizes;
if (m_state == VISIBLE)
sizes = hSplitter->sizes();

View File

@ -153,7 +153,7 @@ void PropListDelegate::paint(QPainter *painter, const QStyleOptionViewItem &opti
void PropListDelegate::setEditorData(QWidget *editor, const QModelIndex &index) const
{
QComboBox *combobox = static_cast<QComboBox *>(editor);
auto *combobox = static_cast<QComboBox *>(editor);
// Set combobox index
switch (static_cast<BitTorrent::FilePriority>(index.data().toInt())) {
case BitTorrent::FilePriority::Ignored:
@ -184,7 +184,7 @@ QWidget *PropListDelegate::createEditor(QWidget *parent, const QStyleOptionViewI
if (index.data().toInt() == static_cast<int>(BitTorrent::FilePriority::Mixed))
return nullptr;
QComboBox *editor = new QComboBox(parent);
auto *editor = new QComboBox(parent);
editor->setFocusPolicy(Qt::StrongFocus);
editor->addItem(tr("Do not download", "Do not download (priority)"));
editor->addItem(tr("Normal", "Normal (priority)"));
@ -195,7 +195,7 @@ QWidget *PropListDelegate::createEditor(QWidget *parent, const QStyleOptionViewI
void PropListDelegate::setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const
{
QComboBox *combobox = static_cast<QComboBox *>(editor);
auto *combobox = static_cast<QComboBox *>(editor);
int value = combobox->currentIndex();
qDebug("PropListDelegate: setModelData(%d)", value);

View File

@ -117,7 +117,7 @@ void ArticleListWidget::checkInvariant() const
QListWidgetItem *ArticleListWidget::createItem(RSS::Article *article) const
{
Q_ASSERT(article);
QListWidgetItem *item = new QListWidgetItem;
auto *item = new QListWidgetItem;
item->setData(Qt::DisplayRole, article->title());
item->setData(Qt::UserRole, reinterpret_cast<quintptr>(article));

View File

@ -232,7 +232,7 @@ void FeedListWidget::dropEvent(QDropEvent *event)
QTreeWidgetItem *FeedListWidget::createItem(RSS::Item *rssItem, QTreeWidgetItem *parentItem)
{
QTreeWidgetItem *item = new QTreeWidgetItem;
auto *item = new QTreeWidgetItem;
item->setData(0, Qt::DisplayRole, QString("%1 (%2)").arg(rssItem->name()).arg(rssItem->unreadCount()));
item->setData(0, Qt::UserRole, reinterpret_cast<quintptr>(rssItem));
m_rssToTreeItemMapping[rssItem] = item;

View File

@ -44,7 +44,7 @@ ScanFoldersDelegate::ScanFoldersDelegate(QObject *parent, QTreeView *foldersView
void ScanFoldersDelegate::setEditorData(QWidget *editor, const QModelIndex &index) const
{
QComboBox *combobox = static_cast<QComboBox*>(editor);
auto *combobox = static_cast<QComboBox*>(editor);
// Set combobox index
if (index.data(Qt::UserRole).toInt() == ScanFoldersModel::CUSTOM_LOCATION)
combobox->setCurrentIndex(4); // '4' is the index of the item after the separator in the QComboBox menu
@ -56,7 +56,7 @@ QWidget *ScanFoldersDelegate::createEditor(QWidget *parent, const QStyleOptionVi
{
if (index.column() != ScanFoldersModel::DOWNLOAD) return nullptr;
QComboBox *editor = new QComboBox(parent);
auto *editor = new QComboBox(parent);
editor->setFocusPolicy(Qt::StrongFocus);
editor->addItem(ScanFoldersModel::pathTypeDisplayName(ScanFoldersModel::DOWNLOAD_IN_WATCH_FOLDER));
@ -75,7 +75,7 @@ QWidget *ScanFoldersDelegate::createEditor(QWidget *parent, const QStyleOptionVi
void ScanFoldersDelegate::comboboxIndexChanged(int index)
{
if (index == ScanFoldersModel::CUSTOM_LOCATION) {
QWidget *w = static_cast<QWidget *>(sender());
auto *w = static_cast<QWidget *>(sender());
if (w && w->parentWidget())
w->parentWidget()->setFocus();
}
@ -83,7 +83,7 @@ void ScanFoldersDelegate::comboboxIndexChanged(int index)
void ScanFoldersDelegate::setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const
{
QComboBox *combobox = static_cast<QComboBox*>(editor);
auto *combobox = static_cast<QComboBox*>(editor);
int value = combobox->currentIndex();
switch (value) {

View File

@ -270,7 +270,7 @@ void PluginSelectDialog::loadSupportedSearchPlugins()
void PluginSelectDialog::addNewPlugin(const QString &pluginName)
{
QTreeWidgetItem *item = new QTreeWidgetItem(m_ui->pluginsTree);
auto *item = new QTreeWidgetItem(m_ui->pluginsTree);
PluginInfo *plugin = m_pluginManager->pluginInfo(pluginName);
item->setText(PLUGIN_NAME, plugin->fullName);
item->setText(PLUGIN_URL, plugin->url);
@ -326,7 +326,7 @@ void PluginSelectDialog::finishPluginUpdate()
void PluginSelectDialog::on_installButton_clicked()
{
PluginSourceDialog *dlg = new PluginSourceDialog(this);
auto *dlg = new PluginSourceDialog(this);
connect(dlg, &PluginSourceDialog::askForLocalFile, this, &PluginSelectDialog::askForLocalPlugin);
connect(dlg, &PluginSourceDialog::askForUrl, this, &PluginSelectDialog::askForPluginUrl);
}

View File

@ -55,7 +55,7 @@ StatusBar::StatusBar(QWidget *parent)
BitTorrent::Session *const session = BitTorrent::Session::instance();
connect(session, &BitTorrent::Session::speedLimitModeChanged, this, &StatusBar::updateAltSpeedsBtn);
QWidget *container = new QWidget(this);
QHBoxLayout *layout = new QHBoxLayout(container);
auto *layout = new QHBoxLayout(container);
layout->setContentsMargins(0,0,0,0);
container->setLayout(layout);

View File

@ -60,7 +60,7 @@ namespace
TagFilterWidget::TagFilterWidget(QWidget *parent)
: QTreeView(parent)
{
TagFilterProxyModel *proxyModel = new TagFilterProxyModel(this);
auto *proxyModel = new TagFilterProxyModel(this);
proxyModel->setSortCaseSensitivity(Qt::CaseInsensitive);
proxyModel->setSourceModel(new TagFilterModel(this));
setModel(proxyModel);

View File

@ -297,7 +297,7 @@ bool TorrentContentModel::setData(const QModelIndex &index, const QVariant &valu
return false;
if ((index.column() == TorrentContentModelItem::COL_NAME) && (role == Qt::CheckStateRole)) {
TorrentContentModelItem *item = static_cast<TorrentContentModelItem*>(index.internalPointer());
auto *item = static_cast<TorrentContentModelItem*>(index.internalPointer());
qDebug("setData(%s, %d", qUtf8Printable(item->name()), value.toInt());
if (static_cast<int>(item->priority()) != value.toInt()) {
BitTorrent::FilePriority prio = BitTorrent::FilePriority::Normal;
@ -318,7 +318,7 @@ bool TorrentContentModel::setData(const QModelIndex &index, const QVariant &valu
if (role == Qt::EditRole) {
Q_ASSERT(index.isValid());
TorrentContentModelItem *item = static_cast<TorrentContentModelItem*>(index.internalPointer());
auto *item = static_cast<TorrentContentModelItem*>(index.internalPointer());
switch (index.column()) {
case TorrentContentModelItem::COL_NAME:
item->setName(value.toString());
@ -343,7 +343,7 @@ TorrentContentModelItem::ItemType TorrentContentModel::itemType(const QModelInde
int TorrentContentModel::getFileIndex(const QModelIndex &index)
{
TorrentContentModelItem *item = static_cast<TorrentContentModelItem*>(index.internalPointer());
auto *item = static_cast<TorrentContentModelItem*>(index.internalPointer());
if (item->itemType() == TorrentContentModelItem::FileType)
return static_cast<TorrentContentModelFile*>(item)->fileIndex();
@ -356,7 +356,7 @@ QVariant TorrentContentModel::data(const QModelIndex &index, int role) const
if (!index.isValid())
return QVariant();
TorrentContentModelItem *item = static_cast<TorrentContentModelItem*>(index.internalPointer());
auto *item = static_cast<TorrentContentModelItem*>(index.internalPointer());
if ((index.column() == TorrentContentModelItem::COL_NAME) && (role == Qt::DecorationRole)) {
if (item->itemType() == TorrentContentModelItem::FolderType)
@ -427,7 +427,7 @@ QModelIndex TorrentContentModel::parent(const QModelIndex &index) const
if (!index.isValid())
return QModelIndex();
TorrentContentModelItem *childItem = static_cast<TorrentContentModelItem*>(index.internalPointer());
auto *childItem = static_cast<TorrentContentModelItem*>(index.internalPointer());
if (!childItem)
return QModelIndex();

View File

@ -129,31 +129,31 @@ StatusFilterWidget::StatusFilterWidget(QWidget *parent, TransferListWidget *tran
, this, &StatusFilterWidget::updateTorrentNumbers);
// Add status filters
QListWidgetItem *all = new QListWidgetItem(this);
auto *all = new QListWidgetItem(this);
all->setData(Qt::DisplayRole, QVariant(tr("All (0)", "this is for the status filter")));
all->setData(Qt::DecorationRole, QIcon(":/icons/skin/filterall.svg"));
QListWidgetItem *downloading = new QListWidgetItem(this);
auto *downloading = new QListWidgetItem(this);
downloading->setData(Qt::DisplayRole, QVariant(tr("Downloading (0)")));
downloading->setData(Qt::DecorationRole, QIcon(":/icons/skin/downloading.svg"));
QListWidgetItem *seeding = new QListWidgetItem(this);
auto *seeding = new QListWidgetItem(this);
seeding->setData(Qt::DisplayRole, QVariant(tr("Seeding (0)")));
seeding->setData(Qt::DecorationRole, QIcon(":/icons/skin/uploading.svg"));
QListWidgetItem *completed = new QListWidgetItem(this);
auto *completed = new QListWidgetItem(this);
completed->setData(Qt::DisplayRole, QVariant(tr("Completed (0)")));
completed->setData(Qt::DecorationRole, QIcon(":/icons/skin/completed.svg"));
QListWidgetItem *resumed = new QListWidgetItem(this);
auto *resumed = new QListWidgetItem(this);
resumed->setData(Qt::DisplayRole, QVariant(tr("Resumed (0)")));
resumed->setData(Qt::DecorationRole, QIcon(":/icons/skin/resumed.svg"));
QListWidgetItem *paused = new QListWidgetItem(this);
auto *paused = new QListWidgetItem(this);
paused->setData(Qt::DisplayRole, QVariant(tr("Paused (0)")));
paused->setData(Qt::DecorationRole, QIcon(":/icons/skin/paused.svg"));
QListWidgetItem *active = new QListWidgetItem(this);
auto *active = new QListWidgetItem(this);
active->setData(Qt::DisplayRole, QVariant(tr("Active (0)")));
active->setData(Qt::DecorationRole, QIcon(":/icons/skin/filteractive.svg"));
QListWidgetItem *inactive = new QListWidgetItem(this);
auto *inactive = new QListWidgetItem(this);
inactive->setData(Qt::DisplayRole, QVariant(tr("Inactive (0)")));
inactive->setData(Qt::DecorationRole, QIcon(":/icons/skin/filterinactive.svg"));
QListWidgetItem *errored = new QListWidgetItem(this);
auto *errored = new QListWidgetItem(this);
errored->setData(Qt::DisplayRole, QVariant(tr("Errored (0)")));
errored->setData(Qt::DecorationRole, QIcon(":/icons/skin/error.svg"));
@ -198,16 +198,16 @@ TrackerFiltersList::TrackerFiltersList(QWidget *parent, TransferListWidget *tran
, m_totalTorrents(0)
, m_downloadTrackerFavicon(true)
{
QListWidgetItem *allTrackers = new QListWidgetItem(this);
auto *allTrackers = new QListWidgetItem(this);
allTrackers->setData(Qt::DisplayRole, QVariant(tr("All (0)", "this is for the tracker filter")));
allTrackers->setData(Qt::DecorationRole, GuiIconProvider::instance()->getIcon("network-server"));
QListWidgetItem *noTracker = new QListWidgetItem(this);
auto *noTracker = new QListWidgetItem(this);
noTracker->setData(Qt::DisplayRole, QVariant(tr("Trackerless (0)")));
noTracker->setData(Qt::DecorationRole, GuiIconProvider::instance()->getIcon("network-server"));
QListWidgetItem *errorTracker = new QListWidgetItem(this);
auto *errorTracker = new QListWidgetItem(this);
errorTracker->setData(Qt::DisplayRole, QVariant(tr("Error (0)")));
errorTracker->setData(Qt::DecorationRole, style()->standardIcon(QStyle::SP_MessageBoxCritical));
QListWidgetItem *warningTracker = new QListWidgetItem(this);
auto *warningTracker = new QListWidgetItem(this);
warningTracker->setData(Qt::DisplayRole, QVariant(tr("Warning (0)")));
warningTracker->setData(Qt::DecorationRole, style()->standardIcon(QStyle::SP_MessageBoxWarning));
m_trackers.insert("", QStringList());
@ -558,10 +558,10 @@ TransferListFiltersWidget::TransferListFiltersWidget(QWidget *parent, TransferLi
Preferences *const pref = Preferences::instance();
// Construct lists
QVBoxLayout *vLayout = new QVBoxLayout(this);
QScrollArea *scroll = new QScrollArea(this);
auto *vLayout = new QVBoxLayout(this);
auto *scroll = new QScrollArea(this);
QFrame *frame = new QFrame(scroll);
QVBoxLayout *frameLayout = new QVBoxLayout(frame);
auto *frameLayout = new QVBoxLayout(frame);
QFont font;
font.setBold(true);
font.setCapitalization(QFont::AllUppercase);
@ -586,7 +586,7 @@ TransferListFiltersWidget::TransferListFiltersWidget(QWidget *parent, TransferLi
statusLabel->setFont(font);
frameLayout->addWidget(statusLabel);
StatusFilterWidget *statusFilters = new StatusFilterWidget(this, transferList);
auto *statusFilters = new StatusFilterWidget(this, transferList);
frameLayout->addWidget(statusFilters);
QCheckBox *categoryLabel = new QCheckBox(tr("Categories"), this);

View File

@ -104,8 +104,8 @@ bool TransferListSortModel::lessThan(const QModelIndex &left, const QModelIndex
// In this case QSortFilterProxyModel::lessThan() converts other types to QString and
// sorts them.
// Thus we can't use the code in the default label.
const BitTorrent::TorrentState leftValue = left.data().value<BitTorrent::TorrentState>();
const BitTorrent::TorrentState rightValue = right.data().value<BitTorrent::TorrentState>();
const auto leftValue = left.data().value<BitTorrent::TorrentState>();
const auto rightValue = right.data().value<BitTorrent::TorrentState>();
if (leftValue != rightValue)
return leftValue < rightValue;
@ -261,7 +261,7 @@ bool TransferListSortModel::filterAcceptsRow(int sourceRow, const QModelIndex &s
bool TransferListSortModel::matchFilter(int sourceRow, const QModelIndex &sourceParent) const
{
TransferListModel *model = qobject_cast<TransferListModel *>(sourceModel());
auto *model = qobject_cast<TransferListModel *>(sourceModel());
if (!model) return false;
BitTorrent::TorrentHandle *const torrent = model->torrentHandle(model->index(sourceRow, 0, sourceParent));

View File

@ -153,7 +153,7 @@ namespace
}
m_checkBoxOffset.setWidth(layoutPadding.width());
QHBoxLayout *layout = new QHBoxLayout(this);
auto *layout = new QHBoxLayout(this);
layout->addWidget(m_checkBox);
layout->addStretch();
layout->setContentsMargins(layoutPadding.width(), layoutPadding.height(), layoutPadding.width(), layoutPadding.height());

View File

@ -491,10 +491,11 @@ void AppController::setPreferencesAction()
if (m.contains("locale")) {
QString locale = m["locale"].toString();
if (pref->getLocale() != locale) {
QTranslator *translator = new QTranslator;
auto *translator = new QTranslator;
if (translator->load(QLatin1String(":/lang/qbittorrent_") + locale)) {
qDebug("%s locale recognized, using translation.", qUtf8Printable(locale));
}else{
}
else {
qDebug("%s locale unrecognized, using default (en).", qUtf8Printable(locale));
}
qApp->installTranslator(translator);