Formatting

This commit is contained in:
Jonas Kvinge 2021-08-23 21:21:08 +02:00
parent ed7794f396
commit ea2bfbda44
111 changed files with 833 additions and 425 deletions

View File

@ -244,8 +244,9 @@ bool SingleApplication::sendMessage(const QByteArray &message, const int timeout
if (isPrimary()) return false;
// Make sure the socket is connected
if (!d->connectToPrimary(timeout, SingleApplicationPrivate::Reconnect))
if (!d->connectToPrimary(timeout, SingleApplicationPrivate::Reconnect)) {
return false;
}
d->socket_->write(message);
const bool dataWritten = d->socket_->waitForBytesWritten(timeout);

View File

@ -237,8 +237,9 @@ bool SingleApplicationPrivate::connectToPrimary(const int timeout, const Connect
forever {
randomSleep();
if (socket_->state() != QLocalSocket::ConnectingState)
if (socket_->state() != QLocalSocket::ConnectingState) {
socket_->connectToServer(blockServerName_);
}
if (socket_->state() == QLocalSocket::ConnectingState) {
socket_->waitForConnected(static_cast<int>(timeout - time.elapsed()));

View File

@ -244,8 +244,9 @@ bool SingleCoreApplication::sendMessage(const QByteArray &message, const int tim
if (isPrimary()) return false;
// Make sure the socket is connected
if (!d->connectToPrimary(timeout, SingleCoreApplicationPrivate::Reconnect))
if (!d->connectToPrimary(timeout, SingleCoreApplicationPrivate::Reconnect)) {
return false;
}
d->socket_->write(message);
const bool dataWritten = d->socket_->waitForBytesWritten(timeout);

View File

@ -237,8 +237,9 @@ bool SingleCoreApplicationPrivate::connectToPrimary(const int timeout, const Con
forever {
randomSleep();
if (socket_->state() != QLocalSocket::ConnectingState)
if (socket_->state() != QLocalSocket::ConnectingState) {
socket_->connectToServer(blockServerName_);
}
if (socket_->state() == QLocalSocket::ConnectingState) {
socket_->waitForConnected(static_cast<int>(timeout - time.elapsed()));

View File

@ -311,8 +311,9 @@ static void input_data_mixed_int24_max (const guint8 * _in, double* out, guint l
#else
gint32 value = GST_READ_UINT24_LE (_in);
#endif
if (value & 0x00800000)
if (value & 0x00800000) {
value |= 0xff000000;
}
out[op] = value / max_value;
op = (op + 1) % nfft;
@ -374,8 +375,9 @@ static void gst_fastspectrum_run_fft (GstFastSpectrum * spectrum, guint input_po
guint bands = spectrum->bands;
guint nfft = 2 * bands - 2;
for (i = 0; i < nfft; i++)
for (i = 0; i < nfft; i++) {
spectrum->fft_input[i] = spectrum->input_ring_buffer[(input_pos + i) % nfft];
}
// Should be safe to execute the same plan multiple times in parallel.
fftw_execute(spectrum->plan);
@ -435,8 +437,9 @@ static GstFlowReturn gst_fastspectrum_transform_ip (GstBaseTransform *trans, Gst
/* rounding error for frames_per_interval in ns,
* aggregated it in accumulated_error */
spectrum->error_per_interval = (spectrum->interval * rate) % GST_SECOND;
if (spectrum->frames_per_interval == 0)
if (spectrum->frames_per_interval == 0) {
spectrum->frames_per_interval = 1;
}
GST_INFO_OBJECT (spectrum, "interval %" GST_TIME_FORMAT ", fpi %"
G_GUINT64_FORMAT ", error %" GST_TIME_FORMAT,
@ -448,8 +451,9 @@ static GstFlowReturn gst_fastspectrum_transform_ip (GstBaseTransform *trans, Gst
gst_fastspectrum_flush (spectrum);
}
if (spectrum->num_frames == 0)
if (spectrum->num_frames == 0) {
spectrum->message_ts = GST_BUFFER_TIMESTAMP (buffer);
}
input_pos = spectrum->input_pos;
input_data = spectrum->input_data;
@ -462,10 +466,12 @@ static GstFlowReturn gst_fastspectrum_transform_ip (GstBaseTransform *trans, Gst
"message frames todo: %u, fft frames todo: %u, input frames %"
G_GSIZE_FORMAT, msg_todo, fft_todo, (size / bpf));
block_size = msg_todo;
if (block_size > (size / bpf))
if (block_size > (size / bpf)) {
block_size = (size / bpf);
if (block_size > fft_todo)
}
if (block_size > fft_todo) {
block_size = fft_todo;
}
/* Move the current frames into our ringbuffers */
input_data(data, spectrum->input_ring_buffer, block_size, max_value, input_pos, nfft);
@ -514,8 +520,9 @@ static GstFlowReturn gst_fastspectrum_transform_ip (GstBaseTransform *trans, Gst
memset(spectrum->spect_magnitude, 0, spectrum->bands * sizeof(double));
}
if (GST_CLOCK_TIME_IS_VALID (spectrum->message_ts))
if (GST_CLOCK_TIME_IS_VALID (spectrum->message_ts)) {
spectrum->message_ts += gst_util_uint64_scale (spectrum->num_frames, GST_SECOND, rate);
}
spectrum->num_frames = 0;
spectrum->num_fft = 0;

View File

@ -126,10 +126,12 @@ void Analyzer::Base::paintEvent(QPaintEvent *e) {
int Analyzer::Base::resizeExponent(int exp) {
if (exp < 3)
if (exp < 3) {
exp = 3;
else if (exp > 9)
}
else if (exp > 9) {
exp = 9;
}
if (exp != fht_->sizeExp()) {
delete fht_;
@ -142,18 +144,24 @@ int Analyzer::Base::resizeExponent(int exp) {
int Analyzer::Base::resizeForBands(const int bands) {
int exp = 0;
if (bands <= 8)
if (bands <= 8) {
exp = 4;
else if (bands <= 16)
}
else if (bands <= 16) {
exp = 5;
else if (bands <= 32)
}
else if (bands <= 32) {
exp = 6;
else if (bands <= 64)
}
else if (bands <= 64) {
exp = 7;
else if (bands <= 128)
}
else if (bands <= 128) {
exp = 8;
else
}
else {
exp = 9;
}
resizeExponent(exp);
return fht_->size() / 2;
@ -164,18 +172,22 @@ void Analyzer::Base::demo(QPainter &p) {
static int t = 201; // FIXME make static to namespace perhaps
if (t > 999) t = 1; // 0 = wasted calculations
if (t > 999) {
t = 1; // 0 = wasted calculations
}
if (t < 201) {
Scope s(32);
const double dt = double(t) / 200;
for (uint i = 0; i < s.size(); ++i)
for (uint i = 0; i < s.size(); ++i) {
s[i] = dt * (sin(M_PI + (i * M_PI) / s.size()) + 1.0);
}
analyze(p, s, new_frame_);
}
else
else {
analyze(p, Scope(32, 0), new_frame_);
}
++t;
@ -196,11 +208,15 @@ void Analyzer::interpolate(const Scope &inVec, Scope &outVec) {
uint64_t indexLeft = offset + 0;
if (indexLeft >= inVec.size()) indexLeft = inVec.size() - 1;
if (indexLeft >= inVec.size()) {
indexLeft = inVec.size() - 1;
}
uint64_t indexRight = offset + 1;
if (indexRight >= inVec.size()) indexRight = inVec.size() - 1;
if (indexRight >= inVec.size()) {
indexRight = inVec.size() - 1;
}
outVec[i] = inVec[indexLeft] * (1.0 - error) + inVec[indexRight] * error;
}
@ -222,7 +238,9 @@ void Analyzer::initSin(Scope &v, const uint size) {
void Analyzer::Base::timerEvent(QTimerEvent *e) {
QWidget::timerEvent(e);
if (e->timerId() != timer_.timerId()) return;
if (e->timerId() != timer_.timerId()) {
return;
}
new_frame_ = true;
update();

View File

@ -103,7 +103,9 @@ AnalyzerContainer::AnalyzerContainer(QWidget *parent)
void AnalyzerContainer::mouseReleaseEvent(QMouseEvent *e) {
if (engine_->type() != Engine::EngineType::GStreamer) return;
if (engine_->type() != Engine::EngineType::GStreamer) {
return;
}
if (e->button() == Qt::RightButton) {
#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
@ -124,8 +126,10 @@ void AnalyzerContainer::wheelEvent(QWheelEvent *e) {
}
void AnalyzerContainer::SetEngine(EngineBase *engine) {
if (current_analyzer_) current_analyzer_->set_engine(engine);
engine_ = engine;
}
void AnalyzerContainer::DisableAnalyzer() {

View File

@ -88,15 +88,17 @@ void BlockAnalyzer::resizeEvent(QResizeEvent *e) {
if (rows_ != oldRows) {
barpixmap_ = QPixmap(kWidth, rows_ * (kHeight + 1));
for (uint i = 0; i < kFadeSize; ++i)
for (uint i = 0; i < kFadeSize; ++i) {
fade_bars_[i] = QPixmap(kWidth, rows_ * (kHeight + 1));
}
yscale_.resize(rows_ + 1);
const int PRE = 1, PRO = 1; // PRE and PRO allow us to restrict the range somewhat
for (int z = 0; z < rows_; ++z)
for (int z = 0; z < rows_; ++z) {
yscale_[z] = 1 - (log10(PRE + z) / log10(PRE + rows_ + PRO));
}
yscale_[rows_] = 0;
@ -168,10 +170,12 @@ void BlockAnalyzer::analyze(QPainter &p, const Analyzer::Scope &s, bool new_fram
for (y = 0; scope_[x] < yscale_[y]; ++y) continue;
// This is opposite to what you'd think, higher than y means the bar is lower than y (physically)
if (static_cast<double>(y) > store_[x])
if (static_cast<double>(y) > store_[x]) {
y = static_cast<int>(store_[x] += step_);
else
}
else {
store_[x] = y;
}
// If y is lower than fade_pos_, then the bar has exceeded the height of the fadeout
// if the fadeout is quite faded now, then display the new one
@ -192,8 +196,9 @@ void BlockAnalyzer::analyze(QPainter &p, const Analyzer::Scope &s, bool new_fram
canvas_painter.drawPixmap(x * (kWidth + 1), y * (kHeight + 1) + y_, *bar(), 0, y * (kHeight + 1), bar()->width(), bar()->height());
}
for (int x = 0; x < store_.size(); ++x)
for (int x = 0; x < store_.size(); ++x) {
canvas_painter.drawPixmap(x * (kWidth + 1), static_cast<int>(store_[x]) * (kHeight + 1) + y_, topbarpixmap_);
}
p.drawPixmap(0, 0, canvas_);
@ -279,20 +284,24 @@ QColor ensureContrast(const QColor &bg, const QColor &fg, int amount) {
// check the saturation for the two colours is sufficient that hue alone can
// provide sufficient contrast
if (ds > amount / 2 && (bs > 125 && fs > 125))
if (ds > amount / 2 && (bs > 125 && fs > 125)) {
return fg;
else if (dv > amount / 2 && (bv > 125 && fv > 125))
}
else if (dv > amount / 2 && (bv > 125 && fv > 125)) {
return fg;
}
}
if (fs < 50 && ds < 40) {
// low saturation on a low saturation is sad
const int tmp = 50 - fs;
fs = 50;
if (static_cast<int>(amount) > tmp)
if (static_cast<int>(amount) > tmp) {
amount -= tmp;
else
}
else {
amount = 0;
}
}
// test that there is available value to honor our contrast requirement
@ -309,19 +318,24 @@ QColor ensureContrast(const QColor &bg, const QColor &fg, int amount) {
return QColor::fromHsv(fh, fs, fv);
}
if (fv > bv && bv > static_cast<int>(amount))
if (fv > bv && bv > static_cast<int>(amount)) {
return QColor::fromHsv(fh, fs, bv - static_cast<int>(amount));
}
if (fv < bv && fv > static_cast<int>(amount))
if (fv < bv && fv > static_cast<int>(amount)) {
return QColor::fromHsv(fh, fs, fv - amount);
}
if (fv > bv && (255 - fv > static_cast<int>(amount)))
if (fv > bv && (255 - fv > static_cast<int>(amount))) {
return QColor::fromHsv(fh, fs, fv + amount);
}
if (fv < bv && (255 - bv > static_cast<int>(amount)))
if (fv < bv && (255 - bv > static_cast<int>(amount))) {
return QColor::fromHsv(fh, fs, bv + amount);
}
return Qt::blue;
}
void BlockAnalyzer::paletteChange(const QPalette&) {
@ -339,9 +353,10 @@ void BlockAnalyzer::paletteChange(const QPalette&) {
bar()->fill(bg);
QPainter p(bar());
for (int y = 0; y < rows_; ++y)
for (int y = 0; y < rows_; ++y) {
// graduate the fg color
p.fillRect(0, y * (kHeight + 1), kWidth, kHeight, QColor(r + static_cast<int>(dr * y), g + static_cast<int>(dg * y), b + static_cast<int>(db * y)));
}
{
const QColor bg2 = palette().color(QPalette::Window).darker(112);
@ -387,8 +402,10 @@ void BlockAnalyzer::drawBackground() {
if (!p.paintEngine()) return;
for (int x = 0; x < columns_; ++x)
for (int y = 0; y < rows_; ++y)
for (int x = 0; x < columns_; ++x) {
for (int y = 0; y < rows_; ++y) {
p.fillRect(x * (kWidth + 1), y * (kHeight + 1) + y_, kWidth, kHeight, bgdark);
}
}
}

View File

@ -158,8 +158,9 @@ void BoomAnalyzer::analyze(QPainter &p, const Scope &scope, const bool new_frame
y = height() - static_cast<int>(bar_height_[i]);
canvas_painter.drawPixmap(x + 1, y, barPixmap_, 0, y, -1, -1);
canvas_painter.setPen(fg_);
if (bar_height_[i] > 0)
if (bar_height_[i] > 0) {
canvas_painter.drawRect(x, y, kColumnWidth - 1, height() - y - 1);
}
y = height() - static_cast<int>(peak_height_[i]);
canvas_painter.setPen(palette().color(QPalette::Midlight));

View File

@ -28,11 +28,13 @@
#include <QVector>
FHT::FHT(int n) : num_((n < 3) ? 0 : 1 << n), exp2_((n < 3) ? -1 : n) {
if (n > 3) {
buf_vector_.resize(num_);
tab_vector_.resize(num_ * 2);
makeCasTable();
}
}
FHT::~FHT() = default;
@ -45,6 +47,7 @@ float *FHT::tab_() { return tab_vector_.data(); }
int *FHT::log_() { return log_vector_.data(); }
void FHT::makeCasTable(void) {
float *costab = tab_();
float *sintab = tab_() + num_ / 2 + 1;
@ -56,6 +59,7 @@ void FHT::makeCasTable(void) {
sintab += 2;
if (sintab > tab_() + num_ * 2) sintab = tab_() + 1;
}
}
void FHT::scale(float *p, float d) const {
@ -94,25 +98,33 @@ void FHT::logSpectrum(float *out, float *p) {
}
void FHT::semiLogSpectrum(float *p) {
power2(p);
for (int i = 0; i < (num_ / 2); i++, p++) {
float e = 10.0 * log10(sqrt(*p / 2));
*p = e < 0 ? 0 : e;
}
}
void FHT::spectrum(float *p) {
power2(p);
for (int i = 0; i < (num_ / 2); i++, p++)
for (int i = 0; i < (num_ / 2); i++, p++) {
*p = static_cast<float>(sqrt(*p / 2));
}
}
void FHT::power(float *p) {
power2(p);
for (int i = 0; i < (num_ / 2); i++) *p++ /= 2;
}
void FHT::power2(float *p) {
_transform(p, num_, 0);
*p = static_cast<float>(2 * pow(*p, 2));
@ -124,13 +136,18 @@ void FHT::power2(float *p) {
p++;
q--;
}
}
void FHT::transform(float *p) {
if (num_ == 8)
if (num_ == 8) {
transform8(p);
else
}
else {
_transform(p, num_, 0);
}
}
void FHT::transform8(float *p) {

View File

@ -209,8 +209,9 @@ void CollectionModel::Init(const bool async) {
endResetModel();
// Show a loading indicator in the status bar too.
if (app_)
if (app_) {
init_task_id_ = app_->task_manager()->StartTask(tr("Loading songs"));
}
ResetAsync();
}
@ -256,11 +257,14 @@ void CollectionModel::SongsDiscovered(const SongList &songs) {
key.append(ContainerKey(type, song));
// Does it exist already?
if (!container_nodes_[i].contains(key)) {
// Create the container
container_nodes_[i][key] = ItemFromSong(type, true, i == 0, container, song, i);
if (container_nodes_[i].contains(key)) {
container = container_nodes_[i][key];
}
else {
// Create the container
container = ItemFromSong(type, true, i == 0, container, song, i);
container_nodes_[i].insert(key, container);
}
container = container_nodes_[i][key];
}
@ -270,7 +274,7 @@ void CollectionModel::SongsDiscovered(const SongList &songs) {
if (!container->lazy_loaded && use_lazy_loading_) continue;
// We've gone all the way down to the deepest level and everything was already lazy loaded, so now we have to create the song in the container.
song_nodes_[song.id()] = ItemFromSong(GroupBy_None, true, false, container, song, -1);
song_nodes_.insert(song.id(), ItemFromSong(GroupBy_None, true, false, container, song, -1));
}
}
@ -570,7 +574,7 @@ void CollectionModel::SongsDeleted(const SongList &songs) {
}
// Remove from pending art loading
for (QMap<quint64, ItemAndCacheKey>::iterator it = pending_art_.begin() ; it != pending_art_.end();) {
for (QMap<quint64, ItemAndCacheKey>::iterator it = pending_art_.begin(); it != pending_art_.end();) {
if (it.value().first == node) {
it = pending_art_.erase(it); // clazy:exclude=strict-iterators
}
@ -897,10 +901,10 @@ void CollectionModel::PostQuery(CollectionItem *parent, const CollectionModel::Q
// Save a pointer to it for later
if (child_type == GroupBy_None) {
song_nodes_[item->metadata.id()] = item;
song_nodes_.insert(item->metadata.id(), item);
}
else {
container_nodes_[child_level][item->key] = item;
container_nodes_[child_level].insert(item->key, item);
}
}

View File

@ -254,10 +254,12 @@ void CollectionView::TotalSongCountUpdated(const int count) {
total_song_count_ = count;
if (old != total_song_count_) update();
if (total_song_count_ == 0)
if (total_song_count_ == 0) {
setCursor(Qt::PointingHandCursor);
else
}
else {
unsetCursor();
}
emit TotalSongCountUpdated_();
@ -269,10 +271,12 @@ void CollectionView::TotalArtistCountUpdated(const int count) {
total_artist_count_ = count;
if (old != total_artist_count_) update();
if (total_artist_count_ == 0)
if (total_artist_count_ == 0) {
setCursor(Qt::PointingHandCursor);
else
}
else {
unsetCursor();
}
emit TotalArtistCountUpdated_();
@ -284,10 +288,12 @@ void CollectionView::TotalAlbumCountUpdated(const int count) {
total_album_count_ = count;
if (old != total_album_count_) update();
if (total_album_count_ == 0)
if (total_album_count_ == 0) {
setCursor(Qt::PointingHandCursor);
else
}
else {
unsetCursor();
}
emit TotalAlbumCountUpdated_();
@ -548,10 +554,12 @@ void CollectionView::keyboardSearch(const QString &search) {
void CollectionView::scrollTo(const QModelIndex &idx, ScrollHint hint) {
if (is_in_keyboard_search_)
if (is_in_keyboard_search_) {
QTreeView::scrollTo(idx, QAbstractItemView::PositionAtTop);
else
}
else {
QTreeView::scrollTo(idx, hint);
}
}

View File

@ -84,12 +84,15 @@ void ContextAlbumsModel::AddSongs(const SongList &songs) {
for (const Song &song : songs) {
if (song_nodes_.contains(song.id())) continue;
CollectionItem *container = root_;
QString key = CollectionModel::ContainerKey(CollectionModel::GroupBy_Album, song);
if (!container_nodes_.contains(key)) {
container_nodes_.insert(key, ItemFromSong(CollectionItem::Type_Container, true, container, song, 0));
CollectionItem *container = nullptr;
if (container_nodes_.contains(key)) {
container = container_nodes_[key];
}
else {
container = ItemFromSong(CollectionItem::Type_Container, true, container, song, 0);
container_nodes_.insert(key, container);
}
container = container_nodes_[key];
song_nodes_[song.id()] = ItemFromSong(CollectionItem::Type_Song, true, container, song, -1);
}
@ -240,7 +243,7 @@ QVariant ContextAlbumsModel::data(const CollectionItem *item, int role) const {
void ContextAlbumsModel::Reset() {
for (QMap<QString, CollectionItem*>::iterator it = container_nodes_.begin() ; it != container_nodes_.end(); ++it) {
for (QMap<QString, CollectionItem*>::iterator it = container_nodes_.begin(); it != container_nodes_.end(); ++it) {
const QString cache_key = AlbumIconPixmapCacheKey(ItemToIndex(it.value()));
QPixmapCache::remove(cache_key);
}

View File

@ -366,10 +366,12 @@ void ContextAlbumsView::OpenInNewPlaylist() {
void ContextAlbumsView::scrollTo(const QModelIndex &idx, ScrollHint hint) {
if (is_in_keyboard_search_)
if (is_in_keyboard_search_) {
QTreeView::scrollTo(idx, QAbstractItemView::PositionAtTop);
else
}
else {
QTreeView::scrollTo(idx, hint);
}
}
@ -386,8 +388,9 @@ void ContextAlbumsView::Organize() {
organize_dialog_->SetDestinationModel(app_->collection_model()->directory_model());
organize_dialog_->SetCopy(false);
if (organize_dialog_->SetSongs(GetSelectedSongs()))
if (organize_dialog_->SetSongs(GetSelectedSongs())) {
organize_dialog_->show();
}
else {
QMessageBox::warning(this, tr("Error"), tr("None of the selected songs were suitable for copying to a device"));
}

View File

@ -311,10 +311,12 @@ bool CommandlineOptions::Parse() {
for (int i = optind; i < argc_; ++i) {
QString value = QFile::decodeName(argv_[i]);
QFileInfo file_info(value);
if (file_info.exists())
if (file_info.exists()) {
urls_ << QUrl::fromLocalFile(file_info.canonicalFilePath());
else
}
else {
urls_ << QUrl::fromUserInput(value);
}
}
return true;

View File

@ -135,10 +135,12 @@ QSqlDatabase Database::Connect() {
db.setConnectOptions("QSQLITE_BUSY_TIMEOUT=30000");
//qLog(Debug) << "Opened database with connection id" << connection_id;
if (!injected_database_name_.isNull())
db.setDatabaseName(injected_database_name_);
else
if (injected_database_name_.isNull()) {
db.setDatabaseName(directory_ + "/" + kDatabaseFilename);
}
else {
db.setDatabaseName(injected_database_name_);
}
if (!db.open()) {
app_->AddError("Database: " + db.lastError().text());
@ -206,8 +208,9 @@ QSqlDatabase Database::Connect() {
// We might have to initialize the schema in some attached databases now, if they were deleted and don't match up with the main schema version.
keys = attached_databases_.keys();
for (const QString &key : keys) {
if (attached_databases_[key].is_temporary_ && attached_databases_[key].schema_.isEmpty())
if (attached_databases_[key].is_temporary_ && attached_databases_[key].schema_.isEmpty()) {
continue;
}
// Find out if there are any tables in this database
QSqlQuery q(db);
q.prepare(QString("SELECT ROWID FROM %1.sqlite_master WHERE type='table'").arg(key));
@ -346,7 +349,9 @@ void Database::DetachDatabase(const QString &database_name) {
void Database::UpdateDatabaseSchema(int version, QSqlDatabase &db) {
QString filename;
if (version == 0) filename = ":/schema/schema.sql";
if (version == 0) {
filename = ":/schema/schema.sql";
}
else {
filename = QString(":/schema/schema-%1.sql").arg(version);
qLog(Debug) << "Applying database schema update" << version << "from" << filename;

View File

@ -109,18 +109,22 @@ bool FilesystemMusicStorage::DeleteFromStorage(const DeleteJob &job) {
if (job.use_trash_) {
#if QT_VERSION >= QT_VERSION_CHECK(5, 15, 0)
if (fileInfo.isDir())
if (fileInfo.isDir()) {
return Utilities::MoveToTrashRecursive(path);
else
}
else {
return QFile::moveToTrash(path);
}
#else
return false;
#endif
}
if (fileInfo.isDir())
if (fileInfo.isDir()) {
return Utilities::RemoveRecursive(path);
else
}
else {
return QFile::remove(path);
}
}

View File

@ -670,8 +670,9 @@ MainWindow::MainWindow(Application *app, std::shared_ptr<SystemTrayIcon> tray_ic
QObject::connect(tidal_view_->albums_collection_view(), &InternetCollectionView::AddToPlaylistSignal, this, &MainWindow::AddToPlaylist);
QObject::connect(tidal_view_->songs_collection_view(), &InternetCollectionView::AddToPlaylistSignal, this, &MainWindow::AddToPlaylist);
QObject::connect(tidal_view_->search_view(), &InternetSearchView::AddToPlaylist, this, &MainWindow::AddToPlaylist);
if (TidalService *tidalservice = qobject_cast<TidalService*> (app_->internet_services()->ServiceBySource(Song::Source_Tidal)))
if (TidalService *tidalservice = qobject_cast<TidalService*> (app_->internet_services()->ServiceBySource(Song::Source_Tidal))) {
QObject::connect(this, &MainWindow::AuthorizationUrlReceived, tidalservice, &TidalService::AuthorizationUrlReceived);
}
#endif
#ifdef HAVE_QOBUZ
@ -1087,10 +1088,12 @@ void MainWindow::ReloadSettings() {
s.beginGroup(SubsonicSettingsPage::kSettingsGroup);
bool enable_subsonic = s.value("enabled", false).toBool();
s.endGroup();
if (enable_subsonic)
if (enable_subsonic) {
ui_->tabs->EnableTab(subsonic_view_);
else
}
else {
ui_->tabs->DisableTab(subsonic_view_);
}
app_->scrobbler()->Service<SubsonicScrobbler>()->ReloadSettings();
#endif
@ -1098,20 +1101,24 @@ void MainWindow::ReloadSettings() {
s.beginGroup(TidalSettingsPage::kSettingsGroup);
bool enable_tidal = s.value("enabled", false).toBool();
s.endGroup();
if (enable_tidal)
if (enable_tidal) {
ui_->tabs->EnableTab(tidal_view_);
else
}
else {
ui_->tabs->DisableTab(tidal_view_);
}
#endif
#ifdef HAVE_QOBUZ
s.beginGroup(QobuzSettingsPage::kSettingsGroup);
bool enable_qobuz = s.value("enabled", false).toBool();
s.endGroup();
if (enable_qobuz)
if (enable_qobuz) {
ui_->tabs->EnableTab(qobuz_view_);
else
}
else {
ui_->tabs->DisableTab(qobuz_view_);
}
#endif
ui_->tabs->ReloadSettings();
@ -1884,10 +1891,12 @@ void MainWindow::PlaylistRightClick(const QPoint global_pos, const QModelIndex &
else if (in_queue == 0 && not_in_queue > 1) playlist_queue_->setText(tr("Queue selected tracks"));
else playlist_queue_->setText(tr("Toggle queue status"));
if (selected > 1)
if (selected > 1) {
playlist_queue_play_next_->setText(tr("Queue selected tracks to play next"));
else
}
else {
playlist_queue_play_next_->setText(tr("Queue to play next"));
}
if (in_skipped == 1 && not_in_skipped == 0) playlist_skip_->setText(tr("Unskip track"));
else if (in_skipped > 1 && not_in_skipped == 0) playlist_skip_->setText(tr("Unskip selected tracks"));
@ -2816,7 +2825,7 @@ void MainWindow::CheckFullRescanRevisions() {
// Collect all reasons
QSet<QString> reasons;
for (int i = from ; i <= to ; ++i) {
for (int i = from; i <= to; ++i) {
QString reason = app_->collection()->full_rescan_reason(i);
if (!reason.isEmpty()) {
reasons.insert(reason);

View File

@ -237,8 +237,9 @@ void MergedProxyModel::SubModelResetSlot() {
QModelIndex MergedProxyModel::GetActualSourceParent(const QModelIndex &source_parent, QAbstractItemModel *model) const {
if (!source_parent.isValid() && model != sourceModel())
if (!source_parent.isValid() && model != sourceModel()) {
return merge_points_.value(model);
}
return source_parent;
}
@ -303,10 +304,12 @@ QModelIndex MergedProxyModel::index(int row, int column, const QModelIndex &pare
QModelIndex source_parent = mapToSource(parent);
const QAbstractItemModel *child_model = merge_points_.key(source_parent);
if (child_model)
if (child_model) {
source_index = child_model->index(row, column, QModelIndex());
else
}
else {
source_index = source_parent.model()->index(row, column, source_parent);
}
}
return mapFromSource(source_index);
@ -316,13 +319,16 @@ QModelIndex MergedProxyModel::index(int row, int column, const QModelIndex &pare
QModelIndex MergedProxyModel::parent(const QModelIndex &child) const {
QModelIndex source_child = mapToSource(child);
if (source_child.model() == sourceModel())
if (source_child.model() == sourceModel()) {
return mapFromSource(source_child.parent());
}
if (!IsKnownModel(source_child.model())) return QModelIndex();
if (!source_child.parent().isValid())
if (!source_child.parent().isValid()) {
return mapFromSource(merge_points_.value(GetModel(source_child)));
}
return mapFromSource(source_child.parent());
}
@ -404,8 +410,10 @@ bool MergedProxyModel::setData(const QModelIndex &idx, const QVariant &value, in
QModelIndex source_index = mapToSource(idx);
if (!source_index.isValid())
if (!source_index.isValid()) {
return sourceModel()->setData(idx, value, role);
}
return GetModel(idx)->setData(idx, value, role);
}
@ -471,8 +479,10 @@ bool MergedProxyModel::canFetchMore(const QModelIndex &parent) const {
QModelIndex source_index = mapToSource(parent);
if (!source_index.isValid())
if (!source_index.isValid()) {
return sourceModel()->canFetchMore(QModelIndex());
}
return source_index.model()->canFetchMore(source_index);
}
@ -481,10 +491,12 @@ void MergedProxyModel::fetchMore(const QModelIndex &parent) {
QModelIndex source_index = mapToSource(parent);
if (!source_index.isValid())
if (!source_index.isValid()) {
sourceModel()->fetchMore(QModelIndex());
else
}
else {
GetModel(source_index)->fetchMore(source_index);
}
}
@ -497,6 +509,7 @@ QAbstractItemModel *MergedProxyModel::GetModel(const QModelIndex &source_index)
for (QAbstractItemModel *submodel : submodels) {
if (submodel == const_model) return submodel;
}
return nullptr;
}

View File

@ -133,8 +133,9 @@ Mpris2::Mpris2(Application *app, QObject *parent)
app_name_[0] = app_name_[0].toUpper();
if (!QGuiApplication::desktopFileName().isEmpty())
if (!QGuiApplication::desktopFileName().isEmpty()) {
desktop_files_ << QGuiApplication::desktopFileName();
}
QStringList domain_split = QCoreApplication::organizationDomain().split(".");
std::reverse(domain_split.begin(), domain_split.end());

View File

@ -97,10 +97,12 @@ int MultiSortFilterProxy::Compare(const QVariant &left, const QVariant &right) c
case QVariant::String:
#endif
default:
if (isSortLocaleAware())
if (isSortLocaleAware()) {
return left.toString().localeAwareCompare(right.toString());
else
}
else {
return left.toString().compare(right.toString(), sortCaseSensitivity());
}
}
return 0;

View File

@ -114,10 +114,12 @@ QList<QNetworkProxy> NetworkProxyFactory::queryProxy(const QNetworkProxyQuery &q
ret.setPort(env_url_.port());
ret.setUser(env_url_.userName());
ret.setPassword(env_url_.password());
if (env_url_.scheme().startsWith("http"))
if (env_url_.scheme().startsWith("http")) {
ret.setType(QNetworkProxy::HttpProxy);
else
}
else {
ret.setType(QNetworkProxy::Socks5Proxy);
}
qLog(Debug) << "Using proxy URL:" << env_url_;
}
break;

View File

@ -111,7 +111,7 @@ Engine::EngineType Player::CreateEngine(Engine::EngineType enginetype) {
Engine::EngineType use_enginetype(Engine::None);
for (int i = 0 ; use_enginetype == Engine::None ; i++) {
for (int i = 0; use_enginetype == Engine::None; i++) {
switch(enginetype) {
case Engine::None:
#ifdef HAVE_GSTREAMER

View File

@ -899,7 +899,7 @@ void Song::InitFromQuery(const SqlRow &q, bool reliable_metadata, int col) {
int x = col;
d->id_ = toint(col);
for (int i = 0 ; i < Song::kColumns.size(); i++) {
for (int i = 0; i < Song::kColumns.size(); i++) {
x++;
if (x >= q.columns_.size()) {
@ -1609,8 +1609,9 @@ bool Song::IsOnSameAlbum(const Song &other) const {
if (is_compilation() != other.is_compilation()) return false;
if (has_cue() && other.has_cue() && cue_path() == other.cue_path())
if (has_cue() && other.has_cue() && cue_path() == other.cue_path()) {
return true;
}
if (is_compilation() && album() == other.album()) return true;

View File

@ -543,8 +543,9 @@ GstPadProbeReturn SongLoader::DataReady(GstPad*, GstPadProbeInfo *info, gpointer
SongLoader *instance = reinterpret_cast<SongLoader*>(self);
if (instance->state_ == Finished)
if (instance->state_ == Finished) {
return GST_PAD_PROBE_OK;
}
GstBuffer *buffer = gst_pad_probe_info_get_buffer(info);
GstMapInfo map;

View File

@ -71,7 +71,7 @@ void StandardItemIconLoader::LoadIcon(const Song &song, QStandardItem *for_item)
void StandardItemIconLoader::RowsAboutToBeRemoved(const QModelIndex &parent, int begin, int end) {
for (QMap<quint64, QStandardItem*>::iterator it = pending_covers_.begin() ; it != pending_covers_.end() ; ) {
for (QMap<quint64, QStandardItem*>::iterator it = pending_covers_.begin(); it != pending_covers_.end();) {
const QStandardItem *item = it.value();
const QStandardItem *item_parent = item->parent();

View File

@ -90,8 +90,9 @@ qreal StyleHelper::sidebarFontSize() {
QColor StyleHelper::notTooBrightHighlightColor() {
QColor highlightColor = QApplication::palette().highlight().color();
if (0.5 * highlightColor.saturationF() + 0.75 - highlightColor.valueF() < 0)
if (0.5 * highlightColor.saturationF() + 0.75 - highlightColor.valueF() < 0) {
highlightColor.setHsvF(highlightColor.hsvHueF(), 0.1 + highlightColor.saturationF() * 2.0, highlightColor.valueF());
}
return highlightColor;
}
@ -108,29 +109,36 @@ QPalette StyleHelper::sidebarFontPalette(const QPalette &original) {
QColor StyleHelper::panelTextColor(bool lightColored) {
if (!lightColored)
return Qt::white;
else
if (lightColored) {
return Qt::black;
}
else {
return Qt::white;
}
}
QColor StyleHelper::baseColor(bool lightColored) {
if (!lightColored)
return m_baseColor;
else
if (lightColored) {
return m_baseColor.lighter(230);
}
else {
return m_baseColor;
}
}
QColor StyleHelper::highlightColor(bool lightColored) {
QColor result = baseColor(lightColored);
if (!lightColored)
result.setHsv(result.hue(), clamp(result.saturation()), clamp(result.value() * 1.16));
else
if (lightColored) {
result.setHsv(result.hue(), clamp(result.saturation()), clamp(result.value() * 1.06));
}
else {
result.setHsv(result.hue(), clamp(result.saturation()), clamp(result.value() * 1.16));
}
return result;
}
@ -284,8 +292,9 @@ static void menuGradientHelper(QPainter *p, const QRect spanRect, const QRect re
void StyleHelper::drawArrow(QStyle::PrimitiveElement element, QPainter *painter, const QStyleOption *option) {
if (option->rect.width() <= 1 || option->rect.height() <= 1)
if (option->rect.width() <= 1 || option->rect.height() <= 1) {
return;
}
const qreal devicePixelRatio = painter->device()->devicePixelRatio();
const bool enabled = option->state & QStyle::State_Enabled;
@ -383,24 +392,30 @@ void StyleHelper::drawCornerImage(const QImage &img, QPainter *painter, const QR
const QSize size = img.size();
if (top > 0) { //top
painter->drawImage(QRectF(rect.left() + left, rect.top(), rect.width() -right - left, top), img, QRectF(leftDIP, 0, size.width() - rightDIP - leftDIP, topDIP));
if (left > 0) //top-left
if (left > 0) { //top-left
painter->drawImage(QRectF(rect.left(), rect.top(), left, top), img, QRectF(0, 0, leftDIP, topDIP));
if (right > 0) //top-right
}
if (right > 0) { //top-right
painter->drawImage(QRectF(rect.left() + rect.width() - right, rect.top(), right, top), img, QRectF(size.width() - rightDIP, 0, rightDIP, topDIP));
}
}
//left
if (left > 0)
if (left > 0) {
painter->drawImage(QRectF(rect.left(), rect.top()+top, left, rect.height() - top - bottom), img, QRectF(0, topDIP, leftDIP, size.height() - bottomDIP - topDIP));
}
//center
painter->drawImage(QRectF(rect.left() + left, rect.top()+top, rect.width() -right - left, rect.height() - bottom - top), img, QRectF(leftDIP, topDIP, size.width() - rightDIP - leftDIP, size.height() - bottomDIP - topDIP));
if (right > 0) //right
if (right > 0) { //right
painter->drawImage(QRectF(rect.left() +rect.width() - right, rect.top()+top, right, rect.height() - top - bottom), img, QRectF(size.width() - rightDIP, topDIP, rightDIP, size.height() - bottomDIP - topDIP));
}
if (bottom > 0) { //bottom
painter->drawImage(QRectF(rect.left() +left, rect.top() + rect.height() - bottom, rect.width() - right - left, bottom), img, QRectF(leftDIP, size.height() - bottomDIP, size.width() - rightDIP - leftDIP, bottomDIP));
if (left > 0) //bottom-left
painter->drawImage(QRectF(rect.left(), rect.top() + rect.height() - bottom, left, bottom), img, QRectF(0, size.height() - bottomDIP, leftDIP, bottomDIP));
if (right > 0) //bottom-right
painter->drawImage(QRectF(rect.left() + rect.width() - right, rect.top() + rect.height() - bottom, right, bottom), img, QRectF(size.width() - rightDIP, size.height() - bottomDIP, rightDIP, bottomDIP));
if (left > 0) { //bottom-left
painter->drawImage(QRectF(rect.left(), rect.top() + rect.height() - bottom, left, bottom), img, QRectF(0, size.height() - bottomDIP, leftDIP, bottomDIP));
}
if (right > 0) { //bottom-right
painter->drawImage(QRectF(rect.left() + rect.width() - right, rect.top() + rect.height() - bottom, right, bottom), img, QRectF(size.width() - rightDIP, size.height() - bottomDIP, rightDIP, bottomDIP));
}
}
}
@ -445,8 +460,9 @@ QString StyleHelper::dpiSpecificImageFile(const QString &fileName) {
// See QIcon::addFile()
if (qApp->devicePixelRatio() > 1.0) {
const QString atDprfileName = imageFileWithResolution(fileName, qRound(qApp->devicePixelRatio()));
if (QFile::exists(atDprfileName))
if (QFile::exists(atDprfileName)) {
return atDprfileName;
}
}
return fileName;
@ -463,9 +479,11 @@ QList<int> StyleHelper::availableImageResolutions(const QString &fileName) {
QList<int> result;
const int maxResolutions = qApp->devicePixelRatio();
for (int i = 1; i <= maxResolutions; ++i)
if (QFile::exists(imageFileWithResolution(fileName, i)))
for (int i = 1; i <= maxResolutions; ++i) {
if (QFile::exists(imageFileWithResolution(fileName, i))) {
result.append(i);
}
}
return result;
}

View File

@ -187,14 +187,18 @@ QString PrettySize(const quint64 bytes) {
QString ret;
if (bytes > 0) {
if (bytes <= 1000)
if (bytes <= 1000) {
ret = QString::number(bytes) + " bytes";
else if (bytes <= 1000 * 1000)
}
else if (bytes <= 1000 * 1000) {
ret = QString::asprintf("%.1f KB", float(bytes) / 1000);
else if (bytes <= 1000 * 1000 * 1000)
}
else if (bytes <= 1000 * 1000 * 1000) {
ret = QString::asprintf("%.1f MB", float(bytes) / (1000 * 1000));
else
}
else {
ret = QString::asprintf("%.1f GB", float(bytes) / (1000 * 1000 * 1000));
}
}
return ret;
@ -239,13 +243,15 @@ bool MoveToTrashRecursive(const QString &path) {
#if QT_VERSION >= QT_VERSION_CHECK(5, 15, 0)
QDir dir(path);
for (const QString &child : dir.entryList(QDir::NoDotAndDotDot | QDir::Dirs | QDir::Hidden)) {
if (!MoveToTrashRecursive(path + "/" + child))
if (!MoveToTrashRecursive(path + "/" + child)) {
return false;
}
}
for (const QString &child : dir.entryList(QDir::NoDotAndDotDot | QDir::Files | QDir::Hidden)) {
if (!QFile::moveToTrash(path + "/" + child))
if (!QFile::moveToTrash(path + "/" + child)) {
return false;
}
}
return dir.rmdir(path);
@ -262,13 +268,15 @@ bool RemoveRecursive(const QString &path) {
QDir dir(path);
for (const QString &child : dir.entryList(QDir::NoDotAndDotDot | QDir::Dirs | QDir::Hidden)) {
if (!RemoveRecursive(path + "/" + child))
if (!RemoveRecursive(path + "/" + child)) {
return false;
}
}
for (const QString &child : dir.entryList(QDir::NoDotAndDotDot | QDir::Files | QDir::Hidden)) {
if (!QFile::remove(path + "/" + child))
if (!QFile::remove(path + "/" + child)) {
return false;
}
}
return dir.rmdir(path);
@ -736,7 +744,7 @@ QString CryptographicRandomString(const int len) {
QString GetRandomString(const int len, const QString &UseCharacters) {
QString randstr;
for (int i = 0 ; i < len ; ++i) {
for (int i = 0; i < len; ++i) {
#if QT_VERSION >= QT_VERSION_CHECK(5, 10, 0)
const int index = QRandomGenerator::global()->bounded(0, UseCharacters.length());
#else
@ -844,7 +852,7 @@ QString ReplaceMessage(const QString &message, const Song &song, const QString &
// Replace the first line
int pos = 0;
QRegularExpressionMatch match;
for (match = variable_replacer.match(message, pos) ; match.hasMatch() ; match = variable_replacer.match(message, pos)) {
for (match = variable_replacer.match(message, pos); match.hasMatch(); match = variable_replacer.match(message, pos)) {
pos = match.capturedStart();
QStringList captured = match.capturedTexts();
copy.replace(captured[0], ReplaceVariable(captured[0], song, newline, html_escaped));
@ -976,7 +984,7 @@ HRGN toHRGN(const QRegion &region) {
HRGN resultRgn = nullptr;
QRegion::const_iterator rects = region.begin();
resultRgn = qt_RectToHRGN(rects[0]);
for (int i = 1 ; i < rect_count ; ++i) {
for (int i = 1; i < rect_count; ++i) {
HRGN tmpRgn = qt_RectToHRGN(rects[i]);
const int res = CombineRgn(resultRgn, resultRgn, tmpRgn, RGN_OR);
if (res == ERROR) qWarning("Error combining HRGNs.");

View File

@ -135,7 +135,7 @@ void Windows7ThumbBar::HandleWinEvent(MSG *msg) {
// Add the buttons
THUMBBUTTON buttons[kMaxButtonCount];
for (int i = 0 ; i < actions_.count() ; ++i) {
for (int i = 0; i < actions_.count(); ++i) {
const QAction *action = actions_[i];
THUMBBUTTON *button = &buttons[i];
button->iId = i;
@ -148,7 +148,7 @@ void Windows7ThumbBar::HandleWinEvent(MSG *msg) {
qLog(Debug) << "Failed to add buttons" << Qt::hex << DWORD (hr);
}
for (int i = 0 ; i < actions_.count() ; ++i) {
for (int i = 0; i < actions_.count(); ++i) {
if (buttons[i].hIcon) {
DestroyIcon(buttons[i].hIcon);
}
@ -182,7 +182,7 @@ void Windows7ThumbBar::ActionChanged() {
qLog(Debug) << "Updating" << actions_.count() << "buttons";
THUMBBUTTON buttons[kMaxButtonCount];
for (int i = 0 ; i < actions_.count() ; ++i) {
for (int i = 0; i < actions_.count(); ++i) {
QAction *action = actions_[i];
THUMBBUTTON *button = &buttons[i];
@ -196,7 +196,7 @@ void Windows7ThumbBar::ActionChanged() {
qLog(Debug) << "Failed to update buttons" << Qt::hex << DWORD (hr);
}
for (int i = 0 ; i < actions_.count() ; ++i) {
for (int i = 0; i < actions_.count(); ++i) {
if (buttons[i].hIcon) {
DestroyIcon(buttons[i].hIcon);
}

View File

@ -142,7 +142,7 @@ void AlbumCoverFetcherSearch::ProviderSearchResults(const int id, const CoverPro
void AlbumCoverFetcherSearch::ProviderSearchResults(CoverProvider *provider, const CoverProviderSearchResults &results) {
CoverProviderSearchResults results_copy(results);
for (int i = 0 ; i < results_copy.count() ; ++i) {
for (int i = 0; i < results_copy.count(); ++i) {
results_copy[i].provider = provider->name();
results_copy[i].score_provider = provider->quality();

View File

@ -47,10 +47,12 @@ void CoverExportRunnable::run() {
EmitCoverSkipped();
}
else {
if (dialog_result_.RequiresCoverProcessing())
if (dialog_result_.RequiresCoverProcessing()) {
ProcessAndExportCover();
else
}
else {
ExportCover();
}
}
}
@ -148,10 +150,12 @@ void CoverExportRunnable::ProcessAndExportCover() {
}
}
if (cover.save(new_file))
if (cover.save(new_file)) {
EmitCoverExported();
else
}
else {
EmitCoverSkipped();
}
}

View File

@ -339,8 +339,9 @@ QVariant DeviceManager::data(const QModelIndex &idx, int role) const {
return info->task_percentage_;
case MusicStorage::Role_Storage:
if (!info->device_ && info->database_id_ != -1)
if (!info->device_ && info->database_id_ != -1) {
const_cast<DeviceManager*>(this)->Connect(info);
}
if (!info->device_) return QVariant();
return QVariant::fromValue<std::shared_ptr<MusicStorage>>(info->device_);
@ -452,7 +453,7 @@ void DeviceManager::PhysicalDeviceAdded(const QString &id) {
// Do we have this device already?
DeviceInfo *info = FindDeviceById(id);
if (info) {
for (int backend_index = 0 ; backend_index < info->backends_.count() ; ++backend_index) {
for (int backend_index = 0; backend_index < info->backends_.count(); ++backend_index) {
if (info->backends_[backend_index].unique_id_ == id) {
info->backends_[backend_index].lister_ = lister;
break;
@ -506,7 +507,7 @@ void DeviceManager::PhysicalDeviceRemoved(const QString &id) {
if (info->database_id_ != -1) {
// Keep the structure around, but just "disconnect" it
for (int backend_index = 0 ; backend_index < info->backends_.count() ; ++backend_index) {
for (int backend_index = 0; backend_index < info->backends_.count(); ++backend_index) {
if (info->backends_[backend_index].unique_id_ == id) {
info->backends_[backend_index].lister_ = nullptr;
break;
@ -523,7 +524,7 @@ void DeviceManager::PhysicalDeviceRemoved(const QString &id) {
}
else {
// If this was the last lister for the device then remove it from the model
for (int backend_index = 0 ; backend_index < info->backends_.count() ; ++backend_index) {
for (int backend_index = 0; backend_index < info->backends_.count(); ++backend_index) {
if (info->backends_[backend_index].unique_id_ == id) {
info->backends_.removeAt(backend_index);
break;
@ -817,8 +818,9 @@ void DeviceManager::SetDeviceOptions(const QModelIndex &idx, const QString &frie
emit dataChanged(idx, idx);
if (info->database_id_ != -1)
if (info->database_id_ != -1) {
backend_->SetDeviceOptions(info->database_id_, friendly_name, icon_name, mode, format);
}
}
@ -853,10 +855,12 @@ void DeviceManager::TasksChanged() {
if (!idx.isValid()) continue;
DeviceInfo *info = IndexToItem(idx);
if (task.progress_max)
if (task.progress_max) {
info->task_percentage_ = static_cast<int>(float(task.progress) / task.progress_max * 100);
else
}
else {
info->task_percentage_ = 0;
}
emit dataChanged(idx, idx);
finished_tasks.removeAll(idx);

View File

@ -144,8 +144,9 @@ void DeviceProperties::ModelChanged() {
if (!isVisible()) return;
if (!index_.isValid())
if (!index_.isValid()) {
reject(); // Device went away
}
else {
UpdateHardwareInfo();
UpdateFormats();

View File

@ -47,10 +47,12 @@ QString GioLister::DeviceInfo::unique_id() const {
if (!volume_root_uri.isEmpty()) return volume_root_uri;
if (mount_ptr)
if (mount_ptr) {
return QString("Gio/%1/%2/%3").arg(mount_uuid, filesystem_type).arg(filesystem_size);
else
}
else {
return QString("Gio/unmounted/%1").arg(reinterpret_cast<qulonglong>(volume_ptr.get()));
}
}
@ -205,11 +207,13 @@ QList<QUrl> GioLister::MakeDeviceUrls(const QString &id) {
}
QStringList uris;
if (!volume_root_uri.isEmpty())
if (!volume_root_uri.isEmpty()) {
uris << volume_root_uri;
}
if (!mount_uri.isEmpty())
if (!mount_uri.isEmpty()) {
uris << mount_uri;
}
QList<QUrl> ret;
@ -288,9 +292,10 @@ void GioLister::VolumeAdded(GVolume *volume) {
return;
}
#ifdef HAVE_AUDIOCD
if (info.volume_root_uri.startsWith("cdda"))
if (info.volume_root_uri.startsWith("cdda")) {
// Audio CD devices are already handled by CDDA lister
return;
}
#endif
info.ReadDriveInfo(g_volume_get_drive(volume));
info.ReadMountInfo(g_volume_get_mount(volume));
@ -331,9 +336,10 @@ void GioLister::MountAdded(GMount *mount) {
return;
}
#ifdef HAVE_AUDIOCD
if (info.volume_root_uri.startsWith("cdda"))
if (info.volume_root_uri.startsWith("cdda")) {
// Audio CD devices are already handled by CDDA lister
return;
}
#endif
info.ReadMountInfo(mount);
info.ReadDriveInfo(g_mount_get_drive(mount));
@ -363,10 +369,12 @@ void GioLister::MountAdded(GMount *mount) {
devices_[info.unique_id()] = info;
}
if (!old_id.isEmpty())
emit DeviceChanged(old_id);
else
if (old_id.isEmpty()) {
emit DeviceAdded(info.unique_id());
}
else {
emit DeviceChanged(old_id);
}
}
@ -386,8 +394,9 @@ void GioLister::MountChanged(GMount *mount) {
new_info.ReadDriveInfo(g_mount_get_drive(mount));
// Ignore the change if the new info is useless
if (new_info.invalid_enclosing_mount || (devices_[id].filesystem_size != 0 && new_info.filesystem_size == 0) || (!devices_[id].filesystem_type.isEmpty() && new_info.filesystem_type.isEmpty()))
if (new_info.invalid_enclosing_mount || (devices_[id].filesystem_size != 0 && new_info.filesystem_size == 0) || (!devices_[id].filesystem_type.isEmpty() && new_info.filesystem_type.isEmpty())) {
return;
}
devices_[id] = new_info;
}
@ -412,9 +421,11 @@ void GioLister::MountRemoved(GMount *mount) {
}
QString GioLister::DeviceInfo::ConvertAndFree(char *str) {
QString ret = QString::fromUtf8(str);
g_free(str);
return ret;
}
void GioLister::DeviceInfo::ReadMountInfo(GMount *mount) {

View File

@ -315,8 +315,9 @@ void GPodDevice::StartDelete() { Start(); }
bool GPodDevice::RemoveTrackFromITunesDb(const QString &path, const QString &relative_to) {
QString ipod_filename = path;
if (!relative_to.isEmpty() && path.startsWith(relative_to))
if (!relative_to.isEmpty() && path.startsWith(relative_to)) {
ipod_filename.remove(0, relative_to.length() + (relative_to.endsWith('/') ? -1 : 0));
}
ipod_filename.replace('/', ':');
@ -337,7 +338,7 @@ bool GPodDevice::RemoveTrackFromITunesDb(const QString &path, const QString &rel
}
// Remove the track from all playlists
for (GList *playlists = db_->playlists ; playlists != nullptr ; playlists = playlists->next) {
for (GList *playlists = db_->playlists; playlists != nullptr; playlists = playlists->next) {
Itdb_Playlist *playlist = static_cast<Itdb_Playlist*>(playlists->data);
if (itdb_playlist_contains_track(playlist, track)) {
@ -356,11 +357,14 @@ bool GPodDevice::DeleteFromStorage(const DeleteJob &job) {
Q_ASSERT(db_);
if (!RemoveTrackFromITunesDb(job.metadata_.url().toLocalFile(), url_.path()))
if (!RemoveTrackFromITunesDb(job.metadata_.url().toLocalFile(), url_.path())) {
return false;
}
// Remove the file
if (!QFile::remove(job.metadata_.url().toLocalFile())) return false;
if (!QFile::remove(job.metadata_.url().toLocalFile())) {
return false;
}
// Remove it from our collection model
songs_to_remove_ << job.metadata_;
@ -382,4 +386,3 @@ bool GPodDevice::GetSupportedFiletypes(QList<Song::FileType> *ret) {
*ret << Song::FileType_MPEG;
return true;
}

View File

@ -255,8 +255,9 @@ bool MtpDevice::GetSupportedFiletypes(QList<Song::FileType> *ret, LIBMTP_mtpdevi
uint16_t *list = nullptr;
uint16_t length = 0;
if (LIBMTP_Get_Supported_Filetypes(device, &list, &length) != 0 || !list || !length)
if (LIBMTP_Get_Supported_Filetypes(device, &list, &length) != 0 || !list || !length) {
return false;
}
for (int i = 0; i < length; ++i) {
switch (LIBMTP_filetype_t(list[i])) {

View File

@ -164,8 +164,9 @@ void Udisks2Lister::UnmountDevice(const QString &id) {
auto eject_result = drive.Eject(QVariantMap());
eject_result.waitForFinished();
if (eject_result.isError())
if (eject_result.isError()) {
qLog(Warning) << "Failed to eject " << id << ": " << eject_result.error();
}
}
device_data_.remove(id);
@ -313,7 +314,9 @@ void Udisks2Lister::JobCompleted(const bool success, const QString &message) {
OrgFreedesktopUDisks2JobInterface *job = qobject_cast<OrgFreedesktopUDisks2JobInterface*>(sender());
QDBusObjectPath jobPath(job->path());
if (!job->isValid() || !success || !mounting_jobs_.contains(jobPath)) return;
if (!job->isValid() || !success || !mounting_jobs_.contains(jobPath)) {
return;
}
qLog(Debug) << "Pending Job Completed | Path = " << job->path() << " | Mount? = " << mounting_jobs_[jobPath].is_mount << " | Success = " << success;

View File

@ -192,8 +192,10 @@ QString About::ContributorsHtml() const {
QString About::PersonToHtml(const Person &person) {
if (person.email.isNull())
if (person.email.isEmpty()) {
return person.name;
else
}
else {
return QString("%1 &lt;<a href=\"mailto:%2\">%3</a>&gt;").arg(person.name, person.email, person.email);
}
}

View File

@ -878,8 +878,9 @@ void EditTagDialog::FieldValueEdited() {
if (ignore_edits_) return;
const QModelIndexList sel = ui_->song_list->selectionModel()->selectedIndexes();
if (sel.isEmpty())
if (sel.isEmpty()) {
return;
}
QWidget *w = qobject_cast<QWidget*>(sender());
@ -896,8 +897,9 @@ void EditTagDialog::FieldValueEdited() {
void EditTagDialog::ResetField() {
const QModelIndexList sel = ui_->song_list->selectionModel()->selectedIndexes();
if (sel.isEmpty())
if (sel.isEmpty()) {
return;
}
QWidget *w = qobject_cast<QWidget*>(sender());

View File

@ -77,8 +77,9 @@ void ErrorDialog::UpdateContent() {
QString html;
for (const QString &message : current_messages_) {
if (!html.isEmpty())
if (!html.isEmpty()) {
html += "<hr/>";
}
html += message.toHtmlEscaped();
}
ui_->messages->setHtml(html);

View File

@ -266,8 +266,9 @@ void TrackSelectionDialog::SaveData(const QList<Data> &data) {
for (int i = 0; i < data.count(); ++i) {
const Data &ref = data[i];
if (ref.pending_ || ref.results_.isEmpty() || ref.selected_result_ == -1)
if (ref.pending_ || ref.results_.isEmpty() || ref.selected_result_ == -1) {
continue;
}
const Song &new_metadata = ref.results_[ref.selected_result_];
@ -302,8 +303,9 @@ void TrackSelectionDialog::accept() {
QDialog::accept();
for (const Data &tag_data : data_) {
if (tag_data.pending_ || tag_data.results_.isEmpty() || tag_data.selected_result_ == -1)
if (tag_data.pending_ || tag_data.results_.isEmpty() || tag_data.selected_result_ == -1) {
continue;
}
const Song &new_metadata = tag_data.results_[tag_data.selected_result_];

View File

@ -44,7 +44,7 @@ QList<DeviceFinder::Device> AlsaPCMDeviceFinder::ListDevices() {
return ret;
}
for (void **n = hints ; *n ; ++n) {
for (void **n = hints; *n; ++n) {
char *io = snd_device_name_get_hint(*n, "IOID");
char *name = snd_device_name_get_hint(*n, "NAME");
char *desc = snd_device_name_get_hint(*n, "DESC");
@ -52,7 +52,7 @@ QList<DeviceFinder::Device> AlsaPCMDeviceFinder::ListDevices() {
char *desc_last = desc;
QString description;
for (char *desc_i = desc ; desc_i && *desc_i != '\0' ; ++desc_i) {
for (char *desc_i = desc; desc_i && *desc_i != '\0'; ++desc_i) {
if (*desc_i == '\n') {
*desc_i = '\0';
if (!description.isEmpty()) description.append(' ');

View File

@ -175,8 +175,9 @@ void Engine::Base::ReloadSettings() {
void Engine::Base::EmitAboutToEnd() {
if (about_to_end_emitted_)
if (about_to_end_emitted_) {
return;
}
about_to_end_emitted_ = true;
emit TrackAboutToEnd();

View File

@ -122,10 +122,12 @@ GstEngine::~GstEngine() {
if (discoverer_) {
if (discovery_discovered_cb_id_ != -1)
if (discovery_discovered_cb_id_ != -1) {
g_signal_handler_disconnect(G_OBJECT(discoverer_), discovery_discovered_cb_id_);
if (discovery_finished_cb_id_ != -1)
}
if (discovery_finished_cb_id_ != -1) {
g_signal_handler_disconnect(G_OBJECT(discoverer_), discovery_finished_cb_id_);
}
gst_discoverer_stop(discoverer_);
g_object_unref(discoverer_);
@ -210,8 +212,9 @@ bool GstEngine::Load(const QUrl &stream_url, const QUrl &original_url, Engine::T
SetEqualizerParameters(equalizer_preamp_, equalizer_gains_);
// Maybe fade in this track
if (crossfade)
if (crossfade) {
current_pipeline_->StartFader(fadeout_duration_nanosec_, QTimeLine::Forward);
}
// Setting up stream discoverer
if (!discoverer_) {
@ -640,6 +643,7 @@ void GstEngine::SeekNow() {
if (!current_pipeline_->Seek(seek_pos_)) {
qLog(Warning) << "Seek failed";
}
}
void GstEngine::PlayDone(const GstStateChangeReturn ret, const quint64 offset_nanosec, const int pipeline_id) {

View File

@ -130,17 +130,21 @@ GstEnginePipeline::~GstEnginePipeline() {
if (pipeline_) {
if (pad_added_cb_id_ != -1)
if (pad_added_cb_id_ != -1) {
g_signal_handler_disconnect(G_OBJECT(pipeline_), pad_added_cb_id_);
}
if (notify_source_cb_id_ != -1)
if (notify_source_cb_id_ != -1) {
g_signal_handler_disconnect(G_OBJECT(pipeline_), notify_source_cb_id_);
}
if (about_to_finish_cb_id_ != -1)
if (about_to_finish_cb_id_ != -1) {
g_signal_handler_disconnect(G_OBJECT(pipeline_), about_to_finish_cb_id_);
}
if (bus_cb_id_ != -1)
if (bus_cb_id_ != -1) {
g_source_remove(bus_cb_id_);
}
GstBus *bus = gst_pipeline_get_bus(GST_PIPELINE(pipeline_));
if (bus) {
@ -170,9 +174,11 @@ void GstEnginePipeline::set_volume_enabled(const bool enabled) {
}
void GstEnginePipeline::set_stereo_balancer_enabled(const bool enabled) {
stereo_balancer_enabled_ = enabled;
if (!enabled) stereo_balance_ = 0.0F;
if (pipeline_) UpdateStereoBalance();
}
void GstEnginePipeline::set_equalizer_enabled(const bool enabled) {
@ -647,7 +653,7 @@ GstPadProbeReturn GstEnginePipeline::HandoffCallback(GstPad *pad, GstPadProbeInf
int buf16_size = samples * static_cast<int>(sizeof(int16_t)) * channels;
int16_t *d = static_cast<int16_t*>(g_malloc(buf16_size));
memset(d, 0, buf16_size);
for (int i = 0 ; i < (samples * channels) ; ++i) {
for (int i = 0; i < (samples * channels); ++i) {
d[i] = static_cast<int16_t>((s[i] >> 16));
}
gst_buffer_unmap(buf, &map_info);
@ -668,7 +674,7 @@ GstPadProbeReturn GstEnginePipeline::HandoffCallback(GstPad *pad, GstPadProbeInf
int buf16_size = samples * static_cast<int>(sizeof(int16_t)) * channels;
int16_t *d = static_cast<int16_t*>(g_malloc(buf16_size));
memset(d, 0, buf16_size);
for (int i = 0 ; i < (samples * channels) ; ++i) {
for (int i = 0; i < (samples * channels); ++i) {
float sample_float = (s[i] * float(32768.0));
d[i] = static_cast<int16_t>(sample_float);
}
@ -690,7 +696,7 @@ GstPadProbeReturn GstEnginePipeline::HandoffCallback(GstPad *pad, GstPadProbeInf
int buf16_size = samples * static_cast<int>(sizeof(int16_t)) * channels;
int16_t *s16 = static_cast<int16_t*>(g_malloc(buf16_size));
memset(s16, 0, buf16_size);
for (int i = 0 ; i < (samples * channels) ; ++i) {
for (int i = 0; i < (samples * channels); ++i) {
s16[i] = *(reinterpret_cast<int16_t*>(s24+1));
s24 += 3;
if (s24 >= s24e) break;
@ -1071,8 +1077,9 @@ void GstEnginePipeline::BufferingMessageReceived(GstMessage *msg) {
qint64 GstEnginePipeline::position() const {
if (pipeline_is_initialized_)
if (pipeline_is_initialized_) {
gst_element_query_position(pipeline_, GST_FORMAT_TIME, &last_known_position_ns_);
}
return last_known_position_ns_;
@ -1090,8 +1097,9 @@ qint64 GstEnginePipeline::length() const {
GstState GstEnginePipeline::state() const {
GstState s = GST_STATE_NULL, sp = GST_STATE_NULL;
if (!pipeline_ || gst_element_get_state(pipeline_, &s, &sp, kGstStateTimeoutNanosecs) == GST_STATE_CHANGE_FAILURE)
if (!pipeline_ || gst_element_get_state(pipeline_, &s, &sp, kGstStateTimeoutNanosecs) == GST_STATE_CHANGE_FAILURE) {
return GST_STATE_NULL;
}
return s;
@ -1179,10 +1187,12 @@ void GstEnginePipeline::UpdateEqualizer() {
// Update band gains
for (int i = 0; i < kEqBandCount; ++i) {
float gain = eq_enabled_ ? eq_band_gains_[i] : float(0.0);
if (gain < 0)
if (gain < 0) {
gain *= 0.24;
else
}
else {
gain *= 0.12;
}
const int index_in_eq = i + 1;
// Offset because of the first dummy band we created.

View File

@ -53,7 +53,7 @@ QList<DeviceFinder::Device> MMDeviceFinder::ListDevices() {
UINT count;
hr = collection->GetCount(&count);
if (hr == S_OK) {
for (ULONG i = 0 ; i < count ; i++) {
for (ULONG i = 0; i < count; i++) {
IMMDevice *endpoint = nullptr;
hr = collection->Item(i, &endpoint);
if (hr == S_OK) {

View File

@ -189,19 +189,24 @@ void VLCEngine::Seek(const quint64 offset_nanosec) {
}
void VLCEngine::SetVolumeSW(const uint percent) {
if (!Initialized()) return;
if (!volume_control_ && percent != 100) return;
libvlc_audio_set_volume(player_, percent);
}
qint64 VLCEngine::position_nanosec() const {
if (state_ == Engine::Empty) return 0;
const qint64 result = (position() * kNsecPerMsec);
return qint64(qMax(0LL, result));
}
qint64 VLCEngine::length_nanosec() const {
if (state_ == Engine::Empty) return 0;
const qint64 result = (end_nanosec_ - beginning_nanosec_);
if (result > 0) {
@ -211,6 +216,7 @@ qint64 VLCEngine::length_nanosec() const {
// Get the length from the pipeline if we don't know.
return (length() * kNsecPerMsec);
}
}
EngineBase::OutputDetailsList VLCEngine::GetOutputsList() const {
@ -330,7 +336,7 @@ EngineBase::PluginDetailsList VLCEngine::GetPluginList() const {
ret << details;
}
for (libvlc_audio_output_t *audio_output = audio_output_list ; audio_output ; audio_output = audio_output->p_next) {
for (libvlc_audio_output_t *audio_output = audio_output_list; audio_output; audio_output = audio_output->p_next) {
PluginDetails details;
details.name = QString::fromUtf8(audio_output->psz_name);
details.description = QString::fromUtf8(audio_output->psz_description);
@ -349,7 +355,7 @@ void VLCEngine::GetDevicesList(const QString &output) const {
Q_UNUSED(output);
libvlc_audio_output_device_t *audio_output_device_list = libvlc_audio_output_device_list_get(instance_, output_.toUtf8().constData());
for (libvlc_audio_output_device_t *audio_device = audio_output_device_list ; audio_device ; audio_device = audio_device->p_next) {
for (libvlc_audio_output_device_t *audio_device = audio_output_device_list; audio_device; audio_device = audio_device->p_next) {
qLog(Debug) << audio_device->psz_device << audio_device->psz_description;
}
libvlc_audio_output_device_list_release(audio_output_device_list);

View File

@ -209,8 +209,9 @@ void Equalizer::SavePreset() {
QString Equalizer::SaveCurrentPreset() {
QString name = QInputDialog::getText(this, tr("Save preset"), tr("Name"), QLineEdit::Normal, tr(qPrintable(last_preset_)));
if (name.isEmpty())
if (name.isEmpty()) {
return QString();
}
AddPreset(name, current_params());
Save();
@ -362,6 +363,7 @@ Equalizer::Params::Params() : preamp(0) {
}
Equalizer::Params::Params(int g0, int g1, int g2, int g3, int g4, int g5, int g6, int g7, int g8, int g9, int pre) : preamp(pre) {
gain[0] = g0;
gain[1] = g1;
gain[2] = g2;
@ -372,14 +374,17 @@ Equalizer::Params::Params(int g0, int g1, int g2, int g3, int g4, int g5, int g6
gain[7] = g7;
gain[8] = g8;
gain[9] = g9;
}
bool Equalizer::Params::operator==(const Equalizer::Params &other) const {
if (preamp != other.preamp) return false;
for (int i = 0; i < Equalizer::kBands; ++i) {
if (gain[i] != other.gain[i]) return false;
}
return true;
}
bool Equalizer::Params::operator!=(const Equalizer::Params &other) const {
@ -387,13 +392,17 @@ bool Equalizer::Params::operator!=(const Equalizer::Params &other) const {
}
QDataStream &operator<<(QDataStream &s, const Equalizer::Params &p) {
s << p.preamp;
for (int i = 0; i < Equalizer::kBands; ++i) s << p.gain[i];
return s;
}
QDataStream &operator>>(QDataStream &s, Equalizer::Params &p) {
s >> p.preamp;
for (int i = 0; i < Equalizer::kBands; ++i) s >> p.gain[i];
return s;
}

View File

@ -93,10 +93,12 @@ bool GlobalShortcutGrabber::event(QEvent *e) {
if (e->type() == QEvent::ShortcutOverride) {
QKeyEvent *ke = static_cast<QKeyEvent*>(e);
if (modifier_keys_.contains(ke->key()))
if (modifier_keys_.contains(ke->key())) {
ret_ = QKeySequence(ke->modifiers());
else
}
else {
ret_ = QKeySequence(ke->modifiers() | ke->key());
}
UpdateText();

View File

@ -93,16 +93,19 @@ GlobalShortcutsManager::GlobalShortcutsManager(QWidget *parent)
#endif
#ifdef Q_OS_MACOS
if (!system_backend_)
if (!system_backend_) {
system_backend_ = new GlobalShortcutsBackendMacOS(this);
}
#endif
#ifdef Q_OS_WIN
if (!system_backend_)
if (!system_backend_) {
system_backend_ = new GlobalShortcutsBackendSystem(this);
}
#endif
#ifdef HAVE_X11_GLOBALSHORTCUTS
if (!system_backend_ && IsX11Available())
if (!system_backend_ && IsX11Available()) {
system_backend_ = new GlobalShortcutsBackendSystem(this);
}
#endif
ReloadSettings();

View File

@ -222,10 +222,12 @@ void InternetCollectionView::TotalSongCountUpdated(int count) {
total_song_count_ = count;
if (old != total_song_count_) update();
if (total_song_count_ == 0)
if (total_song_count_ == 0) {
setCursor(Qt::PointingHandCursor);
else
}
else {
unsetCursor();
}
emit TotalSongCountUpdated_();
@ -237,10 +239,12 @@ void InternetCollectionView::TotalArtistCountUpdated(int count) {
total_artist_count_ = count;
if (old != total_artist_count_) update();
if (total_artist_count_ == 0)
if (total_artist_count_ == 0) {
setCursor(Qt::PointingHandCursor);
else
}
else {
unsetCursor();
}
emit TotalArtistCountUpdated_();
@ -252,10 +256,12 @@ void InternetCollectionView::TotalAlbumCountUpdated(int count) {
total_album_count_ = count;
if (old != total_album_count_) update();
if (total_album_count_ == 0)
if (total_album_count_ == 0) {
setCursor(Qt::PointingHandCursor);
else
}
else {
unsetCursor();
}
emit TotalAlbumCountUpdated_();
@ -406,10 +412,12 @@ void InternetCollectionView::keyboardSearch(const QString &search) {
void InternetCollectionView::scrollTo(const QModelIndex &idx, ScrollHint hint) {
if (is_in_keyboard_search_)
if (is_in_keyboard_search_) {
QTreeView::scrollTo(idx, QAbstractItemView::PositionAtTop);
else
}
else {
QTreeView::scrollTo(idx, hint);
}
}

View File

@ -329,7 +329,7 @@ void InternetSearchModel::GetChildResults(const QStandardItem *item, InternetSea
const QModelIndex parent_proxy_index = proxy_->mapFromSource(item->index());
// Yes - visit all the children, but do so through the proxy so we get them in the right order.
for (int i = 0 ; i < item->rowCount() ; ++i) {
for (int i = 0; i < item->rowCount(); ++i) {
const QModelIndex proxy_index = parent_proxy_index.model()->index(i, 0, parent_proxy_index);
const QModelIndex idx = proxy_->mapToSource(proxy_index);
GetChildResults(itemFromIndex(idx), results, visited);
@ -361,7 +361,7 @@ void GatherResults(const QStandardItem *parent, InternetSearchView::ResultList *
(*results).append(result);
}
for (int i = 0 ; i < parent->rowCount() ; ++i) {
for (int i = 0; i < parent->rowCount(); ++i) {
GatherResults(parent->child(i), results);
}

View File

@ -509,7 +509,7 @@ void InternetSearchView::SearchDone(const int service_id, const SongList &songs,
}
// Load cached pixmaps into the results
for (InternetSearchView::ResultList::iterator it = results.begin() ; it != results.end() ; ++it) {
for (InternetSearchView::ResultList::iterator it = results.begin(); it != results.end(); ++it) {
it->pixmap_cache_key_ = PixmapCacheKey(*it);
}
@ -594,7 +594,7 @@ MimeData *InternetSearchView::SelectedMimeData() {
QModelIndexList indexes = ui_->results->selectionModel()->selectedRows();
if (indexes.isEmpty()) {
// There's nothing selected - take the first thing in the model that isn't a divider.
for (int i = 0 ; i < front_proxy_->rowCount() ; ++i) {
for (int i = 0; i < front_proxy_->rowCount(); ++i) {
QModelIndex idx = front_proxy_->index(i, 0);
if (!idx.data(CollectionModel::Role_IsDivider).toBool()) {
indexes << idx; // clazy:exclude=reserve-candidates

View File

@ -85,7 +85,7 @@ void LyricsFetcherSearch::ProviderSearchFinished(const quint64 id, const LyricsS
LyricsSearchResults results_copy(results);
float higest_score = 0.0;
for (int i = 0 ; i < results_copy.count() ; ++i) {
for (int i = 0; i < results_copy.count(); ++i) {
results_copy[i].provider = provider->name();
results_copy[i].score = 0.0;
if (results_copy[i].artist.compare(request_.artist, Qt::CaseInsensitive) == 0) {

View File

@ -173,10 +173,12 @@ void MoodbarPipeline::NewPadCallback(GstElement*, GstPad *pad, gpointer data) {
gst_structure_get_int(structure, "rate", &rate);
gst_caps_unref(caps);
if (self->builder_)
if (self->builder_) {
self->builder_->Init(kBands, rate);
else
}
else {
qLog(Error) << "Builder does not exist";
}
}

View File

@ -63,7 +63,7 @@ void TagFetcher::StartFetch(const SongList &songs) {
}
if (have_fingerprints) {
for (int i = 0 ; i < songs_.count() ; ++i) {
for (int i = 0; i < songs_.count(); ++i) {
const Song &song = songs_[i];
emit Progress(song, tr("Identifying song"));
acoustid_client_->Start(i, song.fingerprint(), static_cast<int>(song.length_nanosec() / kNsecPerMsec));

View File

@ -268,8 +268,9 @@ void Organize::ProcessSomeFiles() {
}
// Clean up the temporary transcoded file
if (!task.transcoded_filename_.isEmpty())
if (!task.transcoded_filename_.isEmpty()) {
QFile::remove(task.transcoded_filename_);
}
tasks_complete_++;
}

View File

@ -543,8 +543,9 @@ void OrganizeDialog::UpdatePreviews() {
}
}
if (devices_)
if (devices_) {
AdjustSize();
}
}

View File

@ -135,15 +135,16 @@ QString OrganizeFormat::GetFilenameForSong(const Song &song, QString extension)
int ascii = 128;
if (allow_ascii_ext_) ascii = 255;
QString stripped;
for (int i = 0 ; i < filename.length() ; ++i) {
for (int i = 0; i < filename.length(); ++i) {
const QChar c = filename[i];
if (c.unicode() < ascii) {
stripped.append(c);
}
else {
const QString decomposition = c.decomposition();
if (!decomposition.isEmpty() && decomposition[0].unicode() < ascii)
if (!decomposition.isEmpty() && decomposition[0].unicode() < ascii) {
stripped.append(decomposition[0]);
}
}
}
filename = stripped;
@ -164,9 +165,9 @@ QString OrganizeFormat::GetFilenameForSong(const Song &song, QString extension)
// Fix any parts of the path that start with dots.
QStringList parts_old = filepath.split("/");
QStringList parts_new;
for (int i = 0 ; i < parts_old.count() ; ++i) {
for (int i = 0; i < parts_old.count(); ++i) {
QString part = parts_old[i];
for (int j = 0 ; j < kInvalidPrefixCharactersCount ; ++j) {
for (int j = 0; j < kInvalidPrefixCharactersCount; ++j) {
if (part.startsWith(kInvalidPrefixCharacters[j])) {
part = part.remove(0, 1);
break;
@ -195,7 +196,7 @@ QString OrganizeFormat::ParseBlock(QString block, const Song &song, bool *any_em
// Find any blocks first
int pos = 0;
QRegularExpressionMatch re_match;
for (re_match = block_regexp.match(block, pos) ; re_match.hasMatch() ; re_match = block_regexp.match(block, pos)) {
for (re_match = block_regexp.match(block, pos); re_match.hasMatch(); re_match = block_regexp.match(block, pos)) {
pos = re_match.capturedStart();
// Recursively parse the block
bool empty = false;
@ -210,7 +211,7 @@ QString OrganizeFormat::ParseBlock(QString block, const Song &song, bool *any_em
// Now look for tags
bool empty = false;
pos = 0;
for (re_match = tag_regexp.match(block, pos) ; re_match.hasMatch() ; re_match = tag_regexp.match(block, pos)) {
for (re_match = tag_regexp.match(block, pos); re_match.hasMatch(); re_match = tag_regexp.match(block, pos)) {
pos = re_match.capturedStart();
QString value = TagValue(re_match.captured(1), song);
if (value.isEmpty()) empty = true;
@ -228,42 +229,60 @@ QString OrganizeFormat::TagValue(const QString &tag, const Song &song) const {
QString value;
if (tag == "title")
if (tag == "title") {
value = song.title();
else if (tag == "album")
}
else if (tag == "album") {
value = song.album();
else if (tag == "artist")
}
else if (tag == "artist") {
value = song.artist();
else if (tag == "composer")
}
else if (tag == "composer") {
value = song.composer();
else if (tag == "performer")
}
else if (tag == "performer") {
value = song.performer();
else if (tag == "grouping")
}
else if (tag == "grouping") {
value = song.grouping();
else if (tag == "lyrics")
}
else if (tag == "lyrics") {
value = song.lyrics();
else if (tag == "genre")
}
else if (tag == "genre") {
value = song.genre();
else if (tag == "comment")
}
else if (tag == "comment") {
value = song.comment();
else if (tag == "year")
}
else if (tag == "year") {
value = QString::number(song.year());
else if (tag == "originalyear")
}
else if (tag == "originalyear") {
value = QString::number(song.effective_originalyear());
else if (tag == "track")
}
else if (tag == "track") {
value = QString::number(song.track());
else if (tag == "disc")
}
else if (tag == "disc") {
value = QString::number(song.disc());
else if (tag == "length")
}
else if (tag == "length") {
value = QString::number(song.length_nanosec() / kNsecPerSec);
else if (tag == "bitrate")
}
else if (tag == "bitrate") {
value = QString::number(song.bitrate());
else if (tag == "samplerate")
}
else if (tag == "samplerate") {
value = QString::number(song.samplerate());
else if (tag == "bitdepth")
}
else if (tag == "bitdepth") {
value = QString::number(song.bitdepth());
else if (tag == "extension")
}
else if (tag == "extension") {
value = QFileInfo(song.url().toLocalFile()).suffix();
}
else if (tag == "artistinitial") {
value = song.effective_albumartist().trimmed();
if (!value.isEmpty()) {
@ -298,10 +317,12 @@ QValidator::State OrganizeFormat::Validator::validate(QString &input, int&) cons
// Make sure all the blocks match up
int block_level = 0;
for (int i = 0; i < input.length(); ++i) {
if (input[i] == '{')
block_level++;
else if (input[i] == '}')
block_level--;
if (input[i] == '{') {
++block_level;
}
else if (input[i] == '}') {
--block_level;
}
if (block_level < 0 || block_level > 1) return QValidator::Invalid;
}
@ -311,10 +332,11 @@ QValidator::State OrganizeFormat::Validator::validate(QString &input, int&) cons
// Make sure the tags are valid
QRegularExpressionMatch re_match;
int pos = 0;
for (re_match = tag_regexp.match(input, pos) ; re_match.hasMatch() ; re_match = tag_regexp.match(input, pos)) {
for (re_match = tag_regexp.match(input, pos); re_match.hasMatch(); re_match = tag_regexp.match(input, pos)) {
pos = re_match.capturedStart();
if (!OrganizeFormat::kKnownTags.contains(re_match.captured(1)))
if (!OrganizeFormat::kKnownTags.contains(re_match.captured(1))) {
return QValidator::Invalid;
}
pos += re_match.capturedLength();
}
@ -323,14 +345,11 @@ QValidator::State OrganizeFormat::Validator::validate(QString &input, int&) cons
}
OrganizeFormat::SyntaxHighlighter::SyntaxHighlighter(QObject *parent)
: QSyntaxHighlighter(parent) {}
OrganizeFormat::SyntaxHighlighter::SyntaxHighlighter(QObject *parent) : QSyntaxHighlighter(parent) {}
OrganizeFormat::SyntaxHighlighter::SyntaxHighlighter(QTextEdit *parent)
: QSyntaxHighlighter(parent) {}
OrganizeFormat::SyntaxHighlighter::SyntaxHighlighter(QTextEdit *parent) : QSyntaxHighlighter(parent) {}
OrganizeFormat::SyntaxHighlighter::SyntaxHighlighter(QTextDocument *parent)
: QSyntaxHighlighter(parent) {}
OrganizeFormat::SyntaxHighlighter::SyntaxHighlighter(QTextDocument *parent) : QSyntaxHighlighter(parent) {}
void OrganizeFormat::SyntaxHighlighter::highlightBlock(const QString &text) {
@ -351,7 +370,7 @@ void OrganizeFormat::SyntaxHighlighter::highlightBlock(const QString &text) {
// Blocks
QRegularExpressionMatch re_match;
int pos = 0;
for (re_match = block_regexp.match(text, pos) ; re_match.hasMatch() ; re_match = block_regexp.match(text, pos)) {
for (re_match = block_regexp.match(text, pos); re_match.hasMatch(); re_match = block_regexp.match(text, pos)) {
pos = re_match.capturedStart();
setFormat(pos, re_match.capturedLength(), block_format);
pos += re_match.capturedLength();
@ -359,7 +378,7 @@ void OrganizeFormat::SyntaxHighlighter::highlightBlock(const QString &text) {
// Tags
pos = 0;
for (re_match = tag_regexp.match(text, pos) ; re_match.hasMatch() ; re_match = tag_regexp.match(text, pos)) {
for (re_match = tag_regexp.match(text, pos); re_match.hasMatch(); re_match = tag_regexp.match(text, pos)) {
pos = re_match.capturedStart();
QTextCharFormat f = format(pos);
f.setForeground(QColor(OrganizeFormat::kKnownTags.contains(re_match.captured(1)) ? valid_tag_color : invalid_tag_color));
@ -369,4 +388,3 @@ void OrganizeFormat::SyntaxHighlighter::highlightBlock(const QString &text) {
}
}

View File

@ -193,8 +193,9 @@ void OSDPretty::showEvent(QShowEvent *e) {
fader_->start(); // Timeout will be started in FaderFinished
}
else if (mode_ == Mode_Popup) {
if (!disable_duration())
if (!disable_duration()) {
timeout_->start();
}
// Ensures it is above when showing the preview
raise();
}
@ -370,18 +371,21 @@ void OSDPretty::ShowMessage(const QString &summary, const QString &message, cons
if (toggle_mode()) {
set_toggle_mode(false);
// If timeout is disabled, timer hadn't been started
if (!disable_duration())
if (!disable_duration()) {
timeout_->stop();
}
hide();
}
else {
if (!disable_duration())
if (!disable_duration()) {
timeout_->start(); // Restart the timer
}
}
}
else {
if (toggle_mode())
if (toggle_mode()) {
set_toggle_mode(false);
}
// The OSD is not visible, show it
show();
}
@ -402,10 +406,12 @@ void OSDPretty::setVisible(bool visible) {
void OSDPretty::FaderFinished() {
if (fader_->direction() == QTimeLine::Backward)
if (fader_->direction() == QTimeLine::Backward) {
hide();
else if (mode_ == Mode_Popup && !disable_duration())
}
else if (mode_ == Mode_Popup && !disable_duration()) {
timeout_->start();
}
}
@ -462,8 +468,10 @@ void OSDPretty::enterEvent(QEnterEvent*) {
#else
void OSDPretty::enterEvent(QEvent*) {
#endif
if (mode_ == Mode_Popup)
if (mode_ == Mode_Popup) {
setWindowOpacity(0.25);
}
}
void OSDPretty::leaveEvent(QEvent*) {
@ -472,8 +480,9 @@ void OSDPretty::leaveEvent(QEvent*) {
void OSDPretty::mousePressEvent(QMouseEvent *e) {
if (mode_ == Mode_Popup)
if (mode_ == Mode_Popup) {
hide();
}
else {
original_window_pos_ = pos();
#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))

View File

@ -503,8 +503,9 @@ int Playlist::NextVirtualIndex(int i, const bool ignore_repeat_track) const {
// This one's easy - if we have to repeat the current track then just return i
if (repeat_mode == PlaylistSequence::Repeat_Track && !ignore_repeat_track) {
if (!FilterContainsVirtualIndex(i))
if (!FilterContainsVirtualIndex(i)) {
return virtual_items_.count(); // It's not in the filter any more
}
return i;
}
@ -782,10 +783,12 @@ bool Playlist::dropMimeData(const QMimeData *data, Qt::DropAction action, int ro
if (const SongMimeData *song_data = qobject_cast<const SongMimeData*>(data)) {
// Dragged from a collection
// We want to check if these songs are from the actual local file backend, if they are we treat them differently.
if (song_data->backend && song_data->backend->songs_table() == SCollection::kSongsTable)
if (song_data->backend && song_data->backend->songs_table() == SCollection::kSongsTable) {
InsertSongItems<CollectionPlaylistItem>(song_data->songs, row, play_now, enqueue_now, enqueue_next_now);
else
}
else {
InsertSongItems<SongPlaylistItem>(song_data->songs, row, play_now, enqueue_now, enqueue_next_now);
}
}
else if (const PlaylistItemMimeData *item_data = qobject_cast<const PlaylistItemMimeData*>(data)) {
InsertItems(item_data->items_, row, play_now, enqueue_now, enqueue_next_now);
@ -1184,7 +1187,7 @@ void Playlist::UpdateItems(SongList songs) {
// then we remove song from our list because we will not need to check it again.
// And we also update undo actions.
for (int i = 0; i < items_.size() ; i++) {
for (int i = 0; i < items_.size(); i++) {
// Update current items list
QMutableListIterator<Song> it(songs);
while (it.hasNext()) {
@ -1203,7 +1206,7 @@ void Playlist::UpdateItems(SongList songs) {
items_[i] = new_item;
emit dataChanged(index(i, 0), index(i, ColumnCount - 1));
// Also update undo actions
for (int y = 0 ; y < undo_stack_->count() ; y++) {
for (int y = 0; y < undo_stack_->count(); y++) {
QUndoCommand *undo_action = const_cast<QUndoCommand*>(undo_stack_->command(i));
PlaylistUndoCommands::InsertItems *undo_action_insert = dynamic_cast<PlaylistUndoCommands::InsertItems*>(undo_action);
if (undo_action_insert) {
@ -1883,13 +1886,15 @@ void Playlist::Shuffle() {
int begin = 0;
if (current_item_index_.isValid()) {
if (new_items[0] != new_items[current_item_index_.row()])
if (new_items[0] != new_items[current_item_index_.row()]) {
std::swap(new_items[0], new_items[current_item_index_.row()]);
}
begin = 1;
}
if (dynamic_playlist_ && current_item_index_.isValid())
if (dynamic_playlist_ && current_item_index_.isValid()) {
begin += current_item_index_.row() + 1;
}
const int count = items_.count();
for (int i = begin; i < count; ++i) {
@ -1925,16 +1930,18 @@ void Playlist::ReshuffleIndices() {
if (playlist_sequence_->shuffle_mode() == PlaylistSequence::Shuffle_Off) {
// No shuffling - sort the virtual item list normally.
std::sort(virtual_items_.begin(), virtual_items_.end());
if (current_row() != -1)
if (current_row() != -1) {
current_virtual_index_ = virtual_items_.indexOf(current_row());
}
return;
}
// If the user is already playing a song, advance the begin iterator to only shuffle items that haven't been played yet.
QList<int>::iterator begin = virtual_items_.begin();
QList<int>::iterator end = virtual_items_.end();
if (current_virtual_index_ != -1)
if (current_virtual_index_ != -1) {
std::advance(begin, current_virtual_index_ + 1);
}
std::random_device rd;
std::mt19937 g(rd());

View File

@ -217,8 +217,9 @@ void PlaylistContainer::SetViewModel(Playlist *playlist, const int scroll_positi
UpdateNoMatchesLabel();
// Ensure that tab is current
if (ui_->tab_bar->current_id() != manager_->current_id())
if (ui_->tab_bar->current_id() != manager_->current_id()) {
ui_->tab_bar->set_current_id(manager_->current_id());
}
// Sort out the undo/redo actions
delete undo_;

View File

@ -235,8 +235,9 @@ QStyleOptionViewItem PlaylistDelegateBase::Adjusted(const QStyleOptionViewItem &
QPoint top_left(-view_->horizontalScrollBar()->value(), -view_->verticalScrollBar()->value());
if (view_->header()->logicalIndexAt(top_left) != idx.column())
if (view_->header()->logicalIndexAt(top_left) != idx.column()) {
return option;
}
QStyleOptionViewItem ret(option);
@ -327,8 +328,9 @@ QString DateItemDelegate::displayText(const QVariant &value, const QLocale &loca
bool ok = false;
qint64 time = value.toLongLong(&ok);
if (!ok || time == -1)
if (!ok || time == -1) {
return QString();
}
return QDateTime::fromSecsSinceEpoch(time).toString(QLocale::system().dateTimeFormat(QLocale::ShortFormat));
@ -339,8 +341,9 @@ QString LastPlayedItemDelegate::displayText(const QVariant &value, const QLocale
bool ok = false;
const qint64 time = value.toLongLong(&ok);
if (!ok || time == -1)
if (!ok || time == -1) {
return tr("Never");
}
return Utilities::Ago(time, locale);

View File

@ -165,10 +165,12 @@ class DropTailComparatorDecorator : public SearchTermComparator {
explicit DropTailComparatorDecorator(SearchTermComparator *cmp) : cmp_(cmp) {}
bool Matches(const QString &element) const override {
if (element.length() > 9)
if (element.length() > 9) {
return cmp_->Matches(element.left(element.length() - 9));
else
}
else {
return cmp_->Matches(element);
}
}
private:
QScopedPointer<SearchTermComparator> cmp_;
@ -406,10 +408,12 @@ FilterTree *FilterParser::parseSearchTerm() {
bool inQuotes = false;
for (; iter_ != end_; ++iter_) {
if (inQuotes) {
if (*iter_ == '"')
if (*iter_ == '"') {
inQuotes = false;
else
}
else {
buf_ += *iter_;
}
}
else {
if (*iter_ == '"') {

View File

@ -92,8 +92,9 @@ void PlaylistHeader::contextMenuEvent(QContextMenuEvent *e) {
menu_section_ = logicalIndexAt(e->pos());
if (menu_section_ == -1 || (menu_section_ == logicalIndex(0) && logicalIndex(1) == -1))
if (menu_section_ == -1 || (menu_section_ == logicalIndex(0) && logicalIndex(1) == -1)) {
action_hide_->setVisible(false);
}
else {
action_hide_->setVisible(true);
@ -112,7 +113,7 @@ void PlaylistHeader::contextMenuEvent(QContextMenuEvent *e) {
qDeleteAll(show_actions_);
show_actions_.clear();
for (int i = 0 ; i < count() ; ++i) {
for (int i = 0; i < count(); ++i) {
AddColumnAction(i);
}

View File

@ -141,7 +141,9 @@ void PlaylistItem::RemoveBackgroundColor(short priority) {
}
QColor PlaylistItem::GetCurrentBackgroundColor() const {
if (background_colors_.isEmpty()) return QColor();
if (background_colors_.isEmpty()) {
return QColor();
}
else {
QList<short> background_colors_keys = background_colors_.keys();
return background_colors_[background_colors_keys.last()];

View File

@ -461,10 +461,11 @@ void PlaylistManager::UpdateSummaryText() {
if (!range.isValid()) continue;
selected += range.bottom() - range.top() + 1;
for (int i = range.top() ; i <= range.bottom() ; ++i) {
for (int i = range.top(); i <= range.bottom(); ++i) {
qint64 length = range.model()->index(i, Playlist::Column_Length).data().toLongLong();
if (length > 0)
if (length > 0) {
nanoseconds += length;
}
}
}

View File

@ -377,12 +377,14 @@ void PlaylistTabBar::dragMoveEvent(QDragMoveEvent *e) {
e->setDropAction(Qt::CopyAction);
e->accept(tabRect(drag_hover_tab_));
if (!drag_hover_timer_.isActive())
if (!drag_hover_timer_.isActive()) {
drag_hover_timer_.start(kDragHoverTimeout, this);
}
}
else {
drag_hover_timer_.stop();
}
}
void PlaylistTabBar::dragLeaveEvent(QDragLeaveEvent*) {

View File

@ -75,16 +75,23 @@ RemoveItems::RemoveItems(Playlist *playlist, int pos, int count) : Base(playlist
}
void RemoveItems::redo() {
for (int i = 0; i < ranges_.count(); ++i)
for (int i = 0; i < ranges_.count(); ++i) {
ranges_[i].items_ = playlist_->RemoveItemsWithoutUndo(ranges_[i].pos_, ranges_[i].count_);
}
}
void RemoveItems::undo() {
for (int i = static_cast<int>(ranges_.count() - 1); i >= 0; --i)
for (int i = static_cast<int>(ranges_.count() - 1); i >= 0; --i) {
playlist_->InsertItemsWithoutUndo(ranges_[i].items_, ranges_[i].pos_);
}
}
bool RemoveItems::mergeWith(const QUndoCommand *other) {
const RemoveItems *remove_command = static_cast<const RemoveItems*>(other);
ranges_.append(remove_command->ranges_);
@ -93,6 +100,7 @@ bool RemoveItems::mergeWith(const QUndoCommand *other) {
setText(tr("remove %n songs", "", sum));
return true;
}

View File

@ -505,8 +505,9 @@ void PlaylistView::drawRow(QPainter *painter, const QStyleOptionViewItem &option
const_cast<PlaylistView*>(this)->last_glow_rect_ = opt.rect;
int step = glow_intensity_step_;
if (step >= kGlowIntensitySteps)
if (step >= kGlowIntensitySteps) {
step = 2 * (kGlowIntensitySteps - 1) - step + 1;
}
int row_height = opt.rect.height();
if (row_height != row_height_) {
@ -607,8 +608,9 @@ void PlaylistView::StopGlowing() {
void PlaylistView::StartGlowing() {
currently_glowing_ = true;
if (isVisible() && glow_enabled_)
if (isVisible() && glow_enabled_) {
glow_timer_.start(1500 / kGlowIntensitySteps, this);
}
}
@ -619,8 +621,9 @@ void PlaylistView::hideEvent(QHideEvent *e) {
void PlaylistView::showEvent(QShowEvent *e) {
if (currently_glowing_ && glow_enabled_)
if (currently_glowing_ && glow_enabled_) {
glow_timer_.start(1500 / kGlowIntensitySteps, this);
}
MaybeAutoscroll(Playlist::AutoScroll_Maybe);
@ -710,8 +713,9 @@ void PlaylistView::RemoveSelected() {
// Select the new current item, we want always the item after the last selected
if (new_idx.isValid()) {
// Workaround to update keyboard selected row, if it's not the first row (this also triggers selection)
if (new_row != 0)
if (new_row != 0) {
keyPressEvent(new QKeyEvent(QEvent::KeyPress, Qt::Key_Down, Qt::NoModifier));
}
// Update visual selection with the entire row
selectionModel()->select(new_idx, QItemSelectionModel::ClearAndSelect | QItemSelectionModel::Rows);
}
@ -742,8 +746,9 @@ QModelIndex PlaylistView::NextEditableIndex(const QModelIndex &current) {
QHeaderView *h = header();
int idx = columns.indexOf(h->visualIndex(current.column()));
if (idx + 1 >= columns.size())
if (idx + 1 >= columns.size()) {
return model()->index(current.row() + 1, h->logicalIndex(columns.first()));
}
return model()->index(current.row(), h->logicalIndex(columns[idx + 1]));
@ -755,8 +760,9 @@ QModelIndex PlaylistView::PrevEditableIndex(const QModelIndex &current) {
QHeaderView *h = header();
int idx = columns.indexOf(h->visualIndex(current.column()));
if (idx - 1 < 0)
if (idx - 1 < 0) {
return model()->index(current.row() - 1, h->logicalIndex(columns.last()));
}
return model()->index(current.row(), h->logicalIndex(columns[idx - 1]));
@ -780,19 +786,21 @@ void PlaylistView::closeEditor(QWidget *editor, QAbstractItemDelegate::EndEditHi
else if (hint == QAbstractItemDelegate::EditNextItem || hint == QAbstractItemDelegate::EditPreviousItem) {
QModelIndex idx;
if (hint == QAbstractItemDelegate::EditNextItem)
if (hint == QAbstractItemDelegate::EditNextItem) {
idx = NextEditableIndex(currentIndex());
else
idx = PrevEditableIndex(currentIndex());
if (!idx.isValid()) {
QTreeView::closeEditor(editor, QAbstractItemDelegate::SubmitModelCache);
}
else {
idx = PrevEditableIndex(currentIndex());
}
if (idx.isValid()) {
QTreeView::closeEditor(editor, QAbstractItemDelegate::NoHint);
setCurrentIndex(idx);
QAbstractItemView::edit(idx);
}
else {
QTreeView::closeEditor(editor, QAbstractItemDelegate::SubmitModelCache);
}
}
else {
QTreeView::closeEditor(editor, hint);
@ -905,7 +913,11 @@ void PlaylistView::InhibitAutoscrollTimeout() {
}
void PlaylistView::MaybeAutoscroll(const Playlist::AutoScroll autoscroll) {
if (autoscroll == Playlist::AutoScroll_Always || (autoscroll == Playlist::AutoScroll_Maybe && !inhibit_autoscroll_)) JumpToCurrentlyPlayingTrack();
if (autoscroll == Playlist::AutoScroll_Always || (autoscroll == Playlist::AutoScroll_Maybe && !inhibit_autoscroll_)) {
JumpToCurrentlyPlayingTrack();
}
}
void PlaylistView::JumpToCurrentlyPlayingTrack() {
@ -1077,10 +1089,12 @@ void PlaylistView::paintEvent(QPaintEvent *event) {
break;
case QAbstractItemView::OnViewport:
if (model()->rowCount() == 0)
if (model()->rowCount() == 0) {
drop_pos = 1;
else
}
else {
drop_pos = 1 + visualRect(model()->index(model()->rowCount() - 1, first_column)).bottom();
}
break;
}
@ -1123,23 +1137,29 @@ void PlaylistView::dragMoveEvent(QDragMoveEvent *event) {
}
void PlaylistView::dragEnterEvent(QDragEnterEvent *event) {
QTreeView::dragEnterEvent(event);
cached_tree_ = QPixmap();
drag_over_ = true;
}
void PlaylistView::dragLeaveEvent(QDragLeaveEvent *event) {
QTreeView::dragLeaveEvent(event);
cached_tree_ = QPixmap();
drag_over_ = false;
drop_indicator_row_ = -1;
}
void PlaylistView::dropEvent(QDropEvent *event) {
QTreeView::dropEvent(event);
cached_tree_ = QPixmap();
drop_indicator_row_ = -1;
drag_over_ = false;
}
void PlaylistView::PlaylistDestroyed() {
@ -1438,7 +1458,7 @@ void PlaylistView::set_background_image(const QImage &image) {
if (!background_image_.isNull()) {
// Apply opacity filter
uchar *bits = background_image_.bits();
for (int i = 0 ; i < background_image_.height() * background_image_.bytesPerLine() ; i += 4) {
for (int i = 0; i < background_image_.height() * background_image_.bytesPerLine(); i += 4) {
bits[i + 3] = (opacity_level_ / 100.0) * 255;
}

View File

@ -143,10 +143,12 @@ void SongLoaderInserter::AudioCDTagsLoaded(const bool success) {
SongLoader *loader = qobject_cast<SongLoader*>(sender());
if (!loader || !destination_) return;
if (success)
if (success) {
destination_->UpdateItems(loader->songs());
else
}
else {
qLog(Error) << "Error while getting audio CD metadata from MusicBrainz";
}
deleteLater();

View File

@ -51,7 +51,7 @@ SongList ASXParser::Load(QIODevice *device, const QString &playlist_path, const
// Some playlists have unescaped & characters in URLs :(
QRegularExpression ex("(href\\s*=\\s*\")([^\"]+)\"", QRegularExpression::CaseInsensitiveOption);
int index = 0;
for (QRegularExpressionMatch re_match = ex.match(data, index) ; re_match.hasMatch() ; re_match = ex.match(data, index)) {
for (QRegularExpressionMatch re_match = ex.match(data, index); re_match.hasMatch(); re_match = ex.match(data, index)) {
index = re_match.capturedStart();
QString url = re_match.captured(2);
url.replace(QRegularExpression("&(?!amp;|quot;|apos;|lt;|gt;)"), "&amp;");

View File

@ -110,8 +110,9 @@ QString ParserBase::URLOrFilename(const QUrl &url, const QDir &dir, Playlist::Pa
if (path_type != Playlist::Path_Absolute && QDir::isAbsolutePath(filename)) {
const QString relative = dir.relativeFilePath(filename);
if (!relative.startsWith("../") || path_type == Playlist::Path_Relative)
if (!relative.startsWith("../") || path_type == Playlist::Path_Relative) {
return relative;
}
}
return filename;

View File

@ -65,8 +65,9 @@ SongList PLSParser::Load(QIODevice *device, const QString &playlist_path, const
// Use the title and length we've already loaded if any
if (!songs[n].title().isEmpty()) song.set_title(songs[n].title());
if (songs[n].length_nanosec() != -1)
if (songs[n].length_nanosec() != -1) {
song.set_length_nanosec(songs[n].length_nanosec());
}
songs[n] = song;
}

View File

@ -708,7 +708,7 @@ void QobuzRequest::AlbumsFinishCheck(const QString &artist_id, const int limit,
// Get songs for all the albums.
QHash<QString, Request> ::iterator it;
for (it = album_songs_requests_pending_.begin() ; it != album_songs_requests_pending_.end() ; ++it) {
for (it = album_songs_requests_pending_.begin(); it != album_songs_requests_pending_.end(); ++it) {
Request request = it.value();
AddAlbumSongsRequest(request.artist_id, request.album_id, request.album_artist, request.album);
}

View File

@ -60,8 +60,9 @@ QModelIndex Queue::mapFromSource(const QModelIndex &source_index) const {
const int source_row = source_index.row();
for (int i = 0; i < source_indexes_.count(); ++i) {
if (source_indexes_[i].row() == source_row)
if (source_indexes_[i].row() == source_row) {
return index(i, source_index.column());
}
}
return QModelIndex();
@ -394,7 +395,7 @@ bool Queue::dropMimeData(const QMimeData *data, Qt::DropAction action, int row,
if (!source_indexes.isEmpty()) {
const int insert_point = row == -1 ? static_cast<int>(source_indexes_.count()) : row;
beginInsertRows(QModelIndex(), insert_point, insert_point + static_cast<int>(source_indexes.count() - 1));
for (int i = 0 ; i < source_indexes.count() ; ++i) {
for (int i = 0; i < source_indexes.count(); ++i) {
source_indexes_.insert(insert_point + i, source_indexes[i]);
}
endInsertRows();
@ -409,10 +410,12 @@ Qt::ItemFlags Queue::flags(const QModelIndex &idx) const {
Qt::ItemFlags flags = Qt::ItemIsEnabled | Qt::ItemIsSelectable;
if (idx.isValid())
if (idx.isValid()) {
flags |= Qt::ItemIsDragEnabled;
else
}
else {
flags |= Qt::ItemIsDropEnabled;
}
return flags;

View File

@ -143,8 +143,9 @@ void QueueView::MoveDown() {
QModelIndexList indexes = ui_->list->selectionModel()->selectedRows();
std::stable_sort(indexes.begin(), indexes.end());
if (indexes.isEmpty() || indexes.last().row() == current_playlist_->queue()->rowCount() - 1)
if (indexes.isEmpty() || indexes.last().row() == current_playlist_->queue()->rowCount() - 1) {
return;
}
for (int i = static_cast<int>(indexes.count() - 1); i >= 0; --i) {
current_playlist_->queue()->MoveDown(indexes[i].row());

View File

@ -397,7 +397,7 @@ void LastFMImport::GetRecentTracksRequestFinished(QNetworkReply *reply, const in
}
if (page == 1) {
for (int i = 2 ; i <= pages ; ++i) {
for (int i = 2; i <= pages; ++i) {
AddGetRecentTracksRequest(i);
}
}
@ -518,7 +518,7 @@ void LastFMImport::GetTopTracksRequestFinished(QNetworkReply *reply, const int p
else {
QJsonArray array_track = json_obj["track"].toArray();
for (QJsonArray::iterator it = array_track.begin() ; it != array_track.end() ; ++it) {
for (QJsonArray::iterator it = array_track.begin(); it != array_track.end(); ++it) {
const QJsonValue &value_track = *it;
@ -554,7 +554,7 @@ void LastFMImport::GetTopTracksRequestFinished(QNetworkReply *reply, const int p
}
if (page == 1) {
for (int i = 2 ; i <= pages ; ++i) {
for (int i = 2; i <= pages; ++i) {
AddGetTopTracksRequest(i);
}
}

View File

@ -168,7 +168,7 @@ void ScrobblerCache::WriteCache() {
QJsonArray array;
QHash <quint64, std::shared_ptr<ScrobblerCacheItem>> ::iterator i;
for (i = scrobbler_cache_.begin() ; i != scrobbler_cache_.end() ; ++i) {
for (i = scrobbler_cache_.begin(); i != scrobbler_cache_.end(); ++i) {
ScrobblerCacheItemPtr item = i.value();
QJsonObject object;
object.insert("timestamp", QJsonValue::fromVariant(item->timestamp_));

View File

@ -288,10 +288,12 @@ void AppearanceSettingsPage::Save() {
}
s.setValue(kBackgroundImageType, background_image_type_);
if (background_image_type_ == BackgroundImageType_Custom)
if (background_image_type_ == BackgroundImageType_Custom) {
s.setValue(kBackgroundImageFilename, background_image_filename_);
else
}
else {
s.remove(kBackgroundImageFilename);
}
BackgroundImagePosition backgroundimageposition = BackgroundImagePosition(ui_->combobox_backgroundimageposition->itemData(ui_->combobox_backgroundimageposition->currentIndex()).toInt());
s.setValue(kBackgroundImageMaxSize, ui_->spinbox_background_image_maxsize->value());

View File

@ -211,7 +211,9 @@ void BackendSettingsPage::Load() {
enginetype = ui_->combobox_engine->itemData(ui_->combobox_engine->currentIndex()).value<Engine::EngineType>();
QString output_name;
if (ui_->combobox_output->currentText().isEmpty()) output_name = engine()->DefaultOutput();
if (ui_->combobox_output->currentText().isEmpty()) {
output_name = engine()->DefaultOutput();
}
else {
EngineBase::OutputDetails output = ui_->combobox_output->itemData(ui_->combobox_output->currentIndex()).value<EngineBase::OutputDetails>();
output_name = output.name;
@ -439,7 +441,9 @@ void BackendSettingsPage::Save() {
QString output_name;
QVariant device_value;
if (ui_->combobox_output->currentText().isEmpty()) output_name = engine()->DefaultOutput();
if (ui_->combobox_output->currentText().isEmpty()) {
output_name = engine()->DefaultOutput();
}
else {
EngineBase::OutputDetails output = ui_->combobox_output->itemData(ui_->combobox_output->currentIndex()).value<EngineBase::OutputDetails>();
output_name = output.name;

View File

@ -205,10 +205,12 @@ void BehaviourSettingsPage::Load() {
#endif
QString name = language_map_.key(s.value("language").toString());
if (name.isEmpty())
if (name.isEmpty()) {
ui_->combobox_language->setCurrentIndex(0);
else
}
else {
ui_->combobox_language->setCurrentIndex(ui_->combobox_language->findText(name));
}
ui_->combobox_menuplaymode->setCurrentIndex(ui_->combobox_menuplaymode->findData(s.value("menu_playmode", PlayBehaviour_Never).toInt()));

View File

@ -138,7 +138,7 @@ void ContextSettingsPage::Load() {
ui_->context_custom_text1->setText(s.value(kSettingsTitleFmt, "%title% - %artist%").toString());
ui_->context_custom_text2->setText(s.value(kSettingsSummaryFmt, "%album%").toString());
for (int i = 0 ; i < ContextSettingsOrder::NELEMS ; ++i) {
for (int i = 0; i < ContextSettingsOrder::NELEMS; ++i) {
checkboxes_[i]->setChecked(s.value(kSettingsGroupEnable[i], checkboxes_[i]->isChecked()).toBool());
}

View File

@ -97,7 +97,7 @@ void CoversSettingsPage::Load() {
void CoversSettingsPage::Save() {
QStringList providers;
for (int i = 0 ; i < ui_->providers->count() ; ++i) {
for (int i = 0; i < ui_->providers->count(); ++i) {
const QListWidgetItem *item = ui_->providers->item(i);
if (item->checkState() == Qt::Checked) providers << item->text(); // clazy:exclude=reserve-candidates
}

View File

@ -297,12 +297,15 @@ void GlobalShortcutsSettingsPage::ItemClicked(QTreeWidgetItem *item) {
ui_->shortcut_options->setEnabled(true);
ui_->shortcut_options->setTitle(tr("Shortcut for %1").arg(shortcut.s.action->text()));
if (shortcut.key == shortcut.s.default_key)
if (shortcut.key == shortcut.s.default_key) {
ui_->radio_default->setChecked(true);
else if (shortcut.key.isEmpty())
}
else if (shortcut.key.isEmpty()) {
ui_->radio_none->setChecked(true);
else
}
else {
ui_->radio_custom->setChecked(true);
}
}

View File

@ -97,7 +97,7 @@ void LyricsSettingsPage::Load() {
void LyricsSettingsPage::Save() {
QStringList providers;
for (int i = 0 ; i < ui_->providers->count() ; ++i) {
for (int i = 0; i < ui_->providers->count(); ++i) {
const QListWidgetItem *item = ui_->providers->item(i);
if (item->checkState() == Qt::Checked) providers << item->text(); // clazy:exclude=reserve-candidates
}

View File

@ -111,8 +111,9 @@ NotificationsSettingsPage::NotificationsSettingsPage(SettingsDialog *dialog, QWi
QObject::connect(ui_->notifications_exp_chooser2, &QToolButton::triggered, this, &NotificationsSettingsPage::InsertVariableSecondLine);
QObject::connect(ui_->notifications_disable_duration, &QCheckBox::toggled, ui_->notifications_duration, &NotificationsSettingsPage::setDisabled);
if (!dialog->osd()->SupportsNativeNotifications())
if (!dialog->osd()->SupportsNativeNotifications()) {
ui_->notifications_native->setEnabled(false);
}
if (!dialog->osd()->SupportsTrayPopups()) ui_->notifications_tray->setEnabled(false);
QObject::connect(ui_->notifications_pretty, &QRadioButton::toggled, this, &NotificationsSettingsPage::UpdatePopupVisible);
@ -191,12 +192,15 @@ void NotificationsSettingsPage::Load() {
ui_->notifications_opacity->setValue(static_cast<int>(pretty_popup_->background_opacity() * 100));
QRgb color = pretty_popup_->background_color();
if (color == OSDPretty::kPresetBlue)
if (color == OSDPretty::kPresetBlue) {
ui_->notifications_bg_preset->setCurrentIndex(0);
else if (color == OSDPretty::kPresetRed)
}
else if (color == OSDPretty::kPresetRed) {
ui_->notifications_bg_preset->setCurrentIndex(1);
else
}
else {
ui_->notifications_bg_preset->setCurrentIndex(2);
}
ui_->notifications_bg_preset->setItemData(2, QColor(color), Qt::DecorationRole);
ui_->notifications_disable_duration->setChecked(pretty_popup_->disable_duration());
@ -285,8 +289,7 @@ void NotificationsSettingsPage::PrettyColorPresetChanged(int index) {
void NotificationsSettingsPage::ChooseBgColor() {
QColor color = QColorDialog::getColor(pretty_popup_->background_color(), this);
if (!color.isValid())
return;
if (!color.isValid()) return;
pretty_popup_->set_background_color(color.rgb());
ui_->notifications_bg_preset->setItemData(2, color, Qt::DecorationRole);
@ -298,8 +301,7 @@ void NotificationsSettingsPage::ChooseBgColor() {
void NotificationsSettingsPage::ChooseFgColor() {
QColor color = QColorDialog::getColor(pretty_popup_->foreground_color(), this);
if (!color.isValid())
return;
if (!color.isValid()) return;
pretty_popup_->set_foreground_color(color.rgb());

View File

@ -154,18 +154,24 @@ bool QobuzSettingsPage::eventFilter(QObject *object, QEvent *event) {
}
void QobuzSettingsPage::LogoutClicked() {
service_->Logout();
ui_->login_state->SetLoggedIn(LoginStateWidget::LoggedOut);
ui_->button_login->setEnabled(true);
}
void QobuzSettingsPage::LoginSuccess() {
if (!this->isVisible()) return;
ui_->login_state->SetLoggedIn(LoginStateWidget::LoggedIn);
ui_->button_login->setEnabled(true);
}
void QobuzSettingsPage::LoginFailure(const QString &failure_reason) {
if (!this->isVisible()) return;
QMessageBox::warning(this, tr("Authentication failed"), failure_reason);
}

View File

@ -198,19 +198,25 @@ void TidalSettingsPage::OAuthClicked(const bool enabled) {
}
void TidalSettingsPage::LogoutClicked() {
service_->Logout();
ui_->button_login->setEnabled(true);
ui_->login_state->SetLoggedIn(LoginStateWidget::LoggedOut);
}
void TidalSettingsPage::LoginSuccess() {
if (!this->isVisible()) return;
ui_->login_state->SetLoggedIn(LoginStateWidget::LoggedIn);
ui_->button_login->setEnabled(true);
}
void TidalSettingsPage::LoginFailure(const QString &failure_reason) {
if (!this->isVisible()) return;
QMessageBox::warning(this, tr("Authentication failed"), failure_reason);
ui_->button_login->setEnabled(true);
}

View File

@ -96,8 +96,9 @@ PlaylistItemList PlaylistQueryGenerator::GenerateMore(const int count) {
items << PlaylistItemPtr(PlaylistItem::NewFromSong(song));
previous_ids_ << song.id();
if (previous_ids_.count() > GetDynamicFuture() + GetDynamicHistory())
if (previous_ids_.count() > GetDynamicFuture() + GetDynamicHistory()) {
previous_ids_.removeFirst();
}
}
return items;

View File

@ -331,8 +331,9 @@ void SmartPlaylistQueryWizardPlugin::MoveTermListToBottom(int min, int max) {
Q_UNUSED(min);
// Only scroll to the bottom if a new term is added
if (previous_scrollarea_max_ < max)
if (previous_scrollarea_max_ < max) {
search_page_->ui_->terms_scroll_area->verticalScrollBar()->setValue(max);
}
previous_scrollarea_max_ = max;

View File

@ -101,22 +101,29 @@ QString SmartPlaylistSearchTerm::ToSql() const {
case Op_EndsWith:
return col + " LIKE '%" + value + "'";
case Op_Equals:
if (TypeOf(field_) == Type_Text)
if (TypeOf(field_) == Type_Text) {
return col + " LIKE '" + value + "'";
else if (TypeOf(field_) == Type_Date || TypeOf(field_) == Type_Time || TypeOf(field_) == Type_Rating)
}
else if (TypeOf(field_) == Type_Date || TypeOf(field_) == Type_Time || TypeOf(field_) == Type_Rating) {
return col + " = " + value;
else
}
else {
return col + " = '" + value + "'";
}
case Op_GreaterThan:
if (TypeOf(field_) == Type_Date || TypeOf(field_) == Type_Time || TypeOf(field_) == Type_Rating)
if (TypeOf(field_) == Type_Date || TypeOf(field_) == Type_Time || TypeOf(field_) == Type_Rating) {
return col + " > " + value;
else
}
else {
return col + " > '" + value + "'";
}
case Op_LessThan:
if (TypeOf(field_) == Type_Date || TypeOf(field_) == Type_Time || TypeOf(field_) == Type_Rating)
if (TypeOf(field_) == Type_Date || TypeOf(field_) == Type_Time || TypeOf(field_) == Type_Rating) {
return col + " < " + value;
else
}
else {
return col + " < '" + value + "'";
}
case Op_NumericDate:
return col + " > " + "DATETIME('now', '-" + value + " " + date + "', 'localtime')";
case Op_NumericDateNot:

View File

@ -87,8 +87,9 @@ QUrl SubsonicBaseRequest::CreateUrl(const QString &ressource_name, const QList<P
if (!url.path().isEmpty() && url.path().right(1) == "/") {
url.setPath(url.path() + QString("rest/") + ressource_name + QString(".view"));
}
else
else {
url.setPath(url.path() + QString("/rest/") + ressource_name + QString(".view"));
}
url.setQuery(url_query);

View File

@ -307,7 +307,7 @@ void SubsonicRequest::AlbumsFinishCheck(const int offset, const int size, const
if (albums_requests_queue_.isEmpty() && albums_requests_active_ <= 0) { // Albums list is finished, get songs for all albums.
for (QHash<QString, Request> ::iterator it = album_songs_requests_pending_.begin() ; it != album_songs_requests_pending_.end() ; ++it) {
for (QHash<QString, Request> ::iterator it = album_songs_requests_pending_.begin(); it != album_songs_requests_pending_.end(); ++it) {
Request request = it.value();
AddAlbumSongsRequest(request.artist_id, request.album_id, request.album_artist);
}

View File

@ -728,7 +728,7 @@ void TidalRequest::AlbumsFinishCheck(const QString &artist_id, const int limit,
// Get songs for all the albums.
for (QHash<QString, Request> ::iterator it = album_songs_requests_pending_.begin() ; it != album_songs_requests_pending_.end() ; ++it) {
for (QHash<QString, Request> ::iterator it = album_songs_requests_pending_.begin(); it != album_songs_requests_pending_.end(); ++it) {
Request request = it.value();
AddAlbumSongsRequest(request.artist_id, request.album_id, request.album_artist, request.album, request.album_explicit);
}

View File

@ -105,13 +105,13 @@ GstElement *Transcoder::CreateElementForMimeType(const QString &element_type, co
GstRegistry *registry = gst_registry_get();
GList *const features = gst_registry_get_feature_list(registry, GST_TYPE_ELEMENT_FACTORY);
for (GList *f = features ; f ; f = g_list_next(f)) {
for (GList *f = features; f; f = g_list_next(f)) {
GstElementFactory *factory = GST_ELEMENT_FACTORY(f->data);
// Is this the right type of plugin?
if (QString(gst_element_factory_get_klass(factory)).contains(element_type)) {
const GList *const templates = gst_element_factory_get_static_pad_templates(factory);
for (const GList *t = templates ; t ; t = g_list_next(t)) {
for (const GList *t = templates; t; t = g_list_next(t)) {
// Only interested in source pads
GstStaticPadTemplate *pad_template = reinterpret_cast<GstStaticPadTemplate*>(t->data);
if (pad_template->direction != GST_PAD_SRC) continue;
@ -484,9 +484,8 @@ bool Transcoder::event(QEvent *e) {
// Find this job in the list
JobStateList::iterator it = current_jobs_.begin();
while (it != current_jobs_.end()) {
for (; it != current_jobs_.end(); ++it) {
if (it->get() == finished_event->state_) break;
++it;
}
if (it == current_jobs_.end()) {
// Couldn't find it, maybe GStreamer gave us an event after we'd destroyed the pipeline?

View File

@ -65,22 +65,26 @@ void AutoExpandingTreeView::RecursivelyExpandSlot(const QModelIndex &idx) {
bool AutoExpandingTreeView::RecursivelyExpand(const QModelIndex &idx, int *count) {
if (!CanRecursivelyExpand(idx))
if (!CanRecursivelyExpand(idx)) {
return true;
}
if (model()->canFetchMore(idx))
if (model()->canFetchMore(idx)) {
model()->fetchMore(idx);
}
int children = model()->rowCount(idx);
if (*count + children > kRowsToShow)
if (*count + children > kRowsToShow) {
return false;
}
expand(idx);
*count += children;
for (int i = 0 ; i < children ; ++i) {
if (!RecursivelyExpand(model()->index(i, 0, idx), count))
for (int i = 0; i < children; ++i) {
if (!RecursivelyExpand(model()->index(i, 0, idx), count)) {
return false;
}
}
return true;

View File

@ -87,11 +87,13 @@ class FancyTabBar : public QTabBar { // clazy:exclude=missing-qobject-macro
QSize sizeHint() const override {
FancyTabWidget *tabWidget = qobject_cast<FancyTabWidget*>(parentWidget());
if (tabWidget->mode() == FancyTabWidget::Mode_Tabs || tabWidget->mode() == FancyTabWidget::Mode_IconOnlyTabs) return QTabBar::sizeHint();
if (tabWidget->mode() == FancyTabWidget::Mode_Tabs || tabWidget->mode() == FancyTabWidget::Mode_IconOnlyTabs) {
return QTabBar::sizeHint();
}
QSize size;
int h = 0;
for (int i = 0 ; i < count() ; ++i) {
for (int i = 0; i < count(); ++i) {
if (tabSizeHint(i).width() > size.width()) size.setWidth(tabSizeHint(i).width());
h += tabSizeHint(i).height();
}
@ -105,7 +107,7 @@ class FancyTabBar : public QTabBar { // clazy:exclude=missing-qobject-macro
FancyTabWidget *tabWidget = qobject_cast<FancyTabWidget*>(parentWidget());
if (tabWidget->mode() == FancyTabWidget::Mode_LargeSidebar || tabWidget->mode() == FancyTabWidget::Mode_SmallSidebar) {
int w = 0;
for (int i = 0 ; i < count() ; ++i) {
for (int i = 0; i < count(); ++i) {
if (tabSizeHint(i).width() > w) w = tabSizeHint(i).width();
}
return w;
@ -129,7 +131,7 @@ class FancyTabBar : public QTabBar { // clazy:exclude=missing-qobject-macro
// If the text of any tab is wider than the set width then use that instead.
int w = std::max(FancyTabWidget::TabSize_LargeSidebarMinWidth, tabWidget->iconsize_largesidebar() + 22);
for (int i = 0 ; i < count() ; ++i) {
for (int i = 0; i < count(); ++i) {
QRect rect = fm.boundingRect(QRect(0, 0, std::max(FancyTabWidget::TabSize_LargeSidebarMinWidth, tabWidget->iconsize_largesidebar() + 22), height()), Qt::TextWordWrap, QTabBar::tabText(i));
rect.setWidth(rect.width() + 10);
if (rect.width() > w) w = rect.width();
@ -168,8 +170,9 @@ class FancyTabBar : public QTabBar { // clazy:exclude=missing-qobject-macro
QPoint pos = event->pos();
mouseHoverTabIndex = tabAt(pos);
if (mouseHoverTabIndex > -1)
if (mouseHoverTabIndex > -1) {
update();
}
QTabBar::mouseMoveEvent(event);
}
@ -180,8 +183,9 @@ class FancyTabBar : public QTabBar { // clazy:exclude=missing-qobject-macro
bool verticalTextTabs = false;
if (tabWidget->mode() == FancyTabWidget::Mode_SmallSidebar)
if (tabWidget->mode() == FancyTabWidget::Mode_SmallSidebar) {
verticalTextTabs = true;
}
// if LargeSidebar, restore spacers
if (tabWidget->mode() == FancyTabWidget::Mode_LargeSidebar && spacers.count() > 0) {
@ -194,7 +198,7 @@ class FancyTabBar : public QTabBar { // clazy:exclude=missing-qobject-macro
}
else if (tabWidget->mode() != FancyTabWidget::Mode_LargeSidebar) {
// traverse in the opposite order to save indices of spacers
for (int i = count() - 1 ; i >= 0 ; --i) {
for (int i = count() - 1; i >= 0; --i) {
// spacers are disabled tabs
if (!isTabEnabled(i) && !spacers.contains(i)) {
spacers[i] = tabWidget->widget(i);
@ -206,7 +210,7 @@ class FancyTabBar : public QTabBar { // clazy:exclude=missing-qobject-macro
// Restore any label text that was hidden/cached for the IconOnlyTabs mode
if (labelCache.count() > 0 && tabWidget->mode() != FancyTabWidget::Mode_IconOnlyTabs) {
for (int i = 0 ; i < count() ; ++i) {
for (int i = 0; i < count(); ++i) {
setTabToolTip(i, "");
setTabText(i, labelCache[tabWidget->widget(i)]);
}
@ -215,7 +219,7 @@ class FancyTabBar : public QTabBar { // clazy:exclude=missing-qobject-macro
if (tabWidget->mode() != FancyTabWidget::Mode_LargeSidebar && tabWidget->mode() != FancyTabWidget::Mode_SmallSidebar) {
// Cache and hide label text for IconOnlyTabs mode
if (tabWidget->mode() == FancyTabWidget::Mode_IconOnlyTabs && labelCache.count() == 0) {
for(int i = 0 ; i < count() ; ++i) {
for(int i = 0; i < count(); ++i) {
labelCache[tabWidget->widget(i)] = tabText(i);
setTabToolTip(i, tabText(i));
setTabText(i, "");
@ -486,7 +490,7 @@ void FancyTabWidget::Load(const QString &kSettingsGroup) {
s.endGroup();
QMultiMap <int, TabData*> ::iterator i;
for (i = tabs.begin() ; i != tabs.end() ; ++i) {
for (i = tabs.begin(); i != tabs.end(); ++i) {
TabData *tab = i.value();
const int idx = insertTab(i.key(), tab->page(), tab->icon(), tab->label());
tabBar()->setTabData(idx, QVariant(tab->name()));

View File

@ -113,10 +113,14 @@ void FileView::ReloadSettings() {
}
void FileView::SetPath(const QString &path) {
if (!model_)
lazy_set_path_ = path;
else
if (model_) {
ChangeFilePathWithoutUndo(path);
}
else {
lazy_set_path_ = path;
}
}
void FileView::SetTaskManager(TaskManager *task_manager) {
@ -150,12 +154,14 @@ void FileView::ChangeFilePath(const QString &new_path_native) {
QString new_path = QDir::fromNativeSeparators(new_path_native);
QFileInfo info(new_path);
if (!info.exists() || !info.isDir())
if (!info.exists() || !info.isDir()) {
return;
}
QString old_path(model_->rootPath());
if (old_path == new_path)
if (old_path == new_path) {
return;
}
undo_stack_->push(new UndoCommand(this, new_path));
@ -180,8 +186,9 @@ void FileView::ItemActivated(const QModelIndex &idx) {
void FileView::ItemDoubleClick(const QModelIndex &idx) {
if (model_->isDir(idx))
if (model_->isDir(idx)) {
return;
}
QString file_path = model_->filePath(idx);
@ -287,4 +294,3 @@ void FileView::keyPressEvent(QKeyEvent *e) {
QWidget::keyPressEvent(e);
}

View File

@ -71,8 +71,9 @@ QList<QUrl> FileViewList::UrlListFromSelection() const {
QList<QUrl> urls;
const QModelIndexList indexes = menu_selection_.indexes();
for (const QModelIndex &index : indexes) {
if (index.column() == 0)
if (index.column() == 0) {
urls << QUrl::fromLocalFile(qobject_cast<QFileSystemModel*>(model())->fileInfo(index).canonicalFilePath());
}
}
std::sort(urls.begin(), urls.end());
@ -122,8 +123,9 @@ QStringList FileViewList::FilenamesFromSelection() const {
QStringList filenames;
const QModelIndexList indexes = menu_selection_.indexes();
for (const QModelIndex &index : indexes) {
if (index.column() == 0)
if (index.column() == 0) {
filenames << qobject_cast<QFileSystemModel*>(model())->filePath(index);
}
}
return filenames;

Some files were not shown because too many files have changed in this diff Show More