Remove silencing -Wclazy-qt6-deprecated-api-fixes to workaround clazy bugs

This commit is contained in:
Jonas Kvinge 2021-06-25 18:19:37 +02:00
parent df31b5d59f
commit 8287efd51f
18 changed files with 61 additions and 63 deletions

View File

@ -1167,7 +1167,7 @@ CollectionBackend::AlbumList CollectionBackend::GetAlbums(const QString &artist,
}
return albums.values(); // clazy:exclude=qt6-deprecated-api-fixes
return albums.values();
}

View File

@ -208,17 +208,17 @@ void Mpris2::EmitNotification(const QString &name, const QVariant &val, const QS
void Mpris2::EmitNotification(const QString &name) {
QVariant value;
if (name == "PlaybackStatus") value = PlaybackStatus(); // clazy:exclude=qt6-deprecated-api-fixes
else if (name == "LoopStatus") value = LoopStatus(); // clazy:exclude=qt6-deprecated-api-fixes
else if (name == "Shuffle") value = Shuffle(); // clazy:exclude=qt6-deprecated-api-fixes
else if (name == "Metadata") value = Metadata(); // clazy:exclude=qt6-deprecated-api-fixes
else if (name == "Volume") value = Volume(); // clazy:exclude=qt6-deprecated-api-fixes
else if (name == "Position") value = Position(); // clazy:exclude=qt6-deprecated-api-fixes
else if (name == "CanPlay") value = CanPlay(); // clazy:exclude=qt6-deprecated-api-fixes
else if (name == "CanPause") value = CanPause(); // clazy:exclude=qt6-deprecated-api-fixes
else if (name == "CanSeek") value = CanSeek(); // clazy:exclude=qt6-deprecated-api-fixes
else if (name == "CanGoNext") value = CanGoNext(); // clazy:exclude=qt6-deprecated-api-fixes
else if (name == "CanGoPrevious") value = CanGoPrevious(); // clazy:exclude=qt6-deprecated-api-fixes
if (name == "PlaybackStatus") value = PlaybackStatus();
else if (name == "LoopStatus") value = LoopStatus();
else if (name == "Shuffle") value = Shuffle();
else if (name == "Metadata") value = Metadata();
else if (name == "Volume") value = Volume();
else if (name == "Position") value = Position();
else if (name == "CanPlay") value = CanPlay();
else if (name == "CanPause") value = CanPause();
else if (name == "CanSeek") value = CanSeek();
else if (name == "CanGoNext") value = CanGoNext();
else if (name == "CanGoPrevious") value = CanGoPrevious();
if (value.isValid()) EmitNotification(name, value);

View File

@ -32,27 +32,27 @@
namespace mpris {
inline void AddMetadata(const QString &key, const QString &metadata, QVariantMap *map) {
if (!metadata.isEmpty()) (*map)[key] = metadata; // clazy:exclude=qt6-deprecated-api-fixes
if (!metadata.isEmpty()) (*map)[key] = metadata;
}
inline void AddMetadataAsList(const QString &key, const QString &metadata, QVariantMap *map) {
if (!metadata.isEmpty()) (*map)[key] = QStringList() << metadata; // clazy:exclude=qt6-deprecated-api-fixes
if (!metadata.isEmpty()) (*map)[key] = QStringList() << metadata;
}
inline void AddMetadata(const QString &key, int metadata, QVariantMap *map) {
if (metadata > 0) (*map)[key] = metadata; // clazy:exclude=qt6-deprecated-api-fixes
if (metadata > 0) (*map)[key] = metadata;
}
inline void AddMetadata(const QString &key, qint64 metadata, QVariantMap *map) {
if (metadata > 0) (*map)[key] = metadata; // clazy:exclude=qt6-deprecated-api-fixes
if (metadata > 0) (*map)[key] = metadata;
}
inline void AddMetadata(const QString &key, double metadata, QVariantMap *map) {
if (metadata != 0.0) (*map)[key] = metadata; // clazy:exclude=qt6-deprecated-api-fixes
if (metadata != 0.0) (*map)[key] = metadata;
}
inline void AddMetadata(const QString &key, const QDateTime &metadata, QVariantMap *map) {
if (metadata.isValid()) (*map)[key] = metadata; // clazy:exclude=qt6-deprecated-api-fixes
if (metadata.isValid()) (*map)[key] = metadata;
}
inline QString AsMPRISDateTimeType(const qint64 time) {

View File

@ -384,25 +384,23 @@ void OpenInFileManager(const QString &path, const QUrl &url) {
command = command.split("/").last();
}
// Three is no QProcess::startDetachedCommand function in Qt 6, so ignore the Clazy Qt 6 deprecated API fixes for QProcess::startDetached().
if (command.isEmpty() || command == "exo-open") {
QDesktopServices::openUrl(QUrl::fromLocalFile(path));
}
else if (command.startsWith("nautilus")) {
proc.startDetached(command, QStringList() << command_params << "--select" << url.toLocalFile()); // clazy:exclude=qt6-deprecated-api-fixes
proc.startDetached(command, QStringList() << command_params << "--select" << url.toLocalFile());
}
else if (command.startsWith("dolphin") || command.startsWith("konqueror") || command.startsWith("kfmclient")) {
proc.startDetached(command, QStringList() << command_params << "--select" << "--new-window" << url.toLocalFile()); // clazy:exclude=qt6-deprecated-api-fixes
proc.startDetached(command, QStringList() << command_params << "--select" << "--new-window" << url.toLocalFile());
}
else if (command.startsWith("caja")) {
proc.startDetached(command, QStringList() << command_params << "--no-desktop" << path); // clazy:exclude=qt6-deprecated-api-fixes
proc.startDetached(command, QStringList() << command_params << "--no-desktop" << path);
}
else if (command.startsWith("pcmanfm") || command.startsWith("thunar")) {
proc.startDetached(command, QStringList() << command_params << path); // clazy:exclude=qt6-deprecated-api-fixes
proc.startDetached(command, QStringList() << command_params << path);
}
else {
proc.startDetached(command, QStringList() << command_params << url.toLocalFile()); // clazy:exclude=qt6-deprecated-api-fixes
proc.startDetached(command, QStringList() << command_params << url.toLocalFile());
}
}

View File

@ -61,7 +61,7 @@ void CoverProviders::ReloadSettings() {
QSettings s;
s.beginGroup(CoversSettingsPage::kSettingsGroup);
QStringList providers_enabled = s.value("providers", QStringList() << all_providers.values()).toStringList(); // clazy:exclude=qt6-deprecated-api-fixes
QStringList providers_enabled = s.value("providers", all_providers.values()).toStringList();
s.endGroup();
int i = 0;

View File

@ -310,7 +310,7 @@ void DeezerCoverProvider::HandleSearchReply(QNetworkReply *reply, const int id)
emit SearchFinished(id, CoverProviderSearchResults());
}
else {
CoverProviderSearchResults cover_results = results.values(); // clazy:exclude=qt6-deprecated-api-fixes
CoverProviderSearchResults cover_results = results.values();
std::stable_sort(cover_results.begin(), cover_results.end(), AlbumCoverFetcherSearch::CoverProviderSearchResultCompareNumber);
emit SearchFinished(id, cover_results);
}

View File

@ -182,9 +182,9 @@ QVariantMap GioLister::DeviceHardwareInfo(const QString &id) {
if (!devices_.contains(id)) return ret;
const DeviceInfo &info = devices_[id];
ret[QT_TR_NOOP("Mount point")] = info.mount_path; // clazy:exclude=qt6-deprecated-api-fixes
ret[QT_TR_NOOP("Device")] = info.volume_unix_device; // clazy:exclude=qt6-deprecated-api-fixes
ret[QT_TR_NOOP("URI")] = info.mount_uri; // clazy:exclude=qt6-deprecated-api-fixes
ret[QT_TR_NOOP("Mount point")] = info.mount_path;
ret[QT_TR_NOOP("Device")] = info.volume_unix_device;
ret[QT_TR_NOOP("URI")] = info.mount_uri;
return ret;
}

View File

@ -113,11 +113,11 @@ QVariantMap Udisks2Lister::DeviceHardwareInfo(const QString &id) {
QVariantMap result;
const auto &data = device_data_[id];
result[QT_TR_NOOP("D-Bus path")] = data.dbus_path; // clazy:exclude=qt6-deprecated-api-fixes
result[QT_TR_NOOP("Serial number")] = data.serial; // clazy:exclude=qt6-deprecated-api-fixes
result[QT_TR_NOOP("Mount points")] = data.mount_paths.join(", "); // clazy:exclude=qt6-deprecated-api-fixes
result[QT_TR_NOOP("Partition label")] = data.label; // clazy:exclude=qt6-deprecated-api-fixes
result[QT_TR_NOOP("UUID")] = data.uuid; // clazy:exclude=qt6-deprecated-api-fixes
result[QT_TR_NOOP("D-Bus path")] = data.dbus_path;
result[QT_TR_NOOP("Serial number")] = data.serial;
result[QT_TR_NOOP("Mount points")] = data.mount_paths.join(", ");
result[QT_TR_NOOP("Partition label")] = data.label;
result[QT_TR_NOOP("UUID")] = data.uuid;
return result;

View File

@ -548,7 +548,7 @@ void EditTagDialog::UpdateFieldValue(const FieldData &field, const QModelIndexLi
QVariant value;
if (ExtendedEditor *editor = dynamic_cast<ExtendedEditor*>(field.editor_)) {
value = editor->value(); // clazy:exclude=qt6-deprecated-api-fixes
value = editor->value();
}
else if (field.editor_) {
qLog(Error) << "Missing editor for" << field.editor_->objectName();

View File

@ -101,9 +101,9 @@ QList<DeviceFinder::Device> AlsaDeviceFinder::ListDevices() {
device.card = card;
device.device = dev;
device.value = QString("hw:%1,%2").arg(card).arg(dev); // clazy:exclude=qt6-deprecated-api-fixes
device.value = QString("hw:%1,%2").arg(card).arg(dev);
ret.append(device);
device.value = QString("plughw:%1,%2").arg(card).arg(dev); // clazy:exclude=qt6-deprecated-api-fixes
device.value = QString("plughw:%1,%2").arg(card).arg(dev);
ret.append(device);
}

View File

@ -68,7 +68,7 @@ QList<DeviceFinder::Device> AlsaPCMDeviceFinder::ListDevices() {
}
Device device;
device.value = name; // clazy:exclude=qt6-deprecated-api-fixes
device.value = name;
device.description = description;
device.iconname = GuessIconName(device.description);
ret << device; // clazy:exclude=reserve-candidates

View File

@ -124,7 +124,7 @@ void PulseDeviceFinder::GetSinkInfoCallback(pa_context *c, const pa_sink_info *i
if (info) {
Device dev;
dev.description = QString::fromUtf8(info->description);
dev.value = QString::fromUtf8(info->name); // clazy:exclude=qt6-deprecated-api-fixes
dev.value = QString::fromUtf8(info->name);
dev.iconname = GuessIconName(dev.description);
state->devices.append(dev);

View File

@ -59,7 +59,7 @@ void LyricsProviders::ReloadSettings() {
QSettings s;
s.beginGroup(LyricsSettingsPage::kSettingsGroup);
QStringList providers_enabled = s.value("providers", QStringList() << all_providers.values()).toStringList(); // clazy:exclude=qt6-deprecated-api-fixes
QStringList providers_enabled = s.value("providers", all_providers.values()).toStringList();
s.endGroup();
int i = 0;

View File

@ -147,17 +147,17 @@ void OSDDBus::ShowMessageNative(const QString &summary, const QString &message,
if (!image.isNull()) {
if (version_ >= QVersionNumber(1, 2)) {
hints["image-data"] = QVariant(image); // clazy:exclude=qt6-deprecated-api-fixes
hints["image-data"] = QVariant(image);
}
else if (version_ >= QVersionNumber(1, 1)) {
hints["image_data"] = QVariant(image); // clazy:exclude=qt6-deprecated-api-fixes
hints["image_data"] = QVariant(image);
}
else {
hints["icon_data"] = QVariant(image); // clazy:exclude=qt6-deprecated-api-fixes
hints["icon_data"] = QVariant(image);
}
}
hints["transient"] = QVariant(true); // clazy:exclude=qt6-deprecated-api-fixes
hints["transient"] = QVariant(true);
int id = 0;
if (last_notification_time_.secsTo(QDateTime::currentDateTime()) * 1000 < timeout_msec()) {

View File

@ -81,7 +81,7 @@ SongList PLSParser::Load(QIODevice *device, const QString &playlist_path, const
}
}
return songs.values(); // clazy:exclude=qt6-deprecated-api-fixes
return songs.values();
}

View File

@ -217,9 +217,9 @@ void BackendSettingsPage::Load() {
output_name = output.name;
}
QVariant device_value;
if (ui_->combobox_device->currentText().isEmpty()) device_value = QVariant(); // clazy:exclude=qt6-deprecated-api-fixes
else if (ui_->combobox_device->currentText() == kOutputCustom) device_value = ui_->lineedit_device->text(); // clazy:exclude=qt6-deprecated-api-fixes
else device_value = ui_->combobox_device->itemData(ui_->combobox_device->currentIndex()).value<QVariant>(); // clazy:exclude=qt6-deprecated-api-fixes
if (ui_->combobox_device->currentText().isEmpty()) device_value = QVariant();
else if (ui_->combobox_device->currentText() == kOutputCustom) device_value = ui_->lineedit_device->text();
else device_value = ui_->combobox_device->itemData(ui_->combobox_device->currentIndex()).value<QVariant>();
if (enginetype_current_ != enginetype || output_name != output_current_ || device_value != device_current_) {
set_changed();
@ -296,7 +296,7 @@ void BackendSettingsPage::Load_Output(QString output, QVariant device) {
}
if (!found) { // Output is invalid for this engine, reset to default output.
output = engine()->DefaultOutput();
device = (engine()->CustomDeviceSupport(output) ? QString() : QVariant()); // clazy:exclude=qt6-deprecated-api-fixes
device = (engine()->CustomDeviceSupport(output) ? QString() : QVariant());
for (int i = 0; i < ui_->combobox_output->count(); ++i) {
EngineBase::OutputDetails o = ui_->combobox_output->itemData(i).value<EngineBase::OutputDetails>();
if (o.name == output) {
@ -445,9 +445,9 @@ void BackendSettingsPage::Save() {
output_name = output.name;
}
if (ui_->combobox_device->currentText().isEmpty()) device_value = QVariant(); // clazy:exclude=qt6-deprecated-api-fixes
else if (ui_->combobox_device->currentText() == kOutputCustom) device_value = ui_->lineedit_device->text(); // clazy:exclude=qt6-deprecated-api-fixes
else device_value = ui_->combobox_device->itemData(ui_->combobox_device->currentIndex()).value<QVariant>(); // clazy:exclude=qt6-deprecated-api-fixes
if (ui_->combobox_device->currentText().isEmpty()) device_value = QVariant();
else if (ui_->combobox_device->currentText() == kOutputCustom) device_value = ui_->lineedit_device->text();
else device_value = ui_->combobox_device->itemData(ui_->combobox_device->currentIndex()).value<QVariant>();
QSettings s;
s.beginGroup(kSettingsGroup);

View File

@ -377,31 +377,31 @@ SmartPlaylistSearchTerm SmartPlaylistSearchTermWidget::Term() const {
// The value depends on the data type
const QWidget *value_page = ui_->value_stack->currentWidget();
if (value_page == ui_->page_text) {
ret.value_ = ui_->value_text->text(); // clazy:exclude=qt6-deprecated-api-fixes
ret.value_ = ui_->value_text->text();
}
else if (value_page == ui_->page_empty) {
ret.value_ = ""; // clazy:exclude=qt6-deprecated-api-fixes
ret.value_ = "";
}
else if (value_page == ui_->page_number) {
ret.value_ = ui_->value_number->value(); // clazy:exclude=qt6-deprecated-api-fixes
ret.value_ = ui_->value_number->value();
}
else if (value_page == ui_->page_date) {
ret.value_ = ui_->value_date->dateTime().toSecsSinceEpoch(); // clazy:exclude=qt6-deprecated-api-fixes
ret.value_ = ui_->value_date->dateTime().toSecsSinceEpoch();
}
else if (value_page == ui_->page_time) {
ret.value_ = QTime(0, 0).secsTo(ui_->value_time->time()); // clazy:exclude=qt6-deprecated-api-fixes
ret.value_ = QTime(0, 0).secsTo(ui_->value_time->time());
}
else if (value_page == ui_->page_date_numeric) {
ret.date_ = SmartPlaylistSearchTerm::DateType(ui_->date_type->currentIndex());
ret.value_ = ui_->value_date_numeric->value(); // clazy:exclude=qt6-deprecated-api-fixes
ret.value_ = ui_->value_date_numeric->value();
}
else if (value_page == ui_->page_date_relative) {
ret.date_ = SmartPlaylistSearchTerm::DateType(ui_->date_type_relative->currentIndex());
ret.value_ = ui_->value_date_numeric1->value(); // clazy:exclude=qt6-deprecated-api-fixes
ret.second_value_ = ui_->value_date_numeric2->value(); // clazy:exclude=qt6-deprecated-api-fixes
ret.value_ = ui_->value_date_numeric1->value();
ret.second_value_ = ui_->value_date_numeric2->value();
}
else if (value_page == ui_->page_rating) {
ret.value_ = ui_->value_rating->rating(); // clazy:exclude=qt6-deprecated-api-fixes
ret.value_ = ui_->value_rating->rating();
}
return ret;

View File

@ -294,7 +294,7 @@ void TranscodeDialog::UpdateProgress() {
int progress = (finished_success_ + finished_failed_) * 100;
QMap<QString, float> current_jobs = transcoder_->GetProgress();
QList<float> values = current_jobs.values(); // clazy:exclude=qt6-deprecated-api-fixes
QList<float> values = current_jobs.values();
for (const float value : values) {
progress += qBound(0, int(value * 100), 99);
}