1
0
mirror of https://github.com/strawberrymusicplayer/strawberry synced 2024-12-18 11:39:31 +01:00

Formatting

This commit is contained in:
Jonas Kvinge 2019-04-12 19:55:19 +02:00
parent 77903a5ecd
commit 368bb54870
10 changed files with 29 additions and 36 deletions

View File

@ -37,8 +37,8 @@
#define DataCommaSizeFromQString(x) x.toUtf8().constData(), x.toUtf8().length()
// Reads and writes uint32 length encoded protobufs to a socket.
// This base QObject is separate from AbstractMessageHandler because moc can't
// handle templated classes. Use AbstractMessageHandler instead.
// This base QObject is separate from AbstractMessageHandler because moc can't handle templated classes.
// Use AbstractMessageHandler instead.
class _MessageHandlerBase : public QObject {
Q_OBJECT
@ -76,8 +76,7 @@ protected:
};
// Reads and writes uint32 length encoded MessageType messages to a socket.
// You should subclass this and implement the MessageArrived(MessageType)
// method.
// You should subclass this and implement the MessageArrived(MessageType) method.
template <typename MT>
class AbstractMessageHandler : public _MessageHandlerBase {
public:
@ -87,21 +86,19 @@ public:
typedef MT MessageType;
typedef MessageReply<MT> ReplyType;
// Serialises the message and writes it to the socket. This version MUST be
// called from the thread in which the AbstractMessageHandler was created.
// Serialises the message and writes it to the socket.
// This version MUST be called from the thread in which the AbstractMessageHandler was created.
void SendMessage(const MessageType &message);
// Serialises the message and writes it to the socket. This version may be
// called from any thread.
// Serialises the message and writes it to the socket.
// This version may be called from any thread.
void SendMessageAsync(const MessageType &message);
// Sends the request message inside and takes ownership of the MessageReply.
// The MessageReply's Finished() signal will be emitted when a reply arrives
// with the same ID. Must be called from my thread.
// The MessageReply's Finished() signal will be emitted when a reply arrives with the same ID. Must be called from my thread.
void SendRequest(ReplyType *reply);
// Sets the "id" field of reply to the same as the request, and sends the
// reply on the socket. Used on the worker side.
// Sets the "id" field of reply to the same as the request, and sends the reply on the socket. Used on the worker side.
void SendReply(const MessageType &request, MessageType *reply);
protected:
@ -131,8 +128,7 @@ void AbstractMessageHandler<MT>::SendMessage(const MessageType &message) {
template <typename MT>
void AbstractMessageHandler<MT>::SendMessageAsync(const MessageType &message) {
std::string data = message.SerializeAsString();
metaObject()->invokeMethod(this, "WriteMessage", Qt::QueuedConnection,
Q_ARG(QByteArray, QByteArray(data.data(), data.size())));
metaObject()->invokeMethod(this, "WriteMessage", Qt::QueuedConnection, Q_ARG(QByteArray, QByteArray(data.data(), data.size())));
}
template<typename MT>
@ -159,7 +155,8 @@ bool AbstractMessageHandler<MT>::RawMessageArrived(const QByteArray &data) {
if (reply) {
// This is a reply to a message that we created earlier.
reply->SetReply(message);
} else {
}
else {
MessageArrived(message);
}

View File

@ -22,4 +22,4 @@ class QObject;
void WaitForSignal(QObject *sender, const char *signal);
#endif // WAITFORSIGNAL_H
#endif // WAITFORSIGNAL_H

View File

@ -114,8 +114,7 @@ private:
template <typename T>
Worker *FindWorker(T Worker::*member, T value) {
for (typename QList<Worker>::iterator it = workers_.begin() ;
it != workers_.end() ; ++it) {
for (typename QList<Worker>::iterator it = workers_.begin() ; it != workers_.end() ; ++it) {
if ((*it).*member == value) {
return &(*it);
}
@ -158,8 +157,7 @@ template <typename HandlerType>
WorkerPool<HandlerType>::WorkerPool(QObject *parent)
: _WorkerPoolBase(parent),
next_worker_(0),
next_id_(0)
{
next_id_(0) {
worker_count_ = qBound(1, QThread::idealThreadCount() / 2, 2);
local_server_name_ = qApp->applicationName().toLower();
@ -396,4 +394,3 @@ HandlerType *WorkerPool<HandlerType>::NextHandler() const {
}
#endif // WORKERPOOL_H

View File

@ -41,4 +41,4 @@ private:
TagReader tag_reader_;
};
#endif // TAGREADERWORKER_H
#endif // TAGREADERWORKER_H

View File

@ -595,7 +595,8 @@ bool Database::IntegrityCheck(QSqlDatabase db) {
if (message == "ok") {
ok = true;
break;
} else {
}
else {
if (!error_reported) { app_->AddError(tr("Database corruption detected.")); }
app_->AddError("Database: " + message);
error_reported = true;
@ -677,9 +678,9 @@ void Database::BackupFile(const QString &filename) {
do {
ret = sqlite3_backup_step(backup, 16);
const int page_count = sqlite3_backup_pagecount(backup);
app_->task_manager()->SetTaskProgress(
task_id, page_count - sqlite3_backup_remaining(backup), page_count);
} while (ret == SQLITE_OK);
app_->task_manager()->SetTaskProgress(task_id, page_count - sqlite3_backup_remaining(backup), page_count);
}
while (ret == SQLITE_OK);
if (ret != SQLITE_DONE) {
qLog(Error) << "Database backup failed";

View File

@ -1321,7 +1321,7 @@ void MainWindow::AddToPlaylist(QAction *action) {
}
SongList songs;
for (const PlaylistItemPtr &item : items) {
for (const PlaylistItemPtr item : items) {
songs << item->Metadata();
}
@ -1587,7 +1587,7 @@ void MainWindow::EditTracks() {
void MainWindow::EditTagDialogAccepted() {
for (const PlaylistItemPtr &item : edit_tag_dialog_->playlist_items()) {
for (const PlaylistItemPtr item : edit_tag_dialog_->playlist_items()) {
item->Reload();
}
@ -2256,7 +2256,7 @@ void MainWindow::AutoCompleteTags() {
void MainWindow::AutoCompleteTagsAccepted() {
for (const PlaylistItemPtr &item : autocomplete_tag_items_) {
for (const PlaylistItemPtr item : autocomplete_tag_items_) {
item->Reload();
}

View File

@ -265,8 +265,6 @@ bool RemoveRecursive(const QString &path) {
return dir.rmdir(path);
return true;
}
bool CopyRecursive(const QString &source, const QString &destination) {

View File

@ -861,7 +861,7 @@ void Playlist::InsertItems(const PlaylistItemList &itemsIn, int pos, bool play_n
// exercise vetoes
SongList songs;
for (const PlaylistItemPtr &item : items) {
for (const PlaylistItemPtr item : items) {
songs << item->Metadata();
}
@ -1736,7 +1736,7 @@ QSortFilterProxyModel *Playlist::proxy() const { return proxy_; }
SongList Playlist::GetAllSongs() const {
SongList ret;
for (const PlaylistItemPtr &item : items_) {
for (const PlaylistItemPtr item : items_) {
ret << item->Metadata();
}
return ret;
@ -1746,7 +1746,7 @@ PlaylistItemList Playlist::GetAllItems() const { return items_; }
quint64 Playlist::GetTotalLength() const {
quint64 ret = 0;
for (const PlaylistItemPtr &item : items_) {
for (const PlaylistItemPtr item : items_) {
quint64 length = item->Metadata().length_nanosec();
if (length > 0) ret += length;
}

View File

@ -292,7 +292,7 @@ void PlaylistBackend::SavePlaylist(int playlist, const PlaylistItemList &items,
if (db_->CheckErrors(clear)) return;
// Save the new ones
for (const PlaylistItemPtr &item : items) {
for (const PlaylistItemPtr item : items) {
insert.bindValue(":playlist", playlist);
item->BindToQuery(&insert);

View File

@ -451,7 +451,7 @@ void PlaylistManager::SongsDiscovered(const SongList &songs) {
for (const Song &song : songs) {
for (const Data &data : playlists_) {
PlaylistItemList items = data.p->collection_items_by_id(song.id());
for (PlaylistItemPtr &item : items) {
for (const PlaylistItemPtr item : items) {
if (item->Metadata().directory_id() != song.directory_id()) continue;
static_cast<CollectionPlaylistItem*>(item.get())->SetMetadata(song);
data.p->ItemChanged(item);