Merge pull request #10220 from thalieht/const

Add const to many vars and arguments
This commit is contained in:
Mike Tzou
2019-02-13 12:11:00 +08:00
committed by GitHub
34 changed files with 299 additions and 301 deletions

View File

@@ -850,7 +850,7 @@ void MainWindow::finishedTorrent(BitTorrent::TorrentHandle *const torrent) const
}
// Notification when disk is full
void MainWindow::fullDiskError(BitTorrent::TorrentHandle *const torrent, QString msg) const
void MainWindow::fullDiskError(BitTorrent::TorrentHandle *const torrent, const QString &msg) const
{
showNotificationBaloon(tr("I/O Error", "i.e: Input/Output Error")
, tr("An I/O error occurred for torrent '%1'.\n Reason: %2"
@@ -964,7 +964,7 @@ void MainWindow::askRecursiveTorrentDownloadConfirmation(BitTorrent::TorrentHand
confirmBox->show();
}
void MainWindow::handleDownloadFromUrlFailure(QString url, QString reason) const
void MainWindow::handleDownloadFromUrlFailure(const QString &url, const QString &reason) const
{
// Display a message box
showNotificationBaloon(tr("URL download error")
@@ -1062,7 +1062,7 @@ bool MainWindow::unlockUI()
return true;
}
void MainWindow::notifyOfUpdate(QString)
void MainWindow::notifyOfUpdate(const QString &)
{
// Show restart message
m_statusBar->showRestartRequired();
@@ -1569,7 +1569,7 @@ void MainWindow::updateGUI()
}
}
void MainWindow::showNotificationBaloon(QString title, QString msg) const
void MainWindow::showNotificationBaloon(const QString &title, const QString &msg) const
{
if (!isNotificationsEnabled()) return;
#if (defined(Q_OS_UNIX) && !defined(Q_OS_MAC)) && defined(QT_DBUS_LIB)

View File

@@ -99,20 +99,20 @@ public:
void activate();
void cleanup();
void showNotificationBaloon(QString title, QString msg) const;
void showNotificationBaloon(const QString &title, const QString &msg) const;
private slots:
void showFilterContextMenu(const QPoint &);
void balloonClicked();
void writeSettings();
void readSettings();
void fullDiskError(BitTorrent::TorrentHandle *const torrent, QString msg) const;
void handleDownloadFromUrlFailure(QString, QString) const;
void fullDiskError(BitTorrent::TorrentHandle *const torrent, const QString &msg) const;
void handleDownloadFromUrlFailure(const QString &, const QString &) const;
void tabChanged(int newTab);
bool defineUILockPassword();
void clearUILockPassword();
bool unlockUI();
void notifyOfUpdate(QString);
void notifyOfUpdate(const QString &);
void showConnectionSettings();
void minimizeWindow();
// Keyboard shortcuts

View File

@@ -120,9 +120,9 @@ int PropTabBar::currentIndex() const
void PropTabBar::setCurrentIndex(int index)
{
if (index >= m_btnGroup->buttons().size())
index = 0;
index = 0;
// If asked to hide or if the currently selected tab is clicked
if (index < 0 || m_currentIndex == index) {
if ((index < 0) || (m_currentIndex == index)) {
if (m_currentIndex >= 0) {
m_btnGroup->button(m_currentIndex)->setDown(false);
m_currentIndex = -1;

View File

@@ -149,7 +149,7 @@ QList<QTreeWidgetItem*> TrackerListWidget::getSelectedTrackerItems() const
return selectedTrackers;
}
void TrackerListWidget::setRowColor(int row, QColor color)
void TrackerListWidget::setRowColor(const int row, const QColor &color)
{
const int nbColumns = columnCount();
QTreeWidgetItem *item = topLevelItem(row);

View File

@@ -69,7 +69,7 @@ public:
int visibleColumnsCount() const;
public slots:
void setRowColor(int row, QColor color);
void setRowColor(int row, const QColor &color);
void moveSelectionUp();
void moveSelectionDown();

View File

@@ -228,7 +228,7 @@ void PluginSelectDialog::enableSelection(bool enable)
}
// Set the color of a row in data model
void PluginSelectDialog::setRowColor(int row, QString color)
void PluginSelectDialog::setRowColor(const int row, const QString &color)
{
QTreeWidgetItem *item = m_ui->pluginsTree->topLevelItem(row);
for (int i = 0; i < m_ui->pluginsTree->columnCount(); ++i) {
@@ -236,7 +236,7 @@ void PluginSelectDialog::setRowColor(int row, QString color)
}
}
QList<QTreeWidgetItem*> PluginSelectDialog::findItemsWithUrl(QString url)
QList<QTreeWidgetItem*> PluginSelectDialog::findItemsWithUrl(const QString &url)
{
QList<QTreeWidgetItem*> res;
@@ -249,7 +249,7 @@ QList<QTreeWidgetItem*> PluginSelectDialog::findItemsWithUrl(QString url)
return res;
}
QTreeWidgetItem *PluginSelectDialog::findItemWithID(QString id)
QTreeWidgetItem *PluginSelectDialog::findItemWithID(const QString &id)
{
for (int i = 0; i < m_ui->pluginsTree->topLevelItemCount(); ++i) {
QTreeWidgetItem *item = m_ui->pluginsTree->topLevelItem(i);
@@ -268,7 +268,7 @@ void PluginSelectDialog::loadSupportedSearchPlugins()
addNewPlugin(name);
}
void PluginSelectDialog::addNewPlugin(QString pluginName)
void PluginSelectDialog::addNewPlugin(const QString &pluginName)
{
QTreeWidgetItem *item = new QTreeWidgetItem(m_ui->pluginsTree);
PluginInfo *plugin = m_pluginManager->pluginInfo(pluginName);

View File

@@ -51,8 +51,8 @@ public:
explicit PluginSelectDialog(SearchPluginManager *pluginManager, QWidget *parent = nullptr);
~PluginSelectDialog();
QList<QTreeWidgetItem*> findItemsWithUrl(QString url);
QTreeWidgetItem *findItemWithID(QString id);
QList<QTreeWidgetItem*> findItemsWithUrl(const QString &url);
QTreeWidgetItem *findItemWithID(const QString &id);
protected:
void dropEvent(QDropEvent *event) override;
@@ -64,7 +64,7 @@ private slots:
void on_installButton_clicked();
void on_closeButton_clicked();
void togglePluginState(QTreeWidgetItem*, int);
void setRowColor(int row, QString color);
void setRowColor(int row, const QString &color);
void displayContextMenu(const QPoint &pos);
void enableSelection(bool enable);
void askForLocalPlugin();
@@ -81,7 +81,7 @@ private slots:
private:
void loadSupportedSearchPlugins();
void addNewPlugin(QString pluginName);
void addNewPlugin(const QString &pluginName);
void startAsyncOp();
void finishAsyncOp();
void finishPluginUpdate();

View File

@@ -280,7 +280,7 @@ void SearchWidget::on_pluginsButton_clicked()
new PluginSelectDialog(SearchPluginManager::instance(), this);
}
void SearchWidget::searchTextEdited(QString)
void SearchWidget::searchTextEdited(const QString &)
{
// Enable search button
m_ui->searchButton->setText(tr("Search"));

View File

@@ -74,7 +74,7 @@ private:
void fillCatCombobox();
void fillPluginComboBox();
void selectActivePage();
void searchTextEdited(QString);
void searchTextEdited(const QString &);
void updateButtons();
QString selectedCategory() const;

View File

@@ -466,8 +466,8 @@ QIcon getErrorIcon()
bool isDarkTheme()
{
QPalette pal = QApplication::palette();
const QPalette pal = QApplication::palette();
// QPalette::Base is used for the background of the Treeview
QColor color = pal.color(QPalette::Active, QPalette::Base);
const QColor color = pal.color(QPalette::Active, QPalette::Base);
return (color.lightness() < 127);
}

View File

@@ -338,7 +338,7 @@ TransferListModel *TransferListWidget::getSourceModel() const
return m_listModel;
}
void TransferListWidget::previewFile(QString filePath)
void TransferListWidget::previewFile(const QString &filePath)
{
Utils::Misc::openPath(filePath);
}
@@ -854,7 +854,7 @@ void TransferListWidget::renameSelectedTorrent()
}
}
void TransferListWidget::setSelectionCategory(QString category)
void TransferListWidget::setSelectionCategory(const QString &category)
{
for (const QModelIndex &index : asConst(selectionModel()->selectedRows()))
m_listModel->setData(m_listModel->index(mapToSource(index).row(), TransferListModel::TR_CATEGORY), category, Qt::DisplayRole);
@@ -1173,7 +1173,7 @@ void TransferListWidget::currentChanged(const QModelIndex &current, const QModel
emit currentTorrentChanged(torrent);
}
void TransferListWidget::applyCategoryFilter(QString category)
void TransferListWidget::applyCategoryFilter(const QString &category)
{
if (category.isNull())
m_sortFilterModel->disableCategoryFilter();

View File

@@ -56,7 +56,7 @@ public:
TransferListModel *getSourceModel() const;
public slots:
void setSelectionCategory(QString category);
void setSelectionCategory(const QString &category);
void addSelectionTag(const QString &tag);
void removeSelectionTag(const QString &tag);
void clearSelectionTags();
@@ -90,11 +90,11 @@ public slots:
void displayDLHoSMenu(const QPoint&);
void applyNameFilter(const QString &name);
void applyStatusFilter(int f);
void applyCategoryFilter(QString category);
void applyCategoryFilter(const QString &category);
void applyTagFilter(const QString &tag);
void applyTrackerFilterAll();
void applyTrackerFilter(const QStringList &hashes);
void previewFile(QString filePath);
void previewFile(const QString &filePath);
void renameSelectedTorrent();
protected: