diff --git a/3rdparty/qocoa/main.cpp b/3rdparty/qocoa/main.cpp index 33e7eb8d..51ab0d66 100644 --- a/3rdparty/qocoa/main.cpp +++ b/3rdparty/qocoa/main.cpp @@ -1,4 +1,4 @@ -#include +#include #include "gallery.h" int main(int argc, char *argv[]) diff --git a/3rdparty/qocoa/qbutton.h b/3rdparty/qocoa/qbutton.h index 0578edf9..920399c3 100644 --- a/3rdparty/qocoa/qbutton.h +++ b/3rdparty/qocoa/qbutton.h @@ -3,6 +3,7 @@ #include #include +#include class QButtonPrivate; class QButton : public QWidget diff --git a/3rdparty/qocoa/qbutton_nonmac.cpp b/3rdparty/qocoa/qbutton_nonmac.cpp index 0a79e2ba..4a78bb7f 100644 --- a/3rdparty/qocoa/qbutton_nonmac.cpp +++ b/3rdparty/qocoa/qbutton_nonmac.cpp @@ -20,12 +20,19 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -#include "qbutton.h" - +#include +#include +#include +#include +#include +#include +#include +#include +#include #include #include -#include -#include + +#include "qbutton.h" class QButtonPrivate : public QObject { diff --git a/3rdparty/qocoa/qocoa_mac.h b/3rdparty/qocoa/qocoa_mac.h index ced43117..9d2d5d4b 100644 --- a/3rdparty/qocoa/qocoa_mac.h +++ b/3rdparty/qocoa/qocoa_mac.h @@ -21,8 +21,9 @@ THE SOFTWARE. */ #include +#include #include -#include +#include #include static inline NSString* fromQString(const QString &string) diff --git a/3rdparty/qocoa/qprogressindicatorspinning.h b/3rdparty/qocoa/qprogressindicatorspinning.h index ae40a92a..c987e2e6 100644 --- a/3rdparty/qocoa/qprogressindicatorspinning.h +++ b/3rdparty/qocoa/qprogressindicatorspinning.h @@ -17,8 +17,7 @@ public: Aqua = 12 }; - explicit QProgressIndicatorSpinning(QWidget *parent, - Thickness thickness = Default); + explicit QProgressIndicatorSpinning(QWidget *parent, Thickness thickness = Default); public slots: void animate(bool animate = true); private: diff --git a/3rdparty/qocoa/qprogressindicatorspinning_nonmac.cpp b/3rdparty/qocoa/qprogressindicatorspinning_nonmac.cpp index 6cbded6c..5cc8fdff 100644 --- a/3rdparty/qocoa/qprogressindicatorspinning_nonmac.cpp +++ b/3rdparty/qocoa/qprogressindicatorspinning_nonmac.cpp @@ -20,11 +20,16 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -#include "qprogressindicatorspinning.h" - -#include -#include +#include +#include +#include +#include #include +#include +#include +#include + +#include "qprogressindicatorspinning.h" class QProgressIndicatorSpinningPrivate : public QObject { diff --git a/3rdparty/qocoa/qsearchfield.h b/3rdparty/qocoa/qsearchfield.h index f2a0561e..d8515171 100644 --- a/3rdparty/qocoa/qsearchfield.h +++ b/3rdparty/qocoa/qsearchfield.h @@ -2,7 +2,11 @@ #define QSEARCHFIELD_H #include +#include #include +#include +#include +#include class QSearchFieldPrivate; class QSearchField : public QWidget diff --git a/3rdparty/qocoa/qsearchfield_nonmac.cpp b/3rdparty/qocoa/qsearchfield_nonmac.cpp index c5556d22..31641bf6 100644 --- a/3rdparty/qocoa/qsearchfield_nonmac.cpp +++ b/3rdparty/qocoa/qsearchfield_nonmac.cpp @@ -20,18 +20,22 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -#include "qsearchfield.h" -#include "../../src/core/iconloader.h" - +#include +#include +#include #include -#include -#include -#include -#include +#include +#include +#include +#include #include +#include +#include +#include +#include -#include -#include +#include "../../src/core/iconloader.h" +#include "qsearchfield.h" class QSearchFieldPrivate : public QObject { diff --git a/3rdparty/qsqlite/qsql_sqlite.cpp b/3rdparty/qsqlite/qsql_sqlite.cpp index 33d02284..1b6426e3 100644 --- a/3rdparty/qsqlite/qsql_sqlite.cpp +++ b/3rdparty/qsqlite/qsql_sqlite.cpp @@ -41,24 +41,31 @@ #include "qsql_sqlite.h" -#include -#include -#include -#include -#include -#include -#include -#include -#include - #if defined Q_OS_WIN -# include + #include #else -# include + #include #endif +#include #include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + Q_DECLARE_OPAQUE_POINTER(sqlite3*) Q_DECLARE_METATYPE(sqlite3*) @@ -98,16 +105,11 @@ static QVariant::Type qGetColumnType(const QString &tpName) return QVariant::String; } -static QSqlError qMakeError(sqlite3 *access, const QString &descr, QSqlError::ErrorType type, - int errorCode = -1) -{ - return QSqlError(descr, - QString(reinterpret_cast(sqlite3_errmsg16(access))), - type, errorCode); +static QSqlError qMakeError(sqlite3 *access, const QString &descr, QSqlError::ErrorType type, int errorCode = -1) { + return QSqlError(descr, QString(reinterpret_cast(sqlite3_errmsg16(access))), type, errorCode); } -class QSQLiteDriverPrivate -{ +class QSQLiteDriverPrivate { public: inline QSQLiteDriverPrivate() : access(0) {} sqlite3 *access; @@ -115,8 +117,7 @@ public: }; -class QSQLiteResultPrivate -{ +class QSQLiteResultPrivate { public: QSQLiteResultPrivate(QSQLiteResult *res); void cleanup(); @@ -141,8 +142,7 @@ QSQLiteResultPrivate::QSQLiteResultPrivate(QSQLiteResult* res) : q(res), access( { } -void QSQLiteResultPrivate::cleanup() -{ +void QSQLiteResultPrivate::cleanup() { finalize(); rInf.clear(); skippedStatus = false; @@ -152,17 +152,14 @@ void QSQLiteResultPrivate::cleanup() q->cleanup(); } -void QSQLiteResultPrivate::finalize() -{ - if (!stmt) - return; +void QSQLiteResultPrivate::finalize() { + if (!stmt) return; sqlite3_finalize(stmt); stmt = 0; } -void QSQLiteResultPrivate::initColumns(bool emptyResultset) -{ +void QSQLiteResultPrivate::initColumns(bool emptyResultset) { int nCols = sqlite3_column_count(stmt); if (nCols <= 0) return; @@ -170,13 +167,10 @@ void QSQLiteResultPrivate::initColumns(bool emptyResultset) q->init(nCols); for (int i = 0; i < nCols; ++i) { - QString colName = QString(reinterpret_cast( - sqlite3_column_name16(stmt, i)) - ).remove(QLatin1Char('"')); + QString colName = QString(reinterpret_cast(sqlite3_column_name16(stmt, i))).remove(QLatin1Char('"')); // must use typeName for resolving the type to match QSqliteDriver::record - QString typeName = QString(reinterpret_cast( - sqlite3_column_decltype16(stmt, i))); + QString typeName = QString(reinterpret_cast(sqlite3_column_decltype16(stmt, i))); // sqlite3_column_type is documented to have undefined behavior if the result set is empty int stp = emptyResultset ? -1 : sqlite3_column_type(stmt, i); @@ -184,7 +178,8 @@ void QSQLiteResultPrivate::initColumns(bool emptyResultset) if (!typeName.isEmpty()) { fieldType = qGetColumnType(typeName); - } else { + } + else { // Get the proper type for the field based on stp value switch (stp) { case SQLITE_INTEGER: @@ -213,8 +208,7 @@ void QSQLiteResultPrivate::initColumns(bool emptyResultset) } } -bool QSQLiteResultPrivate::fetchNext(ClementineSqlCachedResult::ValueCache &values, int idx, bool initialFetch) -{ +bool QSQLiteResultPrivate::fetchNext(ClementineSqlCachedResult::ValueCache &values, int idx, bool initialFetch) { int res; int i; @@ -234,8 +228,7 @@ bool QSQLiteResultPrivate::fetchNext(ClementineSqlCachedResult::ValueCache &valu } if (!stmt) { - q->setLastError(QSqlError(QCoreApplication::translate("QSQLiteResult", "Unable to fetch row"), - QCoreApplication::translate("QSQLiteResult", "No query"), QSqlError::ConnectionError)); + q->setLastError(QSqlError(QCoreApplication::translate("QSQLiteResult", "Unable to fetch row"), QCoreApplication::translate("QSQLiteResult", "No query"), QSqlError::ConnectionError)); q->setAt(QSql::AfterLastRow); return false; } @@ -252,9 +245,7 @@ bool QSQLiteResultPrivate::fetchNext(ClementineSqlCachedResult::ValueCache &valu for (i = 0; i < rInf.count(); ++i) { switch (sqlite3_column_type(stmt, i)) { case SQLITE_BLOB: - values[i + idx] = QByteArray(static_cast( - sqlite3_column_blob(stmt, i)), - sqlite3_column_bytes(stmt, i)); + values[i + idx] = QByteArray(static_cast(sqlite3_column_blob(stmt, i)), sqlite3_column_bytes(stmt, i)); break; case SQLITE_INTEGER: values[i + idx] = sqlite3_column_int64(stmt, i); @@ -278,9 +269,7 @@ bool QSQLiteResultPrivate::fetchNext(ClementineSqlCachedResult::ValueCache &valu values[i + idx] = QVariant(QVariant::String); break; default: - values[i + idx] = QString(reinterpret_cast( - sqlite3_column_text16(stmt, i)), - sqlite3_column_bytes16(stmt, i) / sizeof(QChar)); + values[i + idx] = QString(reinterpret_cast(sqlite3_column_text16(stmt, i)), sqlite3_column_bytes16(stmt, i) / sizeof(QChar)); break; } } @@ -297,16 +286,14 @@ bool QSQLiteResultPrivate::fetchNext(ClementineSqlCachedResult::ValueCache &valu // SQLITE_ERROR is a generic error code and we must call sqlite3_reset() // to get the specific error message. res = sqlite3_reset(stmt); - q->setLastError(qMakeError(access, QCoreApplication::translate("QSQLiteResult", - "Unable to fetch row"), QSqlError::ConnectionError, res)); + q->setLastError(qMakeError(access, QCoreApplication::translate("QSQLiteResult", "Unable to fetch row"), QSqlError::ConnectionError, res)); q->setAt(QSql::AfterLastRow); return false; case SQLITE_MISUSE: case SQLITE_BUSY: default: // something wrong, don't get col info, but still return false - q->setLastError(qMakeError(access, QCoreApplication::translate("QSQLiteResult", - "Unable to fetch row"), QSqlError::ConnectionError, res)); + q->setLastError(qMakeError(access, QCoreApplication::translate("QSQLiteResult", "Unable to fetch row"), QSqlError::ConnectionError, res)); sqlite3_reset(stmt); q->setAt(QSql::AfterLastRow); return false; @@ -315,15 +302,13 @@ bool QSQLiteResultPrivate::fetchNext(ClementineSqlCachedResult::ValueCache &valu } QSQLiteResult::QSQLiteResult(const QSQLiteDriver* db) - : ClementineSqlCachedResult(db) -{ + : ClementineSqlCachedResult(db) { d = new QSQLiteResultPrivate(this); d->access = db->d->access; db->d->results.append(this); } -QSQLiteResult::~QSQLiteResult() -{ +QSQLiteResult::~QSQLiteResult() { const QSqlDriver *sqlDriver = driver(); if (sqlDriver) qobject_cast(sqlDriver)->d->results.removeOne(this); @@ -331,20 +316,17 @@ QSQLiteResult::~QSQLiteResult() delete d; } -void QSQLiteResult::virtual_hook(int id, void *data) -{ +void QSQLiteResult::virtual_hook(int id, void *data) { ClementineSqlCachedResult::virtual_hook(id, data); } -bool QSQLiteResult::reset(const QString &query) -{ +bool QSQLiteResult::reset(const QString &query) { if (!prepare(query)) return false; return exec(); } -bool QSQLiteResult::prepare(const QString &query) -{ +bool QSQLiteResult::prepare(const QString &query) { if (!driver() || !driver()->isOpen() || driver()->isOpenError()) return false; @@ -355,29 +337,25 @@ bool QSQLiteResult::prepare(const QString &query) const void *pzTail = NULL; #if (SQLITE_VERSION_NUMBER >= 3003011) - int res = sqlite3_prepare16_v2(d->access, query.constData(), (query.size() + 1) * sizeof(QChar), - &d->stmt, &pzTail); + int res = sqlite3_prepare16_v2(d->access, query.constData(), (query.size() + 1) * sizeof(QChar), &d->stmt, &pzTail); #else - int res = sqlite3_prepare16(d->access, query.constData(), (query.size() + 1) * sizeof(QChar), - &d->stmt, &pzTail); + int res = sqlite3_prepare16(d->access, query.constData(), (query.size() + 1) * sizeof(QChar), &d->stmt, &pzTail); #endif if (res != SQLITE_OK) { - setLastError(qMakeError(d->access, QCoreApplication::translate("QSQLiteResult", - "Unable to execute statement"), QSqlError::StatementError, res)); + setLastError(qMakeError(d->access, QCoreApplication::translate("QSQLiteResult", "Unable to execute statement"), QSqlError::StatementError, res)); d->finalize(); return false; - } else if (pzTail && !QString(reinterpret_cast(pzTail)).trimmed().isEmpty()) { - setLastError(qMakeError(d->access, QCoreApplication::translate("QSQLiteResult", - "Unable to execute multiple statements at a time"), QSqlError::StatementError, SQLITE_MISUSE)); + } + else if (pzTail && !QString(reinterpret_cast(pzTail)).trimmed().isEmpty()) { + setLastError(qMakeError(d->access, QCoreApplication::translate("QSQLiteResult", "Unable to execute multiple statements at a time"), QSqlError::StatementError, SQLITE_MISUSE)); d->finalize(); return false; } return true; } -bool QSQLiteResult::exec() -{ +bool QSQLiteResult::exec() { const QVector values = boundValues(); d->skippedStatus = false; @@ -388,8 +366,7 @@ bool QSQLiteResult::exec() int res = sqlite3_reset(d->stmt); if (res != SQLITE_OK) { - setLastError(qMakeError(d->access, QCoreApplication::translate("QSQLiteResult", - "Unable to reset statement"), QSqlError::StatementError, res)); + setLastError(qMakeError(d->access, QCoreApplication::translate("QSQLiteResult", "Unable to reset statement"), QSqlError::StatementError, res)); d->finalize(); return false; } @@ -401,7 +378,8 @@ bool QSQLiteResult::exec() if (value.isNull()) { res = sqlite3_bind_null(d->stmt, i + 1); - } else { + } + else { switch (value.type()) { case QVariant::ByteArray: { const QByteArray *ba = static_cast(value.constData()); @@ -434,13 +412,13 @@ bool QSQLiteResult::exec() } } if (res != SQLITE_OK) { - setLastError(qMakeError(d->access, QCoreApplication::translate("QSQLiteResult", - "Unable to bind parameters"), QSqlError::StatementError, res)); + setLastError(qMakeError(d->access, QCoreApplication::translate("QSQLiteResult", "Unable to bind parameters"), QSqlError::StatementError, res)); d->finalize(); return false; } } - } else { + } + else { setLastError(QSqlError(QCoreApplication::translate("QSQLiteResult", "Parameter count mismatch") + QString::number(paramCount, 10) + "/" + QString::number(values.count(), 10), QString(), QSqlError::StatementError)); return false; @@ -456,23 +434,19 @@ bool QSQLiteResult::exec() return true; } -bool QSQLiteResult::gotoNext(ClementineSqlCachedResult::ValueCache& row, int idx) -{ +bool QSQLiteResult::gotoNext(ClementineSqlCachedResult::ValueCache& row, int idx) { return d->fetchNext(row, idx, false); } -int QSQLiteResult::size() -{ +int QSQLiteResult::size() { return -1; } -int QSQLiteResult::numRowsAffected() -{ +int QSQLiteResult::numRowsAffected() { return sqlite3_changes(d->access); } -QVariant QSQLiteResult::lastInsertId() const -{ +QVariant QSQLiteResult::lastInsertId() const { if (isActive()) { qint64 id = sqlite3_last_insert_rowid(d->access); if (id) @@ -481,35 +455,30 @@ QVariant QSQLiteResult::lastInsertId() const return QVariant(); } -QSqlRecord QSQLiteResult::record() const -{ +QSqlRecord QSQLiteResult::record() const { if (!isActive() || !isSelect()) return QSqlRecord(); return d->rInf; } -void QSQLiteResult::detachFromResultSet() -{ +void QSQLiteResult::detachFromResultSet() { if (d->stmt) sqlite3_reset(d->stmt); } -QVariant QSQLiteResult::handle() const -{ +QVariant QSQLiteResult::handle() const { return QVariant::fromValue(d->stmt); } ///////////////////////////////////////////////////////// QSQLiteDriver::QSQLiteDriver(QObject * parent) - : QSqlDriver(parent) -{ + : QSqlDriver(parent) { d = new QSQLiteDriverPrivate(); } QSQLiteDriver::QSQLiteDriver(sqlite3 *connection, QObject *parent) - : QSqlDriver(parent) -{ + : QSqlDriver(parent) { d = new QSQLiteDriverPrivate(); d->access = connection; setOpen(true); @@ -579,87 +548,77 @@ bool QSQLiteDriver::open(const QString & db, const QString &, const QString &, c setOpen(true); setOpenError(false); return true; - } else { + } + else { if (d->access) { sqlite3_close(d->access); d->access = 0; } - setLastError(qMakeError(d->access, tr("Error opening database"), - QSqlError::ConnectionError)); + setLastError(qMakeError(d->access, tr("Error opening database"), QSqlError::ConnectionError)); setOpenError(true); return false; } } -void QSQLiteDriver::close() -{ +void QSQLiteDriver::close() { if (isOpen()) { foreach (QSQLiteResult *result, d->results) { result->d->finalize(); } if (sqlite3_close(d->access) != SQLITE_OK) - setLastError(qMakeError(d->access, tr("Error closing database"), - QSqlError::ConnectionError)); + setLastError(qMakeError(d->access, tr("Error closing database"), QSqlError::ConnectionError)); d->access = 0; setOpen(false); setOpenError(false); } } -QSqlResult *QSQLiteDriver::createResult() const -{ +QSqlResult *QSQLiteDriver::createResult() const { return new QSQLiteResult(this); } -bool QSQLiteDriver::beginTransaction() -{ +bool QSQLiteDriver::beginTransaction() { if (!isOpen() || isOpenError()) return false; QSqlQuery q(createResult()); if (!q.exec(QLatin1String("BEGIN"))) { - setLastError(QSqlError(tr("Unable to begin transaction"), - q.lastError().databaseText(), QSqlError::TransactionError)); + setLastError(QSqlError(tr("Unable to begin transaction"), q.lastError().databaseText(), QSqlError::TransactionError)); return false; } return true; } -bool QSQLiteDriver::commitTransaction() -{ +bool QSQLiteDriver::commitTransaction() { if (!isOpen() || isOpenError()) return false; QSqlQuery q(createResult()); if (!q.exec(QLatin1String("COMMIT"))) { - setLastError(QSqlError(tr("Unable to commit transaction"), - q.lastError().databaseText(), QSqlError::TransactionError)); + setLastError(QSqlError(tr("Unable to commit transaction"), q.lastError().databaseText(), QSqlError::TransactionError)); return false; } return true; } -bool QSQLiteDriver::rollbackTransaction() -{ +bool QSQLiteDriver::rollbackTransaction() { if (!isOpen() || isOpenError()) return false; QSqlQuery q(createResult()); if (!q.exec(QLatin1String("ROLLBACK"))) { - setLastError(QSqlError(tr("Unable to rollback transaction"), - q.lastError().databaseText(), QSqlError::TransactionError)); + setLastError(QSqlError(tr("Unable to rollback transaction"), q.lastError().databaseText(), QSqlError::TransactionError)); return false; } return true; } -QStringList QSQLiteDriver::tables(QSql::TableType type) const -{ +QStringList QSQLiteDriver::tables(QSql::TableType type) const { QStringList res; if (!isOpen()) return res; @@ -691,8 +650,7 @@ QStringList QSQLiteDriver::tables(QSql::TableType type) const return res; } -static QSqlIndex qGetTableInfo(QSqlQuery &q, const QString &tableName, bool onlyPIndex = false) -{ +static QSqlIndex qGetTableInfo(QSqlQuery &q, const QString &tableName, bool onlyPIndex = false) { QString schema; QString table(tableName); int indexOfSeparator = tableName.indexOf(QLatin1Char('.')); @@ -720,8 +678,7 @@ static QSqlIndex qGetTableInfo(QSqlQuery &q, const QString &tableName, bool only return ind; } -QSqlIndex QSQLiteDriver::primaryIndex(const QString &tblname) const -{ +QSqlIndex QSQLiteDriver::primaryIndex(const QString &tblname) const { if (!isOpen()) return QSqlIndex(); @@ -734,8 +691,7 @@ QSqlIndex QSQLiteDriver::primaryIndex(const QString &tblname) const return qGetTableInfo(q, table, true); } -QSqlRecord QSQLiteDriver::record(const QString &tbl) const -{ +QSqlRecord QSQLiteDriver::record(const QString &tbl) const { if (!isOpen()) return QSqlRecord(); @@ -748,13 +704,11 @@ QSqlRecord QSQLiteDriver::record(const QString &tbl) const return qGetTableInfo(q, table); } -QVariant QSQLiteDriver::handle() const -{ +QVariant QSQLiteDriver::handle() const { return QVariant::fromValue(d->access); } -QString QSQLiteDriver::escapeIdentifier(const QString &identifier, IdentifierType type) const -{ +QString QSQLiteDriver::escapeIdentifier(const QString &identifier, IdentifierType type) const { Q_UNUSED(type); return _q_escapeIdentifier(identifier); } diff --git a/3rdparty/qsqlite/qsql_sqlite.h b/3rdparty/qsqlite/qsql_sqlite.h index 6a4eb157..9f8d3834 100644 --- a/3rdparty/qsqlite/qsql_sqlite.h +++ b/3rdparty/qsqlite/qsql_sqlite.h @@ -42,8 +42,17 @@ #ifndef QSQL_SQLITE_H #define QSQL_SQLITE_H -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + #include "sqlcachedresult.h" struct sqlite3; @@ -57,16 +66,16 @@ struct sqlite3; QT_BEGIN_HEADER QT_BEGIN_NAMESPACE +class QSQLiteDriver; class QSQLiteDriverPrivate; class QSQLiteResultPrivate; -class QSQLiteDriver; class QSQLiteResult : public ClementineSqlCachedResult { friend class QSQLiteDriver; friend class QSQLiteResultPrivate; public: - explicit QSQLiteResult(const QSQLiteDriver* db); + explicit QSQLiteResult(const QSQLiteDriver *db); ~QSQLiteResult(); QVariant handle() const; @@ -83,7 +92,7 @@ protected: void virtual_hook(int id, void *data); private: - QSQLiteResultPrivate* d; + QSQLiteResultPrivate *d; }; class Q_EXPORT_SQLDRIVER_SQLITE QSQLiteDriver : public QSqlDriver @@ -95,12 +104,7 @@ public: explicit QSQLiteDriver(sqlite3 *connection, QObject *parent = 0); ~QSQLiteDriver(); bool hasFeature(DriverFeature f) const; - bool open(const QString & db, - const QString & user, - const QString & password, - const QString & host, - int port, - const QString & connOpts); + bool open(const QString & db, const QString & user, const QString & password, const QString & host, int port, const QString & connOpts); void close(); QSqlResult *createResult() const; bool beginTransaction(); @@ -114,7 +118,7 @@ public: QString escapeIdentifier(const QString &identifier, IdentifierType) const; private: - QSQLiteDriverPrivate* d; + QSQLiteDriverPrivate *d; }; QT_END_NAMESPACE diff --git a/3rdparty/qsqlite/smain.cpp b/3rdparty/qsqlite/smain.cpp index 35b6b5d7..74f65868 100644 --- a/3rdparty/qsqlite/smain.cpp +++ b/3rdparty/qsqlite/smain.cpp @@ -31,8 +31,13 @@ ** ****************************************************************************/ +#include +#include + #include "smain.h" +#include "qsql_sqlite.h" + QT_BEGIN_NAMESPACE QSQLiteDriverPlugin::QSQLiteDriverPlugin() @@ -40,8 +45,7 @@ QSQLiteDriverPlugin::QSQLiteDriverPlugin() { } -QSqlDriver* QSQLiteDriverPlugin::create(const QString &name) -{ +QSqlDriver *QSQLiteDriverPlugin::create(const QString &name) { if (name == QLatin1String("QSQLITE")) { QSQLiteDriver* driver = new QSQLiteDriver(); return driver; diff --git a/3rdparty/qsqlite/smain.h b/3rdparty/qsqlite/smain.h index 1d91a454..ab701873 100644 --- a/3rdparty/qsqlite/smain.h +++ b/3rdparty/qsqlite/smain.h @@ -31,9 +31,11 @@ ** ****************************************************************************/ -#include -#include -#include "qsql_sqlite.h" +#include +#include +#include +#include +#include QT_BEGIN_NAMESPACE @@ -45,7 +47,7 @@ class QSQLiteDriverPlugin : public QSqlDriverPlugin public: QSQLiteDriverPlugin(); - QSqlDriver* create(const QString &); + QSqlDriver *create(const QString &); }; QT_END_NAMESPACE diff --git a/3rdparty/qsqlite/sqlcachedresult.cpp b/3rdparty/qsqlite/sqlcachedresult.cpp index 22ddfd37..201f133d 100644 --- a/3rdparty/qsqlite/sqlcachedresult.cpp +++ b/3rdparty/qsqlite/sqlcachedresult.cpp @@ -39,9 +39,9 @@ ** ****************************************************************************/ -#include -#include -#include +#include +#include +#include #include "sqlcachedresult.h" @@ -61,8 +61,7 @@ QT_BEGIN_NAMESPACE static const uint initial_cache_size = 128; -class ClementineSqlCachedResultPrivate -{ +class ClementineSqlCachedResultPrivate { public: ClementineSqlCachedResultPrivate(); bool canSeek(int i) const; @@ -84,8 +83,7 @@ ClementineSqlCachedResultPrivate::ClementineSqlCachedResultPrivate(): { } -void ClementineSqlCachedResultPrivate::cleanup() -{ +void ClementineSqlCachedResultPrivate::cleanup() { cache.clear(); forwardOnly = false; atEnd = false; @@ -93,8 +91,7 @@ void ClementineSqlCachedResultPrivate::cleanup() rowCacheEnd = 0; } -void ClementineSqlCachedResultPrivate::init(int count, bool fo) -{ +void ClementineSqlCachedResultPrivate::init(int count, bool fo) { Q_ASSERT(count); cleanup(); forwardOnly = fo; @@ -102,13 +99,13 @@ void ClementineSqlCachedResultPrivate::init(int count, bool fo) if (fo) { cache.resize(count); rowCacheEnd = count; - } else { + } + else { cache.resize(initial_cache_size * count); } } -int ClementineSqlCachedResultPrivate::nextIndex() -{ +int ClementineSqlCachedResultPrivate::nextIndex() { if (forwardOnly) return 0; int newIdx = rowCacheEnd; @@ -119,15 +116,13 @@ int ClementineSqlCachedResultPrivate::nextIndex() return newIdx; } -bool ClementineSqlCachedResultPrivate::canSeek(int i) const -{ +bool ClementineSqlCachedResultPrivate::canSeek(int i) const { if (forwardOnly || i < 0) return false; return rowCacheEnd >= (i + 1) * colCount; } -void ClementineSqlCachedResultPrivate::revertLast() -{ +void ClementineSqlCachedResultPrivate::revertLast() { if (forwardOnly) return; rowCacheEnd -= colCount; @@ -142,23 +137,19 @@ inline int ClementineSqlCachedResultPrivate::cacheCount() const ////////////// -ClementineSqlCachedResult::ClementineSqlCachedResult(const QSqlDriver * db): QSqlResult (db) -{ +ClementineSqlCachedResult::ClementineSqlCachedResult(const QSqlDriver * db): QSqlResult (db) { d = new ClementineSqlCachedResultPrivate(); } -ClementineSqlCachedResult::~ClementineSqlCachedResult() -{ +ClementineSqlCachedResult::~ClementineSqlCachedResult() { delete d; } -void ClementineSqlCachedResult::init(int colCount) -{ +void ClementineSqlCachedResult::init(int colCount) { d->init(colCount, isForwardOnly()); } -bool ClementineSqlCachedResult::fetch(int i) -{ +bool ClementineSqlCachedResult::fetch(int i) { if ((!isActive()) || (i < 0)) return false; if (at() == i) @@ -195,8 +186,7 @@ bool ClementineSqlCachedResult::fetch(int i) return true; } -bool ClementineSqlCachedResult::fetchNext() -{ +bool ClementineSqlCachedResult::fetchNext() { if (d->canSeek(at() + 1)) { setAt(at() + 1); return true; @@ -204,13 +194,11 @@ bool ClementineSqlCachedResult::fetchNext() return cacheNext(); } -bool ClementineSqlCachedResult::fetchPrevious() -{ +bool ClementineSqlCachedResult::fetchPrevious() { return fetch(at() - 1); } -bool ClementineSqlCachedResult::fetchFirst() -{ +bool ClementineSqlCachedResult::fetchFirst() { if (d->forwardOnly && at() != QSql::BeforeFirstRow) { return false; } @@ -221,8 +209,7 @@ bool ClementineSqlCachedResult::fetchFirst() return cacheNext(); } -bool ClementineSqlCachedResult::fetchLast() -{ +bool ClementineSqlCachedResult::fetchLast() { if (d->atEnd) { if (d->forwardOnly) return false; @@ -236,13 +223,13 @@ bool ClementineSqlCachedResult::fetchLast() if (d->forwardOnly && at() == QSql::AfterLastRow) { setAt(i); return true; - } else { + } + else { return fetch(i); } } -QVariant ClementineSqlCachedResult::data(int i) -{ +QVariant ClementineSqlCachedResult::data(int i) { int idx = d->forwardOnly ? i : at() * d->colCount + i; if (i >= d->colCount || i < 0 || at() < 0 || idx >= d->rowCacheEnd) return QVariant(); @@ -250,8 +237,7 @@ QVariant ClementineSqlCachedResult::data(int i) return d->cache.at(idx); } -bool ClementineSqlCachedResult::isNull(int i) -{ +bool ClementineSqlCachedResult::isNull(int i) { int idx = d->forwardOnly ? i : at() * d->colCount + i; if (i > d->colCount || i < 0 || at() < 0 || idx >= d->rowCacheEnd) return true; @@ -259,22 +245,20 @@ bool ClementineSqlCachedResult::isNull(int i) return d->cache.at(idx).isNull(); } -void ClementineSqlCachedResult::cleanup() -{ +void ClementineSqlCachedResult::cleanup() { setAt(QSql::BeforeFirstRow); setActive(false); d->cleanup(); } -void ClementineSqlCachedResult::clearValues() -{ +void ClementineSqlCachedResult::clearValues() { setAt(QSql::BeforeFirstRow); d->rowCacheEnd = 0; d->atEnd = false; } -bool ClementineSqlCachedResult::cacheNext() -{ +bool ClementineSqlCachedResult::cacheNext() { + if (d->atEnd) return false; @@ -292,28 +276,23 @@ bool ClementineSqlCachedResult::cacheNext() return true; } -int ClementineSqlCachedResult::colCount() const -{ +int ClementineSqlCachedResult::colCount() const { return d->colCount; } -ClementineSqlCachedResult::ValueCache &ClementineSqlCachedResult::cache() -{ +ClementineSqlCachedResult::ValueCache &ClementineSqlCachedResult::cache() { return d->cache; } -void ClementineSqlCachedResult::virtual_hook(int id, void *data) -{ +void ClementineSqlCachedResult::virtual_hook(int id, void *data) { QSqlResult::virtual_hook(id, data); } -void ClementineSqlCachedResult::detachFromResultSet() -{ +void ClementineSqlCachedResult::detachFromResultSet() { cleanup(); } -void ClementineSqlCachedResult::setNumericalPrecisionPolicy(QSql::NumericalPrecisionPolicy policy) -{ +void ClementineSqlCachedResult::setNumericalPrecisionPolicy(QSql::NumericalPrecisionPolicy policy) { QSqlResult::setNumericalPrecisionPolicy(policy); cleanup(); } diff --git a/3rdparty/qsqlite/sqlcachedresult.h b/3rdparty/qsqlite/sqlcachedresult.h index c170270a..e2f78bf1 100644 --- a/3rdparty/qsqlite/sqlcachedresult.h +++ b/3rdparty/qsqlite/sqlcachedresult.h @@ -53,13 +53,15 @@ // We mean it. // -#include +#include +#include +#include +#include +#include +#include QT_BEGIN_NAMESPACE -class QVariant; -template class QVector; - class ClementineSqlCachedResultPrivate; class ClementineSqlCachedResult: public QSqlResult diff --git a/3rdparty/qtsingleapplication/qtlocalpeer.cpp b/3rdparty/qtsingleapplication/qtlocalpeer.cpp index 360cd086..bda12e89 100644 --- a/3rdparty/qtsingleapplication/qtlocalpeer.cpp +++ b/3rdparty/qtsingleapplication/qtlocalpeer.cpp @@ -39,14 +39,27 @@ #include "qtlocalpeer.h" -#include -#include -#include + #include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + #if defined(Q_OS_WIN) -#include #include +#include + typedef BOOL(WINAPI*PProcessIdToSessionId)(DWORD,DWORD*); static PProcessIdToSessionId pProcessIdToSessionId = 0; #endif diff --git a/3rdparty/qtsingleapplication/qtlocalpeer.h b/3rdparty/qtsingleapplication/qtlocalpeer.h index f3e7ad89..7bcfb69a 100644 --- a/3rdparty/qtsingleapplication/qtlocalpeer.h +++ b/3rdparty/qtsingleapplication/qtlocalpeer.h @@ -40,9 +40,9 @@ #ifndef QTLOCALPEER_H #define QTLOCALPEER_H +#include +#include #include -#include -#include #include "qtlockedfile.h" diff --git a/3rdparty/qtsingleapplication/qtlockedfile.cpp b/3rdparty/qtsingleapplication/qtlockedfile.cpp index 3e73ba65..41d32189 100644 --- a/3rdparty/qtsingleapplication/qtlockedfile.cpp +++ b/3rdparty/qtsingleapplication/qtlockedfile.cpp @@ -37,6 +37,9 @@ ** ****************************************************************************/ +#include +#include + #include "qtlockedfile.h" /*! diff --git a/3rdparty/qtsingleapplication/qtlockedfile.h b/3rdparty/qtsingleapplication/qtlockedfile.h index 3ef0b5c0..5fd80260 100644 --- a/3rdparty/qtsingleapplication/qtlockedfile.h +++ b/3rdparty/qtsingleapplication/qtlockedfile.h @@ -42,7 +42,7 @@ #include #ifdef Q_OS_WIN -#include +#include #endif #if defined(Q_WS_WIN) || defined(Q_OS_WIN) diff --git a/3rdparty/qtsingleapplication/qtlockedfile_win.cpp b/3rdparty/qtsingleapplication/qtlockedfile_win.cpp index e1a4e0c9..c54861a7 100644 --- a/3rdparty/qtsingleapplication/qtlockedfile_win.cpp +++ b/3rdparty/qtsingleapplication/qtlockedfile_win.cpp @@ -37,9 +37,10 @@ ** ****************************************************************************/ +#include + #include "qtlockedfile.h" #include -#include #define MUTEX_PREFIX "QtLockedFile mutex " // Maximum number of concurrent read locks. Must not be greater than MAXIMUM_WAIT_OBJECTS diff --git a/3rdparty/qtsingleapplication/qtsingleapplication.cpp b/3rdparty/qtsingleapplication/qtsingleapplication.cpp index 48c2e45f..956cf86e 100644 --- a/3rdparty/qtsingleapplication/qtsingleapplication.cpp +++ b/3rdparty/qtsingleapplication/qtsingleapplication.cpp @@ -39,8 +39,12 @@ #include "qtsingleapplication.h" -#include "qtlocalpeer.h" + +#include #include +#include + +#include "qtlocalpeer.h" /*! \class QtSingleApplication qtsingleapplication.h diff --git a/3rdparty/qtsingleapplication/qtsingleapplication.h b/3rdparty/qtsingleapplication/qtsingleapplication.h index 42e97728..09607c43 100644 --- a/3rdparty/qtsingleapplication/qtsingleapplication.h +++ b/3rdparty/qtsingleapplication/qtsingleapplication.h @@ -40,8 +40,11 @@ #ifndef QTSINGLEAPPLICATION_H #define QTSINGLEAPPLICATION_H +#include +#include +#include #include - +#include class QtLocalPeer; #if defined(Q_WS_WIN) || defined(Q_OS_WIN32) diff --git a/3rdparty/qtsingleapplication/qtsinglecoreapplication.cpp b/3rdparty/qtsingleapplication/qtsinglecoreapplication.cpp index cf607710..f671ba80 100644 --- a/3rdparty/qtsingleapplication/qtsinglecoreapplication.cpp +++ b/3rdparty/qtsingleapplication/qtsinglecoreapplication.cpp @@ -37,6 +37,9 @@ ** ****************************************************************************/ +#include +#include +#include #include "qtsinglecoreapplication.h" #include "qtlocalpeer.h" @@ -70,8 +73,7 @@ */ QtSingleCoreApplication::QtSingleCoreApplication(int &argc, char **argv) - : QCoreApplication(argc, argv) -{ + : QCoreApplication(argc, argv) { peer = new QtLocalPeer(this); connect(peer, SIGNAL(messageReceived(const QString&)), SIGNAL(messageReceived(const QString&))); } @@ -83,8 +85,7 @@ QtSingleCoreApplication::QtSingleCoreApplication(int &argc, char **argv) QCoreAppliation constructor. */ QtSingleCoreApplication::QtSingleCoreApplication(const QString &appId, int &argc, char **argv) - : QCoreApplication(argc, argv) -{ + : QCoreApplication(argc, argv) { peer = new QtLocalPeer(this, appId); connect(peer, SIGNAL(messageReceived(const QString&)), SIGNAL(messageReceived(const QString&))); } @@ -101,8 +102,7 @@ QtSingleCoreApplication::QtSingleCoreApplication(const QString &appId, int &argc \sa sendMessage() */ -bool QtSingleCoreApplication::isRunning() -{ +bool QtSingleCoreApplication::isRunning() { return peer->isClient(); } @@ -121,8 +121,7 @@ bool QtSingleCoreApplication::isRunning() \sa isRunning(), messageReceived() */ -bool QtSingleCoreApplication::sendMessage(const QString &message, int timeout) -{ +bool QtSingleCoreApplication::sendMessage(const QString &message, int timeout) { return peer->sendMessage(message, timeout); } @@ -132,8 +131,7 @@ bool QtSingleCoreApplication::sendMessage(const QString &message, int timeout) identifier will be regarded as instances of the same application. */ -QString QtSingleCoreApplication::id() const -{ +QString QtSingleCoreApplication::id() const { return peer->applicationId(); } diff --git a/3rdparty/qtsingleapplication/qtsinglecoreapplication.h b/3rdparty/qtsingleapplication/qtsinglecoreapplication.h index 549d49f5..c5c4a478 100644 --- a/3rdparty/qtsingleapplication/qtsinglecoreapplication.h +++ b/3rdparty/qtsingleapplication/qtsinglecoreapplication.h @@ -41,6 +41,8 @@ #define QTSINGLECOREAPPLICATION_H #include +#include +#include class QtLocalPeer; diff --git a/3rdparty/qxt/qxtglobalshortcut.cpp b/3rdparty/qxt/qxtglobalshortcut.cpp index 6ea380ca..ba9a40e1 100644 --- a/3rdparty/qxt/qxtglobalshortcut.cpp +++ b/3rdparty/qxt/qxtglobalshortcut.cpp @@ -29,10 +29,14 @@ ** *****************************************************************************/ -#include "qxtglobalshortcut_p.h" +#include #include +#include +#include #include +#include "qxtglobalshortcut_p.h" + bool QxtGlobalShortcutPrivate::error = false; #ifndef Q_WS_MAC int QxtGlobalShortcutPrivate::ref = 0; diff --git a/3rdparty/qxt/qxtglobalshortcut.h b/3rdparty/qxt/qxtglobalshortcut.h index 907e04c5..d34dbf12 100644 --- a/3rdparty/qxt/qxtglobalshortcut.h +++ b/3rdparty/qxt/qxtglobalshortcut.h @@ -31,9 +31,12 @@ #define QXTGLOBALSHORTCUT_H -#include "qxtglobal.h" #include #include +#include + +#include "qxtglobal.h" + class QxtGlobalShortcutPrivate; class QXT_GUI_EXPORT QxtGlobalShortcut : public QObject diff --git a/3rdparty/qxt/qxtglobalshortcut_x11.cpp b/3rdparty/qxt/qxtglobalshortcut_x11.cpp index 9ddb1e08..e6259341 100644 --- a/3rdparty/qxt/qxtglobalshortcut_x11.cpp +++ b/3rdparty/qxt/qxtglobalshortcut_x11.cpp @@ -32,12 +32,21 @@ #if QT_VERSION < QT_VERSION_CHECK(5,0,0) # include #else -# include # include # include +# include #endif -#include +#include #include +#include + +#include +#include +#include +#include +#include +#include + #include "keymapper_x11.h" namespace { diff --git a/3rdparty/sha2/sha2.cpp b/3rdparty/sha2/sha2.cpp index 64848d52..e3c8bcba 100644 --- a/3rdparty/sha2/sha2.cpp +++ b/3rdparty/sha2/sha2.cpp @@ -31,8 +31,9 @@ * */ -#include /* memcpy()/memset() or bcopy()/bzero() */ -#include /* assert() */ +#include +#include + #include "sha2.h" /* diff --git a/3rdparty/sha2/sha2.h b/3rdparty/sha2/sha2.h index ae266be2..60e4b969 100644 --- a/3rdparty/sha2/sha2.h +++ b/3rdparty/sha2/sha2.h @@ -35,6 +35,8 @@ #ifndef __STRAWBERRY_SHA2_H__ #define __STRAWBERRY_SHA2_H__ +#include + /* * Import u_intXX_t size_t type definitions from system headers. You * may need to change this, or define these things yourself in this diff --git a/CMakeLists.txt b/CMakeLists.txt index 3687d670..c6ee8fa8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -96,21 +96,19 @@ pkg_check_modules(GSTREAMER_APP gstreamer-app-1.0) pkg_check_modules(GSTREAMER_AUDIO gstreamer-audio-1.0) pkg_check_modules(GSTREAMER_TAG gstreamer-tag-1.0) pkg_check_modules(GSTREAMER_PBUTILS gstreamer-pbutils-1.0) -#pkg_check_modules(GSTREAMER_QTGLIB Qt5GLib-2.0) -#pkg_check_modules(GSTREAMER_QTGST Qt5GStreamer-1.0) -#pkg_check_modules(GSTREAMER_QTGSTUI Qt5GStreamerUi-1.0) -#pkg_check_modules(GSTREAMER_QTGSTUTILS Qt5GStreamerUtils-1.0) pkg_check_modules(LIBXINE libxine) pkg_check_modules(LIBVLC libvlc) pkg_check_modules(PHONON phonon4qt5) pkg_check_modules(LIBGPOD libgpod-1.0>=0.7.92) pkg_check_modules(LIBMTP libmtp>=1.0) - pkg_check_modules(LIBPULSE libpulse) pkg_check_modules(LIBXML libxml-2.0) pkg_check_modules(TAGLIB REQUIRED taglib>=1.8) pkg_check_modules(SQLITE REQUIRED sqlite3>=3.7) pkg_check_modules(LIBGLU REQUIRED glu) +pkg_check_modules(IMOBILEDEVICE libimobiledevice-1.0) +pkg_check_modules(USBMUXD libusbmuxd) +pkg_check_modules(PLIST libplist) find_library(PROTOBUF_STATIC_LIBRARY libprotobuf.a libprotobuf) @@ -178,10 +176,6 @@ include_directories(${GSTREAMER_AUDIO_INCLUDE_DIRS}) include_directories(${GSTREAMER_BASE_INCLUDE_DIRS}) include_directories(${GSTREAMER_TAG_INCLUDE_DIRS}) include_directories(${GSTREAMER_PBUTILS_INCLUDE_DIRS}) -#include_directories(${GSTREAMER_QTGLIB}) -#include_directories(${GSTREAMER_QTGST}) -#include_directories(${GSTREAMER_QTGSTUI}) -#include_directories(${GSTREAMER_QTGSTUTILS}) if (WIN32) # RC compiler @@ -194,9 +188,30 @@ add_definitions(-DQT_NO_CAST_TO_ASCII -DQT_STRICT_ITERATORS) # Optional bits if(WIN32) - option(ENABLE_WIN32_CONSOLE "Show the windows console even outside Debug mode" OFF) + option(ENABLE_WIN32_CONSOLE "Show the windows console even outside Debug mode" ON) endif(WIN32) +optional_component(GSTREAMER ON "Engine: GStreamer backend" + DEPENDS "gstreamer-1.0" GSTREAMER_FOUND + DEPENDS "gstreamer-base-1.0" GSTREAMER_BASE_FOUND + DEPENDS "gstreamer-app-1.0" GSTREAMER_APP_FOUND + DEPENDS "gstreamer-audio-1.0" GSTREAMER_AUDIO_FOUND + DEPENDS "gstreamer-tag-1.0" GSTREAMER_TAG_FOUND + DEPENDS "gstreamer-pbutils-1.0" GSTREAMER_PBUTILS_FOUND +) + +optional_component(XINE ON "Engine: Xine backend" + DEPENDS "libxine" LIBXINE_FOUND +) + +optional_component(VLC ON "Engine: VLC backend" + DEPENDS "libvlc" LIBVLC_FOUND +) + +optional_component(PHONON OFF "Engine: Phonon backend" + DEPENDS "phonon4qt5" PHONON4QT5_FOUND +) + optional_component(AUDIOCD ON "Devices: Audio CD support" DEPENDS "libcdio" CDIO_FOUND ) @@ -262,7 +277,7 @@ else(WIN32) endif(WIN32) # Remove GLU and GL from the link line - they're not really required and don't exist on my mingw toolchain -#list(REMOVE_ITEM QT_LIBRARIES "-lGLU -lGL") +list(REMOVE_ITEM QT_LIBRARIES "-lGLU -lGL") # QSqlLiteDriver: # We do this because we can't guarantee that the driver shipped with Qt exposes the raw sqlite3 functions required for FTS support. @@ -323,6 +338,10 @@ endif() # Qocoa add_subdirectory(3rdparty/qocoa) +#if(IMOBILEDEVICE_FOUND AND PLIST_FOUND) + #add_subdirectory(ext/gstafc) +#endif(IMOBILEDEVICE_FOUND AND PLIST_FOUND) + # Subdirectories add_subdirectory(src) if (WIN32) diff --git a/TODO b/TODO deleted file mode 100644 index 09cec531..00000000 --- a/TODO +++ /dev/null @@ -1,5 +0,0 @@ -Strawberry Music Player -======================= -TODO - -- Finalize / Improve status/context diff --git a/cmake/Summary.cmake b/cmake/Summary.cmake index 6faf83eb..eea579be 100644 --- a/cmake/Summary.cmake +++ b/cmake/Summary.cmake @@ -62,8 +62,7 @@ function(optional_component name default description) elseif(${testing_deps}) string(REPLACE " " ";" arglist "${arg}") if(${arglist}) - # We have to do this instead of if(NOT ${arg}) so that tests may contain - # "NOT" themselves. + # We have to do this instead of if(NOT ${arg}) so that tests may contain "NOT" themselves. else() list(APPEND missing_deps "${current_dep_name}") set(testing_deps FALSE) diff --git a/ext/libstrawberry-common/core/closure.cpp b/ext/libstrawberry-common/core/closure.cpp index 79c56853..ce88643b 100644 --- a/ext/libstrawberry-common/core/closure.cpp +++ b/ext/libstrawberry-common/core/closure.cpp @@ -15,6 +15,11 @@ along with Strawberry. If not, see . */ +#include +#include +#include +#include + #include "closure.h" #include "core/timeconstants.h" diff --git a/ext/libstrawberry-common/core/closure.h b/ext/libstrawberry-common/core/closure.h index b9f1cef0..6502b0bc 100644 --- a/ext/libstrawberry-common/core/closure.h +++ b/ext/libstrawberry-common/core/closure.h @@ -18,15 +18,20 @@ #ifndef CLOSURE_H #define CLOSURE_H -#include #include #include +#include +#include +#include #include #include +#include #include -#include #include +#include +#include +#include #include namespace _detail { @@ -40,11 +45,11 @@ class ClosureBase { virtual void Invoke() = 0; // Tests only. - ObjectHelper* helper() const; + ObjectHelper *helper() const; protected: explicit ClosureBase(ObjectHelper*); - ObjectHelper* helper_; + ObjectHelper *helper_; private: Q_DISABLE_COPY(ClosureBase); @@ -56,7 +61,7 @@ class ClosureBase { class ObjectHelper : public QObject { Q_OBJECT public: - ObjectHelper(QObject* parent, const char* signal, ClosureBase* closure); + ObjectHelper(QObject *parent, const char *signal, ClosureBase *closure); private slots: void Invoked(); @@ -72,12 +77,12 @@ class ObjectHelper : public QObject { void Unpack(QList*); template -void Unpack(QList* list, const Arg& arg) { +void Unpack(QList *list, const Arg &arg) { list->append(Q_ARG(Arg, arg)); } template -void Unpack(QList* list, const Head& head, const Tail&... tail) { +void Unpack(QList *list, const Head &head, const Tail&... tail) { Unpack(list, head); Unpack(list, tail...); } @@ -86,16 +91,16 @@ template class Closure : public ClosureBase { public: Closure( - QObject* sender, - const char* signal, - QObject* receiver, - const char* slot, + QObject *sender, + const char *signal, + QObject *receiver, + const char *slot, const Args&... args) : ClosureBase(new ObjectHelper(sender, signal, this)), // std::bind is the easiest way to store an argument list. function_(std::bind(&Closure::Call, this, args...)), receiver_(receiver) { - const QMetaObject* meta_receiver = receiver->metaObject(); + const QMetaObject *meta_receiver = receiver->metaObject(); QByteArray normalised_slot = QMetaObject::normalizedSignature(slot + 1); const int index = meta_receiver->indexOfSlot(normalised_slot.constData()); Q_ASSERT(index != -1); @@ -127,7 +132,7 @@ class Closure : public ClosureBase { } std::function function_; - QObject* receiver_; + QObject *receiver_; QMetaMethod slot_; }; @@ -136,9 +141,9 @@ class SharedClosure : public Closure { public: SharedClosure( QSharedPointer sender, - const char* signal, - QObject* receiver, - const char* slot, + const char *signal, + QObject *receiver, + const char *slot, const Args&... args) : Closure( sender.data(), @@ -155,8 +160,7 @@ class SharedClosure : public Closure { class CallbackClosure : public ClosureBase { public: - CallbackClosure(QObject* sender, const char* signal, - std::function callback); + CallbackClosure(QObject *sender, const char *signal, std::function callback); virtual void Invoke(); @@ -167,11 +171,11 @@ class CallbackClosure : public ClosureBase { } // namespace _detail template -_detail::ClosureBase* NewClosure( - QObject* sender, - const char* signal, - QObject* receiver, - const char* slot, +_detail::ClosureBase *NewClosure( + QObject *sender, + const char *signal, + QObject *receiver, + const char *slot, const Args&... args) { return new _detail::Closure( sender, signal, receiver, slot, args...); @@ -179,64 +183,64 @@ _detail::ClosureBase* NewClosure( // QSharedPointer variant template -_detail::ClosureBase* NewClosure( +_detail::ClosureBase *NewClosure( QSharedPointer sender, - const char* signal, - QObject* receiver, - const char* slot, + const char *signal, + QObject *receiver, + const char *slot, const Args&... args) { return new _detail::SharedClosure( sender, signal, receiver, slot, args...); } -_detail::ClosureBase* NewClosure(QObject* sender, const char* signal, std::function callback); +_detail::ClosureBase *NewClosure(QObject *sender, const char *signal, std::function callback); template -_detail::ClosureBase* NewClosure(QObject* sender, const char* signal, std::function callback, const Args&... args) { +_detail::ClosureBase *NewClosure(QObject *sender, const char *signal, std::function callback, const Args&... args) { return NewClosure(sender, signal, std::bind(callback, args...)); } template -_detail::ClosureBase* NewClosure( - QObject* sender, - const char* signal, +_detail::ClosureBase *NewClosure( + QObject *sender, + const char *signal, void (*callback)(Args...), const Args&... args) { return NewClosure(sender, signal, std::bind(callback, args...)); } template -_detail::ClosureBase* NewClosure( - QObject* sender, - const char* signal, - T* receiver, Unused (T::*callback)(Args...), +_detail::ClosureBase *NewClosure( + QObject *sender, + const char *signal, + T *receiver, Unused (T::*callback)(Args...), const Args&... args) { return NewClosure(sender, signal, std::bind(callback, receiver, args...)); } template -_detail::ClosureBase* NewClosure(QFuture future, QObject* receiver, const char* slot, const Args&... args) { - QFutureWatcher* watcher = new QFutureWatcher; +_detail::ClosureBase *NewClosure(QFuture future, QObject *receiver, const char *slot, const Args&... args) { + QFutureWatcher *watcher = new QFutureWatcher; watcher->setFuture(future); QObject::connect(watcher, SIGNAL(finished()), watcher, SLOT(deleteLater())); return NewClosure(watcher, SIGNAL(finished()), receiver, slot, args...); } template -_detail::ClosureBase* NewClosure(QFuture future, const F& callback, const Args&... args) { - QFutureWatcher* watcher = new QFutureWatcher; +_detail::ClosureBase *NewClosure(QFuture future, const F &callback, const Args&... args) { + QFutureWatcher *watcher = new QFutureWatcher; watcher->setFuture(future); QObject::connect(watcher, SIGNAL(finished()), watcher, SLOT(deleteLater())); return NewClosure(watcher, SIGNAL(finished()), callback, args...); } -void DoAfter(QObject* receiver, const char* slot, int msec); +void DoAfter(QObject *receiver, const char *slot, int msec); void DoAfter(std::function callback, std::chrono::milliseconds msec); -void DoInAMinuteOrSo(QObject* receiver, const char* slot); +void DoInAMinuteOrSo(QObject *receiver, const char *slot); template void DoAfter(std::function callback, std::chrono::duration duration) { - QTimer* timer = new QTimer; + QTimer *timer = new QTimer; timer->setSingleShot(true); NewClosure(timer, SIGNAL(timeout()), callback); QObject::connect(timer, SIGNAL(timeout()), timer, SLOT(deleteLater())); diff --git a/ext/libstrawberry-common/core/concurrentrun.h b/ext/libstrawberry-common/core/concurrentrun.h index 189b3b61..351d324f 100644 --- a/ext/libstrawberry-common/core/concurrentrun.h +++ b/ext/libstrawberry-common/core/concurrentrun.h @@ -55,9 +55,7 @@ class ThreadFunctorBase : public QFutureInterface, public QRunnable this->reportStarted(); Q_ASSERT(thread_pool); QFuture future = this->future(); - thread_pool->start(this, 0 /* priority: currently we do not support - changing the priority. Might be added later - if needed */); + thread_pool->start(this, 0 /* priority: currently we do not support changing the priority. Might be added later if needed */); return future; } @@ -67,8 +65,7 @@ class ThreadFunctorBase : public QFutureInterface, public QRunnable template class ThreadFunctor : public ThreadFunctorBase { public: - ThreadFunctor(std::function function, - Args... args) + ThreadFunctor(std::function function, Args... args) : function_(std::bind(function, args...)) { } @@ -85,8 +82,7 @@ class ThreadFunctor : public ThreadFunctorBase { template class ThreadFunctor : public ThreadFunctorBase { public: - ThreadFunctor(std::function function, - Args... args) + ThreadFunctor(std::function function, Args... args) : function_(std::bind(function, args...)) { } @@ -107,30 +103,20 @@ namespace ConcurrentRun { // Empty argument form. template - QFuture Run( - QThreadPool* threadpool, - std::function function) { + QFuture Run(QThreadPool* threadpool, std::function function) { return (new ThreadFunctor(function))->Start(threadpool); } // Function object with arguments form. template - QFuture Run( - QThreadPool* threadpool, - std::function function, - const Args&... args) { - return (new ThreadFunctor( - function, args...))->Start(threadpool); + QFuture Run(QThreadPool* threadpool, std::function function, const Args&... args) { + return (new ThreadFunctor(function, args...))->Start(threadpool); } // Support passing C function pointers instead of function objects. template - QFuture Run( - QThreadPool* threadpool, - ReturnType (*function) (Args...), - const Args&... args) { - return Run( - threadpool, std::function(function), args...); + QFuture Run(QThreadPool* threadpool, ReturnType (*function) (Args...), const Args&... args) { + return Run(threadpool, std::function(function), args...); } } diff --git a/ext/libstrawberry-common/core/logging.cpp b/ext/libstrawberry-common/core/logging.cpp index 2a0c0ba7..66ae3b13 100644 --- a/ext/libstrawberry-common/core/logging.cpp +++ b/ext/libstrawberry-common/core/logging.cpp @@ -14,21 +14,28 @@ limitations under the License. */ -#include -#include - #include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #include +#include +#include +#include +#include +#include #ifdef Q_OS_UNIX #include #endif -#include -#include -#include -#include - #include "logging.h" namespace logging { @@ -75,7 +82,7 @@ static void MessageHandler(QtMsgType type, const QMessageLogContext &context, co default: level = Level_Debug; break; } - for (const QString& line : message.split('\n')) { + for (const QString &line : message.split('\n')) { CreateLogger(level, "unknown", -1) << line.toLocal8Bit().constData(); } diff --git a/ext/libstrawberry-common/core/logging.h b/ext/libstrawberry-common/core/logging.h index 2827f68c..729746cd 100644 --- a/ext/libstrawberry-common/core/logging.h +++ b/ext/libstrawberry-common/core/logging.h @@ -18,8 +18,10 @@ #define LOGGING_H #include -#include +#include +#include +#include #include #ifdef QT_NO_DEBUG_STREAM @@ -61,30 +63,30 @@ enum Level { void DumpStackTrace(); - QString ParsePrettyFunction(const char* pretty_function); + QString ParsePrettyFunction(const char *pretty_function); QDebug CreateLogger(Level level, const QString &class_name, int line); -QDebug CreateLoggerFatal(int line, const char* class_name); -QDebug CreateLoggerError(int line, const char* class_name); +QDebug CreateLoggerFatal(int line, const char *class_name); +QDebug CreateLoggerError(int line, const char *class_name); #ifdef QT_NO_WARNING_OUTPUT QNoDebug CreateLoggerWarning(int, const char*); #else -QDebug CreateLoggerWarning(int line, const char* class_name); +QDebug CreateLoggerWarning(int line, const char *class_name); #endif // QT_NO_WARNING_OUTPUT #ifdef QT_NO_DEBUG_OUTPUT QNoDebug CreateLoggerInfo(int, const char*); QNoDebug CreateLoggerDebug(int, const char*); #else -QDebug CreateLoggerInfo(int line, const char* class_name); -QDebug CreateLoggerDebug(int line, const char* class_name); +QDebug CreateLoggerInfo(int line, const char *class_name); +QDebug CreateLoggerDebug(int line, const char *class_name); #endif // QT_NO_DEBUG_OUTPUT -void GLog(const char* domain, int level, const char* message, void* user_data); +void GLog(const char *domain, int level, const char *message, void *user_data); -extern const char* kDefaultLogLevels; +extern const char *kDefaultLogLevels; } QDebug operator<<(QDebug debug, std::chrono::seconds secs); diff --git a/ext/libstrawberry-common/core/messagehandler.cpp b/ext/libstrawberry-common/core/messagehandler.cpp index 4b1a4b6f..47400c4e 100644 --- a/ext/libstrawberry-common/core/messagehandler.cpp +++ b/ext/libstrawberry-common/core/messagehandler.cpp @@ -15,11 +15,15 @@ */ #include "messagehandler.h" -#include "core/logging.h" +#include #include -#include #include +#include +#include +#include + +#include "core/logging.h" _MessageHandlerBase::_MessageHandlerBase(QIODevice *device, QObject *parent) : QObject(parent), diff --git a/ext/libstrawberry-common/core/messagehandler.h b/ext/libstrawberry-common/core/messagehandler.h index 65dfde81..65a1d8fa 100644 --- a/ext/libstrawberry-common/core/messagehandler.h +++ b/ext/libstrawberry-common/core/messagehandler.h @@ -18,21 +18,21 @@ #ifndef MESSAGEHANDLER_H #define MESSAGEHANDLER_H -#include -#include -#include -#include +#include + +#include #include -#include #include +#include +#include +#include +#include +#include +#include +#include -#include "core/logging.h" #include "core/messagereply.h" -class QAbstractSocket; -class QIODevice; -class QLocalSocket; - #define QStringFromStdString(x) QString::fromUtf8(x.data(), x.size()) #define DataCommaSizeFromQString(x) x.toUtf8().constData(), x.toUtf8().length() @@ -45,27 +45,27 @@ class _MessageHandlerBase : public QObject { public: // device can be NULL, in which case you must call SetDevice before writing // any messages. - _MessageHandlerBase(QIODevice* device, QObject* parent); + _MessageHandlerBase(QIODevice *device, QObject *parent); - void SetDevice(QIODevice* device); + void SetDevice(QIODevice *device); // After this is true, messages cannot be sent to the handler any more. bool is_device_closed() const { return is_device_closed_; } protected slots: - void WriteMessage(const QByteArray& data); + void WriteMessage(const QByteArray &data); void DeviceReadyRead(); virtual void DeviceClosed(); protected: - virtual bool RawMessageArrived(const QByteArray& data) = 0; + virtual bool RawMessageArrived(const QByteArray &data) = 0; virtual void AbortAll() = 0; protected: typedef bool (QAbstractSocket::*FlushAbstractSocket)(); typedef bool (QLocalSocket::*FlushLocalSocket)(); - QIODevice* device_; + QIODevice *device_; FlushAbstractSocket flush_abstract_socket_; FlushLocalSocket flush_local_socket_; @@ -82,7 +82,7 @@ protected: template class AbstractMessageHandler : public _MessageHandlerBase { public: - AbstractMessageHandler(QIODevice* device, QObject* parent); + AbstractMessageHandler(QIODevice *device, QObject *parent); ~AbstractMessageHandler() { AbortAll(); } typedef MT MessageType; @@ -90,27 +90,27 @@ public: // 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); + void SendMessage(const MessageType &message); // Serialises the message and writes it to the socket. This version may be // called from any thread. - void SendMessageAsync(const MessageType& message); + 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. - void SendRequest(ReplyType* reply); + 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. - void SendReply(const MessageType& request, MessageType* reply); + void SendReply(const MessageType &request, MessageType *reply); protected: // Called when a message is received from the socket. - virtual void MessageArrived(const MessageType& message) {} + virtual void MessageArrived(const MessageType &message) {} // _MessageHandlerBase - bool RawMessageArrived(const QByteArray& data); + bool RawMessageArrived(const QByteArray &data); void AbortAll(); private: @@ -118,12 +118,11 @@ private: }; template -AbstractMessageHandler::AbstractMessageHandler(QIODevice* device, - QObject* parent) +AbstractMessageHandler::AbstractMessageHandler(QIODevice *device, QObject *parent) : _MessageHandlerBase(device, parent) {} template -void AbstractMessageHandler::SendMessage(const MessageType& message) { +void AbstractMessageHandler::SendMessage(const MessageType &message) { Q_ASSERT(QThread::currentThread() == thread()); std::string data = message.SerializeAsString(); @@ -131,33 +130,32 @@ void AbstractMessageHandler::SendMessage(const MessageType& message) { } template -void AbstractMessageHandler::SendMessageAsync(const MessageType& message) { +void AbstractMessageHandler::SendMessageAsync(const MessageType &message) { std::string data = message.SerializeAsString(); metaObject()->invokeMethod(this, "WriteMessage", Qt::QueuedConnection, Q_ARG(QByteArray, QByteArray(data.data(), data.size()))); } template -void AbstractMessageHandler::SendRequest(ReplyType* reply) { +void AbstractMessageHandler::SendRequest(ReplyType *reply) { pending_replies_[reply->id()] = reply; SendMessage(reply->request_message()); } template -void AbstractMessageHandler::SendReply(const MessageType& request, - MessageType* reply) { +void AbstractMessageHandler::SendReply(const MessageType &request, MessageType *reply) { reply->set_id(request.id()); SendMessage(*reply); } template -bool AbstractMessageHandler::RawMessageArrived(const QByteArray& data) { +bool AbstractMessageHandler::RawMessageArrived(const QByteArray &data) { MessageType message; if (!message.ParseFromArray(data.constData(), data.size())) { return false; } - ReplyType* reply = pending_replies_.take(message.id()); + ReplyType *reply = pending_replies_.take(message.id()); if (reply) { // This is a reply to a message that we created earlier. @@ -171,7 +169,7 @@ bool AbstractMessageHandler::RawMessageArrived(const QByteArray& data) { template void AbstractMessageHandler::AbortAll() { - for (ReplyType* reply : pending_replies_) { + for (ReplyType *reply : pending_replies_) { reply->Abort(); } pending_replies_.clear(); diff --git a/ext/libstrawberry-common/core/messagereply.cpp b/ext/libstrawberry-common/core/messagereply.cpp index 3c17cf43..8535020b 100644 --- a/ext/libstrawberry-common/core/messagereply.cpp +++ b/ext/libstrawberry-common/core/messagereply.cpp @@ -17,6 +17,11 @@ #include "messagereply.h" +#include +#include + +#include "core/logging.h" + _MessageReplyBase::_MessageReplyBase(QObject *parent) : QObject(parent), finished_(false), success_(false) {} diff --git a/ext/libstrawberry-common/core/messagereply.h b/ext/libstrawberry-common/core/messagereply.h index e71b320d..5e2e04ee 100644 --- a/ext/libstrawberry-common/core/messagereply.h +++ b/ext/libstrawberry-common/core/messagereply.h @@ -18,26 +18,26 @@ #ifndef MESSAGEREPLY_H #define MESSAGEREPLY_H +#include #include #include +#include #include "core/logging.h" -// Base QObject for a reply future class that is returned immediately for -// requests that will occur in the background. Similar to QNetworkReply. -// Use MessageReply instead. +// Base QObject for a reply future class that is returned immediately for requests that will occur in the background. +// Similar to QNetworkReply. Use MessageReply instead. class _MessageReplyBase : public QObject { Q_OBJECT public: - _MessageReplyBase(QObject* parent = nullptr); + _MessageReplyBase(QObject *parent = nullptr); virtual int id() const = 0; bool is_finished() const { return finished_; } bool is_successful() const { return success_; } - // Waits for the reply to finish by waiting on a semaphore. Never call this - // from the MessageHandler's thread or it will block forever. + // Waits for the reply to finish by waiting on a semaphore. Never call this from the MessageHandler's thread or it will block forever. // Returns true if the call was successful. bool WaitForFinished(); @@ -58,7 +58,7 @@ protected: template class MessageReply : public _MessageReplyBase { public: - MessageReply(const MessageType& request_message, QObject* parent = nullptr); + MessageReply(const MessageType& request_message, QObject *parent = nullptr); int id() const { return request_message_.id(); } const MessageType& request_message() const { return request_message_; } @@ -73,8 +73,7 @@ private: template -MessageReply::MessageReply(const MessageType& request_message, - QObject* parent) +MessageReply::MessageReply(const MessageType& request_message, QObject *parent) : _MessageReplyBase(parent) { request_message_.MergeFrom(request_message); @@ -94,4 +93,3 @@ void MessageReply::SetReply(const MessageType& message) { } #endif // MESSAGEREPLY_H - diff --git a/ext/libstrawberry-common/core/waitforsignal.cpp b/ext/libstrawberry-common/core/waitforsignal.cpp index 534ffdf9..be29120c 100644 --- a/ext/libstrawberry-common/core/waitforsignal.cpp +++ b/ext/libstrawberry-common/core/waitforsignal.cpp @@ -17,6 +17,7 @@ #include "waitforsignal.h" +#include #include void WaitForSignal(QObject *sender, const char *signal) { diff --git a/ext/libstrawberry-common/core/workerpool.cpp b/ext/libstrawberry-common/core/workerpool.cpp index 1767c009..9eba1a78 100644 --- a/ext/libstrawberry-common/core/workerpool.cpp +++ b/ext/libstrawberry-common/core/workerpool.cpp @@ -15,6 +15,8 @@ along with Strawberry. If not, see . */ +#include + #include "workerpool.h" _WorkerPoolBase::_WorkerPoolBase(QObject *parent) : QObject(parent) {} diff --git a/ext/libstrawberry-common/core/workerpool.h b/ext/libstrawberry-common/core/workerpool.h index 9e283171..4ed982cd 100644 --- a/ext/libstrawberry-common/core/workerpool.h +++ b/ext/libstrawberry-common/core/workerpool.h @@ -18,32 +18,37 @@ #ifndef WORKERPOOL_H #define WORKERPOOL_H -#include -#include -#include -#include -#include -#include +#include + +#include #include +#include +#include +#include #include #include -#include +#include +#include +#include +#include +#include +#include +#include -#include "core/closure.h" #include "core/logging.h" +class QLocalSocket; -// Base class containing signals and slots - required because moc doesn't do -// templated objects. + +// Base class containing signals and slots - required because moc doesn't do templated objects. class _WorkerPoolBase : public QObject { Q_OBJECT public: - _WorkerPoolBase(QObject* parent = nullptr); + _WorkerPoolBase(QObject *parent = nullptr); signals: - // Emitted when a worker failed to start. This usually happens when the - // worker wasn't found, or couldn't be executed. + // Emitted when a worker failed to start. This usually happens when the worker wasn't found, or couldn't be executed. void WorkerFailedToStart(); protected slots: @@ -54,45 +59,41 @@ protected slots: }; -// Manages a pool of one or more external processes. A local socket server is -// started for each process, and the address is passed to the process as -// argv[1]. The process is expected to connect back to the socket server, and -// when it does a HandlerType is created for it. +// Manages a pool of one or more external processes. +// A local socket server is started for each process, and the address is passed to the process as argv[1]. +// The process is expected to connect back to the socket server, and when it does a HandlerType is created for it. // Instances of HandlerType are created in the WorkerPool's thread. template class WorkerPool : public _WorkerPoolBase { public: - WorkerPool(QObject* parent = nullptr); + WorkerPool(QObject *parent = nullptr); ~WorkerPool(); typedef typename HandlerType::MessageType MessageType; typedef typename HandlerType::ReplyType ReplyType; - // Sets the name of the worker executable. This is looked for first in the - // current directory, and then in $PATH. You must call this before calling - // Start(). - void SetExecutableName(const QString& executable_name); + // Sets the name of the worker executable. This is looked for first in the current directory, and then in $PATH. + // You must call this before calling Start(). + void SetExecutableName(const QString &executable_name); - // Sets the number of worker process to use. Defaults to - // 1 <= (processors / 2) <= 2. + // Sets the number of worker process to use. Defaults to 1 <= (processors / 2) <= 2. void SetWorkerCount(int count); - // Sets the prefix to use for the local server (on unix this is a named pipe - // in /tmp). Defaults to QApplication::applicationName(). A random number - // is appended to this name when creating each server. - void SetLocalServerName(const QString& local_server_name); + // Sets the prefix to use for the local server (on unix this is a named pipe in /tmp). + // Defaults to QApplication::applicationName(). + // A random number is appended to this name when creating each server. + void SetLocalServerName(const QString &local_server_name); // Starts all workers. void Start(); - // Fills in the message's "id" field and creates a reply future. The message - // is queued and the WorkerPool's thread will send it to the next available - // worker. Can be called from any thread. - ReplyType* SendMessageWithReply(MessageType* message); + // Fills in the message's "id" field and creates a reply future. + // The message is queued and the WorkerPool's thread will send it to the next available worker. + // Can be called from any thread. + ReplyType *SendMessageWithReply(MessageType *message); protected: - // These are all reimplemented slots, they are called on the WorkerPool's - // thread. + // These are all reimplemented slots, they are called on the WorkerPool's thread. void DoStart(); void NewConnection(); void ProcessError(QProcess::ProcessError error); @@ -105,14 +106,14 @@ private: QLocalServer *local_server_; QLocalSocket *local_socket_; QProcess *process_; - HandlerType* handler_; + HandlerType *handler_; }; // Must only ever be called on my thread. - void StartOneWorker(Worker* worker); + void StartOneWorker(Worker *worker); template - Worker* FindWorker(T Worker::*member, T value) { + Worker *FindWorker(T Worker::*member, T value) { for (typename QList::iterator it = workers_.begin() ; it != workers_.end() ; ++it) { if ((*it).*member == value) { @@ -123,7 +124,7 @@ private: } template - void DeleteQObjectPointerLater(T** p) { + void DeleteQObjectPointerLater(T **p) { if (*p) { (*p)->deleteLater(); *p = NULL; @@ -131,13 +132,11 @@ private: } // Creates a new reply future for the request with the next sequential ID, - // and sets the request's ID to the ID of the reply. Can be called from any - // thread - ReplyType* NewReply(MessageType* message); + // and sets the request's ID to the ID of the reply. Can be called from any thread + ReplyType *NewReply(MessageType *message); - // Returns the next handler, or NULL if there isn't one. Must be called from - // my thread. - HandlerType* NextHandler() const; + // Returns the next handler, or NULL if there isn't one. Must be called from my thread. + HandlerType *NextHandler() const; private: QString local_server_name_; @@ -156,7 +155,7 @@ private: template -WorkerPool::WorkerPool(QObject* parent) +WorkerPool::WorkerPool(QObject *parent) : _WorkerPoolBase(parent), next_worker_(0), next_id_(0) @@ -170,7 +169,7 @@ WorkerPool::WorkerPool(QObject* parent) template WorkerPool::~WorkerPool() { - for (const Worker& worker : workers_) { + for (const Worker &worker : workers_) { if (worker.local_socket_ && worker.process_) { disconnect(worker.process_, SIGNAL(error(QProcess::ProcessError)), this, SLOT(ProcessError(QProcess::ProcessError))); @@ -190,7 +189,7 @@ WorkerPool::~WorkerPool() { } } - for (ReplyType* reply : message_queue_) { + for (ReplyType *reply : message_queue_) { reply->Abort(); } } @@ -202,13 +201,13 @@ void WorkerPool::SetWorkerCount(int count) { } template -void WorkerPool::SetLocalServerName(const QString& local_server_name) { +void WorkerPool::SetLocalServerName(const QString &local_server_name) { Q_ASSERT(workers_.isEmpty()); local_server_name_ = local_server_name; } template -void WorkerPool::SetExecutableName(const QString& executable_name) { +void WorkerPool::SetExecutableName(const QString &executable_name) { Q_ASSERT(workers_.isEmpty()); executable_name_ = executable_name; } @@ -233,7 +232,7 @@ void WorkerPool::DoStart() { search_path << qApp->applicationDirPath() + "/../PlugIns"; #endif - for (const QString& path_prefix : search_path) { + for (const QString &path_prefix : search_path) { const QString executable_path = path_prefix + "/" + executable_name_; if (QFile::exists(executable_path)) { executable_path_ = executable_path; @@ -290,7 +289,7 @@ void WorkerPool::NewConnection() { QLocalServer *server = qobject_cast(sender()); // Find the worker with this server. - Worker* worker = FindWorker(&Worker::local_server_, server); + Worker *worker = FindWorker(&Worker::local_server_, server); if (!worker) return; qLog(Debug) << "Worker" << worker << "connected to" << server->fullServerName(); @@ -322,9 +321,8 @@ void WorkerPool::ProcessError(QProcess::ProcessError error) { switch (error) { case QProcess::FailedToStart: - // Failed to start errors are bad - it usually means the worker isn't - // installed. Don't restart the process, but tell our owner, who will - // probably want to do something fatal. + // Failed to start errors are bad - it usually means the worker isn't installed. + // Don't restart the process, but tell our owner, who will probably want to do something fatal. qLog(Error) << "Worker failed to start"; emit WorkerFailedToStart(); break; @@ -339,7 +337,7 @@ void WorkerPool::ProcessError(QProcess::ProcessError error) { template typename WorkerPool::ReplyType* -WorkerPool::NewReply(MessageType* message) { +WorkerPool::NewReply(MessageType *message) { const int id = next_id_.fetchAndAddOrdered(1); message->set_id(id); @@ -348,8 +346,8 @@ WorkerPool::NewReply(MessageType* message) { template typename WorkerPool::ReplyType* -WorkerPool::SendMessageWithReply(MessageType* message) { - ReplyType* reply = NewReply(message); +WorkerPool::SendMessageWithReply(MessageType *message) { + ReplyType *reply = NewReply(message); // Add the pending reply to the queue { @@ -371,7 +369,7 @@ void WorkerPool::SendQueuedMessages() { ReplyType *reply = message_queue_.dequeue(); // Find a worker for this message - HandlerType* handler = NextHandler(); + HandlerType *handler = NextHandler(); if (!handler) { // No available handlers - put the message on the front of the queue. message_queue_.prepend(reply); diff --git a/ext/libstrawberry-tagreader/fmpsparser.cpp b/ext/libstrawberry-tagreader/fmpsparser.cpp index 4061635a..600f4194 100644 --- a/ext/libstrawberry-tagreader/fmpsparser.cpp +++ b/ext/libstrawberry-tagreader/fmpsparser.cpp @@ -15,12 +15,15 @@ along with Strawberry. If not, see . */ -#include "fmpsparser.h" +#include "config.h" #include -#include -#include +#include +#include +#include + +#include "fmpsparser.h" using std::placeholders::_1; using std::placeholders::_2; @@ -114,8 +117,7 @@ int FMPSParser::ParseListListRef(const QStringRef &data, Result *ret) const { return ParseContainer<';'>(data, std::bind(&FMPSParser::ParseListRef, this, _1, _2), ret); } -// Convenience functions that take QStrings instead of QStringRefs. Use the -// QStringRef versions if possible, they're faster. +// Convenience functions that take QStrings instead of QStringRefs. Use the QStringRef versions if possible, they're faster. int FMPSParser::ParseValue(const QString &data, QVariant *ret) const { return ParseValueRef(QStringRef(&data), ret); } diff --git a/ext/libstrawberry-tagreader/fmpsparser.h b/ext/libstrawberry-tagreader/fmpsparser.h index 9b00fed8..81c7f7c3 100644 --- a/ext/libstrawberry-tagreader/fmpsparser.h +++ b/ext/libstrawberry-tagreader/fmpsparser.h @@ -18,8 +18,13 @@ #ifndef FMPSPARSER_H #define FMPSPARSER_H +#include "config.h" + +#include +#include +#include +#include #include -#include class FMPSParser { public: @@ -30,7 +35,7 @@ public: typedef QList Result; // Parses a FMPS value and returns true on success. - bool Parse(const QString& data); + bool Parse(const QString &data); // Gets the result of the last successful Parse. Result result() const { return result_; } diff --git a/ext/libstrawberry-tagreader/tagreader.cpp b/ext/libstrawberry-tagreader/tagreader.cpp index 7d344ebb..91834ccf 100644 --- a/ext/libstrawberry-tagreader/tagreader.cpp +++ b/ext/libstrawberry-tagreader/tagreader.cpp @@ -15,50 +15,75 @@ along with Strawberry. If not, see . */ +#include "config.h" + #include "tagreader.h" #include - -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#ifdef TAGLIB_HAS_OPUS - #include -#endif -#include -#include -#include -#include -#include -#include -#include -#include -#include - +#include +#include +#include #include -#include "fmpsparser.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "taglib/id3v2frame.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "taglib/asftag.h" +#include "taglib/asfattribute.h" +#include "taglib/asfproperties.h" +#include +#include +#include "taglib/mp4item.h" +#include +#include +#include +#include + +#ifdef TAGLIB_HAS_OPUS + #include +#endif + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + #include "core/logging.h" #include "core/messagehandler.h" + +#include "fmpsparser.h" #include "core/timeconstants.h" // Taglib added support for FLAC pictures in 1.7.0 @@ -71,12 +96,12 @@ class FileRefFactory { public: virtual ~FileRefFactory() {} - virtual TagLib::FileRef *GetFileRef(const QString& filename) = 0; + virtual TagLib::FileRef *GetFileRef(const QString &filename) = 0; }; class TagLibFileRefFactory : public FileRefFactory { public: - virtual TagLib::FileRef *GetFileRef(const QString& filename) { + virtual TagLib::FileRef *GetFileRef(const QString &filename) { #ifdef Q_OS_WIN32 return new TagLib::FileRef(filename.toStdWString().c_str()); #else @@ -87,11 +112,11 @@ class TagLibFileRefFactory : public FileRefFactory { namespace { -TagLib::String StdStringToTaglibString(const std::string& s) { +TagLib::String StdStringToTaglibString(const std::string &s) { return TagLib::String(s.c_str(), TagLib::String::UTF8); } -TagLib::String QStringToTaglibString(const QString& s) { +TagLib::String QStringToTaglibString(const QString &s) { return TagLib::String(s.toUtf8().constData(), TagLib::String::UTF8); } @@ -508,8 +533,7 @@ bool TagReader::SaveFile(const QString &filename, const pb::tagreader::SongMetad } // Handle all the files which have VorbisComments (Ogg, OPUS, ...) in the same way; - // apart, so we keep specific behavior for some formats by adding another - // "else if" block above. + // apart, so we keep specific behavior for some formats by adding another "else if" block above. if (TagLib::Ogg::XiphComment *tag = dynamic_cast(fileref->file()->tag())) { SetVorbisComments(tag, song); } @@ -625,9 +649,7 @@ QByteArray TagReader::LoadEmbeddedArt(const QString &filename) const { TagLib::Ogg::FieldListMap map = xiph_comment->fieldListMap(); #if TAGLIB_MAJOR_VERSION <= 1 && TAGLIB_MINOR_VERSION < 11 - // Other than the below mentioned non-standard COVERART, - // METADATA_BLOCK_PICTURE - // is the proposed tag for cover pictures. + // Other than the below mentioned non-standard COVERART, METADATA_BLOCK_PICTURE is the proposed tag for cover pictures. // (see http://wiki.xiph.org/VorbisComment#METADATA_BLOCK_PICTURE) if (map.contains("METADATA_BLOCK_PICTURE")) { TagLib::StringList pict_list = map["METADATA_BLOCK_PICTURE"]; @@ -687,10 +709,10 @@ QByteArray TagReader::LoadEmbeddedArt(const QString &filename) const { TagLib::MP4::File *aac_file = dynamic_cast(ref.file()); if (aac_file) { TagLib::MP4::Tag *tag = aac_file->tag(); - const TagLib::MP4::ItemListMap& items = tag->itemListMap(); + const TagLib::MP4::ItemListMap &items = tag->itemListMap(); TagLib::MP4::ItemListMap::ConstIterator it = items.find("covr"); if (it != items.end()) { - const TagLib::MP4::CoverArtList& art_list = it->second.toCoverArtList(); + const TagLib::MP4::CoverArtList &art_list = it->second.toCoverArtList(); if (!art_list.isEmpty()) { // Just take the first one for now diff --git a/ext/libstrawberry-tagreader/tagreader.h b/ext/libstrawberry-tagreader/tagreader.h index 64857931..21fb998e 100644 --- a/ext/libstrawberry-tagreader/tagreader.h +++ b/ext/libstrawberry-tagreader/tagreader.h @@ -18,18 +18,19 @@ #ifndef TAGREADER_H #define TAGREADER_H +#include "config.h" + +#include + #include +#include +#include +#include #include -#include "config.h" #include "tagreadermessages.pb.h" -class QNetworkAccessManager; -class QString; -class QTextCodec; -class QUrl; - namespace TagLib { class FileRef; class String; @@ -44,15 +45,14 @@ class FileRefFactory; /** * This class holds all useful methods to read and write tags from/to files. - * You should not use it directly in the main process but rather use a - * TagReaderWorker process (using TagReaderClient) + * You should not use it directly in the main process but rather use a TagReaderWorker process (using TagReaderClient) */ class TagReader { public: TagReader(); - void ReadFile(const QString& filename, pb::tagreader::SongMetadata *song) const; - bool SaveFile(const QString& filename, const pb::tagreader::SongMetadata &song) const; + void ReadFile(const QString &filename, pb::tagreader::SongMetadata *song) const; + bool SaveFile(const QString &filename, const pb::tagreader::SongMetadata &song) const; bool IsMediaFile(const QString &filename) const; QByteArray LoadEmbeddedArt(const QString &filename) const; diff --git a/ext/strawberry-tagreader/main.cpp b/ext/strawberry-tagreader/main.cpp index 5a260e29..1ecb4bba 100644 --- a/ext/strawberry-tagreader/main.cpp +++ b/ext/strawberry-tagreader/main.cpp @@ -15,16 +15,23 @@ along with Strawberry. If not, see . */ -#include "tagreaderworker.h" -#include "core/logging.h" +#include "config.h" +#include +#include + +#include #include +#include #include +#include +#include #include #include +#include -#include -#include +#include "core/logging.h" +#include "tagreaderworker.h" int main(int argc, char **argv) { diff --git a/ext/strawberry-tagreader/tagreaderworker.cpp b/ext/strawberry-tagreader/tagreaderworker.cpp index 49426d44..b058b5b7 100644 --- a/ext/strawberry-tagreader/tagreaderworker.cpp +++ b/ext/strawberry-tagreader/tagreaderworker.cpp @@ -15,15 +15,16 @@ along with Strawberry. If not, see . */ -#include "tagreaderworker.h" +#include "config.h" + +#include #include -#include -#include -#include -#include -#include +#include +#include +#include +#include "tagreaderworker.h" TagReaderWorker::TagReaderWorker(QIODevice *socket, QObject *parent) : AbstractMessageHandler(socket, parent) diff --git a/ext/strawberry-tagreader/tagreaderworker.h b/ext/strawberry-tagreader/tagreaderworker.h index 798f112b..355657e0 100644 --- a/ext/strawberry-tagreader/tagreaderworker.h +++ b/ext/strawberry-tagreader/tagreaderworker.h @@ -19,9 +19,15 @@ #define TAGREADERWORKER_H #include "config.h" + +#include + +#include +#include + +#include "core/messagehandler.h" #include "tagreader.h" #include "tagreadermessages.pb.h" -#include "core/messagehandler.h" class TagReaderWorker : public AbstractMessageHandler { public: diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index b0efe3d4..343fa1ef 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -474,11 +474,7 @@ set(UI ) -set(RESOURCES - ../data/data.qrc - #../data/icons.qrc -) - +set(RESOURCES ../data/data.qrc) set(OTHER_SOURCES) option(USE_INSTALL_PREFIX "Look for data in CMAKE_INSTALL_PREFIX" ON) @@ -487,7 +483,6 @@ option(USE_INSTALL_PREFIX "Look for data in CMAKE_INSTALL_PREFIX" ON) set(GST_ENGINE_SRC engine/gstengine.cpp engine/gstenginepipeline.cpp engine/gstelementdeleter.cpp) set(GST_ENGINE_MOC engine/gstengine.h engine/gstenginepipeline.h engine/gstelementdeleter.h) -#set(GST_ENGINE_LIB GSTREAMER GSTREAMER_BASE GSTREAMER_APP GSTREAMER_AUDIO GSTREAMER_TAG GSTREAMER_PBUTILS GSTREAMER_QTGLIB GSTREAMER_QTGST GSTREAMER_QTGSTUI GSTREAMER_QTGSTUTILS) set(GST_ENGINE_LIB GSTREAMER GSTREAMER_BASE GSTREAMER_APP GSTREAMER_AUDIO GSTREAMER_TAG GSTREAMER_PBUTILS) #set(GST_ENGINE_LIB gstreamer-1.0 gstreamer-base-1.0 gstreamer-app-1.0 streamer-audio-1.0 gstreamer-tag-1.0 gstreamer-pbutils-1.0) #set(GST_ENGINE_LIB ${GSTREAMER_BASE_LIBRARIES} ${GSTREAMER_LIBRARIES} ${GSTREAMER_APP_LIBRARIES} ${GSTREAMER_TAG_LIBRARIES} ${GSTREAMER_PBUTILS_LIBRARIES}) @@ -846,6 +841,7 @@ add_library(strawberry_lib STATIC target_link_libraries(strawberry_lib libstrawberry-common libstrawberry-tagreader + #gstafc ${GLIB_LIBRARIES} ${GIO_LIBRARIES} ${SHA2_LIBRARIES} @@ -886,7 +882,6 @@ if(HAVE_IMOBILEDEVICE) ${IMOBILEDEVICE_LIBRARIES} ${PLIST_LIBRARIES} ${USBMUXD_LIBRARIES} - gstafcsrc ) link_directories(${IMOBILEDEVICE_LIBRARY_DIRS}) link_directories(${USBMUXD_LIBRARY_DIRS}) diff --git a/src/analyzer/analyzer.cpp b/src/analyzer/analyzer.cpp index c708172f..6f8a7f13 100644 --- a/src/analyzer/analyzer.cpp +++ b/src/analyzer/analyzer.cpp @@ -1,11 +1,17 @@ +#include "config.h" + +#include +#include +#include + #include "analyzer.h" -#include "engines/enginebase.h" +#include "engine/enginebase.h" -AnalyzerBase::AnalyzerBase(QWidget* parent) +AnalyzerBase::AnalyzerBase(QWidget *parent) : QGLWidget(parent), engine_(nullptr) {} -void AnalyzerBase::set_engine(Engine::Base* engine) { +void AnalyzerBase::set_engine(Engine::Base *engine) { disconnect(engine_); engine_ = engine; if (engine_) { diff --git a/src/analyzer/analyzerbase.cpp b/src/analyzer/analyzerbase.cpp index 37c38173..bc70dd86 100755 --- a/src/analyzer/analyzerbase.cpp +++ b/src/analyzer/analyzerbase.cpp @@ -15,14 +15,17 @@ * * ***************************************************************************/ -#include "analyzerbase.h" +#include "config.h" -#include //interpolate() +#include -#include //event() +#include #include -#include -#include +#include +#include +#include + +#include "analyzerbase.h" #include "engine/enginebase.h" @@ -45,7 +48,7 @@ template class Analyzer::Base; #endif -Analyzer::Base::Base(QWidget* parent, uint scopeSize) +Analyzer::Base::Base(QWidget *parent, uint scopeSize) : QWidget(parent), m_timeout(40) // msec , @@ -70,9 +73,9 @@ void Analyzer::Base::transform(Scope& scope) // virtual // values // scope.resize( m_fht->size() ); - float* front = static_cast(&scope.front()); + float *front = static_cast(&scope.front()); - float* f = new float[m_fht->size()]; + float *f = new float[m_fht->size()]; m_fht->copy(&f[0], front); m_fht->logSpectrum(front, &f[0]); m_fht->scale(front, 1.0 / 20); @@ -82,7 +85,7 @@ void Analyzer::Base::transform(Scope& scope) // virtual } -void Analyzer::Base::paintEvent(QPaintEvent* e) { +void Analyzer::Base::paintEvent(QPaintEvent *e) { QPainter p(this); p.fillRect(e->rect(), palette().color(QPalette::Window)); @@ -92,8 +95,7 @@ void Analyzer::Base::paintEvent(QPaintEvent* e) { const Engine::Scope& thescope = m_engine->scope(m_timeout); int i = 0; - // convert to mono here - our built in analyzers need mono, but the - // engines provide interleaved pcm + // convert to mono here - our built in analyzers need mono, but the engines provide interleaved pcm for (uint x = 0; (int)x < m_fht->size(); ++x) { m_lastScope[x] = double(thescope[i] + thescope[i + 1]) / (2 * (1 << 15)); i += 2; @@ -180,8 +182,7 @@ void Analyzer::Base::polishEvent() { init(); // virtual } -void Analyzer::interpolate(const Scope& inVec, Scope& outVec) // static -{ +void Analyzer::interpolate(const Scope& inVec, Scope& outVec) { double pos = 0.0; const double step = (double)inVec.size() / outVec.size(); @@ -203,8 +204,7 @@ void Analyzer::interpolate(const Scope& inVec, Scope& outVec) // static } -void Analyzer::initSin(Scope& v, const uint size) // static -{ +void Analyzer::initSin(Scope& v, const uint size) { double step = (M_PI * 2) / size; double radian = 0; @@ -214,7 +214,7 @@ void Analyzer::initSin(Scope& v, const uint size) // static } } -void Analyzer::Base::timerEvent(QTimerEvent* e) { +void Analyzer::Base::timerEvent(QTimerEvent *e) { QWidget::timerEvent(e); if (e->timerId() != m_timer.timerId()) return; diff --git a/src/analyzer/analyzerbase.h b/src/analyzer/analyzerbase.h index 795b5c95..bdca9147 100644 --- a/src/analyzer/analyzerbase.h +++ b/src/analyzer/analyzerbase.h @@ -4,29 +4,38 @@ #ifndef ANALYZERBASE_H #define ANALYZERBASE_H +#include "config.h" + #ifdef __FreeBSD__ #include #endif -#include "analyzer/fht.h" //stack allocated and convenience -#include "engine/engine_fwd.h" -#include //stack allocated and convenience -#include //stack allocated -#include //baseclass -#include //included for convenience +#include +#include -#include //baseclass #ifdef Q_WS_MACX -#include //included for convenience -#include //included for convenience + #include //included for convenience + #include //included for convenience #else -#include //included for convenience -#include //included for convenience + #include //included for convenience + #include //included for convenience #endif -class QEvent; +#include +#include +#include +#include +#include +#include +#include + +#include "analyzer/fht.h" +#include "engine/engine_fwd.h" + +class QHideEvent; +class QShowEvent; +class QTimerEvent; class QPaintEvent; -class QResizeEvent; namespace Analyzer { diff --git a/src/analyzer/analyzercontainer.cpp b/src/analyzer/analyzercontainer.cpp index 7bdfd386..6397f76a 100644 --- a/src/analyzer/analyzercontainer.cpp +++ b/src/analyzer/analyzercontainer.cpp @@ -17,19 +17,32 @@ along with Strawberry. If not, see . */ +#include "config.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + #include "analyzercontainer.h" + +#include "analyzerbase.h" #include "blockanalyzer.h" #include "core/logging.h" -#include -#include -#include -#include -#include - -const char* AnalyzerContainer::kSettingsGroup = "Analyzer"; -const char* AnalyzerContainer::kSettingsFramerate = "framerate"; +const char *AnalyzerContainer::kSettingsGroup = "Analyzer"; +const char *AnalyzerContainer::kSettingsFramerate = "framerate"; // Framerates const int AnalyzerContainer::kLowFramerate = 20; @@ -37,7 +50,7 @@ const int AnalyzerContainer::kMediumFramerate = 25; const int AnalyzerContainer::kHighFramerate = 30; const int AnalyzerContainer::kSuperHighFramerate = 60; -AnalyzerContainer::AnalyzerContainer(QWidget* parent) +AnalyzerContainer::AnalyzerContainer(QWidget *parent) : QWidget(parent), current_framerate_(kMediumFramerate), context_menu_(new QMenu(this)), @@ -51,7 +64,7 @@ AnalyzerContainer::AnalyzerContainer(QWidget* parent) ignore_next_click_(false), current_analyzer_(nullptr), engine_(nullptr) { - QHBoxLayout* layout = new QHBoxLayout(this); + QHBoxLayout *layout = new QHBoxLayout(this); setLayout(layout); layout->setContentsMargins(0, 0, 0, 0); @@ -82,19 +95,18 @@ AnalyzerContainer::AnalyzerContainer(QWidget* parent) Load(); } -void AnalyzerContainer::SetActions(QAction* visualisation) { +void AnalyzerContainer::SetActions(QAction *visualisation) { visualisation_action_ = visualisation; context_menu_->addAction(visualisation_action_); } -void AnalyzerContainer::mouseReleaseEvent(QMouseEvent* e) { +void AnalyzerContainer::mouseReleaseEvent(QMouseEvent *e) { if (e->button() == Qt::LeftButton) { if (ignore_next_click_) { ignore_next_click_ = false; } else { - // Might be the first click in a double click, so wait a while before - // actually doing anything + // Might be the first click in a double click, so wait a while before actually doing anything double_click_timer_->start(); last_click_pos_ = e->globalPos(); } @@ -115,11 +127,11 @@ void AnalyzerContainer::mouseDoubleClickEvent(QMouseEvent*) { if (visualisation_action_) visualisation_action_->trigger(); } -void AnalyzerContainer::wheelEvent(QWheelEvent* e) { +void AnalyzerContainer::wheelEvent(QWheelEvent *e) { emit WheelEvent(e->delta()); } -void AnalyzerContainer::SetEngine(EngineBase* engine) { +void AnalyzerContainer::SetEngine(EngineBase *engine) { if (current_analyzer_) current_analyzer_->set_engine(engine); engine_ = engine; } @@ -132,11 +144,10 @@ void AnalyzerContainer::DisableAnalyzer() { } void AnalyzerContainer::ChangeAnalyzer(int id) { - QObject* instance = analyzer_types_[id]->newInstance(Q_ARG(QWidget*, this)); + QObject *instance = analyzer_types_[id]->newInstance(Q_ARG(QWidget*, this)); if (!instance) { - qLog(Warning) << "Couldn't intialise a new" - << analyzer_types_[id]->className(); + qLog(Warning) << "Couldn't intialise a new" << analyzer_types_[id]->className(); return; } @@ -196,8 +207,7 @@ void AnalyzerContainer::Load() { } void AnalyzerContainer::SaveFramerate(int framerate) { - // For now, framerate is common for all analyzers. Maybe each analyzer should - // have its own framerate? + // For now, framerate is common for all analyzers. Maybe each analyzer should have its own framerate? current_framerate_ = framerate; QSettings s; s.beginGroup(kSettingsGroup); @@ -212,7 +222,7 @@ void AnalyzerContainer::Save() { } void AnalyzerContainer::AddFramerate(const QString& name, int framerate) { - QAction* action = context_menu_framerate_->addAction(name, mapper_framerate_, SLOT(map())); + QAction *action = context_menu_framerate_->addAction(name, mapper_framerate_, SLOT(map())); mapper_framerate_->setMapping(action, framerate); group_framerate_->addAction(action); framerate_list_ << framerate; diff --git a/src/analyzer/analyzercontainer.h b/src/analyzer/analyzercontainer.h index c2ce73af..597d534f 100644 --- a/src/analyzer/analyzercontainer.h +++ b/src/analyzer/analyzercontainer.h @@ -20,13 +20,31 @@ #ifndef ANALYZERCONTAINER_H #define ANALYZERCONTAINER_H -#include -#include -#include +#include "config.h" + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include -#include "analyzerbase.h" #include "engine/engine_fwd.h" +class QMouseEvent; +class QWheelEvent; + +namespace Analyzer { +class Base; +} // namespace Analyzer + class AnalyzerContainer : public QWidget { Q_OBJECT diff --git a/src/analyzer/blockanalyzer.cpp b/src/analyzer/blockanalyzer.cpp index 80294d54..781e41a4 100644 --- a/src/analyzer/blockanalyzer.cpp +++ b/src/analyzer/blockanalyzer.cpp @@ -5,12 +5,19 @@ #include "blockanalyzer.h" -#include - -#include -#include #include +#include +#include + +#include +#include #include +#include +#include +#include + +#include "analyzerbase.h" +#include "fht.h" const uint BlockAnalyzer::HEIGHT = 2; const uint BlockAnalyzer::WIDTH = 4; @@ -19,10 +26,10 @@ const uint BlockAnalyzer::MIN_COLUMNS = 32; // arbituary const uint BlockAnalyzer::MAX_COLUMNS = 256; // must be 2**n const uint BlockAnalyzer::FADE_SIZE = 90; -const char* BlockAnalyzer::kName = +const char *BlockAnalyzer::kName = QT_TRANSLATE_NOOP("AnalyzerContainer", "Block analyzer"); -BlockAnalyzer::BlockAnalyzer(QWidget* parent) +BlockAnalyzer::BlockAnalyzer(QWidget *parent) : Analyzer::Base(parent, 9), m_columns(0) // uint , @@ -43,9 +50,7 @@ BlockAnalyzer::BlockAnalyzer(QWidget* parent) , m_fade_intensity(1 << 8, 32) // vector { - setMinimumSize(MIN_COLUMNS * (WIDTH + 1) - 1, - MIN_ROWS * (HEIGHT + 1) - - 1); //-1 is padding, no drawing takes place there + setMinimumSize(MIN_COLUMNS * (WIDTH + 1) - 1, MIN_ROWS * (HEIGHT + 1) - 1); //-1 is padding, no drawing takes place there setMaximumWidth(MAX_COLUMNS * (WIDTH + 1) - 1); // mxcl says null pixmaps cause crashes, so let's play it safe @@ -54,7 +59,7 @@ BlockAnalyzer::BlockAnalyzer(QWidget* parent) BlockAnalyzer::~BlockAnalyzer() {} -void BlockAnalyzer::resizeEvent(QResizeEvent* e) { +void BlockAnalyzer::resizeEvent(QResizeEvent *e) { QWidget::resizeEvent(e); m_background = QPixmap(size()); @@ -96,8 +101,7 @@ void BlockAnalyzer::resizeEvent(QResizeEvent* e) { } void BlockAnalyzer::determineStep() { - // falltime is dependent on rowcount due to our digital resolution (ie we have - // boxes/blocks of pixels) + // falltime is dependent on rowcount due to our digital resolution (ie we have boxes/blocks of pixels) // I calculated the value 30 based on some trial and error // the fall time of 30 is too slow on framerates above 50fps @@ -119,10 +123,7 @@ void BlockAnalyzer::transform(Analyzer::Scope& s) // pure virtual m_fht->spectrum(front); m_fht->scale(front, 1.0 / 20); - // the second half is pretty dull, so only show it if the user has a large - // analyzer - // by setting to m_scope.size() if large we prevent interpolation of large - // analyzers, this is good! + // the second half is pretty dull, so only show it if the user has a large analyzer by setting to m_scope.size() if large we prevent interpolation of large analyzers, this is good! s.resize(m_scope.size() <= MAX_COLUMNS / 2 ? MAX_COLUMNS / 2 : m_scope.size()); } @@ -158,15 +159,13 @@ void BlockAnalyzer::analyze(QPainter& p, const Analyzer::Scope& s, for (y = 0; m_scope[x] < m_yscale[y]; ++y) ; - // this is opposite to what you'd think, higher than y - // means the bar is lower than y (physically) + // this is opposite to what you'd think, higher than y means the bar is lower than y (physically) if ((float)y > m_store[x]) y = int(m_store[x] += m_step); else m_store[x] = y; - // if y is lower than m_fade_pos, then the bar has exceeded the height of - // the fadeout + // if y is lower than m_fade_pos, then the bar has exceeded the height of the fadeout // if the fadeout is quite faded now, then display the new one if (y <= m_fade_pos[x] /*|| m_fade_intensity[x] < FADE_SIZE / 3*/) { m_fade_pos[x] = y; @@ -181,8 +180,7 @@ void BlockAnalyzer::analyze(QPainter& p, const Analyzer::Scope& s, if (m_fade_intensity[x] == 0) m_fade_pos[x] = m_rows; - // REMEMBER: y is a number from 0 to m_rows, 0 means all blocks are glowing, - // m_rows means none are + // REMEMBER: y is a number from 0 to m_rows, 0 means all blocks are glowing, m_rows means none are canvas_painter.drawPixmap(x * (WIDTH + 1), y * (HEIGHT + 1) + m_y, *bar(), 0, y * (HEIGHT + 1), bar()->width(), bar()->height()); @@ -195,8 +193,7 @@ void BlockAnalyzer::analyze(QPainter& p, const Analyzer::Scope& s, } static inline void adjustToLimits(int& b, int& f, uint& amount) { - // with a range of 0-255 and maximum adjustment of amount, - // maximise the difference between f and b + // with a range of 0-255 and maximum adjustment of amount, maximise the difference between f and b if (b < f) { if (b > 255 - f) { diff --git a/src/analyzer/blockanalyzer.h b/src/analyzer/blockanalyzer.h index eeaf8cf2..e77bf72d 100644 --- a/src/analyzer/blockanalyzer.h +++ b/src/analyzer/blockanalyzer.h @@ -5,12 +5,21 @@ #ifndef BLOCKANALYZER_H #define BLOCKANALYZER_H +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include + #include "analyzerbase.h" -#include class QResizeEvent; -class QMouseEvent; -class QPalette; /** * @author Max Howell diff --git a/src/analyzer/fht.cpp b/src/analyzer/fht.cpp index 9d88631c..50206961 100644 --- a/src/analyzer/fht.cpp +++ b/src/analyzer/fht.cpp @@ -20,6 +20,7 @@ #include #include + #include "fht.h" FHT::FHT(int n) : m_buf(0), m_tab(0), m_log(0) { diff --git a/src/collection/collection.cpp b/src/collection/collection.cpp index c408fc47..b456a3f9 100644 --- a/src/collection/collection.cpp +++ b/src/collection/collection.cpp @@ -20,19 +20,23 @@ #include "config.h" +#include + +#include #include +#include -#include "collection.h" - -#include "collectionmodel.h" -#include "collectionbackend.h" #include "core/application.h" #include "core/database.h" #include "core/player.h" #include "core/tagreaderclient.h" -#include "core/taskmanager.h" #include "core/thread.h" -#include "core/logging.h" +#include "core/utilities.h" +#include "collection.h" +#include "collectionwatcher.h" +#include "collectionbackend.h" +#include "collectionmodel.h" +#include "playlist/playlistmanager.h" const char *Collection::kSongsTable = "songs"; const char *Collection::kDirsTable = "directories"; @@ -47,8 +51,6 @@ Collection::Collection(Application *app, QObject *parent) watcher_(nullptr), watcher_thread_(nullptr) { - //qLog(Debug) << __PRETTY_FUNCTION__; - backend_ = new CollectionBackend; backend()->moveToThread(app->database()->thread()); @@ -62,8 +64,6 @@ Collection::Collection(Application *app, QObject *parent) } Collection::~Collection() { - - //qLog(Debug) << __PRETTY_FUNCTION__; watcher_->deleteLater(); watcher_thread_->exit(); @@ -71,8 +71,6 @@ Collection::~Collection() { } void Collection::Init() { - - //qLog(Debug) << __PRETTY_FUNCTION__; watcher_ = new CollectionWatcher; watcher_thread_ = new Thread(this); @@ -109,8 +107,6 @@ void Collection::PauseWatcher() { watcher_->SetRescanPausedAsync(true); } void Collection::ResumeWatcher() { watcher_->SetRescanPausedAsync(false); } void Collection::ReloadSettings() { - - //qLog(Debug) << __PRETTY_FUNCTION__; watcher_->ReloadSettingsAsync(); @@ -118,14 +114,10 @@ void Collection::ReloadSettings() { void Collection::Stopped() { - //qLog(Debug) << __PRETTY_FUNCTION__; - CurrentSongChanged(Song()); } void Collection::CurrentSongChanged(const Song &song) { - - //qLog(Debug) << __PRETTY_FUNCTION__; TagReaderReply *reply = nullptr; @@ -140,8 +132,6 @@ void Collection::CurrentSongChanged(const Song &song) { SongList Collection::FilterCurrentWMASong(SongList songs, Song* queued) { - //qLog(Debug) << __PRETTY_FUNCTION__; - for (SongList::iterator it = songs.begin(); it != songs.end(); ) { if (it->url() == current_wma_song_url_) { *queued = *it; diff --git a/src/collection/collection.h b/src/collection/collection.h index 619f35c6..9db2e102 100644 --- a/src/collection/collection.h +++ b/src/collection/collection.h @@ -23,19 +23,18 @@ #include "config.h" -#include #include +#include +#include #include #include "core/song.h" class Application; -class Database; +class Thread; class CollectionBackend; class CollectionModel; class CollectionWatcher; -class TaskManager; -class Thread; class Collection : public QObject { Q_OBJECT @@ -85,13 +84,11 @@ class Collection : public QObject { CollectionWatcher *watcher_; Thread *watcher_thread_; - // Hack: Gstreamer doesn't cope well with WMA files being rewritten while - // being played, so we delay statistics and rating changes until the current - // song has finished playing. + // Hack: Gstreamer doesn't cope well with WMA files being rewritten while being played, + // so we delay statistics and rating changes until the current song has finished playing. QUrl current_wma_song_url_; - // DB schema versions which should trigger a full collection rescan (each of - // those with a short reason why). + // DB schema versions which should trigger a full collection rescan (each of those with a short reason why). QHash full_rescan_revisions_; }; diff --git a/src/collection/collectionbackend.cpp b/src/collection/collectionbackend.cpp index f962bb9e..fffa49f0 100644 --- a/src/collection/collectionbackend.cpp +++ b/src/collection/collectionbackend.cpp @@ -20,22 +20,32 @@ #include "config.h" -#include -#include -#include +#include +#include +#include +#include +#include +#include #include -#include +#include #include +#include +#include +#include +#include +#include #include +#include "core/application.h" +#include "core/database.h" +#include "core/logging.h" +#include "core/scopedtransaction.h" +#include "core/utilities.h" + +#include "directory.h" #include "collectionbackend.h" #include "collectionquery.h" #include "sqlrow.h" -#include "core/application.h" -#include "core/database.h" -#include "core/scopedtransaction.h" -#include "core/tagreaderclient.h" -#include "core/utilities.h" const char *CollectionBackend::kSettingsGroup = "Collection"; @@ -258,6 +268,7 @@ void CollectionBackend::AddDirectory(const QString &path) { dir.id = q.lastInsertId().toInt(); emit DirectoryDiscovered(dir, SubdirectoryList()); + } void CollectionBackend::RemoveDirectory(const Directory &dir) { @@ -287,6 +298,7 @@ void CollectionBackend::RemoveDirectory(const Directory &dir) { emit DirectoryDeleted(dir); transaction.Commit(); + } SongList CollectionBackend::FindSongsInDirectory(int id) { @@ -307,6 +319,7 @@ SongList CollectionBackend::FindSongsInDirectory(int id) { ret << song; } return ret; + } void CollectionBackend::AddOrUpdateSubdirs(const SubdirectoryList &subdirs) { @@ -381,8 +394,7 @@ void CollectionBackend::AddOrUpdateSongs(const SongList &songs) { for (const Song &song : songs) { // Do a sanity check first - make sure the song's directory still exists - // This is to fix a possible race condition when a directory is removed - // while CollectionWatcher is scanning it. + // This is to fix a possible race condition when a directory is removed while CollectionWatcher is scanning it. if (!dirs_table_.isEmpty()) { check_dir.bindValue(":id", song.directory_id()); check_dir.exec(); @@ -752,8 +764,7 @@ void CollectionBackend::UpdateCompilations() { QMutexLocker l(db_->Mutex()); QSqlDatabase db(db_->Connect()); - // Look for albums that have songs by more than one 'effective album artist' in the same - // directory + // Look for albums that have songs by more than one 'effective album artist' in the same directory QSqlQuery q(db); q.prepare(QString("SELECT effective_albumartist, album, filename, compilation_detected FROM %1 WHERE unavailable = 0 ORDER BY album").arg(songs_table_)); @@ -819,8 +830,7 @@ void CollectionBackend::UpdateCompilations() { void CollectionBackend::UpdateCompilations(QSqlQuery &find_songs, QSqlQuery &update, SongList &deleted_songs, SongList &added_songs, const QString &album, int compilation_detected) { - // Get songs that were already in that album, so we can tell the model - // they've been updated + // Get songs that were already in that album, so we can tell the model they've been updated find_songs.bindValue(":album", album); find_songs.bindValue(":compilation_detected", int(!compilation_detected)); find_songs.exec(); @@ -1104,6 +1114,7 @@ void CollectionBackend::ResetStatistics(int id) { } void CollectionBackend::DeleteAll() { + { QMutexLocker l(db_->Mutex()); QSqlDatabase db(db_->Connect()); diff --git a/src/collection/collectionbackend.h b/src/collection/collectionbackend.h index b812e0a1..49542fd5 100644 --- a/src/collection/collectionbackend.h +++ b/src/collection/collectionbackend.h @@ -23,13 +23,22 @@ #include "config.h" -#include -#include -#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include -#include "directory.h" -#include "collectionquery.h" #include "core/song.h" +#include "collectionquery.h" +#include "directory.h" class Database; @@ -94,11 +103,9 @@ class CollectionBackendInterface : public QObject { virtual Song GetSongById(int id) = 0; - // Returns all sections of a song with the given filename. If there's just one section - // the resulting list will have it's size equal to 1. + // Returns all sections of a song with the given filename. If there's just one section the resulting list will have it's size equal to 1. virtual SongList GetSongsByUrl(const QUrl &url) = 0; - // Returns a section of a song with the given filename and beginning. If the section - // is not present in collection, returns invalid song. + // Returns a section of a song with the given filename and beginning. If the section is not present in collection, returns invalid song. // Using default beginning value is suitable when searching for single-section songs. virtual Song GetSongByUrl(const QUrl &url, qint64 beginning = 0) = 0; diff --git a/src/collection/collectiondirectorymodel.cpp b/src/collection/collectiondirectorymodel.cpp index 20e176a9..a285c0e7 100644 --- a/src/collection/collectiondirectorymodel.cpp +++ b/src/collection/collectiondirectorymodel.cpp @@ -20,15 +20,23 @@ #include "config.h" -#include "collectiondirectorymodel.h" -#include "collectionbackend.h" +#include +#include +#include +#include +#include +#include + #include "core/application.h" #include "core/filesystemmusicstorage.h" +#include "core/iconloader.h" #include "core/musicstorage.h" #include "core/utilities.h" -#include "core/iconloader.h" +#include "directory.h" +#include "collectionbackend.h" +#include "collectiondirectorymodel.h" -CollectionDirectoryModel::CollectionDirectoryModel(CollectionBackend* backend, QObject* parent) +CollectionDirectoryModel::CollectionDirectoryModel(CollectionBackend *backend, QObject *parent) : QStandardItemModel(parent), dir_icon_(IconLoader::Load("document-open-folder")), backend_(backend) @@ -43,7 +51,7 @@ CollectionDirectoryModel::~CollectionDirectoryModel() {} void CollectionDirectoryModel::DirectoryDiscovered(const Directory &dir) { - QStandardItem* item; + QStandardItem *item; if (Application::kIsPortable && Utilities::UrlOnSameDriveAsStrawberry(QUrl::fromLocalFile(dir.path))) { item = new QStandardItem(Utilities::GetRelativePathToStrawberryBin(QUrl::fromLocalFile(dir.path)).toLocalFile()); } diff --git a/src/collection/collectiondirectorymodel.h b/src/collection/collectiondirectorymodel.h index c2a164a8..915eb069 100644 --- a/src/collection/collectiondirectorymodel.h +++ b/src/collection/collectiondirectorymodel.h @@ -25,11 +25,16 @@ #include -#include +#include #include +#include +#include +#include +#include -#include "directory.h" +class QModelIndex; +struct Directory; class CollectionBackend; class MusicStorage; diff --git a/src/collection/collectionfilterwidget.cpp b/src/collection/collectionfilterwidget.cpp index 620037a5..3b5d21cd 100644 --- a/src/collection/collectionfilterwidget.cpp +++ b/src/collection/collectionfilterwidget.cpp @@ -20,23 +20,35 @@ #include "config.h" +#include +#include +#include +#include +#include +#include #include -#include -#include -#include +#include +#include +#include +#include #include +#include +#include +#include +#include #include #include -#include +#include +#include -#include "collectionfilterwidget.h" +#include "core/iconloader.h" +#include "core/song.h" #include "collectionmodel.h" #include "collectionquery.h" +#include "savedgroupingmanager.h" +#include "collectionfilterwidget.h" #include "groupbydialog.h" #include "ui_collectionfilterwidget.h" -#include "core/song.h" -#include "core/iconloader.h" -#include "settings/settingsdialog.h" CollectionFilterWidget::CollectionFilterWidget(QWidget *parent) : QWidget(parent), @@ -48,8 +60,7 @@ CollectionFilterWidget::CollectionFilterWidget(QWidget *parent) delay_behaviour_(DelayedOnLargeLibraries) { ui_->setupUi(this); - // Add the available fields to the tooltip here instead of the ui - // file to prevent that they get translated by mistake. + // Add the available fields to the tooltip here instead of the ui file to prevent that they get translated by mistake. QString available_fields = Song::kFtsColumns.join(", ").replace(QRegExp("\\bfts"), ""); ui_->filter->setToolTip(ui_->filter->toolTip().arg(available_fields)); @@ -125,8 +136,7 @@ void CollectionFilterWidget::UpdateGroupByActions() { group_by_group_ = CreateGroupByActions(this); group_by_menu_->clear(); group_by_menu_->addActions(group_by_group_->actions()); - connect(group_by_group_, SIGNAL(triggered(QAction*)), - SLOT(GroupByClicked(QAction*))); + connect(group_by_group_, SIGNAL(triggered(QAction*)), SLOT(GroupByClicked(QAction*))); if (model_) { CheckCurrentGrouping(model_->GetGroupBy()); } @@ -338,10 +348,9 @@ void CollectionFilterWidget::keyReleaseEvent(QKeyEvent *e) { void CollectionFilterWidget::FilterTextChanged(const QString &text) { - // Searching with one or two characters can be very expensive on the database - // even with FTS, so if there are a large number of songs in the database - // introduce a small delay before actually filtering the model, so if the - // user is typing the first few characters of something it will be quicker. + // Searching with one or two characters can be very expensive on the database even with FTS, + // so if there are a large number of songs in the database introduce a small delay before actually filtering the model, + // so if the user is typing the first few characters of something it will be quicker. const bool delay = (delay_behaviour_ == AlwaysDelayed) || (delay_behaviour_ == DelayedOnLargeLibraries && !text.isEmpty() && text.length() < 3 && model_->total_song_count() >= 100000); if (delay) { diff --git a/src/collection/collectionfilterwidget.h b/src/collection/collectionfilterwidget.h index 098163c1..215d6b64 100644 --- a/src/collection/collectionfilterwidget.h +++ b/src/collection/collectionfilterwidget.h @@ -24,22 +24,29 @@ #include "config.h" #include +#include #include +#include +#include +#include +#include +#include +#include +#include +#include +#include "collectionquery.h" #include "collectionmodel.h" -#include "savedgroupingmanager.h" + +class QKeyEvent; class GroupByDialog; +class SavedGroupingManager; class SettingsDialog; class Ui_CollectionFilterWidget; - struct QueryOptions; -class QMenu; -class QActionGroup; -class QSignalMapper; - class CollectionFilterWidget : public QWidget { Q_OBJECT diff --git a/src/collection/collectionitem.h b/src/collection/collectionitem.h index 25c742b2..c46414b9 100644 --- a/src/collection/collectionitem.h +++ b/src/collection/collectionitem.h @@ -23,9 +23,6 @@ #include "config.h" -#include -#include - #include "core/simpletreeitem.h" #include "core/song.h" diff --git a/src/collection/collectionmodel.cpp b/src/collection/collectionmodel.cpp index 805c4210..f1530aa5 100644 --- a/src/collection/collectionmodel.cpp +++ b/src/collection/collectionmodel.cpp @@ -22,32 +22,44 @@ #include +#include +#include +#include +#include +#include #include +#include +#include #include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include #include #include -#include +#include +#include +#include +#include -#include "collectionmodel.h" - -#include "collectionbackend.h" -#include "collectionitem.h" -#include "collectiondirectorymodel.h" -#include "collectionview.h" -#include "sqlrow.h" #include "core/application.h" +#include "core/closure.h" #include "core/database.h" +#include "core/iconloader.h" #include "core/logging.h" #include "core/taskmanager.h" -#include "core/utilities.h" -#include "core/iconloader.h" -#include "covermanager/albumcoverloader.h" +#include "collectionquery.h" +#include "collectionbackend.h" +#include "collectiondirectorymodel.h" +#include "collectionitem.h" +#include "collectionmodel.h" +#include "sqlrow.h" +#include "playlist/playlistmanager.h" #include "playlist/songmimedata.h" +#include "covermanager/albumcoverloader.h" using std::placeholders::_1; using std::placeholders::_2; @@ -178,11 +190,9 @@ void CollectionModel::SongsDiscovered(const SongList &songs) { // Hey, we've already got that one! if (song_nodes_.contains(song.id())) continue; - // Before we can add each song we need to make sure the required container - // items already exist in the tree. These depend on which "group by" - // settings the user has on the collection. Eg. if the user grouped by - // artist and album, we would need to make sure nodes for the song's artist - // and album were already in the tree. + // Before we can add each song we need to make sure the required container items already exist in the tree. + // These depend on which "group by" settings the user has on the collection. + // Eg. if the user grouped by artist and album, we would need to make sure nodes for the song's artist and album were already in the tree. // Find parent containers in the tree CollectionItem *container = root_; @@ -190,8 +200,7 @@ void CollectionModel::SongsDiscovered(const SongList &songs) { GroupBy type = group_by_[i]; if (type == GroupBy_None) break; - // Special case: if the song is a compilation and the current GroupBy - // level is Artists, then we want the Various Artists node :( + // Special case: if the song is a compilation and the current GroupBy level is Artists, then we want the Various Artists node :( if (IsArtistGroupBy(type) && song.is_compilation()) { if (container->compilation_artist_node_ == nullptr) CreateCompilationArtistNode(true, container); @@ -240,15 +249,13 @@ void CollectionModel::SongsDiscovered(const SongList &songs) { container = container_nodes_[i][key]; } - // If we just created the damn thing then we don't need to continue into - // it any further because it'll get lazy-loaded properly later. + // If we just created the damn thing then we don't need to continue into it any further because it'll get lazy-loaded properly later. if (!container->lazy_loaded) break; } if (!container->lazy_loaded) 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. + // 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); } @@ -256,9 +263,8 @@ void CollectionModel::SongsDiscovered(const SongList &songs) { void CollectionModel::SongsSlightlyChanged(const SongList &songs) { - // This is called if there was a minor change to the songs that will not - // normally require the collection to be restructured. We can just update our - // internal cache of Song objects without worrying about resetting the model. + // This is called if there was a minor change to the songs that will not normally require the collection to be restructured. + // We can just update our internal cache of Song objects without worrying about resetting the model. for (const Song &song : songs) { if (song_nodes_.contains(song.id())) { song_nodes_[song.id()]->metadata = song; @@ -285,8 +291,7 @@ CollectionItem *CollectionModel::CreateCompilationArtistNode(bool signal, Collec QString CollectionModel::DividerKey(GroupBy type, CollectionItem *item) const { - // Items which are to be grouped under the same divider must produce the - // same divider key. This will only get called for top-level items. + // Items which are to be grouped under the same divider must produce the same divider key. This will only get called for top-level items. if (item->sort_text.isEmpty()) return QString(); @@ -371,8 +376,7 @@ QString CollectionModel::DividerDisplayText(GroupBy type, const QString &key) co void CollectionModel::SongsDeleted(const SongList &songs) { - // Delete the actual song nodes first, keeping track of each parent so we - // might check to see if they're empty later. + // Delete the actual song nodes first, keeping track of each parent so we might check to see if they're empty later. QSet parents; for (const Song &song : songs) { if (song_nodes_.contains(song.id())) { @@ -386,11 +390,9 @@ void CollectionModel::SongsDeleted(const SongList &songs) { endRemoveRows(); } else { - // If we get here it means some of the songs we want to delete haven't - // been lazy-loaded yet. This is bad, because it would mean that to - // clean up empty parents we would need to lazy-load them all - // individually to see if they're empty. This can take a very long time, - // so better to just reset the model and be done with it. + // If we get here it means some of the songs we want to delete haven't been lazy-loaded yet. + // This is bad, because it would mean that to clean up empty parents we would need to lazy-load them all individually to see if they're empty. + // This can take a very long time, so better to just reset the model and be done with it. Reset(); return; } @@ -399,9 +401,8 @@ void CollectionModel::SongsDeleted(const SongList &songs) { // Now delete empty parents QSet divider_keys; while (!parents.isEmpty()) { - // Since we are going to remove elements from the container, we - // need a copy to iterate over. If we iterate over the original, - // the behavior will be undefined. + // Since we are going to remove elements from the container, we need a copy to iterate over. + // If we iterate over the original, the behavior will be undefined. QSet parents_copy = parents; for (CollectionItem *node : parents_copy) { parents.remove(node); diff --git a/src/collection/collectionmodel.h b/src/collection/collectionmodel.h index 1f8a7d30..c7fbcc76 100644 --- a/src/collection/collectionmodel.h +++ b/src/collection/collectionmodel.h @@ -23,26 +23,40 @@ #include "config.h" -#include -#include -#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include -#include "collectionitem.h" -#include "collectionquery.h" -#include "collectionwatcher.h" -#include "sqlrow.h" #include "core/simpletreemodel.h" #include "core/song.h" +#include "collectionquery.h" +#include "collectionitem.h" +#include "sqlrow.h" #include "covermanager/albumcoverloaderoptions.h" -#include "engine/engine_fwd.h" -#include "playlist/playlistmanager.h" class Application; -class AlbumCoverLoader; -class CollectionDirectoryModel; class CollectionBackend; - -class QSettings; +class CollectionDirectoryModel; +class CollectionItem; class CollectionModel : public SimpleTreeModel { Q_OBJECT @@ -190,8 +204,7 @@ signals: private: // Provides some optimisations for loading the list of items in the root. - // This gets called a lot when filtering the playlist, so it's nice to be - // able to do it in a background thread. + // This gets called a lot when filtering the playlist, so it's nice to be able to do it in a background thread. QueryResult RunQuery(CollectionItem *parent); void PostQuery(CollectionItem *parent, const QueryResult &result, bool signal); @@ -200,25 +213,18 @@ signals: void BeginReset(); // Functions for working with queries and creating items. - // When the model is reset or when a node is lazy-loaded the Collection - // constructs a database query to populate the items. Filters are added - // for each parent item, restricting the songs returned to a particular - // album or artist for example. + // When the model is reset or when a node is lazy-loaded the Collection constructs a database query to populate the items. + // Filters are added for each parent item, restricting the songs returned to a particular album or artist for example. static void InitQuery(GroupBy type, CollectionQuery *q); void FilterQuery(GroupBy type, CollectionItem *item, CollectionQuery *q); - // Items can be created either from a query that's been run to populate a - // node, or by a spontaneous SongsDiscovered emission from the backend. + // Items can be created either from a query that's been run to populate a node, or by a spontaneous SongsDiscovered emission from the backend. CollectionItem *ItemFromQuery(GroupBy type, bool signal, bool create_divider, CollectionItem *parent, const SqlRow &row, int container_level); CollectionItem *ItemFromSong(GroupBy type, bool signal, bool create_divider, CollectionItem *parent, const Song &s, int container_level); // The "Various Artists" node is an annoying special case. CollectionItem *CreateCompilationArtistNode(bool signal, CollectionItem *parent); - // Smart playlists are shown in another top-level node - - void ItemFromSmartPlaylist(const QSettings &s, bool notify) const; - // Helpers for ItemFromQuery and ItemFromSong CollectionItem *InitItem(GroupBy type, bool signal, CollectionItem *parent, int container_level); void FinishItem(GroupBy type, bool signal, bool create_divider, CollectionItem *parent, CollectionItem *item); @@ -256,8 +262,7 @@ signals: QIcon artist_icon_; QIcon album_icon_; - // used as a generic icon to show when no cover art is found, - // fixed to the same size as the artwork (32x32) + // Used as a generic icon to show when no cover art is found, fixed to the same size as the artwork (32x32) QPixmap no_cover_icon_; QIcon playlists_dir_icon_; QIcon playlist_icon_; diff --git a/src/collection/collectionplaylistitem.cpp b/src/collection/collectionplaylistitem.cpp index 69f2c9d0..d7687ccf 100644 --- a/src/collection/collectionplaylistitem.cpp +++ b/src/collection/collectionplaylistitem.cpp @@ -20,10 +20,14 @@ #include "config.h" +#include +#include +#include + #include "collectionplaylistitem.h" #include "core/tagreaderclient.h" -#include +class SqlRow; CollectionPlaylistItem::CollectionPlaylistItem(const QString &type) : PlaylistItem(type) {} diff --git a/src/collection/collectionplaylistitem.h b/src/collection/collectionplaylistitem.h index 7e72973d..48ec2bf0 100644 --- a/src/collection/collectionplaylistitem.h +++ b/src/collection/collectionplaylistitem.h @@ -23,9 +23,17 @@ #include "config.h" +#include + +#include +#include +#include + #include "core/song.h" #include "playlist/playlistitem.h" +class SqlRow; + class CollectionPlaylistItem : public PlaylistItem { public: CollectionPlaylistItem(const QString &type); diff --git a/src/collection/collectionquery.cpp b/src/collection/collectionquery.cpp index 01a1644e..4908ed55 100644 --- a/src/collection/collectionquery.cpp +++ b/src/collection/collectionquery.cpp @@ -20,21 +20,26 @@ #include "config.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include + #include "collectionquery.h" #include "core/song.h" -#include -#include -#include - QueryOptions::QueryOptions() : max_age_(-1), query_mode_(QueryMode_All) {} CollectionQuery::CollectionQuery(const QueryOptions& options) : include_unavailable_(false), join_with_fts_(false), limit_(-1) { if (!options.filter().isEmpty()) { - // We need to munge the filter text a little bit to get it to work as - // expected with sqlite's FTS3: + // We need to munge the filter text a little bit to get it to work as expected with sqlite's FTS3: // 1) Append * to all tokens. // 2) Prefix "fts" to column names. // 3) Remove colons which don't correspond to column names. @@ -50,8 +55,7 @@ CollectionQuery::CollectionQuery(const QueryOptions& options) if (token.contains(':')) { // Only prefix fts if the token is a valid column name. - if (Song::kFtsColumns.contains("fts" + token.section(':', 0, 0), - Qt::CaseInsensitive)) { + if (Song::kFtsColumns.contains("fts" + token.section(':', 0, 0), Qt::CaseInsensitive)) { // Account for multiple colons. QString columntoken = token.section(':', 0, 0, QString::SectionIncludeTrailingSep); QString subtoken = token.section(':', 1, -1); @@ -82,16 +86,12 @@ CollectionQuery::CollectionQuery(const QueryOptions& options) bound_values_ << cutoff; } - // TODO: currently you cannot use any QueryMode other than All and fts at the - // same time. - // joining songs, duplicated_songs and songs_fts all together takes a huge - // amount of - // time. the query takes about 20 seconds on my machine then. why? - // untagged mode could work with additional filtering but I'm disabling it - // just to be - // consistent - this way filtering is available only in the All mode. - // remember though that when you fix the Duplicates + FTS cooperation, enable - // the filtering in both Duplicates and Untagged modes. + // TODO: Currently you cannot use any QueryMode other than All and fts at the same time. + // Joining songs, duplicated_songs and songs_fts all together takes a huge amount of time. + // The query takes about 20 seconds on my machine then. Why? + // Untagged mode could work with additional filtering but I'm disabling it just to be consistent + // this way filtering is available only in the All mode. + // Remember though that when you fix the Duplicates + FTS cooperation, enable the filtering in both Duplicates and Untagged modes. duplicates_only_ = options.query_mode() == QueryOptions::QueryMode_Duplicates; if (options.query_mode() == QueryOptions::QueryMode_Untagged) { @@ -114,7 +114,7 @@ void CollectionQuery::AddWhere(const QString &column, const QVariant &value, con // ignore 'literal' for IN if (!op.compare("IN", Qt::CaseInsensitive)) { QStringList final; - for (const QString& single_value : value.toStringList()) { + for (const QString &single_value : value.toStringList()) { final.append("?"); bound_values_ << single_value; } @@ -122,8 +122,7 @@ void CollectionQuery::AddWhere(const QString &column, const QVariant &value, con where_clauses_ << QString("%1 IN (" + final.join(",") + ")").arg(column); } else { - // Do integers inline - sqlite seems to get confused when you pass integers - // to bound parameters + // Do integers inline - sqlite seems to get confused when you pass integers to bound parameters if (value.type() == QVariant::Int) { where_clauses_ << QString("%1 %2 %3").arg(column, op, value.toString()); } @@ -136,10 +135,8 @@ void CollectionQuery::AddWhere(const QString &column, const QVariant &value, con } void CollectionQuery::AddCompilationRequirement(bool compilation) { - // The unary + is added to prevent sqlite from using the index - // idx_comp_artist. When joining with fts, sqlite 3.8 has a tendency - // to use this index and thereby nesting the tables in an order - // which gives very poor performance + // The unary + is added to prevent sqlite from using the index idx_comp_artist. + // When joining with fts, sqlite 3.8 has a tendency to use this index and thereby nesting the tables in an order which gives very poor performance where_clauses_ << QString("+compilation_effective = %1").arg(compilation ? 1 : 0); @@ -175,7 +172,7 @@ QSqlQuery CollectionQuery::Exec(QSqlDatabase db, const QString &songs_table, con query_.prepare(sql); // Bind values - for (const QVariant& value : bound_values_) { + for (const QVariant &value : bound_values_) { query_.addBindValue(value); } diff --git a/src/collection/collectionquery.h b/src/collection/collectionquery.h index 3369d8a0..c25b909a 100644 --- a/src/collection/collectionquery.h +++ b/src/collection/collectionquery.h @@ -23,11 +23,14 @@ #include "config.h" -#include +#include + +#include #include -#include +#include #include -#include +#include +#include class Song; class CollectionBackend; @@ -36,13 +39,9 @@ class CollectionBackend; struct QueryOptions { // Modes of CollectionQuery: // - use the all songs table - // - use the duplicated songs view; by duplicated we mean those songs - // for which the (artist, album, title) tuple is found more than once - // in the songs table - // - use the untagged songs view; by untagged we mean those for which - // at least one of the (artist, album, title) tags is empty - // Please note that additional filtering based on fts table (the filter - // attribute) won't work in Duplicates and Untagged modes. + // - use the duplicated songs view; by duplicated we mean those songs for which the (artist, album, title) tuple is found more than once in the songs table + // - use the untagged songs view; by untagged we mean those for which at least one of the (artist, album, title) tags is empty + // Please note that additional filtering based on fts table (the filter attribute) won't work in Duplicates and Untagged modes. enum QueryMode { QueryMode_All, QueryMode_Duplicates, @@ -83,8 +82,7 @@ class CollectionQuery { // Sets an ORDER BY clause on the query. void SetOrderBy(const QString &order_by) { order_by_ = order_by; } - // Adds a fragment of WHERE clause. When executed, this Query will connect all - // the fragments with AND operator. + // Adds a fragment of WHERE clause. When executed, this Query will connect all the fragments with AND operator. // Please note that IN operator expects a QStringList as value. void AddWhere(const QString &column, const QVariant &value, const QString &op = "="); diff --git a/src/collection/collectionview.cpp b/src/collection/collectionview.cpp index b6ba197c..e26c9bec 100644 --- a/src/collection/collectionview.cpp +++ b/src/collection/collectionview.cpp @@ -20,35 +20,59 @@ #include "config.h" -#include "collectionview.h" +#include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include #include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #include +#include #include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "core/application.h" +#include "core/iconloader.h" +#include "core/mimedata.h" +#include "core/utilities.h" +#include "collectionbackend.h" #include "collectiondirectorymodel.h" #include "collectionfilterwidget.h" -#include "collectionmodel.h" #include "collectionitem.h" -#include "collectionbackend.h" -#include "core/application.h" -#include "core/logging.h" -#include "core/mimedata.h" -#include "core/musicstorage.h" -#include "core/utilities.h" -#include "core/iconloader.h" +#include "collectionmodel.h" +#include "collectionview.h" #include "device/devicemanager.h" #include "device/devicestatefiltermodel.h" +#include "dialogs/edittagdialog.h" #ifdef HAVE_GSTREAMER #include "dialogs/organisedialog.h" -#include "dialogs/organiseerrordialog.h" #endif #include "settings/collectionsettingspage.h" @@ -293,8 +317,7 @@ bool CollectionView::RestoreLevelFocus(const QModelIndex &parent) { } else if (last_selected_path_.contains(text)) { emit expand(current); - // If a selected container or song were not found, we've got into a wrong subtree - // (happens with "unknown" all the time) + // If a selected container or song were not found, we've got into a wrong subtree (happens with "unknown" all the time) if (!RestoreLevelFocus(current)) { emit collapse(current); } @@ -312,8 +335,6 @@ bool CollectionView::RestoreLevelFocus(const QModelIndex &parent) { void CollectionView::ReloadSettings() { - //qLog(Debug) << __PRETTY_FUNCTION__; - QSettings settings; settings.beginGroup(CollectionSettingsPage::kSettingsGroup); @@ -330,8 +351,6 @@ void CollectionView::ReloadSettings() { void CollectionView::SetApplication(Application *app) { - //qLog(Debug) << __PRETTY_FUNCTION__; - app_ = app; ReloadSettings(); @@ -342,8 +361,6 @@ void CollectionView::SetFilter(CollectionFilterWidget *filter) { filter_ = filte void CollectionView::TotalSongCountUpdated(int count) { - //qLog(Debug) << __FUNCTION__ << count; - bool old = total_song_count_; total_song_count_ = count; if (old != total_song_count_) update(); @@ -359,8 +376,6 @@ void CollectionView::TotalSongCountUpdated(int count) { void CollectionView::TotalArtistCountUpdated(int count) { - //qLog(Debug) << __FUNCTION__ << count; - bool old = total_artist_count_; total_artist_count_ = count; if (old != total_artist_count_) update(); @@ -376,8 +391,6 @@ void CollectionView::TotalArtistCountUpdated(int count) { void CollectionView::TotalAlbumCountUpdated(int count) { - //qLog(Debug) << __FUNCTION__ << count; - bool old = total_album_count_; total_album_count_ = count; if (old != total_album_count_) update(); @@ -393,8 +406,6 @@ void CollectionView::TotalAlbumCountUpdated(int count) { void CollectionView::paintEvent(QPaintEvent *event) { - //qLog(Debug) << __FUNCTION__; - if (total_song_count_ == 0) { QPainter p(viewport()); QRect rect(viewport()->rect()); @@ -491,7 +502,6 @@ void CollectionView::contextMenuEvent(QContextMenuEvent *e) { } // TODO: check if custom plugin actions should be enabled / visible - //const int songs_selected = smart_playlists + smart_playlists_header + regular_elements; const int songs_selected = regular_elements; const bool regular_elements_only = songs_selected == regular_elements && regular_elements > 0; @@ -502,7 +512,6 @@ void CollectionView::contextMenuEvent(QContextMenuEvent *e) { add_to_playlist_enqueue_->setEnabled(songs_selected); // if neither edit_track not edit_tracks are available, we show disabled edit_track element - //edit_track_->setVisible(!smart_playlists_only && (regular_editable <= 1)); edit_track_->setVisible(regular_editable <= 1); edit_track_->setEnabled(regular_editable == 1); @@ -534,9 +543,9 @@ void CollectionView::ShowInVarious(bool on) { if (!context_menu_index_.isValid()) return; - // Map is from album name -> all artists sharing that album name, built from each selected - // song. We put through "Various Artists" changes one album at a time, to make sure the old album - // node gets removed (due to all children removed), before the new one gets added + // Map is from album name -> all artists sharing that album name, built from each selected song. + // We put through "Various Artists" changes one album at a time, + // to make sure the old album node gets removed (due to all children removed), before the new one gets added QMultiMap albums; for (const Song& song : GetSelectedSongs()) { if (albums.find(song.album(), song.artist()) == albums.end()) @@ -586,16 +595,12 @@ void CollectionView::Load() { void CollectionView::AddToPlaylist() { - //qLog(Debug) << __PRETTY_FUNCTION__; - emit AddToPlaylistSignal(model()->mimeData(selectedIndexes())); } void CollectionView::AddToPlaylistEnqueue() { - //qLog(Debug) << __PRETTY_FUNCTION__; - QMimeData *data = model()->mimeData(selectedIndexes()); if (MimeData* mime_data = qobject_cast(data)) { mime_data->enqueue_now_ = true; diff --git a/src/collection/collectionview.h b/src/collection/collectionview.h index 214fac9c..dd0bb7f3 100644 --- a/src/collection/collectionview.h +++ b/src/collection/collectionview.h @@ -24,21 +24,38 @@ #include "config.h" #include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #include +#include +#include +#include +#include #include "core/song.h" -#include "dialogs/edittagdialog.h" #include "widgets/autoexpandingtreeview.h" +class QContextMenuEvent; +class QHelpEvent; +class QMouseEvent; +class QPaintEvent; + class Application; class CollectionFilterWidget; +class EditTagDialog; #ifdef HAVE_GSTREAMER class OrganiseDialog; #endif -class QMimeData; - class CollectionItemDelegate : public QStyledItemDelegate { Q_OBJECT @@ -57,11 +74,8 @@ class CollectionView : public AutoExpandingTreeView { CollectionView(QWidget *parent = nullptr); ~CollectionView(); - //static const char *kSettingsGroup; - - // Returns Songs currently selected in the collection view. Please note that the - // selection is recursive meaning that if for example an album is selected - // this will return all of it's songs. + // Returns Songs currently selected in the collection view. + // Please note that the selection is recursive meaning that if for example an album is selected this will return all of it's songs. SongList GetSelectedSongs() const; void SetApplication(Application *app); diff --git a/src/collection/collectionviewcontainer.cpp b/src/collection/collectionviewcontainer.cpp index e0012b14..065c035b 100644 --- a/src/collection/collectionviewcontainer.cpp +++ b/src/collection/collectionviewcontainer.cpp @@ -20,6 +20,11 @@ #include "config.h" +#include +#include + +#include "collectionfilterwidget.h" +#include "collectionview.h" #include "collectionviewcontainer.h" #include "ui_collectionviewcontainer.h" diff --git a/src/collection/collectionviewcontainer.h b/src/collection/collectionviewcontainer.h index 8026a9d7..ce5ad0ea 100644 --- a/src/collection/collectionviewcontainer.h +++ b/src/collection/collectionviewcontainer.h @@ -23,6 +23,7 @@ #include "config.h" +#include #include class CollectionFilterWidget; diff --git a/src/collection/collectionwatcher.cpp b/src/collection/collectionwatcher.cpp index 8ab777f0..a7a1c26d 100644 --- a/src/collection/collectionwatcher.cpp +++ b/src/collection/collectionwatcher.cpp @@ -20,34 +20,42 @@ #include "config.h" -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include -// This is defined by one of the windows headers that is included by taglib. -#ifdef RemoveDirectory -#undef RemoveDirectory -#endif - -#include "collectionwatcher.h" - -#include "collectionbackend.h" #include "core/filesystemwatcherinterface.h" #include "core/logging.h" #include "core/tagreaderclient.h" #include "core/taskmanager.h" #include "core/utilities.h" +#include "directory.h" +#include "collectionbackend.h" +#include "collectionwatcher.h" #include "playlistparsers/cueparser.h" #include "settings/collectionsettingspage.h" -#include -#include -#include -#include -#include -#include -#include -#include -#include +// This is defined by one of the windows headers that is included by taglib. +#ifdef RemoveDirectory +#undef RemoveDirectory +#endif namespace { static const char *kNoMediaFile = ".nomedia"; @@ -218,8 +226,7 @@ void CollectionWatcher::AddDirectory(const Directory &dir, const SubdirectoryLis ScanSubdirectory(dir.path, Subdirectory(), &transaction); } else { - // We can do an incremental scan - looking at the mtimes of each - // subdirectory and only rescan if the directory has changed. + // We can do an incremental scan - looking at the mtimes of each subdirectory and only rescan if the directory has changed. ScanTransaction transaction(this, dir.id, true); transaction.SetKnownSubdirs(subdirs); transaction.AddToProgressMax(subdirs.count()); @@ -268,8 +275,7 @@ void CollectionWatcher::ScanSubdirectory(const QString &path, const Subdirectory QStringList files_on_disk; SubdirectoryList my_new_subdirs; - // If a directory is moved then only its parent gets a changed notification, - // so we need to look and see if any of our children don't exist any more. + // If a directory is moved then only its parent gets a changed notification, so we need to look and see if any of our children don't exist any more. // If one has been removed, "rescan" it to get the deleted songs SubdirectoryList previous_subdirs = t->GetImmediateSubdirs(path); for (const Subdirectory& subdir : previous_subdirs) { @@ -289,8 +295,7 @@ void CollectionWatcher::ScanSubdirectory(const QString &path, const Subdirectory if (child_info.isDir()) { if (!child_info.isHidden() && !t->HasSeenSubdir(child)) { - // We haven't seen this subdirectory before - add it to a list and - // later we'll tell the backend about it and scan it. + // We haven't seen this subdirectory before - add it to a list and later we'll tell the backend about it and scan it. Subdirectory new_subdir; new_subdir.directory_id = -1; new_subdir.path = child; @@ -332,8 +337,7 @@ void CollectionWatcher::ScanSubdirectory(const QString &path, const Subdirectory QFileInfo file_info(file); if (!file_info.exists()) { - // Partially fixes race condition - if file was removed between being - // added to the list and now. + // Partially fixes race condition - if file was removed between being added to the list and now. files_on_disk.removeAll(file); continue; } @@ -345,8 +349,7 @@ void CollectionWatcher::ScanSubdirectory(const QString &path, const Subdirectory bool cue_deleted = song_cue_mtime == 0 && matching_song.has_cue(); bool cue_added = matching_cue_mtime != 0 && !matching_song.has_cue(); - // watch out for cue songs which have their mtime equal to - // qMax(media_file_mtime, cue_sheet_mtime) + // watch out for cue songs which have their mtime equal to qMax(media_file_mtime, cue_sheet_mtime) bool changed = (matching_song.mtime() != qMax(file_info.lastModified().toTime_t(), song_cue_mtime)) || cue_deleted || cue_added; // Also want to look to see whether the album art has changed @@ -372,7 +375,8 @@ void CollectionWatcher::ScanSubdirectory(const QString &path, const Subdirectory // nothing has changed - mark the song available without re-scanning if (matching_song.is_unavailable()) t->readded_songs << matching_song; - } else { + } + else { // The song is on disk but not in the DB SongList song_list = ScanNewFile(file, path, matching_cue, &cues_processed); @@ -437,7 +441,7 @@ void CollectionWatcher::UpdateCueAssociatedSongs(const QString &file, const QStr QSet used_ids; - // update every song that's in the cue and collection + // Update every song that's in the cue and collection for (Song cue_song : cue_parser_->Load(&cue, matching_cue, path)) { cue_song.set_directory_id(t->dir()); @@ -463,9 +467,7 @@ void CollectionWatcher::UpdateCueAssociatedSongs(const QString &file, const QStr void CollectionWatcher::UpdateNonCueAssociatedSong(const QString &file, const Song &matching_song, const QString &image, bool cue_deleted, ScanTransaction *t) { - // if a cue got deleted, we turn it's first section into the new - // 'raw' (cueless) song and we just remove the rest of the sections - // from the collection + // If a cue got deleted, we turn it's first section into the new 'raw' (cueless) song and we just remove the rest of the sections from the collection if (cue_deleted) { for (const Song &song : backend_->GetSongsByUrl(QUrl::fromLocalFile(file))) { @@ -490,7 +492,7 @@ SongList CollectionWatcher::ScanNewFile(const QString &file, const QString &path SongList song_list; uint matching_cue_mtime = GetMtimeForCue(matching_cue); - // if it's a cue - create virtual tracks + // If it's a cue - create virtual tracks if (matching_cue_mtime) { // don't process the same cue many times if (cues_processed->contains(matching_cue)) return song_list; @@ -498,9 +500,9 @@ SongList CollectionWatcher::ScanNewFile(const QString &file, const QString &path QFile cue(matching_cue); cue.open(QIODevice::ReadOnly); - // Ignore FILEs pointing to other media files. Also, watch out for incorrect - // media files. Playlist parser for CUEs considers every entry in sheet - // valid and we don't want invalid media getting into collection! + // Ignore FILEs pointing to other media files. + // Also, watch out for incorrect media files. + // Playlist parser for CUEs considers every entry in sheet valid and we don't want invalid media getting into collection! QString file_nfd = file.normalized(QString::NormalizationForm_D); for (const Song& cue_song : cue_parser_->Load(&cue, matching_cue, path)) { if (cue_song.url().toLocalFile().normalized(QString::NormalizationForm_D) == file_nfd) { @@ -533,15 +535,13 @@ void CollectionWatcher::PreserveUserSetData(const QString &file, const QString & out->set_id(matching_song.id()); - // Previous versions of Clementine incorrectly overwrote this and - // stored it in the DB, so we can't rely on matching_song to - // know if it has embedded artwork or not, but we can check here. + // Previous versions of Clementine incorrectly overwrote this and stored it in the DB, + // so we can't rely on matching_song to know if it has embedded artwork or not, but we can check here. if (!out->has_embedded_cover()) out->set_art_automatic(image); out->MergeUserSetData(matching_song); - // The song was deleted from the database (e.g. due to an unmounted - // filesystem), but has been restored. + // The song was deleted from the database (e.g. due to an unmounted filesystem), but has been restored. if (matching_song.is_unavailable()) { qLog(Debug) << file << " unavailable song restored"; @@ -562,7 +562,7 @@ void CollectionWatcher::PreserveUserSetData(const QString &file, const QString & uint CollectionWatcher::GetMtimeForCue(const QString &cue_path) { - // slight optimisation + // Slight optimisation if (cue_path.isEmpty()) { return 0; } @@ -593,7 +593,7 @@ void CollectionWatcher::RemoveDirectory(const Directory &dir) { watched_dirs_.remove(dir.id); // Stop watching the directory's subdirectories - for (const QString& subdir_path : subdir_mapping_.keys(dir)) { + for (const QString &subdir_path : subdir_mapping_.keys(dir)) { fs_watcher_->RemovePath(subdir_path); subdir_mapping_.remove(subdir_path); } @@ -662,8 +662,7 @@ QString CollectionWatcher::PickBestImage(const QStringList &images) { QStringList filtered; for (const QString &filter_text : best_image_filters_) { - // the images in the images list are represented by a full path, - // so we need to isolate just the filename + // The images in the images list are represented by a full path, so we need to isolate just the filename for (const QString& image : images) { QFileInfo file_info(image); QString filename(file_info.fileName()); @@ -671,14 +670,13 @@ QString CollectionWatcher::PickBestImage(const QStringList &images) { filtered << image; } - /* We assume the filters are give in the order best to worst, so - if we've got a result, we go with it. Otherwise we might - start capturing more generic rules */ + // We assume the filters are give in the order best to worst, so if we've got a result, we go with it. + // Otherwise we might start capturing more generic rules if (!filtered.isEmpty()) break; } if (filtered.isEmpty()) { - // the filter was too restrictive, just use the original list + // The filter was too restrictive, just use the original list filtered = images; } @@ -734,7 +732,7 @@ void CollectionWatcher::ReloadSettings() { best_image_filters_.clear(); QStringList filters = s.value("cover_art_patterns", QStringList() << "front" << "cover").toStringList(); - for (const QString& filter : filters) { + for (const QString &filter : filters) { QString s = filter.trimmed(); if (!s.isEmpty()) best_image_filters_ << s; } diff --git a/src/collection/collectionwatcher.h b/src/collection/collectionwatcher.h index c743e677..fc0d517e 100644 --- a/src/collection/collectionwatcher.h +++ b/src/collection/collectionwatcher.h @@ -23,22 +23,24 @@ #include "config.h" -#include "directory.h" +#include -#include +#include #include -#include +#include #include +#include +#include +#include +#include +#include "directory.h" #include "core/song.h" -class QFileSystemWatcher; -class QTimer; - -class CueParser; -class FileSystemWatcherInterface; class CollectionBackend; +class FileSystemWatcherInterface; class TaskManager; +class CueParser; class CollectionWatcher : public QObject { Q_OBJECT @@ -76,14 +78,11 @@ signals: private: // This class encapsulates a full or partial scan of a directory. - // Each directory has one or more subdirectories, and any number of - // subdirectories can be scanned during one transaction. ScanSubdirectory() - // adds its results to the members of this transaction class, and they are - // "committed" through calls to the CollectionBackend in the transaction's dtor. - // The transaction also caches the list of songs in this directory according - // to the collection. Multiple calls to FindSongsInSubdirectory during one - // transaction will only result in one call to - // CollectionBackend::FindSongsInDirectory. + // Each directory has one or more subdirectories, and any number of subdirectories can be scanned during one transaction. + // ScanSubdirectory() adds its results to the members of this transaction class, + // and they are "committed" through calls to the CollectionBackend in the transaction's dtor. + // The transaction also caches the list of songs in this directory according to the collection. + // Multiple calls to FindSongsInSubdirectory during one transaction will only result in one call to CollectionBackend::FindSongsInDirectory. class ScanTransaction { public: ScanTransaction(CollectionWatcher *watcher, int dir, bool incremental, bool ignores_mtime = false); @@ -120,10 +119,9 @@ signals: int dir_; // Incremental scan enters a directory only if it has changed since the last scan. bool incremental_; - // This type of scan updates every file in a folder that's - // being scanned. Even if it detects the file hasn't changed since - // the last scan. Also, since it's ignoring mtimes on folders too, - // it will go as deep in the folder hierarchy as it's possible. + // This type of scan updates every file in a folder that's being scanned. + // Even if it detects the file hasn't changed since the last scan. + // Also, since it's ignoring mtimes on folders too, it will go as deep in the folder hierarchy as it's possible. bool ignores_mtime_; CollectionWatcher *watcher_; @@ -153,18 +151,14 @@ signals: uint GetMtimeForCue(const QString &cue_path); void PerformScan(bool incremental, bool ignore_mtimes); - // Updates the sections of a cue associated and altered (according to mtime) - // media file during a scan. + // Updates the sections of a cue associated and altered (according to mtime) media file during a scan. void UpdateCueAssociatedSongs(const QString &file, const QString &path, const QString &matching_cue, const QString &image, ScanTransaction *t); - // Updates a single non-cue associated and altered (according to mtime) song - // during a scan. + // Updates a single non-cue associated and altered (according to mtime) song during a scan. void UpdateNonCueAssociatedSong(const QString &file, const Song &matching_song, const QString &image, bool cue_deleted, ScanTransaction *t); - // Updates a new song with some metadata taken from it's equivalent old - // song (for example rating and score). + // Updates a new song with some metadata taken from it's equivalent old song (for example rating and score). void PreserveUserSetData(const QString &file, const QString &image, const Song &matching_song, Song *out, ScanTransaction *t); // Scans a single media file that's present on the disk but not yet in the collection. - // It may result in a multiple files added to the collection when the media file - // has many sections (like a CUE related media file). + // It may result in a multiple files added to the collection when the media file has many sections (like a CUE related media file). SongList ScanNewFile(const QString &file, const QString &path, const QString &matching_cue, QSet *cues_processed); private: @@ -175,11 +169,8 @@ signals: FileSystemWatcherInterface *fs_watcher_; QHash subdir_mapping_; - /* A list of words use to try to identify the (likely) best image - * found in an directory to use as cover artwork. - * e.g. using ["front", "cover"] would identify front.jpg and - * exclude back.jpg. - */ + // A list of words use to try to identify the (likely) best image found in an directory to use as cover artwork. + // e.g. using ["front", "cover"] would identify front.jpg and exclude back.jpg. QStringList best_image_filters_; bool stop_requested_; diff --git a/src/collection/directory.h b/src/collection/directory.h index feb3ba13..8d4eb827 100644 --- a/src/collection/directory.h +++ b/src/collection/directory.h @@ -23,11 +23,10 @@ #include "config.h" +#include #include #include -#include - -class QSqlQuery; +#include struct Directory { Directory() : id(-1) {} diff --git a/src/collection/groupbydialog.cpp b/src/collection/groupbydialog.cpp index a7e4b5d0..8d24a066 100644 --- a/src/collection/groupbydialog.cpp +++ b/src/collection/groupbydialog.cpp @@ -22,8 +22,13 @@ #include +#include +#include +#include #include +#include +#include "collectionmodel.h" #include "groupbydialog.h" #include "ui_groupbydialog.h" @@ -31,9 +36,13 @@ using std::placeholders::_1; using std::placeholders::_2; -#include +#include #include #include +#include +#include +#include +#include using boost::multi_index_container; using boost::multi_index::indexed_by; @@ -70,7 +79,7 @@ class GroupByDialogPrivate { MappingContainer mapping_; }; -GroupByDialog::GroupByDialog(QWidget* parent) : QDialog(parent), ui_(new Ui_GroupByDialog), p_(new GroupByDialogPrivate) { +GroupByDialog::GroupByDialog(QWidget *parent) : QDialog(parent), ui_(new Ui_GroupByDialog), p_(new GroupByDialogPrivate) { ui_->setupUi(this); Reset(); diff --git a/src/collection/groupbydialog.h b/src/collection/groupbydialog.h index a43d2b2b..00ee6e1d 100644 --- a/src/collection/groupbydialog.h +++ b/src/collection/groupbydialog.h @@ -26,6 +26,9 @@ #include #include +#include +#include +#include #include "collectionmodel.h" diff --git a/src/collection/savedgroupingmanager.cpp b/src/collection/savedgroupingmanager.cpp index 97d109e1..fe227e56 100644 --- a/src/collection/savedgroupingmanager.cpp +++ b/src/collection/savedgroupingmanager.cpp @@ -18,19 +18,33 @@ * */ -#include "config.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "core/logging.h" #include "core/iconloader.h" #include "collectionfilterwidget.h" #include "collectionmodel.h" #include "savedgroupingmanager.h" #include "ui_savedgroupingmanager.h" -#include -#include -#include -#include - SavedGroupingManager::SavedGroupingManager(QWidget *parent) : QDialog(parent), ui_(new Ui_SavedGroupingManager), @@ -58,6 +72,7 @@ SavedGroupingManager::~SavedGroupingManager() { } QString SavedGroupingManager::GroupByToString(const CollectionModel::GroupBy &g) { + switch (g) { case CollectionModel::GroupBy_None: { return tr("None"); @@ -137,8 +152,7 @@ void SavedGroupingManager::Remove() { if (ui_->list->selectionModel()->hasSelection()) { QSettings s; s.beginGroup(CollectionModel::kSavedGroupingsSettingsGroup); - for (const QModelIndex &index : - ui_->list->selectionModel()->selectedRows()) { + for (const QModelIndex &index : ui_->list->selectionModel()->selectedRows()) { if (index.isValid()) { qLog(Debug) << "Remove saved grouping: " << model_->item(index.row(), 0)->text(); s.remove(model_->item(index.row(), 0)->text()); diff --git a/src/collection/savedgroupingmanager.h b/src/collection/savedgroupingmanager.h index 866211cf..29675ee1 100644 --- a/src/collection/savedgroupingmanager.h +++ b/src/collection/savedgroupingmanager.h @@ -24,12 +24,15 @@ #include "config.h" #include +#include +#include #include +#include #include "collectionmodel.h" -class Ui_SavedGroupingManager; class CollectionFilterWidget; +class Ui_SavedGroupingManager; class SavedGroupingManager : public QDialog { Q_OBJECT diff --git a/src/collection/sqlrow.cpp b/src/collection/sqlrow.cpp index d76c6df2..17d4731b 100644 --- a/src/collection/sqlrow.cpp +++ b/src/collection/sqlrow.cpp @@ -20,12 +20,14 @@ #include "config.h" -#include "collectionquery.h" -#include "sqlrow.h" - +#include #include #include +#include "sqlrow.h" + +#include "collectionquery.h" + SqlRow::SqlRow(const QSqlQuery &query) { Init(query); } SqlRow::SqlRow(const CollectionQuery &query) { Init(query); } diff --git a/src/collection/sqlrow.h b/src/collection/sqlrow.h index 4d04a28d..2ec0dccf 100644 --- a/src/collection/sqlrow.h +++ b/src/collection/sqlrow.h @@ -25,8 +25,7 @@ #include #include - -class QSqlQuery; +#include class CollectionQuery; @@ -37,7 +36,7 @@ class SqlRow { SqlRow(const QSqlQuery &query); SqlRow(const CollectionQuery &query); - const QVariant& value(int i) const { return columns_[i]; } + const QVariant &value(int i) const { return columns_[i]; } QList columns_; diff --git a/src/core/appearance.cpp b/src/core/appearance.cpp index 2e48a819..58e7a148 100644 --- a/src/core/appearance.cpp +++ b/src/core/appearance.cpp @@ -20,11 +20,16 @@ #include "config.h" -#include "appearance.h" +#include #include +#include +#include +#include +#include #include +#include "appearance.h" #include "settings/appearancesettingspage.h" const char *Appearance::kUseCustomColorSet = "use-custom-set"; diff --git a/src/core/appearance.h b/src/core/appearance.h index 92987fd6..4d27b383 100644 --- a/src/core/appearance.h +++ b/src/core/appearance.h @@ -29,17 +29,17 @@ class Appearance : public QObject { public: - explicit Appearance(QObject* parent = nullptr); + explicit Appearance(QObject *parent = nullptr); // Load the user preferred theme, which could the default system theme or a custom set of colors that user has chosen void LoadUserTheme(); void ResetToSystemDefaultTheme(); - void ChangeForegroundColor(const QColor& color); - void ChangeBackgroundColor(const QColor& color); + void ChangeForegroundColor(const QColor &color); + void ChangeBackgroundColor(const QColor &color); - static const char* kSettingsGroup; - static const char* kUseCustomColorSet; - static const char* kForegroundColor; - static const char* kBackgroundColor; + static const char *kSettingsGroup; + static const char *kUseCustomColorSet; + static const char *kForegroundColor; + static const char *kBackgroundColor; static const QPalette kDefaultPalette; private: diff --git a/src/core/application.cpp b/src/core/application.cpp index b30df146..267e49f2 100644 --- a/src/core/application.cpp +++ b/src/core/application.cpp @@ -18,20 +18,27 @@ * */ -#include "application.h" - #include "config.h" -#include "core/appearance.h" -#include "core/database.h" +#include "application.h" + +#include + +#include +#include +#include + +#include "core/closure.h" #include "core/lazy.h" -#include "core/player.h" #include "core/tagreaderclient.h" -#include "core/taskmanager.h" -#include "engine/enginetype.h" + +#include "database.h" +#include "taskmanager.h" +#include "player.h" +#include "appearance.h" + #include "engine/enginedevice.h" #include "device/devicemanager.h" -#include "collection/collectionbackend.h" #include "collection/collection.h" #include "playlist/playlistbackend.h" #include "playlist/playlistmanager.h" @@ -40,7 +47,7 @@ #include "covermanager/currentartloader.h" #ifdef HAVE_LIBLASTFM #include "covermanager/lastfmcoverprovider.h" -#endif // HAVE_LIBLASTFM +#endif #include "covermanager/amazoncoverprovider.h" #include "covermanager/discogscoverprovider.h" #include "covermanager/musicbrainzcoverprovider.h" @@ -77,9 +84,9 @@ class ApplicationImpl { cover_providers_([=]() { CoverProviders *cover_providers = new CoverProviders(app); // Initialize the repository of cover providers. - #ifdef HAVE_LIBLASTFM - cover_providers->AddProvider(new LastFmCoverProvider(app)); - #endif +#ifdef HAVE_LIBLASTFM + cover_providers->AddProvider(new LastFmCoverProvider(app)); +#endif cover_providers->AddProvider(new AmazonCoverProvider(app)); cover_providers->AddProvider(new DiscogsCoverProvider(app)); cover_providers->AddProvider(new MusicbrainzCoverProvider(app)); @@ -121,8 +128,7 @@ Application::Application(QObject *parent) Application::~Application() { // It's important that the device manager is deleted before the database. - // Deleting the database deletes all objects that have been created in its - // thread, including some device collection backends. + // Deleting the database deletes all objects that have been created in its thread, including some device collection backends. p_->device_manager_.reset(); for (QThread *thread : threads_) { @@ -151,14 +157,6 @@ void Application::MoveToThread(QObject *object, QThread *thread) { void Application::AddError(const QString& message) { emit ErrorAdded(message); } -QString Application::language_without_region() const { - const int underscore = language_name_.indexOf('_'); - if (underscore != -1) { - return language_name_.left(underscore); - } - return language_name_; -} - void Application::ReloadSettings() { emit SettingsChanged(); } void Application::OpenSettingsDialogAtPage(SettingsDialog::Page page) { diff --git a/src/core/application.h b/src/core/application.h index f16c6550..4caffdb0 100644 --- a/src/core/application.h +++ b/src/core/application.h @@ -24,29 +24,31 @@ #include "config.h" #include +#include #include -#include #include +#include +#include #include "settings/settingsdialog.h" +class TaskManager; class ApplicationImpl; class TagReaderClient; class Database; -class Appearance; -class TaskManager; +class EngineDevice; class Player; -class DeviceManager; +class Appearance; class Collection; -class PlaylistBackend; -class PlaylistManager; -class AlbumCoverLoader; -class CoverProviders; -class CurrentArtLoader; class CollectionBackend; class CollectionModel; -class EngineDevice; +class PlaylistBackend; +class PlaylistManager; +class DeviceManager; +class CoverProviders; +class AlbumCoverLoader; +class CurrentArtLoader; class Application : public QObject { Q_OBJECT @@ -57,11 +59,6 @@ class Application : public QObject { explicit Application(QObject *parent = nullptr); ~Application(); - const QString &language_name() const { return language_name_; } - // Same as language_name, but remove the region code at the end if there is one - QString language_without_region() const; - void set_language_name(const QString &name) { language_name_ = name; } - TagReaderClient *tag_reader_client() const; Database *database() const; Appearance *appearance() const; @@ -96,7 +93,6 @@ signals: void SettingsDialogRequested(SettingsDialog::Page page); private: - QString language_name_; std::unique_ptr p_; QList threads_; diff --git a/src/core/cachedlist.h b/src/core/cachedlist.h index 010ed010..177d0be8 100644 --- a/src/core/cachedlist.h +++ b/src/core/cachedlist.h @@ -23,6 +23,8 @@ #include "config.h" +#include +#include #include #include diff --git a/src/core/commandlineoptions.cpp b/src/core/commandlineoptions.cpp index 18e780d4..25588c10 100644 --- a/src/core/commandlineoptions.cpp +++ b/src/core/commandlineoptions.cpp @@ -19,19 +19,25 @@ */ #include "config.h" - -#include "commandlineoptions.h" #include "version.h" -#include "core/logging.h" #include #include #include +#include +#include +#include +#include #include -#include +#include #include +#include +#include +#include +#include "commandlineoptions.h" +#include "core/logging.h" const char *CommandlineOptions::kHelpText = "%1: strawberry [%2] [%3]\n" @@ -93,7 +99,7 @@ CommandlineOptions::CommandlineOptions(int argc, char* *argv) RemoveArg("-session", 2); } -void CommandlineOptions::RemoveArg(const QString& starts_with, int count) { +void CommandlineOptions::RemoveArg(const QString &starts_with, int count) { for (int i = 0; i < argc_; ++i) { QString opt(argv_[i]); diff --git a/src/core/commandlineoptions.h b/src/core/commandlineoptions.h index dbcae545..c39567d5 100644 --- a/src/core/commandlineoptions.h +++ b/src/core/commandlineoptions.h @@ -23,9 +23,13 @@ #include "config.h" -#include -#include +#include + #include +#include +#include +#include +#include class CommandlineOptions { friend QDataStream &operator<<(QDataStream &s, const CommandlineOptions &a); diff --git a/src/core/database.cpp b/src/core/database.cpp index 9f02ea4b..da849d24 100644 --- a/src/core/database.cpp +++ b/src/core/database.cpp @@ -20,27 +20,36 @@ #include "config.h" -#include "database.h" -#include "scopedtransaction.h" -#include "core/application.h" -#include "core/logging.h" -#include "core/taskmanager.h" - +#include #include -#include - -#include -#include -#include -#include -#include -#include -#include -#include +#include #include -#include +#include +#include +#include +#include +#include +#include +#include #include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "core/logging.h" +#include "taskmanager.h" +#include "database.h" +#include "application.h" +#include "scopedtransaction.h" const char *Database::kDatabaseFilename = "strawberry.db"; const int Database::kSchemaVersion = 0; @@ -269,7 +278,8 @@ QSqlDatabase Database::Connect() { { #ifdef SQLITE_DBCONFIG_ENABLE_FTS3_TOKENIZER - // In case sqlite>=3.12 is compiled without -DSQLITE_ENABLE_FTS3_TOKENIZER (generally a good idea due to security reasons) the fts3 support should be enabled explicitly. + // In case sqlite>=3.12 is compiled without -DSQLITE_ENABLE_FTS3_TOKENIZER + // (generally a good idea due to security reasons) the fts3 support should be enabled explicitly. QVariant v = db.driver()->handle(); if (v.isValid() && qstrcmp(v.typeName(), "sqlite3*") == 0) { sqlite3 *handle = *static_cast(v.data()); @@ -283,8 +293,7 @@ QSqlDatabase Database::Connect() { if (!set_fts_tokenizer.exec()) { qLog(Warning) << "Couldn't register FTS3 tokenizer : " << set_fts_tokenizer.lastError(); } - // Implicit invocation of ~QSqlQuery() when leaving the scope - // to release any remaining database locks! + // Implicit invocation of ~QSqlQuery() when leaving the scope to release any remaining database locks! } if (db.tables().count() == 0) { @@ -313,8 +322,7 @@ QSqlDatabase Database::Connect() { UpdateMainSchema(&db); } - // We might have to initialise the schema in some attached databases now, if - // they were deleted and don't match up with the main schema version. + // We might have to initialise the schema in some attached databases now, if they were deleted and don't match up with the main schema version. for (const QString &key : attached_databases_.keys()) { if (attached_databases_[key].is_temporary_ && attached_databases_[key].schema_.isEmpty()) continue; @@ -338,8 +346,7 @@ void Database::UpdateMainSchema(QSqlDatabase *db) { { QSqlQuery q("SELECT version FROM schema_version", *db); if (q.next()) schema_version = q.value(0).toInt(); - // Implicit invocation of ~QSqlQuery() when leaving the scope - // to release any remaining database locks! + // Implicit invocation of ~QSqlQuery() when leaving the scope to release any remaining database locks! } startup_schema_version_ = schema_version; @@ -382,9 +389,8 @@ void Database::RecreateAttachedDb(const QString &database_name) { } } - // We can't just re-attach the database now because it needs to be done for - // each thread. Close all the database connections, so each thread will - // re-attach it when they next connect. + // We can't just re-attach the database now because it needs to be done for each thread. + // Close all the database connections, so each thread will re-attach it when they next connect. for (const QString &name : QSqlDatabase::connectionNames()) { QSqlDatabase::removeDatabase(name); } @@ -482,12 +488,9 @@ void Database::ExecSchemaCommands(QSqlDatabase &db, const QString &schema, int s // Run each command const QStringList commands(schema.split(QRegExp("; *\n\n"))); - // We don't want this list to reflect possible DB schema changes - // so we initialize it before executing any statements. - // If no outer transaction is provided the song tables need to - // be queried before beginning an inner transaction! Otherwise - // DROP TABLE commands on song tables may fail due to database - // locks. + // We don't want this list to reflect possible DB schema changes so we initialize it before executing any statements. + // If no outer transaction is provided the song tables need to be queried before beginning an inner transaction! Otherwise + // DROP TABLE commands on song tables may fail due to database locks. const QStringList song_tables(SongsTables(db, schema_version)); if (!in_transaction) { @@ -505,12 +508,10 @@ void Database::ExecSongTablesCommands(QSqlDatabase &db, const QStringList &song_ for (const QString &command : commands) { // There are now lots of "songs" tables that need to have the same schema: - // songs, magnatune_songs, and device_*_songs. We allow a magic value - // in the schema files to update all songs tables at once. + // songs, magnatune_songs, and device_*_songs. We allow a magic value in the schema files to update all songs tables at once. if (command.contains(kMagicAllSongsTables)) { for (const QString &table : song_tables) { - // Another horrible hack: device songs tables don't have matching _fts - // tables, so if this command tries to touch one, ignore it. + // Another horrible hack: device songs tables don't have matching _fts tables, so if this command tries to touch one, ignore it. if (table.startsWith("device_") && command.contains(QString(kMagicAllSongsTables) + "_fts")) { continue; diff --git a/src/core/database.h b/src/core/database.h index 1b997258..83905d59 100644 --- a/src/core/database.h +++ b/src/core/database.h @@ -23,15 +23,20 @@ #include "config.h" -#include -#include -#include -#include -#include -#include - +#include #include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + extern "C" { struct sqlite3_tokenizer; diff --git a/src/core/dbusscreensaver.cpp b/src/core/dbusscreensaver.cpp index ad9cc136..064d07c1 100644 --- a/src/core/dbusscreensaver.cpp +++ b/src/core/dbusscreensaver.cpp @@ -20,11 +20,13 @@ #include "config.h" -#include "dbusscreensaver.h" - #include +#include #include #include +#include + +#include "dbusscreensaver.h" DBusScreensaver::DBusScreensaver(const QString &service, const QString &path, const QString &interface) : service_(service), path_(path), interface_(interface) {} diff --git a/src/core/dbusscreensaver.h b/src/core/dbusscreensaver.h index d00313f7..17c60fb6 100644 --- a/src/core/dbusscreensaver.h +++ b/src/core/dbusscreensaver.h @@ -23,8 +23,10 @@ #include "config.h" +#include #include +#include "config.h" #include "screensaver.h" class DBusScreensaver : public Screensaver { diff --git a/src/core/deletefiles.cpp b/src/core/deletefiles.cpp index 275ac2c2..5de70cfe 100644 --- a/src/core/deletefiles.cpp +++ b/src/core/deletefiles.cpp @@ -20,19 +20,21 @@ #include "config.h" -#include "deletefiles.h" - -#include -#include +#include #include +#include +#include +#include #include -#include "musicstorage.h" #include "taskmanager.h" +#include "song.h" +#include "deletefiles.h" +#include "musicstorage.h" const int DeleteFiles::kBatchSize = 50; -DeleteFiles::DeleteFiles(TaskManager* task_manager, std::shared_ptr storage) +DeleteFiles::DeleteFiles(TaskManager *task_manager, std::shared_ptr storage) : thread_(nullptr), task_manager_(task_manager), storage_(storage), @@ -91,8 +93,7 @@ void DeleteFiles::ProcessSomeFiles() { emit Finished(songs_with_errors_); - // Move back to the original thread so deleteLater() can get called in - // the main thread's event loop + // Move back to the original thread so deleteLater() can get called in the main thread's event loop moveToThread(original_thread_); deleteLater(); diff --git a/src/core/deletefiles.h b/src/core/deletefiles.h index b26c8506..750d38e0 100644 --- a/src/core/deletefiles.h +++ b/src/core/deletefiles.h @@ -24,13 +24,17 @@ #include "config.h" #include +#include #include +#include +#include +#include #include "song.h" -class MusicStorage; class TaskManager; +class MusicStorage; class DeleteFiles : public QObject { Q_OBJECT @@ -41,11 +45,11 @@ class DeleteFiles : public QObject { static const int kBatchSize; - void Start(const SongList& songs); - void Start(const QStringList& filenames); + void Start(const SongList &songs); + void Start(const QStringList &filenames); signals: - void Finished(const SongList& songs_with_errors); + void Finished(const SongList &songs_with_errors); private slots: void ProcessSomeFiles(); @@ -67,4 +71,3 @@ signals: }; #endif // DELETEFILES_H - diff --git a/src/core/filesystemmusicstorage.cpp b/src/core/filesystemmusicstorage.cpp index b58f7026..2a009762 100644 --- a/src/core/filesystemmusicstorage.cpp +++ b/src/core/filesystemmusicstorage.cpp @@ -20,13 +20,21 @@ #include "config.h" -#include "filesystemmusicstorage.h" -#include "core/logging.h" -#include "core/utilities.h" +#include #include #include +#include +#include #include +#include + +#include "core/logging.h" +#include "utilities.h" +#include "song.h" +#include "musicstorage.h" + +#include "filesystemmusicstorage.h" FilesystemMusicStorage::FilesystemMusicStorage(const QString &root) : root_(root) {} diff --git a/src/core/filesystemmusicstorage.h b/src/core/filesystemmusicstorage.h index e30a33f7..d2a37059 100644 --- a/src/core/filesystemmusicstorage.h +++ b/src/core/filesystemmusicstorage.h @@ -23,6 +23,9 @@ #include "config.h" +#include +#include + #include "musicstorage.h" class FilesystemMusicStorage : public virtual MusicStorage { diff --git a/src/core/filesystemwatcherinterface.cpp b/src/core/filesystemwatcherinterface.cpp index 12d7eaf9..304c4665 100644 --- a/src/core/filesystemwatcherinterface.cpp +++ b/src/core/filesystemwatcherinterface.cpp @@ -20,8 +20,9 @@ #include "config.h" -#include "filesystemwatcherinterface.h" +#include +#include "filesystemwatcherinterface.h" #include "qtfslistener.h" #ifdef Q_OS_DARWIN @@ -43,4 +44,3 @@ FileSystemWatcherInterface *FileSystemWatcherInterface::Create(QObject *parent) return ret; } - diff --git a/src/core/filesystemwatcherinterface.h b/src/core/filesystemwatcherinterface.h index 5749bd45..1479d300 100644 --- a/src/core/filesystemwatcherinterface.h +++ b/src/core/filesystemwatcherinterface.h @@ -24,17 +24,18 @@ #include "config.h" #include +#include class FileSystemWatcherInterface : public QObject { Q_OBJECT public: explicit FileSystemWatcherInterface(QObject *parent = nullptr); virtual void Init() {} - virtual void AddPath(const QString& path) = 0; - virtual void RemovePath(const QString& path) = 0; + virtual void AddPath(const QString &path) = 0; + virtual void RemovePath(const QString &path) = 0; virtual void Clear() = 0; - static FileSystemWatcherInterface* Create(QObject *parent = nullptr); + static FileSystemWatcherInterface *Create(QObject *parent = nullptr); signals: void PathChanged(const QString &path); diff --git a/src/core/flowlayout.cpp b/src/core/flowlayout.cpp index 864d40dd..9d3bd736 100644 --- a/src/core/flowlayout.cpp +++ b/src/core/flowlayout.cpp @@ -38,9 +38,19 @@ ** ****************************************************************************/ +#include #include +#include +#include +#include +#include +#include +#include +#include +#include #include "flowlayout.h" + //! [1] FlowLayout::FlowLayout(QWidget *parent, int margin, int hSpacing, int vSpacing) : QLayout(parent), m_hSpace(hSpacing), m_vSpace(vSpacing) @@ -144,12 +154,10 @@ int FlowLayout::doLayout(const QRect& rect, bool testOnly) const { QWidget* wid = item->widget(); int spaceX = horizontalSpacing(); if (spaceX == -1) - spaceX = wid->style()->layoutSpacing( - QSizePolicy::PushButton, QSizePolicy::PushButton, Qt::Horizontal); + spaceX = wid->style()->layoutSpacing(QSizePolicy::PushButton, QSizePolicy::PushButton, Qt::Horizontal); int spaceY = verticalSpacing(); if (spaceY == -1) - spaceY = wid->style()->layoutSpacing( - QSizePolicy::PushButton, QSizePolicy::PushButton, Qt::Vertical); + spaceY = wid->style()->layoutSpacing(QSizePolicy::PushButton, QSizePolicy::PushButton, Qt::Vertical); //! [10] //! [11] int nextX = x + item->sizeHint().width() + spaceX; @@ -173,10 +181,12 @@ int FlowLayout::smartSpacing(QStyle::PixelMetric pm) const { QObject* parent = this->parent(); if (!parent) { return -1; - } else if (parent->isWidgetType()) { + } + else if (parent->isWidgetType()) { QWidget *pw = static_cast(parent); return pw->style()->pixelMetric(pm, 0, pw); - } else { + } + else { return static_cast(parent)->spacing(); } } diff --git a/src/core/flowlayout.h b/src/core/flowlayout.h index df177dc0..30069f21 100644 --- a/src/core/flowlayout.h +++ b/src/core/flowlayout.h @@ -41,15 +41,20 @@ #ifndef FLOWLAYOUT_H #define FLOWLAYOUT_H +#include + #include -#include +#include #include -#include +#include +#include +#include +#include + //! [0] class FlowLayout : public QLayout { public: - FlowLayout(QWidget* parent, int margin = -1, int hSpacing = -1, - int vSpacing = -1); + FlowLayout(QWidget* parent, int margin = -1, int hSpacing = -1, int vSpacing = -1); FlowLayout(int margin = -1, int hSpacing = -1, int vSpacing = -1); ~FlowLayout(); diff --git a/src/core/iconloader.cpp b/src/core/iconloader.cpp index 730106ba..22591668 100644 --- a/src/core/iconloader.cpp +++ b/src/core/iconloader.cpp @@ -22,20 +22,19 @@ #include "config.h" #include -#include +#include +#include +#include +#include #include -#include -#include "iconloader.h" #include "core/logging.h" -#include "core/appearance.h" +#include "iconloader.h" QList IconLoader::sizes_; QString IconDefault(":/icons/64x64/strawberry.png"); void IconLoader::Init() { - - //qLog(Debug) << __PRETTY_FUNCTION__; sizes_.clear(); sizes_ << 22 << 32 << 48 << 64; @@ -50,8 +49,6 @@ QIcon IconLoader::Load(const QString &name) { QIcon ret; - //qLog(Debug) << __PRETTY_FUNCTION__ << name; - if (name.isEmpty()) { qLog(Warning) << "Icon name is empty!"; ret.addFile(IconDefault, QSize(64, 64)); diff --git a/src/core/iconloader.h b/src/core/iconloader.h index 308bafdf..161d82dd 100644 --- a/src/core/iconloader.h +++ b/src/core/iconloader.h @@ -21,6 +21,8 @@ #ifndef ICONLOADER_H #define ICONLOADER_H +#include +#include #include class IconLoader { diff --git a/src/core/mac_startup.h b/src/core/mac_startup.h index 1d8458eb..77da0625 100644 --- a/src/core/mac_startup.h +++ b/src/core/mac_startup.h @@ -3,17 +3,19 @@ #include "config.h" +#include #include -class MacGlobalShortcutBackend; class QObject; class QWidget; +class MacGlobalShortcutBackend; + class PlatformInterface { public: // Called when the application should show itself. virtual void Activate() = 0; - virtual bool LoadUrl(const QString& url) = 0; + virtual bool LoadUrl(const QString &url) = 0; virtual ~PlatformInterface() {} }; @@ -21,8 +23,8 @@ class PlatformInterface { namespace mac { void MacMain(); -void SetShortcutHandler(MacGlobalShortcutBackend* handler); -void SetApplicationHandler(PlatformInterface* handler); +void SetShortcutHandler(MacGlobalShortcutBackend *handler); +void SetApplicationHandler(PlatformInterface *handler); void CheckForUpdates(); QString GetBundlePath(); @@ -30,7 +32,7 @@ QString GetResourcesPath(); QString GetApplicationSupportPath(); QString GetMusicDirectory(); -void EnableFullScreen(const QWidget& main_window); +void EnableFullScreen(const QWidget &main_window); } // namespace mac diff --git a/src/core/mac_startup.mm b/src/core/mac_startup.mm index 3e1fec45..92cab46a 100644 --- a/src/core/mac_startup.mm +++ b/src/core/mac_startup.mm @@ -42,6 +42,7 @@ #import "3rdparty/SPMediaKeyTap/SPMediaKeyTap.h" #include "config.h" + #include "globalshortcuts.h" #include "mac_delegate.h" #include "mac_startup.h" @@ -49,8 +50,8 @@ #include "macglobalshortcutbackend.h" #include "utilities.h" #include "core/logging.h" -#include "core/scoped_cftyperef.h" -#include "core/scoped_nsautorelease_pool.h" +#include "scoped_cftyperef.h" +#include "scoped_nsautorelease_pool.h" #ifdef HAVE_SPARKLE #import @@ -58,11 +59,11 @@ #include #include +#include #include #include #include #include -#include #include @@ -78,8 +79,7 @@ QDebug operator<<(QDebug dbg, NSObject* object) { @interface MacApplication : NSApplication { PlatformInterface* application_handler_; AppDelegate* delegate_; - // shortcut_handler_ only used to temporarily save it - // AppDelegate does all the heavy-shortcut-lifting + // shortcut_handler_ only used to temporarily save it AppDelegate does all the heavy-shortcut-lifting MacGlobalShortcutBackend* shortcut_handler_; } diff --git a/src/core/mac_utilities.h b/src/core/mac_utilities.h index d3dc93bd..b0b057ed 100644 --- a/src/core/mac_utilities.h +++ b/src/core/mac_utilities.h @@ -20,6 +20,7 @@ #include "config.h" +#include #include #include @@ -34,5 +35,5 @@ namespace mac { QKeySequence KeySequenceFromNSEvent(NSEvent* event); void DumpDictionary(CFDictionaryRef dict); -float GetDevicePixelRatio(QWidget* widget); +float GetDevicePixelRatio(QWidget *widget); } diff --git a/src/core/macfslistener.h b/src/core/macfslistener.h index 34529045..f85e1ec3 100644 --- a/src/core/macfslistener.h +++ b/src/core/macfslistener.h @@ -26,6 +26,7 @@ #include #include +#include #include #include diff --git a/src/core/macfslistener.mm b/src/core/macfslistener.mm index 9a2d0f4c..b89b1fad 100644 --- a/src/core/macfslistener.mm +++ b/src/core/macfslistener.mm @@ -27,7 +27,7 @@ #include #include "core/logging.h" -#include "core/scoped_nsobject.h" +#include "scoped_nsobject.h" MacFSListener::MacFSListener(QObject* parent) : FileSystemWatcherInterface(parent), run_loop_(nullptr), stream_(nullptr) { diff --git a/src/core/macsystemtrayicon.h b/src/core/macsystemtrayicon.h index 72ff5546..c4fb7338 100644 --- a/src/core/macsystemtrayicon.h +++ b/src/core/macsystemtrayicon.h @@ -25,6 +25,10 @@ #include +#include +#include +#include + #include "systemtrayicon.h" class MacSystemTrayIconPrivate; diff --git a/src/core/macsystemtrayicon.mm b/src/core/macsystemtrayicon.mm index a2efe869..6a1df5b8 100644 --- a/src/core/macsystemtrayicon.mm +++ b/src/core/macsystemtrayicon.mm @@ -22,13 +22,12 @@ #include "macsystemtrayicon.h" -#include "core/mac_delegate.h" -#include "core/song.h" +#include "mac_delegate.h" +#include "song.h" -#include #include +#include #include - #include #include diff --git a/src/core/main.cpp b/src/core/main.cpp index b99e8642..def88474 100644 --- a/src/core/main.cpp +++ b/src/core/main.cpp @@ -21,16 +21,27 @@ #include "config.h" #include "version.h" +#include +#include +#include #include +#include #include - -#include -#include - -#ifdef Q_OS_UNIX - #include -#endif // Q_OS_UNIX +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#ifdef HAVE_DBUS +# include +#endif #ifdef Q_OS_DARWIN #include @@ -45,53 +56,26 @@ #include #endif // Q_OS_WIN32 -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#ifdef HAVE_DBUS - #include - #include -#endif - -#ifdef HAVE_DBUS - #include "core/mpris.h" - #include "core/mpris2.h" -#endif -#include "core/application.h" -#include "core/mainwindow.h" -#include "core/commandlineoptions.h" -#include "core/database.h" #include "core/logging.h" -#include "core/mac_startup.h" -#include "core/metatypes.h" -#include "core/network.h" -#include "core/networkproxyfactory.h" -#include "core/song.h" -#include "core/utilities.h" -#include "core/iconloader.h" -#include "core/systemtrayicon.h" -#include "core/scangiomodulepath.h" - -#include "widgets/osd.h" - -#include "tagreadermessages.pb.h" #include "qtsingleapplication.h" #include "qtsinglecoreapplication.h" +#ifdef HAVE_DBUS + #include "mpris.h" +#endif +#include "utilities.h" +#include "metatypes.h" +#include "iconloader.h" +#include "mainwindow.h" +#include "commandlineoptions.h" +#include "systemtrayicon.h" +#include "application.h" +#include "networkproxyfactory.h" +#include "scangiomodulepath.h" + +#include "widgets/osd.h" + #ifdef HAVE_DBUS QDBusArgument &operator<<(QDBusArgument &arg, const QImage &image); const QDBusArgument &operator>>(const QDBusArgument &arg, QImage &image); diff --git a/src/core/mainwindow.cpp b/src/core/mainwindow.cpp index bd075ef9..9deee69e 100644 --- a/src/core/mainwindow.cpp +++ b/src/core/mainwindow.cpp @@ -20,102 +20,112 @@ */ #include "config.h" -#include "version.h" + +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "core/logging.h" +#include "core/closure.h" #include "mainwindow.h" #include "ui_mainwindow.h" -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "core/appearance.h" -#include "core/application.h" -#include "core/commandlineoptions.h" -#include "core/database.h" -#include "core/filesystemmusicstorage.h" -#include "core/logging.h" -#include "core/mac_startup.h" -#include "core/mergedproxymodel.h" -#include "core/mimedata.h" -#include "core/mpris_common.h" -#include "core/network.h" -#include "core/player.h" -#include "core/songloader.h" -#include "core/stylesheetloader.h" -#include "core/taskmanager.h" -#include "core/timeconstants.h" -#include "core/utilities.h" -#include "core/iconloader.h" -#include "core/qtsystemtrayicon.h" -#include "core/systemtrayicon.h" -#include "core/windows7thumbbar.h" -#include "globalshortcuts/globalshortcuts.h" -#include "widgets/statusview.h" +#include "utilities.h" +#include "timeconstants.h" +#include "commandlineoptions.h" +#include "mimedata.h" +#include "iconloader.h" +#include "taskmanager.h" +#include "song.h" +#include "stylesheetloader.h" +#include "systemtrayicon.h" +#include "windows7thumbbar.h" +#include "application.h" +#include "database.h" +#include "player.h" +#include "appearance.h" #include "engine/enginebase.h" -#include "engine/gstengine.h" -#include "collection/groupbydialog.h" +#include "dialogs/errordialog.h" +#include "dialogs/about.h" +#include "dialogs/console.h" +#include "dialogs/trackselectiondialog.h" +#include "dialogs/edittagdialog.h" +#ifdef HAVE_GSTREAMER +#include "dialogs/organisedialog.h" +#endif +#include "widgets/fancytabwidget.h" +#include "widgets/playingwidget.h" +#include "widgets/sliderwidget.h" +#include "widgets/statusview.h" +#include "widgets/fileview.h" +#include "widgets/multiloadingindicator.h" +#include "widgets/osd.h" +#include "widgets/stylehelper.h" +#include "widgets/trackslider.h" #include "collection/collection.h" #include "collection/collectionbackend.h" #include "collection/collectiondirectorymodel.h" #include "collection/collectionfilterwidget.h" +#include "collection/collectionmodel.h" +#include "collection/collectionquery.h" +#include "collection/collectionview.h" #include "collection/collectionviewcontainer.h" -#include "playlist/playlistbackend.h" #include "playlist/playlist.h" +#include "playlist/playlistbackend.h" +#include "playlist/playlistcontainer.h" #include "playlist/playlistlistcontainer.h" #include "playlist/playlistmanager.h" #include "playlist/playlistsequence.h" #include "playlist/playlistview.h" #include "playlist/queue.h" #include "playlist/queuemanager.h" -#include "playlist/songplaylistitem.h" #include "playlistparsers/playlistparser.h" +#include "analyzer/analyzercontainer.h" +#include "equalizer/equalizer.h" +#include "globalshortcuts/globalshortcuts.h" +#include "musicbrainz/tagfetcher.h" +#include "covermanager/albumcovermanager.h" #include "device/devicemanager.h" #include "device/devicestatefiltermodel.h" #include "device/deviceview.h" #include "device/deviceviewcontainer.h" -#include "musicbrainz/tagfetcher.h" -#include "equalizer/equalizer.h" #include "transcoder/transcodedialog.h" -#include "dialogs/about.h" -#include "dialogs/console.h" -#include "dialogs/edittagdialog.h" -#ifdef HAVE_GSTREAMER -#include "dialogs/organisedialog.h" -#include "dialogs/organiseerrordialog.h" -#endif -#include "dialogs/trackselectiondialog.h" -#include "dialogs/errordialog.h" -#include "widgets/fileview.h" -#include "widgets/multiloadingindicator.h" -#include "widgets/osd.h" -#include "widgets/stylehelper.h" -#include "widgets/trackslider.h" -#include "settings/settingsdialog.h" -#include "covermanager/albumcovermanager.h" - #include "settings/behavioursettingspage.h" #include "settings/playlistsettingspage.h" +#include "settings/settingsdialog.h" #ifdef Q_OS_DARWIN #include "ui/macsystemtrayicon.h" @@ -151,7 +161,7 @@ MainWindow::MainWindow(Application *app, SystemTrayIcon *tray_icon, OSD *osd, co device_view_(device_view_container_->view()), settings_dialog_(std::bind(&MainWindow::CreateSettingsDialog, this)), cover_manager_([=]() { - AlbumCoverManager* cover_manager = new AlbumCoverManager(app, app->collection_backend()); + AlbumCoverManager *cover_manager = new AlbumCoverManager(app, app->collection_backend()); cover_manager->Init(); // Cover manager connections @@ -163,13 +173,13 @@ MainWindow::MainWindow(Application *app, SystemTrayIcon *tray_icon, OSD *osd, co equalizer_(new Equalizer), #ifdef HAVE_GSTREAMER organise_dialog_([=]() { - OrganiseDialog* dialog = new OrganiseDialog(app->task_manager()); + OrganiseDialog *dialog = new OrganiseDialog(app->task_manager()); dialog->SetDestinationModel(app->collection()->model()->directory_model()); return dialog; }), #endif queue_manager_([=]() { - QueueManager* manager = new QueueManager; + QueueManager *manager = new QueueManager; manager->SetPlaylistManager(app->playlist_manager()); return manager; }), @@ -345,9 +355,6 @@ MainWindow::MainWindow(Application *app, SystemTrayIcon *tray_icon, OSD *osd, co connect(ui_->action_add_folder, SIGNAL(triggered()), SLOT(AddFolder())); connect(ui_->action_cover_manager, SIGNAL(triggered()), SLOT(ShowCoverManager())); connect(ui_->action_equalizer, SIGNAL(triggered()), equalizer_.get(), SLOT(show())); -#ifdef HAVE_GSTREAMER - //connect(ui_->action_transcode, SIGNAL(triggered()), SLOT(ShowTranscodeDialog())); -#endif connect(ui_->action_jump, SIGNAL(triggered()), ui_->playlist->view(), SLOT(JumpToCurrentlyPlayingTrack())); connect(ui_->action_update_collection, SIGNAL(triggered()), app_->collection(), SLOT(IncrementalScan())); connect(ui_->action_full_collection_scan, SIGNAL(triggered()), app_->collection(), SLOT(FullScan())); @@ -375,7 +382,7 @@ MainWindow::MainWindow(Application *app, SystemTrayIcon *tray_icon, OSD *osd, co ui_->action_repeat_mode->setMenu(ui_->playlist_sequence->repeat_menu()); // Stop actions - QMenu* stop_menu = new QMenu(this); + QMenu *stop_menu = new QMenu(this); stop_menu->addAction(ui_->action_stop); stop_menu->addAction(ui_->action_stop_after_this_track); ui_->stop_button->setMenu(stop_menu); @@ -439,7 +446,7 @@ MainWindow::MainWindow(Application *app, SystemTrayIcon *tray_icon, OSD *osd, co connect(device_view_, SIGNAL(AddToPlaylistSignal(QMimeData*)), SLOT(AddToPlaylist(QMimeData*))); // Collection filter widget - QActionGroup* collection_view_group = new QActionGroup(this); + QActionGroup *collection_view_group = new QActionGroup(this); collection_show_all_ = collection_view_group->addAction(tr("Show all songs")); collection_show_duplicates_ = collection_view_group->addAction(tr("Show only duplicates")); @@ -452,12 +459,12 @@ MainWindow::MainWindow(Application *app, SystemTrayIcon *tray_icon, OSD *osd, co connect(collection_view_group, SIGNAL(triggered(QAction*)), SLOT(ChangeCollectionQueryMode(QAction*))); - QAction* collection_config_action = new QAction(IconLoader::Load("configure"), tr("Configure collection..."), this); + QAction *collection_config_action = new QAction(IconLoader::Load("configure"), tr("Configure collection..."), this); connect(collection_config_action, SIGNAL(triggered()), SLOT(ShowCollectionConfig())); collection_view_->filter()->SetSettingsGroup(kSettingsGroup); collection_view_->filter()->SetCollectionModel(app_->collection()->model()); - QAction* separator = new QAction(this); + QAction *separator = new QAction(this); separator->setSeparator(true); collection_view_->filter()->AddMenuAction(collection_show_all_); @@ -509,11 +516,10 @@ MainWindow::MainWindow(Application *app, SystemTrayIcon *tray_icon, OSD *osd, co ui_->action_shuffle->setShortcut(QKeySequence()); #endif - // We have to add the actions on the playlist menu to this QWidget otherwise - // their shortcut keys don't work + // We have to add the actions on the playlist menu to this QWidget otherwise their shortcut keys don't work addActions(playlist_menu_->actions()); - connect(ui_->playlist, SIGNAL(UndoRedoActionsChanged(QAction*,QAction*)), SLOT(PlaylistUndoRedoChanged(QAction*,QAction*))); + connect(ui_->playlist, SIGNAL(UndoRedoActionsChanged(QAction*, QAction*)), SLOT(PlaylistUndoRedoChanged(QAction*, QAction*))); #ifdef HAVE_GSTREAMER playlist_copy_to_device_->setDisabled(app_->device_manager()->connected_devices_model()->rowCount() == 0); @@ -539,7 +545,7 @@ MainWindow::MainWindow(Application *app, SystemTrayIcon *tray_icon, OSD *osd, co #if (defined(Q_OS_DARWIN) && defined(HAVE_SPARKLE)) || defined(Q_OS_WIN32) // Add check for updates item to application menu. - QAction* check_updates = ui_->menu_tools->addAction(tr("Check for updates...")); + QAction *check_updates = ui_->menu_tools->addAction(tr("Check for updates...")); check_updates->setMenuRole(QAction::ApplicationSpecificRole); connect(check_updates, SIGNAL(triggered(bool)), SLOT(CheckForUpdates())); #endif @@ -602,11 +608,11 @@ MainWindow::MainWindow(Application *app, SystemTrayIcon *tray_icon, OSD *osd, co PlayingWidgetPositionChanged(); // Load theme - // This is tricky: we need to save the default/system palette now, before - // loading user preferred theme (which will overide it), to be able to restore it later + // This is tricky: we need to save the default/system palette now, + // before loading user preferred theme (which will overide it), to be able to restore it later const_cast(Appearance::kDefaultPalette) = QApplication::palette(); app_->appearance()->LoadUserTheme(); - StyleSheetLoader* css_loader = new StyleSheetLoader(this); + StyleSheetLoader *css_loader = new StyleSheetLoader(this); css_loader->SetStyleSheet(this, ":style/mainwindow.css"); RefreshStyleSheet(); @@ -643,8 +649,7 @@ MainWindow::MainWindow(Application *app, SystemTrayIcon *tray_icon, OSD *osd, co file_view_->SetPath(settings_.value("file_path", QDir::homePath()).toString()); TabSwitched(); - // Users often collapse one side of the splitter by mistake and don't know - // how to restore it. This must be set after the state is restored above. + // Users often collapse one side of the splitter by mistake and don't know how to restore it. This must be set after the state is restored above. ui_->splitter->setChildrenCollapsible(false); ReloadSettings(); @@ -703,8 +708,6 @@ MainWindow::~MainWindow() { } void MainWindow::ReloadSettings() { - - //qLog(Debug) << __PRETTY_FUNCTION__; QSettings settings; @@ -809,8 +812,9 @@ void MainWindow::VolumeChanged(int volume) { } void MainWindow::SongChanged(const Song &song) { - - setWindowTitle(song.PrettyTitleWithArtist() + " --- Strawberry Music Player"); + + //setWindowTitle(song.PrettyTitleWithArtist() + " --- Strawberry Music Player"); + setWindowTitle(song.PrettyTitleWithArtist()); tray_icon_->SetProgress(0); } @@ -837,8 +841,6 @@ void MainWindow::TrackSkipped(PlaylistItemPtr item) { void MainWindow::resizeEvent(QResizeEvent*) { SaveGeometry(); } void MainWindow::TabSwitched() { - - //qLog(Debug) << __PRETTY_FUNCTION__ << ui_->tabs->current_index() ; if (ui_->tabs->current_index() > 0) ui_->now_playing->SetEnabled(); @@ -850,8 +852,6 @@ void MainWindow::TabSwitched() { } void MainWindow::SaveGeometry() { - - //qLog(Debug) << __PRETTY_FUNCTION__; was_maximized_ = isMaximized(); settings_.setValue("maximized", was_maximized_); @@ -866,8 +866,6 @@ void MainWindow::SaveGeometry() { } void MainWindow::SavePlaybackStatus() { - - //qLog(Debug) << __PRETTY_FUNCTION__; QSettings settings; @@ -885,8 +883,6 @@ void MainWindow::SavePlaybackStatus() { } void MainWindow::LoadPlaybackStatus() { - - //qLog(Debug) << __PRETTY_FUNCTION__; QSettings settings; @@ -933,8 +929,7 @@ void MainWindow::PlayIndex(const QModelIndex &index) { int row = index.row(); if (index.model() == app_->playlist_manager()->current()->proxy()) { - // The index was in the proxy model (might've been filtered), so we need - // to get the actual row in the source model. + // The index was in the proxy model (might've been filtered), so we need to get the actual row in the source model. row = app_->playlist_manager()->current()->proxy()->mapToSource(index).row(); } @@ -947,10 +942,8 @@ void MainWindow::PlaylistDoubleClick(const QModelIndex &index) { int row = index.row(); if (index.model() == app_->playlist_manager()->current()->proxy()) { - // The index was in the proxy model (might've been filtered), so we need - // to get the actual row in the source model. - row = - app_->playlist_manager()->current()->proxy()->mapToSource(index).row(); + // The index was in the proxy model (might've been filtered), so we need to get the actual row in the source model. + row = app_->playlist_manager()->current()->proxy()->mapToSource(index).row(); } QModelIndexList dummyIndexList; @@ -1028,8 +1021,7 @@ void MainWindow::SetHiddenInTray(bool hidden) { settings_.setValue("hidden", hidden); - // Some window managers don't remember maximized state between calls to - // hide() and show(), so we have to remember it ourself. + // Some window managers don't remember maximized state between calls to hide() and show(), so we have to remember it ourself. if (hidden) { //was_maximized_ = isMaximized(); hide(); @@ -1053,11 +1045,9 @@ void MainWindow::Seeked(qlonglong microseconds) { } void MainWindow::UpdateTrackPosition() { - - //qLog(Debug) << __PRETTY_FUNCTION__; // Track position in seconds - //Playlist* playlist = app_->playlist_manager()->active(); + //Playlist *playlist = app_->playlist_manager()->active(); PlaylistItemPtr item(app_->player()->GetCurrentItem()); const int position = std::floor(float(app_->player()->engine()->position_nanosec()) / kNsecPerSec + 0.5); @@ -1086,7 +1076,7 @@ void MainWindow::UpdateTrackSliderPosition() { ui_->track_slider->SetValue(slider_position, slider_length); } -void MainWindow::ApplyAddBehaviour(MainWindow::AddBehaviour b, MimeData* data) const { +void MainWindow::ApplyAddBehaviour(MainWindow::AddBehaviour b, MimeData *data) const { switch (b) { case AddBehaviour_Append: @@ -1110,9 +1100,7 @@ void MainWindow::ApplyAddBehaviour(MainWindow::AddBehaviour b, MimeData* data) c } } -void MainWindow::ApplyPlayBehaviour(MainWindow::PlayBehaviour b, MimeData* data) const { - - //qLog(Debug) << __PRETTY_FUNCTION__; +void MainWindow::ApplyPlayBehaviour(MainWindow::PlayBehaviour b, MimeData *data) const { switch (b) { case PlayBehaviour_Always: @@ -1129,9 +1117,7 @@ void MainWindow::ApplyPlayBehaviour(MainWindow::PlayBehaviour b, MimeData* data) } } -void MainWindow::AddToPlaylist(QMimeData* data) { - - //qLog(Debug) << __PRETTY_FUNCTION__; +void MainWindow::AddToPlaylist(QMimeData *data) { if (!data) return; @@ -1157,15 +1143,13 @@ void MainWindow::AddToPlaylist(QMimeData* data) { delete data; } -void MainWindow::AddToPlaylist(QAction* action) { - - //qLog(Debug) << __PRETTY_FUNCTION__; +void MainWindow::AddToPlaylist(QAction *action) { int destination = action->data().toInt(); PlaylistItemList items; // get the selected playlist items - for (const QModelIndex& index : ui_->playlist->view()->selectionModel()->selection().indexes()) { + for (const QModelIndex &index : ui_->playlist->view()->selectionModel()->selection().indexes()) { if (index.column() != 0) continue; int row = app_->playlist_manager()->current()->proxy()->mapToSource(index).row(); items << app_->playlist_manager()->current()->item_at(row); @@ -1198,8 +1182,6 @@ void MainWindow::AddToPlaylist(QAction* action) { void MainWindow::PlaylistRightClick(const QPoint &global_pos, const QModelIndex &index) { - //qLog(Debug) << __PRETTY_FUNCTION__; - QModelIndex source_index = app_->playlist_manager()->current()->proxy()->mapToSource(index); playlist_menu_index_ = source_index; @@ -1374,10 +1356,10 @@ void MainWindow::PlaylistRightClick(const QPoint &global_pos, const QModelIndex QMenu *add_to_another_menu = new QMenu(tr("Add to another playlist"), this); add_to_another_menu->setIcon(IconLoader::Load("list-add")); - for (const PlaylistBackend::Playlist& playlist : app_->playlist_backend()->GetAllOpenPlaylists()) { + for (const PlaylistBackend::Playlist &playlist : app_->playlist_backend()->GetAllOpenPlaylists()) { // don't add the current playlist if (playlist.id != app_->playlist_manager()->current()->id()) { - QAction* existing_playlist = new QAction(this); + QAction *existing_playlist = new QAction(this); existing_playlist->setText(playlist.name); existing_playlist->setData(playlist.id); add_to_another_menu->addAction(existing_playlist); @@ -1386,7 +1368,7 @@ void MainWindow::PlaylistRightClick(const QPoint &global_pos, const QModelIndex add_to_another_menu->addSeparator(); // add to a new playlist - QAction* new_playlist = new QAction(this); + QAction *new_playlist = new QAction(this); new_playlist->setText(tr("New playlist")); new_playlist->setData(-1); // fake id add_to_another_menu->addAction(new_playlist); @@ -1414,7 +1396,7 @@ void MainWindow::EditTracks() { SongList songs; PlaylistItemList items; - for (const QModelIndex& index : ui_->playlist->view()->selectionModel()->selection().indexes()) { + for (const QModelIndex &index : ui_->playlist->view()->selectionModel()->selection().indexes()) { if (index.column() != 0) continue; int row =app_->playlist_manager()->current()->proxy()->mapToSource(index).row(); PlaylistItemPtr item(app_->playlist_manager()->current()->item_at(row)); @@ -1456,7 +1438,7 @@ void MainWindow::RenumberTracks() { if (first_song.track() > 0) track = first_song.track(); } - for (const QModelIndex& index : indexes) { + for (const QModelIndex &index : indexes) { if (index.column() != 0) continue; const QModelIndex source_index =app_->playlist_manager()->current()->proxy()->mapToSource(index); @@ -1466,7 +1448,7 @@ void MainWindow::RenumberTracks() { if (song.IsEditable()) { song.set_track(track); - TagReaderReply* reply =TagReaderClient::Instance()->SaveFile(song.url().toLocalFile(), song); + TagReaderReply *reply =TagReaderClient::Instance()->SaveFile(song.url().toLocalFile(), song); NewClosure(reply, SIGNAL(Finished(bool)), this, SLOT(SongSaveComplete(TagReaderReply*, QPersistentModelIndex)),reply, QPersistentModelIndex(source_index)); } @@ -1474,7 +1456,7 @@ void MainWindow::RenumberTracks() { } } -void MainWindow::SongSaveComplete(TagReaderReply* reply,const QPersistentModelIndex& index) { +void MainWindow::SongSaveComplete(TagReaderReply *reply,const QPersistentModelIndex &index) { if (reply->is_successful() && index.isValid()) { app_->playlist_manager()->current()->ReloadItems(QList()<< index.row()); } @@ -1487,7 +1469,7 @@ void MainWindow::SelectionSetValue() { QModelIndexList indexes =ui_->playlist->view()->selectionModel()->selection().indexes(); - for (const QModelIndex& index : indexes) { + for (const QModelIndex &index : indexes) { if (index.column() != 0) continue; const QModelIndex source_index =app_->playlist_manager()->current()->proxy()->mapToSource(index); @@ -1495,7 +1477,7 @@ void MainWindow::SelectionSetValue() { Song song = app_->playlist_manager()->current()->item_at(row)->Metadata(); if (Playlist::set_column_value(song, column, column_value)) { - TagReaderReply* reply =TagReaderClient::Instance()->SaveFile(song.url().toLocalFile(), song); + TagReaderReply *reply =TagReaderClient::Instance()->SaveFile(song.url().toLocalFile(), song); NewClosure(reply, SIGNAL(Finished(bool)), this, SLOT(SongSaveComplete(TagReaderReply*, QPersistentModelIndex)),reply, QPersistentModelIndex(source_index)); } @@ -1507,8 +1489,7 @@ void MainWindow::EditValue() { if (!current.isValid()) return; - // Edit the last column that was right-clicked on. If nothing's ever been - // right clicked then look for the first editable column. + // Edit the last column that was right-clicked on. If nothing's ever been right clicked then look for the first editable column. int column = playlist_menu_index_.column(); if (column == -1) { for (int i = 0; i < ui_->playlist->view()->model()->columnCount(); ++i) { @@ -1524,15 +1505,13 @@ void MainWindow::EditValue() { void MainWindow::AddFile() { - //qLog(Debug) << __PRETTY_FUNCTION__; - // Last used directory QString directory =settings_.value("add_media_path", QDir::currentPath()).toString(); PlaylistParser parser(app_->collection_backend()); // Show dialog - QStringList file_names = QFileDialog::getOpenFileNames(this, tr("Add file"), directory,QString("%1 (%2);;%3;;%4").arg(tr("Music"), FileView::kFileFilter,parser.filters(),tr(kAllFilesFilterSpec))); + QStringList file_names = QFileDialog::getOpenFileNames(this, tr("Add file"), directory, QString("%1 (%2);;%3;;%4").arg(tr("Music"), FileView::kFileFilter, parser.filters(), tr(kAllFilesFilterSpec))); if (file_names.isEmpty()) return; @@ -1541,11 +1520,11 @@ void MainWindow::AddFile() { // Convert to URLs QList urls; - for (const QString& path : file_names) { + for (const QString &path : file_names) { urls << QUrl::fromLocalFile(QFileInfo(path).canonicalFilePath()); } - MimeData* data = new MimeData; + MimeData *data = new MimeData; data->setUrls(urls); AddToPlaylist(data); } @@ -1562,15 +1541,14 @@ void MainWindow::AddFolder() { settings_.setValue("add_folder_path", directory); // Add media - MimeData* data = new MimeData; + MimeData *data = new MimeData; data->setUrls(QList() << QUrl::fromLocalFile(QFileInfo(directory).canonicalFilePath())); AddToPlaylist(data); } void MainWindow::AddCDTracks() { - MimeData* data = new MimeData; - // We are putting empty data, but we specify cdda mimetype to indicate that - // we want to load audio cd tracks + MimeData *data = new MimeData; + // We are putting empty data, but we specify cdda mimetype to indicate that we want to load audio cd tracks data->open_in_new_playlist_ = true; data->setData(Playlist::kCddaMimeType, QByteArray()); AddToPlaylist(data); @@ -1582,7 +1560,7 @@ void MainWindow::ShowInCollection() { QModelIndexList proxy_indexes =ui_->playlist->view()->selectionModel()->selectedRows(); SongList songs; - for (const QModelIndex& proxy_index : proxy_indexes) { + for (const QModelIndex &proxy_index : proxy_indexes) { QModelIndex index =app_->playlist_manager()->current()->proxy()->mapToSource(proxy_index); if (app_->playlist_manager()->current()->item_at(index.row())->IsLocalCollectionItem()) { songs << app_->playlist_manager()->current()->item_at(index.row())->Metadata(); @@ -1600,11 +1578,11 @@ void MainWindow::PlaylistRemoveCurrent() { ui_->playlist->view()->RemoveSelected(false); } -void MainWindow::PlaylistEditFinished(const QModelIndex& index) { +void MainWindow::PlaylistEditFinished(const QModelIndex &index) { if (index == playlist_menu_index_) SelectionSetValue(); } -void MainWindow::CommandlineOptionsReceived(const QString& string_options) { +void MainWindow::CommandlineOptionsReceived(const QString &string_options) { CommandlineOptions options; options.Load(string_options.toLatin1()); @@ -1617,7 +1595,7 @@ void MainWindow::CommandlineOptionsReceived(const QString& string_options) { CommandlineOptionsReceived(options); } -void MainWindow::CommandlineOptionsReceived(const CommandlineOptions& options) { +void MainWindow::CommandlineOptionsReceived(const CommandlineOptions &options) { switch (options.player_action()) { case CommandlineOptions::Player_Play: if (options.urls().empty()) { @@ -1651,7 +1629,7 @@ void MainWindow::CommandlineOptionsReceived(const CommandlineOptions& options) { } if (!options.urls().empty()) { - MimeData* data = new MimeData; + MimeData *data = new MimeData; data->setUrls(options.urls()); // Behaviour depends on command line options, so set it here data->override_user_settings_ = true; @@ -1698,7 +1676,7 @@ void MainWindow::CommandlineOptionsReceived(const CommandlineOptions& options) { if (options.toggle_pretty_osd()) app_->player()->TogglePrettyOSD(); } -void MainWindow::ForceShowOSD(const Song& song, const bool toggle) { +void MainWindow::ForceShowOSD(const Song &song, const bool toggle) { if (toggle) { osd_->SetPrettyOSDToggleMode(toggle); } @@ -1709,11 +1687,11 @@ void MainWindow::Activate() { show(); } -bool MainWindow::LoadUrl(const QString& url) { +bool MainWindow::LoadUrl(const QString &url) { if (!QFile::exists(url)) return false; - MimeData* data = new MimeData; + MimeData *data = new MimeData; data->setUrls(QList() << QUrl::fromLocalFile(url)); AddToPlaylist(data); @@ -1726,7 +1704,7 @@ void MainWindow::CheckForUpdates() { #endif } -void MainWindow::PlaylistUndoRedoChanged(QAction* undo, QAction* redo) { +void MainWindow::PlaylistUndoRedoChanged(QAction *undo, QAction *redo) { playlist_menu_->insertAction(playlist_undoredo_, undo); playlist_menu_->insertAction(playlist_undoredo_, redo); @@ -1737,7 +1715,7 @@ void MainWindow::AddFilesToTranscoder() { QStringList filenames; - for (const QModelIndex& index : ui_->playlist->view()->selectionModel()->selection().indexes()) { + for (const QModelIndex &index : ui_->playlist->view()->selectionModel()->selection().indexes()) { if (index.column() != 0) continue; int row =app_->playlist_manager()->current()->proxy()->mapToSource(index).row(); PlaylistItemPtr item(app_->playlist_manager()->current()->item_at(row)); @@ -1775,37 +1753,36 @@ void MainWindow::PlayingWidgetPositionChanged() { } #ifdef HAVE_GSTREAMER -void MainWindow::CopyFilesToCollection(const QList& urls) { +void MainWindow::CopyFilesToCollection(const QList &urls) { organise_dialog_->SetDestinationModel(app_->collection_model()->directory_model()); organise_dialog_->SetUrls(urls); organise_dialog_->SetCopy(true); organise_dialog_->show(); } -void MainWindow::MoveFilesToCollection(const QList& urls) { +void MainWindow::MoveFilesToCollection(const QList &urls) { organise_dialog_->SetDestinationModel(app_->collection_model()->directory_model()); organise_dialog_->SetUrls(urls); organise_dialog_->SetCopy(false); organise_dialog_->show(); } -void MainWindow::CopyFilesToDevice(const QList& urls) { +void MainWindow::CopyFilesToDevice(const QList &urls) { organise_dialog_->SetDestinationModel(app_->device_manager()->connected_devices_model(), true); organise_dialog_->SetCopy(true); if (organise_dialog_->SetUrls(urls)) organise_dialog_->show(); else { - QMessageBox::warning(this, tr("Error"), - tr("None of the selected songs were suitable for copying to a device")); + QMessageBox::warning(this, tr("Error"), tr("None of the selected songs were suitable for copying to a device")); } } #endif -void MainWindow::EditFileTags(const QList& urls) { +void MainWindow::EditFileTags(const QList &urls) { //EnsureEditTagDialogCreated(); SongList songs; - for (const QUrl& url : urls) { + for (const QUrl &url : urls) { Song song; song.set_url(url); song.set_valid(true); @@ -1831,9 +1808,8 @@ void MainWindow::PlaylistOrganiseSelected(bool copy) { QModelIndexList proxy_indexes = ui_->playlist->view()->selectionModel()->selectedRows(); SongList songs; - for (const QModelIndex& proxy_index : proxy_indexes) { + for (const QModelIndex &proxy_index : proxy_indexes) { QModelIndex index =app_->playlist_manager()->current()->proxy()->mapToSource(proxy_index); - songs << app_->playlist_manager()->current()->item_at(index.row())->Metadata(); } @@ -1859,7 +1835,7 @@ void MainWindow::PlaylistDelete() { // Get selected songs SongList selected_songs; QModelIndexList proxy_indexes = ui_->playlist->view()->selectionModel()->selectedRows(); - for (const QModelIndex& proxy_index : proxy_indexes) { + for (const QModelIndex &proxy_index : proxy_indexes) { QModelIndex index = app_->playlist_manager()->current()->proxy()->mapToSource(proxy_index); selected_songs << app_->playlist_manager()->current()->item_at(index.row())->Metadata(); } @@ -1879,7 +1855,7 @@ void MainWindow::PlaylistDelete() { ui_->playlist->view()->RemoveSelected(true); - DeleteFiles* delete_files = new DeleteFiles(app_->task_manager(), storage); + DeleteFiles *delete_files = new DeleteFiles(app_->task_manager(), storage); connect(delete_files, SIGNAL(Finished(SongList)), SLOT(DeleteFinished(SongList))); delete_files->Start(selected_songs); } @@ -1890,7 +1866,7 @@ void MainWindow::PlaylistOpenInBrowser() { QList urls; QModelIndexList proxy_indexes = ui_->playlist->view()->selectionModel()->selectedRows(); - for (const QModelIndex& proxy_index : proxy_indexes) { + for (const QModelIndex &proxy_index : proxy_indexes) { const QModelIndex index = app_->playlist_manager()->current()->proxy()->mapToSource(proxy_index); urls << QUrl(index.sibling(index.row(), Playlist::Column_Filename).data().toString()); } @@ -1899,10 +1875,10 @@ void MainWindow::PlaylistOpenInBrowser() { } #if 0 -void MainWindow::DeleteFinished(const SongList& songs_with_errors) { +void MainWindow::DeleteFinished(const SongList &songs_with_errors) { if (songs_with_errors.isEmpty()) return; - OrganiseErrorDialog* dialog = new OrganiseErrorDialog(this); + OrganiseErrorDialog *dialog = new OrganiseErrorDialog(this); dialog->Show(OrganiseErrorDialog::Type_Delete, songs_with_errors); // It deletes itself when the user closes it } @@ -1911,7 +1887,7 @@ void MainWindow::DeleteFinished(const SongList& songs_with_errors) { void MainWindow::PlaylistQueue() { QModelIndexList indexes; - for (const QModelIndex& proxy_index : ui_->playlist->view()->selectionModel()->selectedRows()) { + for (const QModelIndex &proxy_index : ui_->playlist->view()->selectionModel()->selectedRows()) { indexes << app_->playlist_manager()->current()->proxy()->mapToSource(proxy_index); } @@ -1936,7 +1912,7 @@ void MainWindow::PlaylistCopyToDevice() { QModelIndexList proxy_indexes = ui_->playlist->view()->selectionModel()->selectedRows(); SongList songs; - for (const QModelIndex& proxy_index : proxy_indexes) { + for (const QModelIndex &proxy_index : proxy_indexes) { QModelIndex index = app_->playlist_manager()->current()->proxy()->mapToSource(proxy_index); songs << app_->playlist_manager()->current()->item_at(index.row())->Metadata(); @@ -1953,7 +1929,7 @@ void MainWindow::PlaylistCopyToDevice() { } #endif -void MainWindow::ChangeCollectionQueryMode(QAction* action) { +void MainWindow::ChangeCollectionQueryMode(QAction *action) { if (action == collection_show_duplicates_) { collection_view_->filter()->SetQueryMode(QueryOptions::QueryMode_Duplicates); } @@ -1979,9 +1955,9 @@ void MainWindow::ShowCoverManager() { } -SettingsDialog* MainWindow::CreateSettingsDialog() { +SettingsDialog *MainWindow::CreateSettingsDialog() { - SettingsDialog* settings_dialog = new SettingsDialog(app_); + SettingsDialog *settings_dialog = new SettingsDialog(app_); settings_dialog->SetGlobalShortcutManager(global_shortcuts_); //settings_dialog->SetSongInfoView(song_info_view_); @@ -2022,7 +1998,7 @@ void MainWindow::OpenSettingsDialogAtPage(SettingsDialog::Page page) { settings_dialog_->OpenAtPage(page); } -EditTagDialog* MainWindow::CreateEditTagDialog() { +EditTagDialog *MainWindow::CreateEditTagDialog() { EditTagDialog *edit_tag_dialog = new EditTagDialog(app_); connect(edit_tag_dialog, SIGNAL(accepted()), SLOT(EditTagDialogAccepted())); @@ -2062,7 +2038,7 @@ void MainWindow::ShowTranscodeDialog() { } #endif -void MainWindow::ShowErrorDialog(const QString& message) { +void MainWindow::ShowErrorDialog(const QString &message) { //if (!error_dialog_) { // error_dialog_.reset(new ErrorDialog); //} @@ -2074,13 +2050,12 @@ void MainWindow::CheckFullRescanRevisions() { int from = app_->database()->startup_schema_version(); int to = app_->database()->current_schema_version(); - // if we're restoring DB from scratch or nothing has - // changed, do nothing + // if we're restoring DB from scratch or nothing has changed, do nothing if (from == 0 || from == to) { return; } - // collect all reasons + // Collect all reasons QSet reasons; for (int i = from; i <= to; i++) { QString reason = app_->collection()->full_rescan_reason(i); @@ -2093,7 +2068,7 @@ void MainWindow::CheckFullRescanRevisions() { // if we have any... if (!reasons.isEmpty()) { QString message = tr("The version of Strawberry you've just updated to requires a full collection rescan because of the new features listed below:") + "
    "; - for(const QString& reason : reasons) { + for(const QString &reason : reasons) { message += ("
  • " + reason + "
  • "); } message += "
" + tr("Would you like to run a full rescan right now?"); @@ -2142,12 +2117,10 @@ void MainWindow::ShowSongInfoConfig() { void MainWindow::PlaylistViewSelectionModelChanged() { - //qLog(Debug) << __PRETTY_FUNCTION__; - connect(ui_->playlist->view()->selectionModel(),SIGNAL(currentChanged(QModelIndex, QModelIndex)), SLOT(PlaylistCurrentChanged(QModelIndex))); } -void MainWindow::PlaylistCurrentChanged(const QModelIndex& proxy_current) { +void MainWindow::PlaylistCurrentChanged(const QModelIndex &proxy_current) { const QModelIndex source_current =app_->playlist_manager()->current()->proxy()->mapToSource(proxy_current); // If the user moves the current index using the keyboard and then presses @@ -2161,7 +2134,7 @@ void MainWindow::Raise() { } #ifdef Q_OS_WIN32 -bool MainWindow::winEvent(MSG* msg, long*) { +bool MainWindow::winEvent(MSG *msg, long*) { thumbbar_->HandleWinEvent(msg); return false; } @@ -2169,8 +2142,6 @@ bool MainWindow::winEvent(MSG* msg, long*) { void MainWindow::Exit() { - //qLog(Debug) << __PRETTY_FUNCTION__; - SavePlaybackStatus(); //settings_.setValue("show_sidebar", ui_->action_toggle_show_sidebar->isChecked()); @@ -2185,10 +2156,6 @@ void MainWindow::Exit() { } } -#ifdef HAVE_GSTREAMER - //gst_deinit(); -#endif - qApp->quit(); } @@ -2212,7 +2179,7 @@ void MainWindow::AutoCompleteTags() { // Get the selected songs and start fetching tags for them SongList songs; autocomplete_tag_items_.clear(); - for (const QModelIndex& index : ui_->playlist->view()->selectionModel()->selection().indexes()) { + for (const QModelIndex &index : ui_->playlist->view()->selectionModel()->selection().indexes()) { if (index.column() != 0) continue; int row = app_->playlist_manager()->current()->proxy()->mapToSource(index).row(); PlaylistItemPtr item(app_->playlist_manager()->current()->item_at(row)); @@ -2269,11 +2236,11 @@ void MainWindow::FocusCollectionTab() { } void MainWindow::ShowConsole() { - Console* console = new Console(app_, this); + Console *console = new Console(app_, this); console->show(); } -void MainWindow::keyPressEvent(QKeyEvent* event) { +void MainWindow::keyPressEvent(QKeyEvent *event) { if (event->key() == Qt::Key_Space) { app_->player()->PlayPause(); event->accept(); diff --git a/src/core/mainwindow.h b/src/core/mainwindow.h index 0a265a9f..b5dea6da 100644 --- a/src/core/mainwindow.h +++ b/src/core/mainwindow.h @@ -24,38 +24,43 @@ #include "config.h" #include +#include +#include +#include +#include #include -#include #include -#include -#include -#include -#include -#include #include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #include "core/lazy.h" -#include "core/mac_startup.h" #include "core/tagreaderclient.h" #include "engine/engine_fwd.h" +#include "mac_startup.h" +#include "widgets/osd.h" #include "collection/collectionmodel.h" #include "playlist/playlistitem.h" -#ifdef HAVE_GSTREAMER -#include "dialogs/organisedialog.h" -#endif #include "settings/settingsdialog.h" -class StatusView; class About; -class AlbumCoverManager; -class Appearance; +class AlbumCoverManager;; class Application; -class ArtistInfoView; +class CollectionViewContainer; class CommandlineOptions; -class CoverProviders; -class Database; -class DeviceManager; class DeviceView; class DeviceViewContainer; class EditTagDialog; @@ -63,35 +68,26 @@ class Equalizer; class ErrorDialog; class FileView; class GlobalShortcuts; -class GroupByDialog; -class Collection; -class CollectionViewContainer; class MimeData; -class MultiLoadingIndicator; -class OSD; -class Player; -class PlaylistBackend; +class OrganiseDialog; class PlaylistListContainer; -class PlaylistManager; class QueueManager; class Song; +class StatusView; class SystemTrayIcon; class TagFetcher; -class TaskManager; class TrackSelectionDialog; #ifdef HAVE_GSTREAMER class TranscodeDialog; #endif -class Windows7ThumbBar; class Ui_MainWindow; - -class QSortFilterProxyModel; +class Windows7ThumbBar; class MainWindow : public QMainWindow, public PlatformInterface { Q_OBJECT public: - MainWindow(Application *app, SystemTrayIcon* tray_icon, OSD* osd, const CommandlineOptions& options, QWidget* parent = nullptr); + MainWindow(Application *app, SystemTrayIcon *tray_icon, OSD *osd, const CommandlineOptions& options, QWidget *parent = nullptr); ~MainWindow(); static const char *kSettingsGroup; @@ -129,12 +125,12 @@ class MainWindow : public QMainWindow, public PlatformInterface { void CommandlineOptionsReceived(const CommandlineOptions& options); protected: - void keyPressEvent(QKeyEvent* event); - void resizeEvent(QResizeEvent* event); - void closeEvent(QCloseEvent* event); + void keyPressEvent(QKeyEvent *event); + void resizeEvent(QResizeEvent *event); + void closeEvent(QCloseEvent *event); #ifdef Q_OS_WIN32 - bool winEvent(MSG* message, long* result); + bool winEvent(MSG *message, long *result); #endif // PlatformInterface @@ -174,7 +170,7 @@ signals: void AutoCompleteTags(); void AutoCompleteTagsAccepted(); #endif - void PlaylistUndoRedoChanged(QAction* undo, QAction* redo); + void PlaylistUndoRedoChanged(QAction *undo, QAction *redo); #ifdef HAVE_GSTREAMER void AddFilesToTranscoder(); #endif @@ -189,7 +185,7 @@ signals: void PlaylistOpenInBrowser(); void ShowInCollection(); - void ChangeCollectionQueryMode(QAction* action); + void ChangeCollectionQueryMode(QAction *action); void PlayIndex(const QModelIndex& index); void PlaylistDoubleClick(const QModelIndex& index); @@ -205,8 +201,8 @@ signals: #endif void EditFileTags(const QList& urls); - void AddToPlaylist(QMimeData* data); - void AddToPlaylist(QAction* action); + void AddToPlaylist(QMimeData *data); + void AddToPlaylist(QAction *action); void VolumeWheelEvent(int delta); void ToggleShowHide(); @@ -245,8 +241,8 @@ signals: void ShowQueueManager(); void EnsureSettingsDialogCreated(); void EnsureEditTagDialogCreated(); - SettingsDialog* CreateSettingsDialog(); - EditTagDialog* CreateEditTagDialog(); + SettingsDialog *CreateSettingsDialog(); + EditTagDialog *CreateEditTagDialog(); void OpenSettingsDialog(); void OpenSettingsDialogAtPage(SettingsDialog::Page page); @@ -281,12 +277,12 @@ signals: Windows7ThumbBar *thumbbar_; Application *app_; - SystemTrayIcon * tray_icon_; - OSD* osd_; + SystemTrayIcon *tray_icon_; + OSD *osd_; Lazy edit_tag_dialog_; Lazy about_dialog_; - GlobalShortcuts* global_shortcuts_; + GlobalShortcuts *global_shortcuts_; CollectionViewContainer *collection_view_; StatusView *status_view_; diff --git a/src/core/mergedproxymodel.cpp b/src/core/mergedproxymodel.cpp index bc31005d..906117af 100644 --- a/src/core/mergedproxymodel.cpp +++ b/src/core/mergedproxymodel.cpp @@ -20,21 +20,32 @@ #include "config.h" -#include "mergedproxymodel.h" -#include "core/logging.h" - +#include #include +#include +#include #include +#include +#include +#include + +#include "mergedproxymodel.h" // boost::multi_index still relies on these being in the global namespace. using std::placeholders::_1; using std::placeholders::_2; -#include -#include +#include +#include #include +#include +#include +#include #include +#include +#include +#include using boost::multi_index::hashed_unique; using boost::multi_index::identity; @@ -44,12 +55,12 @@ using boost::multi_index::multi_index_container; using boost::multi_index::ordered_unique; using boost::multi_index::tag; -std::size_t hash_value(const QModelIndex& index) { return qHash(index); } +std::size_t hash_value(const QModelIndex &index) { return qHash(index); } namespace { struct Mapping { - explicit Mapping(const QModelIndex& _source_index) : source_index(_source_index) {} + explicit Mapping(const QModelIndex &_source_index) : source_index(_source_index) {} QModelIndex source_index; }; @@ -73,7 +84,7 @@ class MergedProxyModelPrivate { MappingContainer mappings_; }; -MergedProxyModel::MergedProxyModel(QObject* parent) +MergedProxyModel::MergedProxyModel(QObject *parent) : QAbstractProxyModel(parent), resetting_model_(nullptr), p_(new MergedProxyModelPrivate) {} @@ -81,12 +92,12 @@ MergedProxyModel::MergedProxyModel(QObject* parent) MergedProxyModel::~MergedProxyModel() { DeleteAllMappings(); } void MergedProxyModel::DeleteAllMappings() { - const auto& begin = p_->mappings_.get().begin(); - const auto& end = p_->mappings_.get().end(); + const auto &begin = p_->mappings_.get().begin(); + const auto &end = p_->mappings_.get().end(); qDeleteAll(begin, end); } -void MergedProxyModel::AddSubModel(const QModelIndex& source_parent, QAbstractItemModel* submodel) { +void MergedProxyModel::AddSubModel(const QModelIndex &source_parent, QAbstractItemModel *submodel) { connect(submodel, SIGNAL(modelReset()), this, SLOT(SubModelReset())); connect(submodel, SIGNAL(rowsAboutToBeInserted(QModelIndex, int, int)), this, SLOT(RowsAboutToBeInserted(QModelIndex, int, int))); @@ -105,13 +116,13 @@ void MergedProxyModel::AddSubModel(const QModelIndex& source_parent, QAbstractIt if (rows) endInsertRows(); } -void MergedProxyModel::RemoveSubModel(const QModelIndex& source_parent) { +void MergedProxyModel::RemoveSubModel(const QModelIndex &source_parent) { + // Find the submodel that the parent corresponded to - QAbstractItemModel* submodel = merge_points_.key(source_parent); + QAbstractItemModel *submodel = merge_points_.key(source_parent); merge_points_.remove(submodel); - // The submodel might have been deleted already so we must be careful not - // to dereference it. + // The submodel might have been deleted already so we must be careful not to dereference it. // Remove all the children of the item that got deleted QModelIndex proxy_parent = mapFromSource(source_parent); @@ -129,13 +140,15 @@ void MergedProxyModel::RemoveSubModel(const QModelIndex& source_parent) { if ((*it)->source_index.model() == submodel) { delete *it; it = p_->mappings_.get().erase(it); - } else { + } + else { ++it; } } + } -void MergedProxyModel::setSourceModel(QAbstractItemModel* source_model) { +void MergedProxyModel::setSourceModel(QAbstractItemModel *source_model) { if (sourceModel()) { disconnect(sourceModel(), SIGNAL(modelReset()), this, SLOT(SourceModelReset())); @@ -179,11 +192,10 @@ void MergedProxyModel::SourceModelReset() { void MergedProxyModel::SubModelReset() { - QAbstractItemModel* submodel = static_cast(sender()); + QAbstractItemModel *submodel = static_cast(sender()); - // TODO: When we require Qt 4.6, use beginResetModel() and endResetModel() - // in CollectionModel and catch those here - that will let us do away with this - // std::numeric_limits::max() hack. + // TODO: When we require Qt 4.6, use beginResetModel() and endResetModel() in CollectionModel and catch those here + // that will let us do away with this std::numeric_limits::max() hack. // Remove all the children of the item that got deleted QModelIndex source_parent = merge_points_.value(submodel); @@ -202,7 +214,8 @@ void MergedProxyModel::SubModelReset() { if ((*it)->source_index.model() == submodel) { delete *it; it = p_->mappings_.get().erase(it); - } else { + } + else { ++it; } } @@ -218,7 +231,7 @@ void MergedProxyModel::SubModelReset() { } -QModelIndex MergedProxyModel::GetActualSourceParent(const QModelIndex& source_parent, QAbstractItemModel* model) const { +QModelIndex MergedProxyModel::GetActualSourceParent(const QModelIndex &source_parent, QAbstractItemModel *model) const { if (!source_parent.isValid() && model != sourceModel()) return merge_points_.value(model); @@ -226,7 +239,7 @@ QModelIndex MergedProxyModel::GetActualSourceParent(const QModelIndex& source_pa } -void MergedProxyModel::RowsAboutToBeInserted(const QModelIndex& source_parent, int start, int end) { +void MergedProxyModel::RowsAboutToBeInserted(const QModelIndex &source_parent, int start, int end) { beginInsertRows(mapFromSource(GetActualSourceParent(source_parent, static_cast(sender()))), start, end); } @@ -234,7 +247,7 @@ void MergedProxyModel::RowsInserted(const QModelIndex&, int, int) { endInsertRows(); } -void MergedProxyModel::RowsAboutToBeRemoved(const QModelIndex& source_parent, int start, int end) { +void MergedProxyModel::RowsAboutToBeRemoved(const QModelIndex &source_parent, int start, int end) { beginRemoveRows(mapFromSource(GetActualSourceParent(source_parent, static_cast(sender()))), start, end); } @@ -242,13 +255,12 @@ void MergedProxyModel::RowsRemoved(const QModelIndex&, int, int) { endRemoveRows(); } -QModelIndex MergedProxyModel::mapToSource(const QModelIndex& proxy_index) const { +QModelIndex MergedProxyModel::mapToSource(const QModelIndex &proxy_index) const { if (!proxy_index.isValid()) return QModelIndex(); - Mapping* mapping = static_cast(proxy_index.internalPointer()); - if (p_->mappings_.get().find(mapping) == - p_->mappings_.get().end()) + Mapping *mapping = static_cast(proxy_index.internalPointer()); + if (p_->mappings_.get().find(mapping) == p_->mappings_.get().end()) return QModelIndex(); if (mapping->source_index.model() == resetting_model_) return QModelIndex(); @@ -256,17 +268,18 @@ QModelIndex MergedProxyModel::mapToSource(const QModelIndex& proxy_index) const } -QModelIndex MergedProxyModel::mapFromSource(const QModelIndex& source_index) const { +QModelIndex MergedProxyModel::mapFromSource(const QModelIndex &source_index) const { if (!source_index.isValid()) return QModelIndex(); if (source_index.model() == resetting_model_) return QModelIndex(); // Add a mapping if we don't have one already - const auto& it = p_->mappings_.get().find(source_index); - Mapping* mapping; + const auto &it = p_->mappings_.get().find(source_index); + Mapping *mapping; if (it != p_->mappings_.get().end()) { mapping = *it; - } else { + } + else { mapping = new Mapping(source_index); const_cast(this)->p_->mappings_.insert(mapping); } @@ -284,7 +297,7 @@ QModelIndex MergedProxyModel::index(int row, int column, const QModelIndex &pare } else { QModelIndex source_parent = mapToSource(parent); - const QAbstractItemModel* child_model = merge_points_.key(source_parent); + const QAbstractItemModel *child_model = merge_points_.key(source_parent); if (child_model) source_index = child_model->index(row, column, QModelIndex()); @@ -296,7 +309,7 @@ QModelIndex MergedProxyModel::index(int row, int column, const QModelIndex &pare } -QModelIndex MergedProxyModel::parent(const QModelIndex& child) const { +QModelIndex MergedProxyModel::parent(const QModelIndex &child) const { QModelIndex source_child = mapToSource(child); if (source_child.model() == sourceModel()) @@ -310,17 +323,16 @@ QModelIndex MergedProxyModel::parent(const QModelIndex& child) const { } -int MergedProxyModel::rowCount(const QModelIndex& parent) const { +int MergedProxyModel::rowCount(const QModelIndex &parent) const { if (!parent.isValid()) return sourceModel()->rowCount(QModelIndex()); QModelIndex source_parent = mapToSource(parent); if (!IsKnownModel(source_parent.model())) return 0; - const QAbstractItemModel* child_model = merge_points_.key(source_parent); + const QAbstractItemModel *child_model = merge_points_.key(source_parent); if (child_model) { - // Query the source model but disregard what it says, so it gets a chance - // to lazy load + // Query the source model but disregard what it says, so it gets a chance to lazy load source_parent.model()->rowCount(source_parent); return child_model->rowCount(QModelIndex()); @@ -330,34 +342,34 @@ int MergedProxyModel::rowCount(const QModelIndex& parent) const { } -int MergedProxyModel::columnCount(const QModelIndex& parent) const { +int MergedProxyModel::columnCount(const QModelIndex &parent) const { if (!parent.isValid()) return sourceModel()->columnCount(QModelIndex()); QModelIndex source_parent = mapToSource(parent); if (!IsKnownModel(source_parent.model())) return 0; - const QAbstractItemModel* child_model = merge_points_.key(source_parent); + const QAbstractItemModel *child_model = merge_points_.key(source_parent); if (child_model) return child_model->columnCount(QModelIndex()); return source_parent.model()->columnCount(source_parent); } -bool MergedProxyModel::hasChildren(const QModelIndex& parent) const { +bool MergedProxyModel::hasChildren(const QModelIndex &parent) const { if (!parent.isValid()) return sourceModel()->hasChildren(QModelIndex()); QModelIndex source_parent = mapToSource(parent); if (!IsKnownModel(source_parent.model())) return false; - const QAbstractItemModel* child_model = merge_points_.key(source_parent); + const QAbstractItemModel *child_model = merge_points_.key(source_parent); if (child_model) return child_model->hasChildren(QModelIndex()) || source_parent.model()->hasChildren(source_parent); return source_parent.model()->hasChildren(source_parent); } -QVariant MergedProxyModel::data(const QModelIndex& proxyIndex, int role) const { +QVariant MergedProxyModel::data(const QModelIndex &proxyIndex, int role) const { QModelIndex source_index = mapToSource(proxyIndex); if (!IsKnownModel(source_index.model())) return QVariant(); @@ -366,7 +378,7 @@ QVariant MergedProxyModel::data(const QModelIndex& proxyIndex, int role) const { } -QMap MergedProxyModel::itemData(const QModelIndex& proxy_index) const { +QMap MergedProxyModel::itemData(const QModelIndex &proxy_index) const { QModelIndex source_index = mapToSource(proxy_index); @@ -375,7 +387,7 @@ QMap MergedProxyModel::itemData(const QModelIndex& proxy_index) c } -Qt::ItemFlags MergedProxyModel::flags(const QModelIndex& index) const { +Qt::ItemFlags MergedProxyModel::flags(const QModelIndex &index) const { QModelIndex source_index = mapToSource(index); @@ -384,7 +396,7 @@ Qt::ItemFlags MergedProxyModel::flags(const QModelIndex& index) const { } -bool MergedProxyModel::setData(const QModelIndex& index, const QVariant& value, int role) { +bool MergedProxyModel::setData(const QModelIndex &index, const QVariant &value, int role) { QModelIndex source_index = mapToSource(index); @@ -399,7 +411,7 @@ QStringList MergedProxyModel::mimeTypes() const { QStringList ret; ret << sourceModel()->mimeTypes(); - for (const QAbstractItemModel* model : merge_points_.keys()) { + for (const QAbstractItemModel *model : merge_points_.keys()) { ret << model->mimeTypes(); } @@ -407,12 +419,12 @@ QStringList MergedProxyModel::mimeTypes() const { } -QMimeData* MergedProxyModel::mimeData(const QModelIndexList& indexes) const { +QMimeData *MergedProxyModel::mimeData(const QModelIndexList &indexes) const { if (indexes.isEmpty()) return 0; // Only ask the first index's model - const QAbstractItemModel* model = mapToSource(indexes[0]).model(); + const QAbstractItemModel *model = mapToSource(indexes[0]).model(); if (!model) { return 0; } @@ -420,7 +432,7 @@ QMimeData* MergedProxyModel::mimeData(const QModelIndexList& indexes) const { // Only ask about the indexes that are actually in that model QModelIndexList indexes_in_model; - for (const QModelIndex& proxy_index : indexes) { + for (const QModelIndex &proxy_index : indexes) { QModelIndex source_index = mapToSource(proxy_index); if (source_index.model() != model) continue; indexes_in_model << source_index; @@ -430,7 +442,7 @@ QMimeData* MergedProxyModel::mimeData(const QModelIndexList& indexes) const { } -bool MergedProxyModel::dropMimeData(const QMimeData* data, Qt::DropAction action, int row, int column, const QModelIndex& parent) { +bool MergedProxyModel::dropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent) { if (!parent.isValid()) { return false; @@ -440,7 +452,7 @@ bool MergedProxyModel::dropMimeData(const QMimeData* data, Qt::DropAction action } -QModelIndex MergedProxyModel::FindSourceParent(const QModelIndex& proxy_index) const { +QModelIndex MergedProxyModel::FindSourceParent(const QModelIndex &proxy_index) const { if (!proxy_index.isValid()) return QModelIndex(); @@ -450,7 +462,7 @@ QModelIndex MergedProxyModel::FindSourceParent(const QModelIndex& proxy_index) c } -bool MergedProxyModel::canFetchMore(const QModelIndex& parent) const { +bool MergedProxyModel::canFetchMore(const QModelIndex &parent) const { QModelIndex source_index = mapToSource(parent); @@ -460,7 +472,7 @@ bool MergedProxyModel::canFetchMore(const QModelIndex& parent) const { } -void MergedProxyModel::fetchMore(const QModelIndex& parent) { +void MergedProxyModel::fetchMore(const QModelIndex &parent) { QModelIndex source_index = mapToSource(parent); @@ -471,27 +483,26 @@ void MergedProxyModel::fetchMore(const QModelIndex& parent) { } -QAbstractItemModel* MergedProxyModel::GetModel(const QModelIndex& source_index) const { +QAbstractItemModel *MergedProxyModel::GetModel(const QModelIndex &source_index) const { - // This is essentially const_cast(source_index.model()), - // but without the const_cast - const QAbstractItemModel* const_model = source_index.model(); + // This is essentially const_cast(source_index.model()), but without the const_cast + const QAbstractItemModel *const_model = source_index.model(); if (const_model == sourceModel()) return sourceModel(); - for (QAbstractItemModel* submodel : merge_points_.keys()) { + for (QAbstractItemModel *submodel : merge_points_.keys()) { if (submodel == const_model) return submodel; } return nullptr; } -void MergedProxyModel::DataChanged(const QModelIndex& top_left, const QModelIndex& bottom_right) { +void MergedProxyModel::DataChanged(const QModelIndex &top_left, const QModelIndex &bottom_right) { emit dataChanged(mapFromSource(top_left), mapFromSource(bottom_right)); } void MergedProxyModel::LayoutAboutToBeChanged() { old_merge_points_.clear(); - for (QAbstractItemModel* key : merge_points_.keys()) { + for (QAbstractItemModel *key : merge_points_.keys()) { old_merge_points_[key] = merge_points_.value(key); } @@ -499,7 +510,7 @@ void MergedProxyModel::LayoutAboutToBeChanged() { void MergedProxyModel::LayoutChanged() { - for (QAbstractItemModel* key : merge_points_.keys()) { + for (QAbstractItemModel *key : merge_points_.keys()) { if (!old_merge_points_.contains(key)) continue; const int old_row = old_merge_points_[key].row(); @@ -514,29 +525,28 @@ void MergedProxyModel::LayoutChanged() { } -bool MergedProxyModel::IsKnownModel(const QAbstractItemModel* model) const { +bool MergedProxyModel::IsKnownModel(const QAbstractItemModel *model) const { - if (model == this || model == sourceModel() || - merge_points_.contains(const_cast(model))) + if (model == this || model == sourceModel() || merge_points_.contains(const_cast(model))) return true; return false; } -QModelIndexList MergedProxyModel::mapFromSource(const QModelIndexList& source_indexes) const { +QModelIndexList MergedProxyModel::mapFromSource(const QModelIndexList &source_indexes) const { QModelIndexList ret; - for (const QModelIndex& index : source_indexes) { + for (const QModelIndex &index : source_indexes) { ret << mapFromSource(index); } return ret; } -QModelIndexList MergedProxyModel::mapToSource(const QModelIndexList& proxy_indexes) const { +QModelIndexList MergedProxyModel::mapToSource(const QModelIndexList &proxy_indexes) const { QModelIndexList ret; - for (const QModelIndex& index : proxy_indexes) { + for (const QModelIndex &index : proxy_indexes) { ret << mapToSource(index); } return ret; diff --git a/src/core/mergedproxymodel.h b/src/core/mergedproxymodel.h index db46cbea..1f64b5d2 100644 --- a/src/core/mergedproxymodel.h +++ b/src/core/mergedproxymodel.h @@ -24,10 +24,21 @@ #include "config.h" #include +#include +#include +#include +#include +#include +#include #include +#include +#include +#include +#include +#include -std::size_t hash_value(const QModelIndex& index); +std::size_t hash_value(const QModelIndex &index); class MergedProxyModelPrivate; @@ -35,71 +46,68 @@ class MergedProxyModel : public QAbstractProxyModel { Q_OBJECT public: - explicit MergedProxyModel(QObject* parent = nullptr); + explicit MergedProxyModel(QObject *parent = nullptr); ~MergedProxyModel(); // Make another model appear as a child of the given item in the source model. - void AddSubModel(const QModelIndex& source_parent, QAbstractItemModel* submodel); - void RemoveSubModel(const QModelIndex& source_parent); + void AddSubModel(const QModelIndex &source_parent, QAbstractItemModel *submodel); + void RemoveSubModel(const QModelIndex &source_parent); - // Find the item in the source model that is the parent of the model - // containing proxy_index. If proxy_index is in the source model, then - // this just returns mapToSource(proxy_index). - QModelIndex FindSourceParent(const QModelIndex& proxy_index) const; + // Find the item in the source model that is the parent of the model containing proxy_index. + // If proxy_index is in the source model, then this just returns mapToSource(proxy_index). + QModelIndex FindSourceParent(const QModelIndex &proxy_index) const; // QAbstractItemModel - QModelIndex index(int row, int column, const QModelIndex& parent) const; - QModelIndex parent(const QModelIndex& child) const; - int rowCount(const QModelIndex& parent) const; - int columnCount(const QModelIndex& parent) const; + QModelIndex index(int row, int column, const QModelIndex &parent) const; + QModelIndex parent(const QModelIndex &child) const; + int rowCount(const QModelIndex &parent) const; + int columnCount(const QModelIndex &parent) const; QVariant data(const QModelIndex &proxyIndex, int role = Qt::DisplayRole) const; - bool hasChildren(const QModelIndex& parent) const; - QMap itemData(const QModelIndex& proxyIndex) const; - Qt::ItemFlags flags(const QModelIndex& index) const; - bool setData(const QModelIndex& index, const QVariant& value, int role); + bool hasChildren(const QModelIndex &parent) const; + QMap itemData(const QModelIndex &proxyIndex) const; + Qt::ItemFlags flags(const QModelIndex &index) const; + bool setData(const QModelIndex &index, const QVariant &value, int role); QStringList mimeTypes() const; - QMimeData* mimeData(const QModelIndexList& indexes) const; - bool dropMimeData(const QMimeData* data, Qt::DropAction action, int row, int column, const QModelIndex& parent); - bool canFetchMore(const QModelIndex& parent) const; - void fetchMore(const QModelIndex& parent); + QMimeData *mimeData(const QModelIndexList &indexes) const; + bool dropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent); + bool canFetchMore(const QModelIndex &parent) const; + void fetchMore(const QModelIndex &parent); // QAbstractProxyModel - // Note that these implementations of map{To,From}Source will not always - // give you an index in sourceModel(), you might get an index in one of the - // child models instead. - QModelIndex mapFromSource(const QModelIndex& sourceIndex) const; - QModelIndex mapToSource(const QModelIndex& proxyIndex) const; - void setSourceModel(QAbstractItemModel* sourceModel); + // Note that these implementations of map{To,From}Source will not always give you an index in sourceModel(), + // you might get an index in one of the child models instead. + QModelIndex mapFromSource(const QModelIndex &sourceIndex) const; + QModelIndex mapToSource(const QModelIndex &proxyIndex) const; + void setSourceModel(QAbstractItemModel *sourceModel); // Convenience functions that call map{To,From}Source multiple times. - QModelIndexList mapFromSource(const QModelIndexList& source_indexes) const; - QModelIndexList mapToSource(const QModelIndexList& proxy_indexes) const; + QModelIndexList mapFromSource(const QModelIndexList &source_indexes) const; + QModelIndexList mapToSource(const QModelIndexList &proxy_indexes) const; signals: - void SubModelReset(const QModelIndex& root, QAbstractItemModel* model); + void SubModelReset(const QModelIndex &root, QAbstractItemModel *model); private slots: void SourceModelReset(); void SubModelReset(); - void RowsAboutToBeInserted(const QModelIndex& source_parent, int start, int end); - void RowsInserted(const QModelIndex& source_parent, int start, int end); - void RowsAboutToBeRemoved(const QModelIndex& source_parent, int start, int end); - void RowsRemoved(const QModelIndex& source_parent, int start, int end); - void DataChanged(const QModelIndex& top_left, const QModelIndex& bottom_right); + void RowsAboutToBeInserted(const QModelIndex &source_parent, int start, int end); + void RowsInserted(const QModelIndex &source_parent, int start, int end); + void RowsAboutToBeRemoved(const QModelIndex &source_parent, int start, int end); + void RowsRemoved(const QModelIndex &source_parent, int start, int end); + void DataChanged(const QModelIndex &top_left, const QModelIndex &bottom_right); void LayoutAboutToBeChanged(); void LayoutChanged(); private: - QModelIndex GetActualSourceParent(const QModelIndex& source_parent, - QAbstractItemModel* model) const; - QAbstractItemModel* GetModel(const QModelIndex& source_index) const; + QModelIndex GetActualSourceParent(const QModelIndex &source_parent, QAbstractItemModel *model) const; + QAbstractItemModel *GetModel(const QModelIndex &source_index) const; void DeleteAllMappings(); - bool IsKnownModel(const QAbstractItemModel* model) const; + bool IsKnownModel(const QAbstractItemModel *model) const; QMap merge_points_; - QAbstractItemModel* resetting_model_; + QAbstractItemModel *resetting_model_; QMap old_merge_points_; diff --git a/src/core/metatypes.cpp b/src/core/metatypes.cpp index c1bf05d1..c6bd7341 100644 --- a/src/core/metatypes.cpp +++ b/src/core/metatypes.cpp @@ -18,48 +18,70 @@ * */ -#include "metatypes.h" #include "config.h" -#include -#include -#include - #include "metatypes.h" +#ifdef HAVE_GSTREAMER +# include +# include +#endif + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#ifdef HAVE_DBUS +# include +#endif + +#include "song.h" + +#include "engine/engine_fwd.h" #include "engine/enginebase.h" #include "engine/enginetype.h" #ifdef HAVE_GSTREAMER -# include "engine/gstengine.h" # include "engine/gstenginepipeline.h" #endif #include "collection/directory.h" -#include "playlist/playlist.h" -#include "equalizer/equalizer.h" +#include "playlist/playlistitem.h" +#include "playlist/playlistsequence.h" #include "covermanager/albumcoverfetcher.h" +#include "equalizer/equalizer.h" #ifdef HAVE_DBUS -#include -#include "core/mpris2.h" -#include "dbus/metatypes.h" -#endif - -class QNetworkReply; -#ifdef HAVE_GSTREAMER - class GstEnginePipeline; +# include "mpris2.h" +# include "dbus/metatypes.h" #endif void RegisterMetaTypes() { - //qRegisterMetaType("CollapsibleInfoPane::Data"); + qRegisterMetaType("const char*"); - qRegisterMetaType("CoverSearchResult"); - qRegisterMetaType("CoverSearchResults"); + qRegisterMetaType>("QList"); + qRegisterMetaType>("QList"); + qRegisterMetaType(); + qRegisterMetaType("QAbstractSocket::SocketState"); + qRegisterMetaType("QNetworkCookie"); + qRegisterMetaType >("QList"); + qRegisterMetaType("QNetworkReply*"); + qRegisterMetaType("QNetworkReply**"); + qRegisterMetaTypeStreamOperators >("ColumnAlignmentMap"); qRegisterMetaType("Directory"); qRegisterMetaType("DirectoryList"); + qRegisterMetaType("Subdirectory"); + qRegisterMetaType("SubdirectoryList"); + qRegisterMetaType("Song"); + qRegisterMetaType >("QList"); + qRegisterMetaType("SongList"); + qRegisterMetaType("EngineType"); qRegisterMetaType("Engine::SimpleMetaBundle"); qRegisterMetaType("Engine::State"); qRegisterMetaType("Engine::TrackChangeFlags"); - qRegisterMetaType("Equalizer::Params"); qRegisterMetaType("EngineBase::OutputDetails"); #ifdef HAVE_GSTREAMER qRegisterMetaType("GstBuffer*"); @@ -68,36 +90,22 @@ void RegisterMetaTypes() { #endif qRegisterMetaType("PlaylistItemList"); qRegisterMetaType("PlaylistItemPtr"); - qRegisterMetaType >("QList"); - qRegisterMetaType>("QList"); qRegisterMetaType >("QList"); qRegisterMetaType("PlaylistSequence::RepeatMode"); qRegisterMetaType("PlaylistSequence::ShuffleMode"); - qRegisterMetaType("QAbstractSocket::SocketState"); - qRegisterMetaType >("QList"); - qRegisterMetaType >("QList"); - qRegisterMetaType("QNetworkCookie"); - qRegisterMetaType("QNetworkReply*"); - qRegisterMetaType("QNetworkReply**"); - qRegisterMetaType("SongList"); - qRegisterMetaType("Song"); + qRegisterMetaType("CoverSearchResult"); + qRegisterMetaType >("QList"); + qRegisterMetaType("CoverSearchResults"); + qRegisterMetaType("Equalizer::Params"); qRegisterMetaTypeStreamOperators("Equalizer::Params"); - qRegisterMetaTypeStreamOperators >("ColumnAlignmentMap"); - qRegisterMetaType("SubdirectoryList"); - qRegisterMetaType("Subdirectory"); - qRegisterMetaType>("QList"); - qRegisterMetaType(); - - qRegisterMetaType("EngineType"); - #ifdef HAVE_DBUS + qDBusRegisterMetaType>(); qDBusRegisterMetaType(); qDBusRegisterMetaType(); qDBusRegisterMetaType(); - qDBusRegisterMetaType>(); qDBusRegisterMetaType(); - qDBusRegisterMetaType(); qDBusRegisterMetaType(); + qDBusRegisterMetaType(); qDBusRegisterMetaType(); qDBusRegisterMetaType(); #endif diff --git a/src/core/mimedata.h b/src/core/mimedata.h index d2e42ee6..0d22d77c 100644 --- a/src/core/mimedata.h +++ b/src/core/mimedata.h @@ -23,7 +23,9 @@ #include "config.h" +#include #include +#include class MimeData : public QMimeData { Q_OBJECT @@ -41,13 +43,11 @@ class MimeData : public QMimeData { // If this is set then MainWindow will not touch any of the other flags. bool override_user_settings_; - // If this is set then the playlist will be cleared before these songs - // are inserted. + // If this is set then the playlist will be cleared before these songs are inserted. bool clear_first_; - // If this is set then the first item that is inserted will start playing - // immediately. Note: this is always overridden with the user's preference - // if the MimeData goes via MainWindow, unless you set override_user_settings_. + // If this is set then the first item that is inserted will start playing immediately. + // Note: this is always overridden with the user's preference if the MimeData goes via MainWindow, unless you set override_user_settings_. bool play_now_; // If this is set then the items are added to the queue after being inserted. @@ -59,14 +59,12 @@ class MimeData : public QMimeData { // This serves as a name for the new playlist in 'open_in_new_playlist_' mode. QString name_for_new_playlist_; - // This can be set if this MimeData goes via MainWindow (ie. it is created - // manually in a double-click). The MainWindow will set the above flags to - // the defaults set by the user. + // This can be set if this MimeData goes via MainWindow (ie. it is created manually in a double-click). + // The MainWindow will set the above flags to the defaults set by the user. bool from_doubleclick_; - // Returns a pretty name for a playlist containing songs described by this MimeData - // object. By pretty name we mean the value of 'name_for_new_playlist_' or generic - // "Playlist" string if the 'name_for_new_playlist_' attribute is empty. + // Returns a pretty name for a playlist containing songs described by this MimeData object. + // By pretty name we mean the value of 'name_for_new_playlist_' or generic "Playlist" string if the 'name_for_new_playlist_' attribute is empty. QString get_name_for_new_playlist() { return name_for_new_playlist_.isEmpty() ? tr("Playlist") : name_for_new_playlist_; } diff --git a/src/core/mpris.cpp b/src/core/mpris.cpp index 48ec576d..2349df9a 100644 --- a/src/core/mpris.cpp +++ b/src/core/mpris.cpp @@ -18,15 +18,16 @@ * */ - #include "config.h" +#include + #include "mpris.h" #include "mpris2.h" namespace mpris { -Mpris::Mpris(Application* app, QObject* parent) : QObject(parent), mpris2_(new mpris::Mpris2(app, this)) { +Mpris::Mpris(Application *app, QObject *parent) : QObject(parent), mpris2_(new mpris::Mpris2(app, this)) { connect(mpris2_, SIGNAL(RaiseMainWindow()), SIGNAL(RaiseMainWindow())); } diff --git a/src/core/mpris.h b/src/core/mpris.h index e82f3364..e23e5c14 100644 --- a/src/core/mpris.h +++ b/src/core/mpris.h @@ -24,6 +24,7 @@ #include "config.h" #include +#include class Application; diff --git a/src/core/mpris2.cpp b/src/core/mpris2.cpp index 596cc811..f26ef69b 100644 --- a/src/core/mpris2.cpp +++ b/src/core/mpris2.cpp @@ -20,30 +20,48 @@ #include "config.h" +#include +#include #include #include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #include -#include +#include +#include +#include +#include +#include "core/logging.h" + +#include "mpris_common.h" #include "mpris2.h" -#include "core/application.h" -#include "core/mainwindow.h" -#include "core/logging.h" -#include "core/mpris_common.h" -#include "core/mpris2_player.h" -#include "core/mpris2_playlists.h" -#include "core/mpris2_root.h" -#include "core/mpris2_tracklist.h" -#include "core/player.h" -#include "core/timeconstants.h" +#include "timeconstants.h" +#include "song.h" +#include "application.h" +#include "player.h" #include "engine/enginebase.h" #include "playlist/playlist.h" +#include "playlist/playlistitem.h" #include "playlist/playlistmanager.h" #include "playlist/playlistsequence.h" #include "covermanager/currentartloader.h" +#include +#include +#include +#include + QDBusArgument &operator<<(QDBusArgument &arg, const MprisPlaylist &playlist) { arg.beginStructure(); arg << playlist.id << playlist.name << playlist.icon; @@ -75,11 +93,11 @@ const QDBusArgument &operator>> (const QDBusArgument &arg, MaybePlaylist &playli namespace mpris { -const char* Mpris2::kMprisObjectPath = "/org/mpris/MediaPlayer2"; -const char* Mpris2::kServiceName = "org.mpris.MediaPlayer2.strawberry"; -const char* Mpris2::kFreedesktopPath = "org.freedesktop.DBus.Properties"; +const char *Mpris2::kMprisObjectPath = "/org/mpris/MediaPlayer2"; +const char *Mpris2::kServiceName = "org.mpris.MediaPlayer2.strawberry"; +const char *Mpris2::kFreedesktopPath = "org.freedesktop.DBus.Properties"; -Mpris2::Mpris2(Application* app, QObject* parent) : QObject(parent), app_(app) { +Mpris2::Mpris2(Application *app, QObject *parent) : QObject(parent), app_(app) { new Mpris2Root(this); new Mpris2TrackList(this); @@ -184,8 +202,7 @@ QString Mpris2::DesktopEntryAbsolutePath() const { xdg_data_dirs.append("/usr/share/"); for (const QString &directory : xdg_data_dirs) { - QString path = QString("%1/applications/%2.desktop").arg( - directory, QApplication::applicationName().toLower()); + QString path = QString("%1/applications/%2.desktop").arg(directory, QApplication::applicationName().toLower()); if (QFile::exists(path)) return path; } return QString(); @@ -276,9 +293,11 @@ void Mpris2::SetLoopStatus(const QString &value) { if (value == "None") { mode = PlaylistSequence::Repeat_Off; - } else if (value == "Track") { + } + else if (value == "Track") { mode = PlaylistSequence::Repeat_Track; - } else if (value == "Playlist") { + } + else if (value == "Playlist") { mode = PlaylistSequence::Repeat_Playlist; } @@ -312,8 +331,7 @@ QString Mpris2::current_track_id() const { return QString("/org/strawberry/strawberrymusicplayer/Track/%1").arg(QString::number(app_->playlist_manager()->active()->current_row())); } -// We send Metadata change notification as soon as the process of -// changing song starts... +// We send Metadata change notification as soon as the process of changing song starts... void Mpris2::CurrentSongChanged(const Song &song) { ArtLoaded(song, ""); @@ -367,8 +385,7 @@ bool Mpris2::CanPlay() const { return app_->playlist_manager()->active() && app_->playlist_manager()->active()->rowCount() != 0 && !(app_->player()->GetState() == Engine::Playing); } -// This one's a bit different than MPRIS 1 - we want this to be true even when -// the song is already paused or stopped. +// This one's a bit different than MPRIS 1 - we want this to be true even when the song is already paused or stopped. bool Mpris2::CanPause() const { return (app_->player()->GetCurrentItem() && app_->player()->GetState() == Engine::Playing && !(app_->player()->GetCurrentItem()->options() & PlaylistItem::PauseDisabled)) || PlaybackStatus() == "Paused" || PlaybackStatus() == "Stopped"; } @@ -474,7 +491,7 @@ QDBusObjectPath MakePlaylistPath(int id) { MaybePlaylist Mpris2::ActivePlaylist() const { MaybePlaylist maybe_playlist; - Playlist* current_playlist = app_->playlist_manager()->current(); + Playlist *current_playlist = app_->playlist_manager()->current(); maybe_playlist.valid = current_playlist; if (!current_playlist) { return maybe_playlist; @@ -511,7 +528,7 @@ void Mpris2::ActivatePlaylist(const QDBusObjectPath &playlist_id) { MprisPlaylistList Mpris2::GetPlaylists(quint32 index, quint32 max_count, const QString &order, bool reverse_order) { MprisPlaylistList ret; - for (Playlist* p : app_->playlist_manager()->GetAllPlaylists()) { + for (Playlist *p : app_->playlist_manager()->GetAllPlaylists()) { MprisPlaylist mpris_playlist; mpris_playlist.id = MakePlaylistPath(p->id()); mpris_playlist.name = app_->playlist_manager()->GetPlaylistName(p->id()); @@ -526,7 +543,7 @@ MprisPlaylistList Mpris2::GetPlaylists(quint32 index, quint32 max_count, const Q } -void Mpris2::PlaylistChanged(Playlist* playlist) { +void Mpris2::PlaylistChanged(Playlist *playlist) { MprisPlaylist mpris_playlist; mpris_playlist.id = MakePlaylistPath(playlist->id()); @@ -535,9 +552,8 @@ void Mpris2::PlaylistChanged(Playlist* playlist) { } -void Mpris2::PlaylistCollectionChanged(Playlist* playlist) { +void Mpris2::PlaylistCollectionChanged(Playlist *playlist) { EmitNotification("PlaylistCount", "", "org.mpris.MediaPlayer2.Playlists"); } } // namespace mpris - diff --git a/src/core/mpris2.h b/src/core/mpris2.h index 607272a8..03363005 100644 --- a/src/core/mpris2.h +++ b/src/core/mpris2.h @@ -23,14 +23,28 @@ #include "config.h" -#include "playlist/playlistitem.h" +#include -#include +#include #include +#include +#include +#include +#include +#include +#include +#include +#include +#include #include +#include +#include +#include + +#include "engine/engine_fwd.h" class Application; -class MainWindow; +class Song; class Playlist; typedef QList TrackMetadata; diff --git a/src/core/mpris_common.h b/src/core/mpris_common.h index 600d67c8..75905f8c 100644 --- a/src/core/mpris_common.h +++ b/src/core/mpris_common.h @@ -23,10 +23,11 @@ #include "config.h" -#include #include -#include #include +#include +#include +#include namespace mpris { diff --git a/src/core/multisortfilterproxy.cpp b/src/core/multisortfilterproxy.cpp index 777759ac..8d14a422 100644 --- a/src/core/multisortfilterproxy.cpp +++ b/src/core/multisortfilterproxy.cpp @@ -20,12 +20,16 @@ #include "config.h" -#include "multisortfilterproxy.h" -#include "core/logging.h" - -#include +#include +#include +#include +#include +#include #include -#include +#include +#include + +#include "multisortfilterproxy.h" MultiSortFilterProxy::MultiSortFilterProxy(QObject *parent) : QSortFilterProxyModel(parent) {} @@ -62,8 +66,7 @@ static inline int DoCompare(T left, T right) { int MultiSortFilterProxy::Compare(const QVariant &left, const QVariant &right) const { - // Copied from the QSortFilterProxyModel::lessThan implementation, but returns - // -1, 0 or 1 instead of true or false. + // Copied from the QSortFilterProxyModel::lessThan implementation, but returns -1, 0 or 1 instead of true or false. switch (left.userType()) { case QVariant::Invalid: return (right.type() != QVariant::Invalid) ? -1 : 0; case QVariant::Int: return DoCompare(left.toInt(), right.toInt()); diff --git a/src/core/multisortfilterproxy.h b/src/core/multisortfilterproxy.h index 1f770aea..70f3657c 100644 --- a/src/core/multisortfilterproxy.h +++ b/src/core/multisortfilterproxy.h @@ -23,7 +23,14 @@ #include "config.h" +#include + +#include +#include #include +#include +#include +#include class MultiSortFilterProxy : public QSortFilterProxyModel { public: diff --git a/src/core/musicstorage.cpp b/src/core/musicstorage.cpp index 7ae5849b..b801efe2 100644 --- a/src/core/musicstorage.cpp +++ b/src/core/musicstorage.cpp @@ -18,11 +18,8 @@ * */ -#include "config.h" - #include "musicstorage.h" MusicStorage::MusicStorage() { } - diff --git a/src/core/musicstorage.h b/src/core/musicstorage.h index 1e5507cc..66d7da5f 100644 --- a/src/core/musicstorage.h +++ b/src/core/musicstorage.h @@ -23,12 +23,15 @@ #include "config.h" -#include "song.h" - +#include #include #include #include +#include +#include + +#include "song.h" class MusicStorage { public: diff --git a/src/core/network.cpp b/src/core/network.cpp index 326055c5..369bbbd8 100644 --- a/src/core/network.cpp +++ b/src/core/network.cpp @@ -20,17 +20,23 @@ #include "config.h" -#include "network.h" - +#include #include +#include #include -#include +#include +#include +#include +#include #include -#include +#include #include +#include +#include +#include #include "core/closure.h" -#include "core/logging.h" +#include "network.h" QMutex ThreadSafeNetworkDiskCache::sMutex; QNetworkDiskCache *ThreadSafeNetworkDiskCache::sCache = nullptr; diff --git a/src/core/network.h b/src/core/network.h index 1b8e69e8..be3a9a8f 100644 --- a/src/core/network.h +++ b/src/core/network.h @@ -23,12 +23,26 @@ #include "config.h" -#include -#include -#include -#include +#include -class QNetworkDiskCache; +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +class QTimerEvent; class ThreadSafeNetworkDiskCache : public QAbstractNetworkCache { public: diff --git a/src/core/networkproxyfactory.cpp b/src/core/networkproxyfactory.cpp index 70b45a66..9d825921 100644 --- a/src/core/networkproxyfactory.cpp +++ b/src/core/networkproxyfactory.cpp @@ -20,16 +20,20 @@ #include "config.h" -#include "networkproxyfactory.h" - #include -#include -#include +#include +#include +#include +#include #include +#include +#include #include +#include #include "core/logging.h" +#include "networkproxyfactory.h" NetworkProxyFactory *NetworkProxyFactory::sInstance = nullptr; const char *NetworkProxyFactory::kSettingsGroup = "NetworkProxy"; @@ -40,8 +44,7 @@ NetworkProxyFactory::NetworkProxyFactory() port_(8080), use_authentication_(false) { #ifdef Q_OS_LINUX - // Linux uses environment variables to pass proxy configuration information, - // which systemProxyForQuery doesn't support for some reason. + // Linux uses environment variables to pass proxy configuration information, which systemProxyForQuery doesn't support for some reason. QStringList urls; urls << QString::fromLocal8Bit(getenv("HTTP_PROXY")); diff --git a/src/core/networkproxyfactory.h b/src/core/networkproxyfactory.h index bca6328c..a4bde04d 100644 --- a/src/core/networkproxyfactory.h +++ b/src/core/networkproxyfactory.h @@ -23,9 +23,15 @@ #include "config.h" +#include + +#include #include -#include +#include +#include #include +#include +#include class NetworkProxyFactory : public QNetworkProxyFactory { public: diff --git a/src/core/organise.cpp b/src/core/organise.cpp index 3cb16408..06a34e07 100644 --- a/src/core/organise.cpp +++ b/src/core/organise.cpp @@ -18,23 +18,26 @@ * */ -#include "config.h" - -#include "organise.h" - #include -#include +#include +#include +#include #include #include -#include +#include +#include #include +#include -#include "musicstorage.h" -#include "taskmanager.h" #include "core/logging.h" -#include "core/tagreaderclient.h" -#include "core/utilities.h" +#include "utilities.h" +#include "taskmanager.h" +#include "musicstorage.h" +#include "organise.h" +#include "transcoder/transcoder.h" + +class OrganiseFormat; using std::placeholders::_1; @@ -112,8 +115,7 @@ void Organise::ProcessSomeFiles() { emit Finished(files_with_errors_); - // Move back to the original thread so deleteLater() can get called in - // the main thread's event loop + // Move back to the original thread so deleteLater() can get called in the main thread's event loop moveToThread(original_thread_); deleteLater(); @@ -165,9 +167,8 @@ void Organise::ProcessSomeFiles() { qLog(Debug) << "Transcoding to" << task.transcoded_filename_; - // Start the transcoding - this will happen in the background and - // FileTranscoded() will get called when it's done. At that point the - // task will get re-added to the pending queue with the new filename. + // Start the transcoding - this will happen in the background and FileTranscoded() will get called when it's done. + // At that point the task will get re-added to the pending queue with the new filename. transcoder_->AddJob(task.song_info_.song_.url().toLocalFile(), preset, task.transcoded_filename_); transcoder_->Start(); continue; @@ -223,9 +224,7 @@ Song::FileType Organise::CheckTranscode(Song::FileType original_type) const { if (format != Song::Type_Unknown) return format; - // The user hasn't visited the device properties page yet to set a - // preferred format for the device, so we have to pick the best - // available one. + // The user hasn't visited the device properties page yet to set a preferred format for the device, so we have to pick the best available one. return Transcoder::PickBestFormat(supported_filetypes_); } return Song::Type_Unknown; @@ -251,9 +250,8 @@ void Organise::UpdateProgress() { tasks_transcoding_[filename].transcode_progress_ = transcode_progress[filename]; } - // Count the progress of all tasks that are in the queue. Files that need - // transcoding total 50 for the transcode and 50 for the copy, files that - // only need to be copied total 100. + // Count the progress of all tasks that are in the queue. + // Files that need transcoding total 50 for the transcode and 50 for the copy, files that only need to be copied total 100. int progress = tasks_complete_ * 100; for (const Task &task : tasks_pending_) { diff --git a/src/core/organise.h b/src/core/organise.h index 1429d822..59872845 100644 --- a/src/core/organise.h +++ b/src/core/organise.h @@ -24,16 +24,27 @@ #include "config.h" #include +#include -#include #include +#include #include +#include +#include +#include +#include +#include +#include +#include +#include "core/song.h" #include "organiseformat.h" -#include "transcoder/transcoder.h" + +class QTimerEvent; class MusicStorage; class TaskManager; +class Transcoder; class Organise : public QObject { Q_OBJECT diff --git a/src/core/organiseformat.cpp b/src/core/organiseformat.cpp index 3a58cda2..e8321f8f 100644 --- a/src/core/organiseformat.cpp +++ b/src/core/organiseformat.cpp @@ -20,17 +20,30 @@ #include "config.h" -#include "organiseformat.h" - +#include #include #include -#include +#include +#include +#include +#include +#include +#include #include +#include +#include +#include +#include +#include #include "core/arraysize.h" -#include "core/timeconstants.h" -#include "core/utilities.h" -#include "core/logging.h" + +#include "timeconstants.h" +#include "utilities.h" +#include "song.h" +#include "organiseformat.h" + +class QTextDocument; const char *OrganiseFormat::kTagPattern = "\\%([a-zA-Z]*)"; const char *OrganiseFormat::kBlockPattern = "\\{([^{}]+)\\}"; @@ -95,11 +108,8 @@ QString OrganiseFormat::GetFilenameForSong(const Song &song) const { QString filename = ParseBlock(format_, song); if (QFileInfo(filename).completeBaseName().isEmpty()) { - // Avoid having empty filenames, or filenames with extension only: in this - // case, keep the original filename. - // We remove the extension from "filename" if it exists, as - // song.basefilename() - // also contains the extension. + // Avoid having empty filenames, or filenames with extension only: in this case, keep the original filename. + // We remove the extension from "filename" if it exists, as song.basefilename() also contains the extension. filename = Utilities::PathWithoutFilenameExtension(filename) + song.basefilename(); } @@ -112,7 +122,8 @@ QString OrganiseFormat::GetFilenameForSong(const Song &song) const { const QCharRef c = filename[i]; if (c < 128) { stripped.append(c); - } else { + } + else { const QString decomposition = c.decomposition(); if (!decomposition.isEmpty() && decomposition[0] < 128) stripped.append(decomposition[0]); diff --git a/src/core/organiseformat.h b/src/core/organiseformat.h index 7a1c95a2..9d736bfa 100644 --- a/src/core/organiseformat.h +++ b/src/core/organiseformat.h @@ -23,19 +23,26 @@ #include "config.h" +#include + +#include +#include +#include +#include +#include +#include #include #include -#include -#include "core/song.h" +class Song; class OrganiseFormat { public: explicit OrganiseFormat(const QString &format = QString()); - static const char* kTagPattern; - static const char* kBlockPattern; + static const char *kTagPattern; + static const char *kBlockPattern; static const QStringList kKnownTags; static const char kInvalidFatCharacters[]; static const int kInvalidFatCharactersCount; @@ -57,7 +64,7 @@ class OrganiseFormat { class Validator : public QValidator { public: - explicit Validator(QObject* parent = nullptr); + explicit Validator(QObject *parent = nullptr); QValidator::State validate(QString &format, int &pos) const; }; @@ -70,14 +77,14 @@ class OrganiseFormat { static const QRgb kInvalidTagColorDark; static const QRgb kBlockColorDark; - explicit SyntaxHighlighter(QObject* parent = nullptr); - explicit SyntaxHighlighter(QTextEdit* parent); - explicit SyntaxHighlighter(QTextDocument* parent); + explicit SyntaxHighlighter(QObject *parent = nullptr); + explicit SyntaxHighlighter(QTextEdit *parent); + explicit SyntaxHighlighter(QTextDocument *parent); void highlightBlock(const QString &format); }; private: - QString ParseBlock(QString block, const Song &song, bool* any_empty = nullptr) const; + QString ParseBlock(QString block, const Song &song, bool *any_empty = nullptr) const; QString TagValue(const QString &tag, const Song &song) const; QString format_; diff --git a/src/core/player.cpp b/src/core/player.cpp index 5472d01c..58fbaf5f 100644 --- a/src/core/player.cpp +++ b/src/core/player.cpp @@ -18,23 +18,33 @@ * */ -#include "player.h" - #include "config.h" +#include "player.h" + #include +#include +#include #include +#include +#include +#include +#include +#include +#include +#include #include -#include -#include "core/application.h" #include "core/logging.h" -#include "core/urlhandler.h" -#include "core/timeconstants.h" -#include "engine/enginetype.h" + +#include "song.h" +#include "timeconstants.h" +#include "urlhandler.h" +#include "application.h" + #include "engine/enginebase.h" -#include "engine/enginedevice.h" +#include "engine/enginetype.h" #ifdef HAVE_GSTREAMER # include "engine/gstengine.h" @@ -53,10 +63,9 @@ #include "playlist/playlist.h" #include "playlist/playlistitem.h" #include "playlist/playlistmanager.h" - -#include "analyzer/analyzercontainer.h" +#include "playlist/playlistsequence.h" #include "equalizer/equalizer.h" - +#include "analyzer/analyzercontainer.h" #include "settings/backendsettingspage.h" #include "settings/behavioursettingspage.h" #include "settings/playlistsettingspage.h" @@ -76,8 +85,6 @@ Player::Player(Application *app, QObject *parent) menu_previousmode_(PreviousBehaviour_DontRestart), seek_step_sec_(10) { - - //qLog(Debug) << __PRETTY_FUNCTION__; QSettings s; s.beginGroup(BackendSettingsPage::kSettingsGroup); @@ -101,8 +108,6 @@ Player::Player(Application *app, QObject *parent) Player::~Player() {} EngineBase *Player::CreateEngine(Engine::EngineType enginetype) { - - //qLog(Debug) << __PRETTY_FUNCTION__; bool engine = false; EngineBase *enginebase = nullptr; @@ -170,8 +175,6 @@ EngineBase *Player::CreateEngine(Engine::EngineType enginetype) { void Player::Init() { - //qLog(Debug) << __PRETTY_FUNCTION__; - connect(engine_.get(), SIGNAL(Error(QString)), SIGNAL(Error(QString))); connect(engine_.get(), SIGNAL(ValidSongRequested(QUrl)), SLOT(ValidSongRequested(QUrl))); connect(engine_.get(), SIGNAL(InvalidSongRequested(QUrl)), SLOT(InvalidSongRequested(QUrl))); @@ -213,8 +216,6 @@ void Player::SetEqualizer(Equalizer *equalizer) { void Player::ReloadSettings() { - //qLog(Debug) << __PRETTY_FUNCTION__; - QSettings s; s.beginGroup(PlaylistSettingsPage::kSettingsGroup); @@ -230,8 +231,6 @@ void Player::ReloadSettings() { } void Player::HandleLoadResult(const UrlHandler::LoadResult &result) { - - //qLog(Debug) << __PRETTY_FUNCTION__; // Might've been an async load, so check we're still on the same item shared_ptr item = app_->playlist_manager()->active()->current_item(); @@ -254,8 +253,7 @@ void Player::HandleLoadResult(const UrlHandler::LoadResult &result) { qLog(Debug) << "URL handler for" << result.original_url_ << "returned" << result.media_url_; - // If there was no length info in song's metadata, use the one provided by - // URL handler, if there is one + // If there was no length info in song's metadata, use the one provided by URL handler, if there is one if (item->Metadata().length_nanosec() <= 0 && result.length_nanosec_ != -1) { Song song = item->Metadata(); song.set_length_nanosec(result.length_nanosec_); @@ -281,8 +279,6 @@ void Player::HandleLoadResult(const UrlHandler::LoadResult &result) { void Player::Next() { NextInternal(Engine::Manual); } void Player::NextInternal(Engine::TrackChangeFlags change) { - - //qLog(Debug) << __PRETTY_FUNCTION__; if (HandleStopAfter()) return; @@ -303,8 +299,6 @@ void Player::NextInternal(Engine::TrackChangeFlags change) { } void Player::NextItem(Engine::TrackChangeFlags change) { - - //qLog(Debug) << __PRETTY_FUNCTION__; Playlist *active_playlist = app_->playlist_manager()->active(); @@ -313,8 +307,7 @@ void Player::NextItem(Engine::TrackChangeFlags change) { const PlaylistSequence::RepeatMode repeat_mode = active_playlist->sequence()->repeat_mode(); if (repeat_mode != PlaylistSequence::Repeat_Off) { if ((repeat_mode == PlaylistSequence::Repeat_Track && nb_errors_received_ >= 3) || (nb_errors_received_ >= app_->playlist_manager()->active()->proxy()->rowCount())) { - // We received too many "Error" state changes: probably looping over a - // playlist which contains only unavailable elements: stop now. + // We received too many "Error" state changes: probably looping over a playlist which contains only unavailable elements: stop now. nb_errors_received_ = 0; Stop(); return; @@ -338,12 +331,9 @@ void Player::NextItem(Engine::TrackChangeFlags change) { } bool Player::HandleStopAfter() { - - //qLog(Debug) << __PRETTY_FUNCTION__; if (app_->playlist_manager()->active()->stop_after_current()) { - // Find what the next track would've been, and mark that one as current - // so it plays next time the user presses Play. + // Find what the next track would've been, and mark that one as current so it plays next time the user presses Play. const int next_row = app_->playlist_manager()->active()->next_row(); if (next_row != -1) { app_->playlist_manager()->active()->set_current_row(next_row, true); @@ -358,8 +348,6 @@ bool Player::HandleStopAfter() { } void Player::TrackEnded() { - - //qLog(Debug) << __PRETTY_FUNCTION__; if (HandleStopAfter()) return; @@ -372,8 +360,6 @@ void Player::TrackEnded() { void Player::PlayPause() { - //qLog(Debug) << __PRETTY_FUNCTION__; - switch (engine_->state()) { case Engine::Paused: engine_->Unpause(); @@ -504,7 +490,7 @@ void Player::PlayAt(int index, Engine::TrackChangeFlags change, bool reshuffle) if (change == Engine::Manual && engine_->position_nanosec() != engine_->length_nanosec()) { emit TrackSkipped(current_item_); - const QUrl& url = current_item_->Url(); + const QUrl &url = current_item_->Url(); if (url_handlers_.contains(url.scheme())) { url_handlers_[url.scheme()]->TrackSkipped(); } @@ -541,8 +527,7 @@ void Player::PlayAt(int index, Engine::TrackChangeFlags change, bool reshuffle) } void Player::CurrentMetadataChanged(const Song &metadata) { - // those things might have changed (especially when a previously invalid - // song was reloaded) so we push the latest version into Engine + // those things might have changed (especially when a previously invalid song was reloaded) so we push the latest version into Engine engine_->RefreshMarkers(metadata.beginning_nanosec(), metadata.end_nanosec()); } @@ -551,8 +536,7 @@ void Player::SeekTo(int seconds) { const qint64 length_nanosec = engine_->length_nanosec(); - // If the length is 0 then either there is no song playing, or the song isn't - // seekable. + // If the length is 0 then either there is no song playing, or the song isn't seekable. if (length_nanosec <= 0) { return; } @@ -581,8 +565,7 @@ void Player::EngineMetadataReceived(const Engine::SimpleMetaBundle &bundle) { Engine::SimpleMetaBundle bundle_copy = bundle; - // Maybe the metadata is from icycast and has "Artist - Title" shoved - // together in the title field. + // Maybe the metadata is from icycast and has "Artist - Title" shoved together in the title field. const int dash_pos = bundle_copy.title.indexOf('-'); if (dash_pos != -1 && bundle_copy.artist.isEmpty()) { // Split on " - " if it exists, otherwise split on "-". @@ -654,10 +637,8 @@ void Player::TogglePrettyOSD() { void Player::TrackAboutToEnd() { - // If the current track was from a URL handler then it might have special - // behaviour to queue up a subsequent track. We don't want to preload (and - // scrobble) the next item in the playlist if it's just going to be stopped - // again immediately after. + // If the current track was from a URL handler then it might have special behaviour to queue up a subsequent track. + // We don't want to preload (and scrobble) the next item in the playlist if it's just going to be stopped again immediately after. if (app_->playlist_manager()->active()->current_item()) { const QUrl url = app_->playlist_manager()->active()->current_item()->Url(); if (url_handlers_.contains(url.scheme())) { @@ -674,24 +655,20 @@ void Player::TrackAboutToEnd() { } if (engine_->is_autocrossfade_enabled()) { - // Crossfade is on, so just start playing the next track. The current one - // will fade out, and the new one will fade in + // Crossfade is on, so just start playing the next track. The current one will fade out, and the new one will fade in - // But, if there's no next track and we don't want to fade out, then do - // nothing and just let the track finish to completion. + // But, if there's no next track and we don't want to fade out, then do nothing and just let the track finish to completion. if (!engine_->is_fadeout_enabled() && !has_next_row) return; - // If the next track is on the same album (or same cue file), and the - // user doesn't want to crossfade between tracks on the same album, then - // don't do this automatic crossfading. + // If the next track is on the same album (or same cue file), + // and the user doesn't want to crossfade between tracks on the same album, then don't do this automatic crossfading. if (engine_->crossfade_same_album() || !has_next_row || !next_item || !current_item_->Metadata().IsOnSameAlbum(next_item->Metadata())) { TrackEnded(); return; } } - // Crossfade is off, so start preloading the next track so we don't get a - // gap between songs. + // Crossfade is off, so start preloading the next track so we don't get a gap between songs. if (!has_next_row || !next_item) return; QUrl url = next_item->Url(); @@ -726,8 +703,8 @@ void Player::InvalidSongRequested(const QUrl &url) { // first send the notification to others... emit SongChangeRequestProcessed(url, false); - // ... and now when our listeners have completed their processing of the - // current item we can change the current item by skipping to the next song + // ... and now when our listeners have completed their processing of the current item we can change + // the current item by skipping to the next song //NextItem(Engine::Auto); } diff --git a/src/core/player.h b/src/core/player.h index 2f3cb127..2b937a2d 100644 --- a/src/core/player.h +++ b/src/core/player.h @@ -24,26 +24,30 @@ #include "config.h" #include +#include -#include +#include #include +#include +#include +#include +#include #include -#include "config.h" -#include "core/song.h" -#include "core/urlhandler.h" -#include "covermanager/albumcoverloader.h" +#include "urlhandler.h" #include "engine/engine_fwd.h" #include "engine/enginetype.h" -#include "engine/enginedevice.h" #include "playlist/playlistitem.h" -#include "analyzer/analyzercontainer.h" -#include "equalizer/equalizer.h" class Application; +class Song; class AnalyzerContainer; class Equalizer; +namespace Engine { +struct SimpleMetaBundle; +} // namespace Engine + class PlayerInterface : public QObject { Q_OBJECT @@ -66,8 +70,7 @@ class PlayerInterface : public QObject { // Manual track change to the specified track virtual void PlayAt(int i, Engine::TrackChangeFlags change, bool reshuffle) = 0; - // If there's currently a song playing, pause it, otherwise play the track - // that was playing last, or the first one on the playlist + // If there's currently a song playing, pause it, otherwise play the track that was playing last, or the first one on the playlist virtual void PlayPause() = 0; virtual void RestartOrPrevious() = 0; @@ -103,8 +106,8 @@ signals: // Emitted when there's a manual change to the current's track position. void Seeked(qlonglong microseconds); - // Emitted when Player has processed a request to play another song. This contains - // the URL of the song and a flag saying whether it was able to play the song. + // Emitted when Player has processed a request to play another song. + // This contains the URL of the song and a flag saying whether it was able to play the song. void SongChangeRequestProcessed(const QUrl &url, bool valid); // The toggle parameter is true when user requests to toggle visibility for Pretty OSD diff --git a/src/core/qhash_qurl.h b/src/core/qhash_qurl.h deleted file mode 100644 index cfab3e46..00000000 --- a/src/core/qhash_qurl.h +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Strawberry Music Player - * This file was part of Clementine. - * Copyright 2012, David Sansome - * - * Strawberry is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Strawberry is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Strawberry. If not, see . - * - */ - -#ifndef QHASH_QURL_H -#define QHASH_QURL_H - -#include - -#if QT_VERSION < 0x040700 -inline uint qHash(const QUrl& url) { return qHash(url.toEncoded()); } -#endif - -#endif // QHASH_QURL_H - diff --git a/src/core/qtfslistener.cpp b/src/core/qtfslistener.cpp index 3893a02a..5fe94c61 100644 --- a/src/core/qtfslistener.cpp +++ b/src/core/qtfslistener.cpp @@ -20,9 +20,10 @@ #include "config.h" -#include "qtfslistener.h" +#include -#include +#include "filesystemwatcherinterface.h" +#include "qtfslistener.h" QtFSListener::QtFSListener(QObject *parent) : FileSystemWatcherInterface(parent), watcher_(this) { @@ -40,4 +41,3 @@ void QtFSListener::Clear() { watcher_.removePaths(watcher_.directories()); watcher_.removePaths(watcher_.files()); } - diff --git a/src/core/qtfslistener.h b/src/core/qtfslistener.h index e262738b..7ea4b8df 100644 --- a/src/core/qtfslistener.h +++ b/src/core/qtfslistener.h @@ -23,9 +23,11 @@ #include "config.h" -#include "filesystemwatcherinterface.h" - +#include #include +#include + +#include "filesystemwatcherinterface.h" class QtFSListener : public FileSystemWatcherInterface { Q_OBJECT diff --git a/src/core/qtsystemtrayicon.cpp b/src/core/qtsystemtrayicon.cpp index 530e9c19..4bc8d4ac 100644 --- a/src/core/qtsystemtrayicon.cpp +++ b/src/core/qtsystemtrayicon.cpp @@ -20,19 +20,22 @@ #include "config.h" -#include "iconloader.h" -#include "qtsystemtrayicon.h" - -#include "core/song.h" -#include "core/logging.h" - +#include #include -#include -#include -#include -#include #include -#include +#include +#include +#include +#include +#include +#include +#include + +#include "song.h" +#include "iconloader.h" + +#include "systemtrayicon.h" +#include "qtsystemtrayicon.h" QtSystemTrayIcon::QtSystemTrayIcon(QObject *parent) : SystemTrayIcon(parent), @@ -44,8 +47,6 @@ QtSystemTrayIcon::QtSystemTrayIcon(QObject *parent) action_mute_(nullptr) { - //qLog(Debug) << __PRETTY_FUNCTION__; - QIcon theme_icon = IconLoader::Load("strawberry-panel"); QIcon theme_icon_grey = IconLoader::Load("strawberry-panel-grey"); @@ -79,8 +80,6 @@ QtSystemTrayIcon::~QtSystemTrayIcon() { bool QtSystemTrayIcon::eventFilter(QObject *object, QEvent *event) { - //qLog(Debug) << __PRETTY_FUNCTION__; - if (QObject::eventFilter(object, event)) return true; if (object != tray_) return false; @@ -90,7 +89,8 @@ bool QtSystemTrayIcon::eventFilter(QObject *object, QEvent *event) { if (e->modifiers() == Qt::ShiftModifier) { if (e->delta() > 0) { emit SeekForward(); - } else { + } + else { emit SeekBackward(); } } @@ -113,12 +113,9 @@ bool QtSystemTrayIcon::eventFilter(QObject *object, QEvent *event) { } void QtSystemTrayIcon::SetupMenu(QAction *previous, QAction *play, QAction *stop, QAction *stop_after, QAction *next, QAction *mute, QAction *quit) { - - //qLog(Debug) << __PRETTY_FUNCTION__; - // Creating new actions and connecting them to old ones. This allows us to - // use old actions without displaying shortcuts that can not be used when - // Strawberry's window is hidden + // Creating new actions and connecting them to old ones. + // This allows us to use old actions without displaying shortcuts that can not be used when Strawberry's window is hidden menu_->addAction(previous->icon(), previous->text(), previous, SLOT(trigger())); action_play_pause_ = menu_->addAction(play->icon(), play->text(), play, SLOT(trigger())); action_stop_ = menu_->addAction(stop->icon(), stop->text(), stop, SLOT(trigger())); @@ -140,8 +137,6 @@ void QtSystemTrayIcon::SetupMenu(QAction *previous, QAction *play, QAction *stop void QtSystemTrayIcon::Clicked(QSystemTrayIcon::ActivationReason reason) { - //qLog(Debug) << __PRETTY_FUNCTION__; - switch (reason) { case QSystemTrayIcon::DoubleClick: case QSystemTrayIcon::Trigger: diff --git a/src/core/qtsystemtrayicon.h b/src/core/qtsystemtrayicon.h index 218d9daa..ecf7c842 100644 --- a/src/core/qtsystemtrayicon.h +++ b/src/core/qtsystemtrayicon.h @@ -23,24 +23,36 @@ #include "config.h" +#include + +#include +#include +#include +#include +#include +#include +#include + #include "systemtrayicon.h" -#include +class QEvent; + +class Song; class QtSystemTrayIcon : public SystemTrayIcon { Q_OBJECT public: - QtSystemTrayIcon(QObject* parent = nullptr); + QtSystemTrayIcon(QObject *parent = nullptr); ~QtSystemTrayIcon(); - void SetupMenu(QAction* previous, QAction *play, QAction *stop, QAction *stop_after, QAction *next, QAction *mute, QAction *quit); + void SetupMenu(QAction *previous, QAction *play, QAction *stop, QAction *stop_after, QAction *next, QAction *mute, QAction *quit); bool IsVisible() const; void SetVisible(bool visible); void ShowPopup(const QString &summary, const QString &message, int timeout); - void SetNowPlaying(const Song& song, const QString& image_path); + void SetNowPlaying(const Song &song, const QString &image_path); void ClearNowPlaying(); protected: diff --git a/src/core/scangiomodulepath.cpp b/src/core/scangiomodulepath.cpp index 635ca64d..d5eb2163 100644 --- a/src/core/scangiomodulepath.cpp +++ b/src/core/scangiomodulepath.cpp @@ -18,23 +18,24 @@ * */ -//#ifdef HAVE_GIO -//#undef signals // Clashes with GIO, and not needed in this file +#include "config.h" + #include #include #include +#include +#include #include +#include #include "core/logging.h" -//namespace { - void ScanGIOModulePath() { QString gio_module_path; #if defined(Q_OS_WIN32) - gio_module_path = QCoreApplication::applicationDirPath() + "/gio-modules"; + gio_module_path = QDir::toNativeSeparators(QCoreApplication::applicationDirPath() + "/gio-modules"); #endif if (!gio_module_path.isEmpty()) { @@ -43,6 +44,3 @@ void ScanGIOModulePath() { g_io_modules_scan_all_in_directory(bytes.data()); } } - -//} // namespace -//#endif // HAVE_GIO diff --git a/src/core/scopedtransaction.cpp b/src/core/scopedtransaction.cpp index 8e892b8c..c27d1dc2 100644 --- a/src/core/scopedtransaction.cpp +++ b/src/core/scopedtransaction.cpp @@ -20,11 +20,11 @@ #include "config.h" -#include "scopedtransaction.h" -#include "core/logging.h" - +#include #include -#include + +#include "core/logging.h" +#include "scopedtransaction.h" ScopedTransaction::ScopedTransaction(QSqlDatabase* db) : db_(db), pending_(true) { diff --git a/src/core/scopedtransaction.h b/src/core/scopedtransaction.h index 6d0f1033..c3cb3b94 100644 --- a/src/core/scopedtransaction.h +++ b/src/core/scopedtransaction.h @@ -23,22 +23,22 @@ #include "config.h" +#include #include -class QSqlDatabase; +#include // Opens a transaction on a database. -// Rolls back the transaction if the object goes out of scope before Commit() -// is called. +// Rolls back the transaction if the object goes out of scope before Commit() is called. class ScopedTransaction : boost::noncopyable { public: - ScopedTransaction(QSqlDatabase* db); + ScopedTransaction(QSqlDatabase *db); ~ScopedTransaction(); void Commit(); private: - QSqlDatabase* db_; + QSqlDatabase *db_; bool pending_; }; diff --git a/src/core/screensaver.cpp b/src/core/screensaver.cpp index 7075d715..b0fe9b01 100644 --- a/src/core/screensaver.cpp +++ b/src/core/screensaver.cpp @@ -20,22 +20,19 @@ #include "config.h" -#include +#ifdef HAVE_DBUS +# include +# include +# include +# include "dbusscreensaver.h" +#endif #include "screensaver.h" -#ifdef HAVE_DBUS - #include "dbusscreensaver.h" - #include - #include -#endif - #ifdef Q_OS_DARWIN #include "macscreensaver.h" #endif -#include - const char *Screensaver::kGnomeService = "org.gnome.ScreenSaver"; const char *Screensaver::kGnomePath = "/"; const char *Screensaver::kGnomeInterface = "org.gnome.ScreenSaver"; diff --git a/src/core/settingsprovider.h b/src/core/settingsprovider.h index 2ef1779b..c6cc9613 100644 --- a/src/core/settingsprovider.h +++ b/src/core/settingsprovider.h @@ -24,6 +24,7 @@ #include "config.h" #include +#include #include class SettingsProvider { @@ -59,4 +60,3 @@ class DefaultSettingsProvider : public SettingsProvider { }; #endif // SETTINGSPROVIDER_H - diff --git a/src/core/signalchecker.cpp b/src/core/signalchecker.cpp index 285fcf7e..8c21995d 100644 --- a/src/core/signalchecker.cpp +++ b/src/core/signalchecker.cpp @@ -22,9 +22,12 @@ #include "config.h" -#include "signalchecker.h" +#include +#include -#include "core/logging.h" +#include + +#include "signalchecker.h" gulong CheckedGConnect(gpointer source, const char *signal, GCallback callback, gpointer data, const int callback_param_count) { @@ -38,8 +41,7 @@ gulong CheckedGConnect(gpointer source, const char *signal, GCallback callback, GSignalQuery query; g_signal_query(signal_id, &query); - // The signature for a signal callback is always: - // return_type callback(gpointer data1, params..., gpointer data2); + // The signature for a signal callback is always: return_type callback(gpointer data1, params..., gpointer data2); int signal_params = query.n_params + 2; if (signal_params != callback_param_count) { qFatal("Connecting callback to signal with different parameters counts"); diff --git a/src/core/signalchecker.h b/src/core/signalchecker.h index facc1aec..3f375df8 100644 --- a/src/core/signalchecker.h +++ b/src/core/signalchecker.h @@ -23,6 +23,7 @@ #include "config.h" +#include #include #include diff --git a/src/core/simpletreeitem.h b/src/core/simpletreeitem.h index 71f3e65a..38ae4e1e 100644 --- a/src/core/simpletreeitem.h +++ b/src/core/simpletreeitem.h @@ -23,10 +23,11 @@ #include "config.h" -#include "simpletreemodel.h" - -#include #include +#include +#include + +#include "simpletreemodel.h" template class SimpleTreeItem { diff --git a/src/core/simpletreemodel.h b/src/core/simpletreemodel.h index 8830708f..497503f2 100644 --- a/src/core/simpletreemodel.h +++ b/src/core/simpletreemodel.h @@ -23,9 +23,9 @@ #include "config.h" +#include #include - -class QModelIndex; +#include template class SimpleTreeModel : public QAbstractItemModel { diff --git a/src/core/song.cpp b/src/core/song.cpp index c9013ee4..0102748b 100644 --- a/src/core/song.cpp +++ b/src/core/song.cpp @@ -20,24 +20,28 @@ #include "config.h" -#include "song.h" - -#include +#include +#include "tstring.h" +#include +#include #include -#include +#include #include #include -#include #include -#include -#include -#include +#include +#include +#include #include -#include #include - -#include +#include +#include +#include +#include +#include +#include +#include #ifdef HAVE_LIBGPOD #include @@ -47,17 +51,18 @@ #include #endif -#include "core/application.h" #include "core/logging.h" #include "core/messagehandler.h" -#include "core/mpris_common.h" -#include "core/timeconstants.h" -#include "core/utilities.h" + #include "engine/enginebase.h" +#include "timeconstants.h" +#include "utilities.h" +#include "song.h" +#include "application.h" +#include "mpris_common.h" #include "collection/sqlrow.h" -#include "tagreadermessages.pb.h" -#include "widgets/trackslider.h" #include "covermanager/albumcoverloader.h" +#include "tagreadermessages.pb.h" const QStringList Song::kColumns = QStringList() << "title" << "album" @@ -129,6 +134,8 @@ const QString Song::kFtsUpdateSpec = Utilities::Updateify(Song::kFtsColumns).joi const QString Song::kManuallyUnsetCover = "(unset)"; const QString Song::kEmbeddedCover = "(embedded)"; +const QRegExp Song::kCoverRemoveDisc(" ?-? ((\\(|\\[)?)(Disc|CD) ?([0-9]{1,2})((\\)|\\])?)$"); + struct Song::Private : public QSharedData { Private(); @@ -438,8 +445,6 @@ QString Song::Decode(const QString &tag, const QTextCodec *codec) { void Song::InitFromProtobuf(const pb::tagreader::SongMetadata &pb) { - //qLog(Debug) << __PRETTY_FUNCTION__; - d->init_from_file_ = true; d->valid_ = pb.valid(); d->title_ = QStringFromStdString(pb.title()); @@ -484,8 +489,6 @@ void Song::InitFromProtobuf(const pb::tagreader::SongMetadata &pb) { void Song::ToProtobuf(pb::tagreader::SongMetadata *pb) const { - //qLog(Debug) << __PRETTY_FUNCTION__; - const QByteArray url(d->url_.toEncoded()); pb->set_valid(d->valid_); @@ -684,9 +687,8 @@ void Song::InitFromFilePartial(const QString &filename) { set_url(QUrl::fromLocalFile(filename)); // We currently rely on filename suffix to know if it's a music file or not. - // TODO: I know this is not satisfying, but currently, we rely on TagLib - // which seems to have the behavior (filename checks). Someday, it would be - // nice to perform some magic tests everywhere. + // TODO: I know this is not satisfying, but currently, we rely on TagLib which seems to have the behavior (filename checks). + // Someday, it would be nice to perform some magic tests everywhere. QFileInfo info(filename); d->basefilename_ = info.fileName(); QString suffix = info.suffix().toLower(); @@ -704,9 +706,14 @@ void Song::InitFromFilePartial(const QString &filename) { void Song::InitArtManual() { + QString album2 = d->album_; + album2.remove(Song::kCoverRemoveDisc); + + //qLog(Debug) << __PRETTY_FUNCTION__ << d->artist_ << d->album_ << album2; + // If we don't have an art, check if we have one in the cache if (d->art_manual_.isEmpty() && d->art_automatic_.isEmpty()) { - QString filename(Utilities::Sha1CoverHash(d->artist_, d->album_).toHex() + ".jpg"); + QString filename(Utilities::Sha1CoverHash(d->artist_, album2).toHex() + ".jpg"); QString path(AlbumCoverLoader::ImageCacheDir() + "/" + filename); if (QFile::exists(path)) { d->art_manual_ = path; @@ -718,8 +725,6 @@ void Song::InitArtManual() { #ifdef HAVE_LIBGPOD void Song::InitFromItdb(const Itdb_Track *track, const QString &prefix) { - //qLog(Debug) << __PRETTY_FUNCTION__; - d->valid_ = true; d->title_ = QString::fromUtf8(track->title); @@ -799,8 +804,6 @@ void Song::ToItdb(Itdb_Track *track) const { #ifdef HAVE_LIBMTP void Song::InitFromMTP(const LIBMTP_track_t *track, const QString &host) { - //qLog(Debug) << __PRETTY_FUNCTION__; - d->valid_ = true; d->title_ = QString::fromUtf8(track->title); @@ -841,8 +844,6 @@ void Song::InitFromMTP(const LIBMTP_track_t *track, const QString &host) { void Song::ToMTP(LIBMTP_track_t *track) const { - //qLog(Debug) << __PRETTY_FUNCTION__; - track->item_id = 0; track->parent_id = 0; track->storage_id = 0; @@ -886,12 +887,9 @@ void Song::ToMTP(LIBMTP_track_t *track) const { void Song::MergeFromSimpleMetaBundle(const Engine::SimpleMetaBundle &bundle) { - //qLog(Debug) << __PRETTY_FUNCTION__; - if (d->init_from_file_ || d->url_.scheme() == "file") { - // This Song was already loaded using taglib. Our tags are probably better - // than the engine's. Note: init_from_file_ is used for non-file:// URLs - // when the metadata is known to be good, like from Jamendo. + // This Song was already loaded using taglib. Our tags are probably better than the engine's. + // Note: init_from_file_ is used for non-file:// URLs when the metadata is known to be good, like from Jamendo. return; } @@ -1051,8 +1049,6 @@ QString Song::SampleRateBitDepthToText() const { bool Song::IsMetadataEqual(const Song &other) const { - //qLog(Debug) << __PRETTY_FUNCTION__; - return d->title_ == other.d->title_ && d->album_ == other.d->album_ && d->artist_ == other.d->artist_ && diff --git a/src/core/song.h b/src/core/song.h index c7c4f7fa..d36bc7ec 100644 --- a/src/core/song.h +++ b/src/core/song.h @@ -21,14 +21,28 @@ #ifndef SONG_H #define SONG_H -#include -#include -#include -#include -#include - #include "config.h" -#include "engine/engine_fwd.h" + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace Engine { +struct SimpleMetaBundle; +} // namespace Engine namespace pb { namespace tagreader { @@ -36,9 +50,6 @@ class SongMetadata; } // namespace tagreader } // namespace pb -class QSqlQuery; -class QUrl; - #ifdef HAVE_LIBGPOD struct _Itdb_Track; #endif @@ -75,11 +86,12 @@ class Song { static const QString kManuallyUnsetCover; static const QString kEmbeddedCover; + + static const QRegExp kCoverRemoveDisc; static QString JoinSpec(const QString &table); - // Don't change these values - they're stored in the database, and defined - // in the tag reader protobuf. + // Don't change these values - they're stored in the database, and defined in the tag reader protobuf. // If a new lossless file is added, also add it to IsFileLossless(). enum FileType { Type_Unknown = 0, @@ -129,9 +141,8 @@ class Song { void ToMTP(LIBMTP_track_struct *track) const; #endif - // Copies important statistics from the other song to this one, overwriting - // any data that already exists. Useful when you want updated tags from disk - // but you want to keep user stats. + // Copies important statistics from the other song to this one, overwriting any data that already exists. + // Useful when you want updated tags from disk but you want to keep user stats. void MergeUserSetData(const Song &other); static QString Decode(const QString &tag, const QTextCodec *codec = nullptr); @@ -204,8 +215,7 @@ class Song { // Returns true if this Song had it's cover manually unset by user. bool has_manually_unset_cover() const; - // This method represents an explicit request to unset this song's - // cover. + // This method represents an explicit request to unset this song's cover. void manually_unset_cover(); // Returns true if this song (it's media file) has an embedded cover. @@ -288,15 +298,15 @@ class Song { bool operator==(const Song &other) const; - // Two songs that are on the same album will have the same AlbumKey. It is - // more efficient to use IsOnSameAlbum, but this function can be used when - // you need to hash the key to do fast lookups. + // Two songs that are on the same album will have the same AlbumKey. + // It is more efficient to use IsOnSameAlbum, but this function can be used when you need to hash the key to do fast lookups. QString AlbumKey() const; Song &operator=(const Song &other); private: struct Private; + QSharedDataPointer d; }; Q_DECLARE_METATYPE(Song); diff --git a/src/core/songloader.cpp b/src/core/songloader.cpp index 32d553b9..94480936 100644 --- a/src/core/songloader.cpp +++ b/src/core/songloader.cpp @@ -20,36 +20,46 @@ #include "config.h" -#include "songloader.h" - +#include #include -#if defined(HAVE_GSTREAMER) && defined(HAVE_AUDIOCD) - #include +#ifdef HAVE_GSTREAMER +# include #endif +#include +#include #include +#include +#include +#include #include +#include #include +#include +#include #include +#include #include +#include #include -#include "config.h" #include "core/logging.h" -#include "core/player.h" -#include "core/signalchecker.h" -#include "core/song.h" -#include "core/tagreaderclient.h" -#include "core/timeconstants.h" + +#include "signalchecker.h" +#include "player.h" +#include "song.h" +#include "songloader.h" +#include "tagreaderclient.h" #include "collection/collectionbackend.h" +#include "collection/collectionquery.h" #include "collection/sqlrow.h" #include "playlistparsers/cueparser.h" #include "playlistparsers/parserbase.h" #include "playlistparsers/playlistparser.h" #if defined(HAVE_AUDIOCD) && defined(HAVE_GSTREAMER) - #include "device/cddasongloader.h" +# include "device/cddasongloader.h" #endif using std::placeholders::_1; @@ -98,7 +108,7 @@ SongLoader::~SongLoader() { } SongLoader::Result SongLoader::Load(const QUrl &url) { - + url_ = url; if (url_.scheme() == "file") { @@ -106,7 +116,8 @@ SongLoader::Result SongLoader::Load(const QUrl &url) { } if (sRawUriSchemes.contains(url_.scheme()) || player_->HandlerForUrl(url) != nullptr) { - // The URI scheme indicates that it can't possibly be a playlist, or we have a custom handler for the URL, so add it as a raw stream. AddAsRawStream(); + // The URI scheme indicates that it can't possibly be a playlist, + // or we have a custom handler for the URL, so add it as a raw stream. AddAsRawStream(); return Success; } @@ -181,7 +192,7 @@ SongLoader::Result SongLoader::LoadLocal(const QString &filename) { query.AddWhere("filename", url.toEncoded()); if (collection_->ExecQuery(&query) && query.Next()) { - // we may have many results when the file has many sections + // We may have many results when the file has many sections do { Song song; song.InitFromQuery(query, true); @@ -195,8 +206,7 @@ SongLoader::Result SongLoader::LoadLocal(const QString &filename) { } // It's not in the database, load it asynchronously. - preload_func_ = - std::bind(&SongLoader::LoadLocalAsync, this, filename); + preload_func_ = std::bind(&SongLoader::LoadLocalAsync, this, filename); return BlockingLoadRequired; } @@ -215,8 +225,7 @@ void SongLoader::LoadLocalAsync(const QString &filename) { ParserBase *parser = playlist_parser_->ParserForMagic(data); if (!parser) { - // Check the file extension as well, maybe the magic failed, or it was a - // basic M3U file which is just a plain list of filenames. + // Check the file extension as well, maybe the magic failed, or it was a basic M3U file which is just a plain list of filenames. parser = playlist_parser_->ParserForExtension(QFileInfo(filename).suffix().toLower()); } @@ -307,10 +316,10 @@ void SongLoader::LoadLocalDirectory(const QString &filename) { qStableSort(songs_.begin(), songs_.end(), CompareSongs); - // Load the first song: all songs will be loaded async, but we want the first - // one in our list to be fully loaded, so if the user has the "Start playing - // when adding to playlist" preference behaviour set, it can enjoy the first - // song being played (seek it, have moodbar, etc.) + // Load the first song: + // all songs will be loaded async, but we want the first one in our list to be fully loaded, + // so if the user has the "Start playing when adding to playlist" preference behaviour set, + // it can enjoy the first song being played (seek it, have moodbar, etc.) if (!songs_.isEmpty()) EffectiveSongLoad(&(*songs_.begin())); } @@ -357,15 +366,11 @@ void SongLoader::LoadRemote() { qLog(Debug) << "Loading remote file" << url_; - // It's not a local file so we have to fetch it to see what it is. We use - // gstreamer to do this since it handles funky URLs for us (http://, ssh://, - // etc) and also has typefinder plugins. - // First we wait for typefinder to tell us what it is. If it's not text/plain - // or text/uri-list assume it's a song and return success. - // Otherwise wait to get 512 bytes of data and do magic on it - if the magic - // fails then we don't know what it is so return failure. - // If the magic succeeds then we know for sure it's a playlist - so read the - // rest of the file, parse the playlist and return success. + // It's not a local file so we have to fetch it to see what it is. + // We use gstreamer to do this since it handles funky URLs for us (http://, ssh://, etc) and also has typefinder plugins. + // First we wait for typefinder to tell us what it is. If it's not text/plain or text/uri-list assume it's a song and return success. + // Otherwise wait to get 512 bytes of data and do magic on it - if the magic fails then we don't know what it is so return failure. + // If the magic succeeds then we know for sure it's a playlist - so read the rest of the file, parse the playlist and return success. timeout_timer_->start(timeout_); diff --git a/src/core/songloader.h b/src/core/songloader.h index c00edd09..f7d900ce 100644 --- a/src/core/songloader.h +++ b/src/core/songloader.h @@ -23,26 +23,32 @@ #include "config.h" -#include #include +#include +#include +#include #ifdef HAVE_GSTREAMER - #include +# include #endif +#include #include #include +#include +#include +#include #include +#include #include "song.h" -#include "core/tagreaderclient.h" -#include "musicbrainz/musicbrainzclient.h" -class CueParser; -class CollectionBackendInterface; -class ParserBase; class Player; +class CollectionBackendInterface; class PlaylistParser; +class ParserBase; +class CueParser; + #if defined(HAVE_AUDIOCD) && defined(HAVE_GSTREAMER) class CddaSongLoader; #endif @@ -67,16 +73,13 @@ class SongLoader : public QObject { int timeout() const { return timeout_; } void set_timeout(int msec) { timeout_ = msec; } - // If Success is returned the songs are fully loaded. If BlockingLoadRequired - // is returned LoadFilenamesBlocking() needs to be called next. + // If Success is returned the songs are fully loaded. If BlockingLoadRequired is returned LoadFilenamesBlocking() needs to be called next. Result Load(const QUrl &url); - // Loads the files with only filenames. When finished, songs() contains a - // complete list of all Song objects, but without metadata. This method is - // blocking, do not call it from the UI thread. + // Loads the files with only filenames. When finished, songs() contains a complete list of all Song objects, but without metadata. + // This method is blocking, do not call it from the UI thread. void LoadFilenamesBlocking(); - // Completely load songs previously loaded with LoadFilenamesBlocking(). When - // finished, the Song objects in songs() contain metadata now. This method is - // blocking, do not call it from the UI thread. + // Completely load songs previously loaded with LoadFilenamesBlocking(). + // When finished, the Song objects in songs() contain metadata now. This method is blocking, do not call it from the UI thread. void LoadMetadataBlocking(); Result LoadAudioCD(); @@ -91,7 +94,7 @@ signals: #if defined(HAVE_AUDIOCD) && defined(HAVE_GSTREAMER) void AudioCDTracksLoadedSlot(const SongList &songs); void AudioCDTracksTagsLoaded(const SongList &songs); -#endif // HAVE_AUDIOCD +#endif // HAVE_AUDIOCD && HAVE_GSTREAMER private: enum State { WaitingForType, WaitingForMagic, WaitingForData, Finished }; @@ -105,7 +108,7 @@ signals: #ifdef HAVE_GSTREAMER void LoadRemote(); - + // GStreamer callbacks static void TypeFound(GstElement *typefind, uint probability, GstCaps *caps, void *self); static GstPadProbeReturn DataReady(GstPad*, GstPadProbeInfo *buf, gpointer self); @@ -117,7 +120,6 @@ signals: void EndOfStreamReached(); void MagicReady(); bool IsPipelinePlaying(); - #endif private: diff --git a/src/core/standarditemiconloader.cpp b/src/core/standarditemiconloader.cpp index 7e3ea5a2..1e0bbefb 100644 --- a/src/core/standarditemiconloader.cpp +++ b/src/core/standarditemiconloader.cpp @@ -20,12 +20,21 @@ #include "config.h" -#include -#include +#include +#include +#include #include +#include +#include +#include +#include +#include +#include +#include +#include -#include "standarditemiconloader.h" #include "covermanager/albumcoverloader.h" +#include "standarditemiconloader.h" StandardItemIconLoader::StandardItemIconLoader(AlbumCoverLoader *cover_loader, QObject *parent) : QObject(parent), @@ -34,13 +43,13 @@ StandardItemIconLoader::StandardItemIconLoader(AlbumCoverLoader *cover_loader, Q { cover_options_.desired_height_ = 16; - connect(cover_loader_, SIGNAL(ImageLoaded(quint64,QImage)), SLOT(ImageLoaded(quint64,QImage))); + connect(cover_loader_, SIGNAL(ImageLoaded(quint64, QImage)), SLOT(ImageLoaded(quint64, QImage))); } void StandardItemIconLoader::SetModel(QAbstractItemModel *model) { if (model_) { - disconnect(model_, SIGNAL(rowsAboutToBeRemoved(QModelIndex,int,int)), this, SLOT(RowsAboutToBeRemoved(QModelIndex,int,int))); + disconnect(model_, SIGNAL(rowsAboutToBeRemoved(QModelIndex, int, int)), this, SLOT(RowsAboutToBeRemoved(QModelIndex, int, int))); } model_ = model; @@ -50,19 +59,19 @@ void StandardItemIconLoader::SetModel(QAbstractItemModel *model) { } -void StandardItemIconLoader::LoadIcon(const QString& art_automatic, const QString& art_manual, QStandardItem *for_item) { +void StandardItemIconLoader::LoadIcon(const QString &art_automatic, const QString &art_manual, QStandardItem *for_item) { const quint64 id = cover_loader_->LoadImageAsync(cover_options_, art_automatic, art_manual); pending_covers_[id] = for_item; } -void StandardItemIconLoader::LoadIcon(const Song& song, QStandardItem *for_item) { +void StandardItemIconLoader::LoadIcon(const Song &song, QStandardItem *for_item) { const quint64 id = cover_loader_->LoadImageAsync(cover_options_, song); pending_covers_[id] = for_item; } -void StandardItemIconLoader::RowsAboutToBeRemoved(const QModelIndex& parent, int begin, int end) { +void StandardItemIconLoader::RowsAboutToBeRemoved(const QModelIndex &parent, int begin, int end) { for (QMap::iterator it = pending_covers_.begin() ; it != pending_covers_.end() ; ) { const QStandardItem *item = it.value(); @@ -86,7 +95,7 @@ void StandardItemIconLoader::ModelReset() { } -void StandardItemIconLoader::ImageLoaded(quint64 id, const QImage& image) { +void StandardItemIconLoader::ImageLoaded(quint64 id, const QImage &image) { QStandardItem *item = pending_covers_.take(id); if (!item) return; diff --git a/src/core/standarditemiconloader.h b/src/core/standarditemiconloader.h index 8f4b8eb4..08855b99 100644 --- a/src/core/standarditemiconloader.h +++ b/src/core/standarditemiconloader.h @@ -23,17 +23,20 @@ #include "config.h" -#include +#include #include +#include +#include +#include +#include +#include #include "covermanager/albumcoverloaderoptions.h" -class AlbumCoverLoader; class Song; +class AlbumCoverLoader; -class QAbstractItemModel; class QModelIndex; -class QStandardItem; // Uses an AlbumCoverLoader to asynchronously load and set an icon on a QStandardItem. class StandardItemIconLoader : public QObject { @@ -46,8 +49,7 @@ class StandardItemIconLoader : public QObject { void SetModel(QAbstractItemModel *model); - void LoadIcon(const QString &art_automatic, const QString &art_manual, - QStandardItem *for_item); + void LoadIcon(const QString &art_automatic, const QString &art_manual, QStandardItem *for_item); void LoadIcon(const Song &song, QStandardItem *for_item); private slots: diff --git a/src/core/stylesheetloader.cpp b/src/core/stylesheetloader.cpp index 132e8b87..a10b4a2a 100644 --- a/src/core/stylesheetloader.cpp +++ b/src/core/stylesheetloader.cpp @@ -20,11 +20,17 @@ #include "config.h" -#include "stylesheetloader.h" -#include "core/logging.h" - +#include +#include +#include #include -#include +#include +#include +#include +#include + +#include "core/logging.h" +#include "stylesheetloader.h" StyleSheetLoader::StyleSheetLoader(QObject *parent) : QObject(parent) {} diff --git a/src/core/stylesheetloader.h b/src/core/stylesheetloader.h index 5c1abe49..ea02000a 100644 --- a/src/core/stylesheetloader.h +++ b/src/core/stylesheetloader.h @@ -23,18 +23,21 @@ #include "config.h" -#include -#include +#include + +#include #include +#include #include +#include +#include class StyleSheetLoader : public QObject { public: explicit StyleSheetLoader(QObject *parent = nullptr); // Sets the given stylesheet on the given widget. - // If the stylesheet contains strings like %palette-[role], these get replaced - // with actual palette colours. + // If the stylesheet contains strings like %palette-[role], these get replaced with actual palette colours. // The stylesheet is reloaded when the widget's palette changes. void SetStyleSheet(QWidget *widget, const QString& filename); @@ -43,7 +46,7 @@ class StyleSheetLoader : public QObject { private: void UpdateStyleSheet(QWidget *widget); - void ReplaceColor(QString *css, const QString& name, const QPalette& palette, QPalette::ColorRole role) const; + void ReplaceColor(QString *css, const QString& name, const QPalette &palette, QPalette::ColorRole role) const; private: QMap filenames_; diff --git a/src/core/systemtrayicon.cpp b/src/core/systemtrayicon.cpp index 6724bb15..be07c6df 100644 --- a/src/core/systemtrayicon.cpp +++ b/src/core/systemtrayicon.cpp @@ -22,14 +22,14 @@ #include -#include -#include -#include +#include +#include #include -#include -#include +#include +#include +#include +#include -#include "macsystemtrayicon.h" #include "qtsystemtrayicon.h" #include "systemtrayicon.h" diff --git a/src/core/systemtrayicon.h b/src/core/systemtrayicon.h index f7b2f35f..4fd3de02 100644 --- a/src/core/systemtrayicon.h +++ b/src/core/systemtrayicon.h @@ -23,10 +23,13 @@ #include "config.h" -#include -#include +#include + +#include +#include +#include +#include -class QAction; class Song; class SystemTrayIcon : public QObject { @@ -43,10 +46,7 @@ class SystemTrayIcon : public QObject { // Called by the OSD virtual void ShowPopup(const QString &summary, const QString &message, int timeout) {} - /** - * If this get's invoked with image_path equal to nullptr, the tooltip should - * still be shown - just without the cover art. - */ + // If this get's invoked with image_path equal to nullptr, the tooltip should still be shown - just without the cover art. virtual void SetNowPlaying(const Song &song, const QString &image_path) {} virtual void ClearNowPlaying() {} diff --git a/src/core/tagreaderclient.cpp b/src/core/tagreaderclient.cpp index 621cf4e2..ed654755 100644 --- a/src/core/tagreaderclient.cpp +++ b/src/core/tagreaderclient.cpp @@ -20,14 +20,21 @@ #include "config.h" -#include "tagreaderclient.h" +#include -#include -#include -#include -#include +#include +#include #include -#include +#include +#include +#include +#include + +#include "core/logging.h" +#include "core/workerpool.h" + +#include "song.h" +#include "tagreaderclient.h" const char *TagReaderClient::kWorkerExecutableName = "strawberry-tagreader"; TagReaderClient *TagReaderClient::sInstance = nullptr; diff --git a/src/core/tagreaderclient.h b/src/core/tagreaderclient.h index c1a3d478..ec567129 100644 --- a/src/core/tagreaderclient.h +++ b/src/core/tagreaderclient.h @@ -23,15 +23,21 @@ #include "config.h" -#include "song.h" -#include "tagreadermessages.pb.h" +#include + +#include +#include +#include +#include + #include "core/messagehandler.h" #include "core/workerpool.h" -#include +#include "song.h" +#include "tagreadermessages.pb.h" -class QLocalServer; -class QProcess; +class Song; +template class WorkerPool; class TagReaderClient : public QObject { Q_OBJECT @@ -51,9 +57,8 @@ class TagReaderClient : public QObject { ReplyType *IsMediaFile(const QString &filename); ReplyType *LoadEmbeddedArt(const QString &filename); - // Convenience functions that call the above functions and wait for a - // response. These block the calling thread with a semaphore, and must NOT - // be called from the TagReaderClient's thread. + // Convenience functions that call the above functions and wait for a response. + // These block the calling thread with a semaphore, and must NOT be called from the TagReaderClient's thread. void ReadFileBlocking(const QString &filename, Song *song); bool SaveFileBlocking(const QString &filename, const Song &metadata); bool IsMediaFileBlocking(const QString &filename); diff --git a/src/core/taskmanager.cpp b/src/core/taskmanager.cpp index d7c81ebe..dbc2f89b 100644 --- a/src/core/taskmanager.cpp +++ b/src/core/taskmanager.cpp @@ -20,6 +20,11 @@ #include "config.h" +#include +#include +#include +#include + #include "taskmanager.h" TaskManager::TaskManager(QObject *parent) : QObject(parent), next_task_id_(1) {} diff --git a/src/core/taskmanager.h b/src/core/taskmanager.h index 9edd9f24..bc775323 100644 --- a/src/core/taskmanager.h +++ b/src/core/taskmanager.h @@ -23,9 +23,14 @@ #include "config.h" -#include -#include +#include + +#include #include +#include +#include +#include +#include class TaskManager : public QObject { Q_OBJECT diff --git a/src/core/thread.cpp b/src/core/thread.cpp index de65cecb..ac209e6f 100644 --- a/src/core/thread.cpp +++ b/src/core/thread.cpp @@ -17,7 +17,10 @@ #include "config.h" +#include + #include "thread.h" +#include "utilities.h" void Thread::run() { Utilities::SetThreadIOPriority(io_priority_); diff --git a/src/core/thread.h b/src/core/thread.h index 6a86498c..94dab505 100644 --- a/src/core/thread.h +++ b/src/core/thread.h @@ -20,8 +20,10 @@ #include "config.h" +#include #include -#include "core/utilities.h" + +#include "utilities.h" // Improve QThread by adding a SetIoPriority function class Thread : public QThread { diff --git a/src/core/urlhandler.cpp b/src/core/urlhandler.cpp index 540a1e4c..9bad893b 100644 --- a/src/core/urlhandler.cpp +++ b/src/core/urlhandler.cpp @@ -17,8 +17,14 @@ * along with Strawberry. If not, see . * */ + #include "config.h" +#include +#include +#include +#include + #include "urlhandler.h" UrlHandler::LoadResult::LoadResult(const QUrl &original_url, Type type, const QUrl &media_url, qint64 length_nanosec) : original_url_(original_url), type_(type), media_url_(media_url), length_nanosec_(length_nanosec) {} diff --git a/src/core/urlhandler.h b/src/core/urlhandler.h index 02bb9c19..b8ac113c 100644 --- a/src/core/urlhandler.h +++ b/src/core/urlhandler.h @@ -23,9 +23,11 @@ #include "config.h" -#include +#include #include +#include #include +#include class UrlHandler : public QObject { Q_OBJECT @@ -37,17 +39,14 @@ class UrlHandler : public QObject { virtual QString scheme() const = 0; virtual QIcon icon() const; - // Returned by StartLoading() and LoadNext(), indicates what the player - // should do when it wants to load a URL. + // Returned by StartLoading() and LoadNext(), indicates what the player should do when it wants to load a URL. struct LoadResult { enum Type { - // There wasn't a track available, and the player should move on to the - // next playlist item. + // There wasn't a track available, and the player should move on to the next playlist item. NoMoreTracks, - // There might be another track available but the handler needs to do some - // work (eg. fetching a remote playlist) to find out. AsyncLoadComplete - // will be emitted later with the same original_url. + // There might be another track available but the handler needs to do some work (eg. fetching a remote playlist) to find out. + // AsyncLoadComplete will be emitted later with the same original_url. WillLoadAsynchronously, // There was a track available. Its url is in media_url. @@ -69,12 +68,10 @@ class UrlHandler : public QObject { qint64 length_nanosec_; }; - // Called by the Player when a song starts loading - gives the handler - // a chance to do something clever to get a playable track. + // Called by the Player when a song starts loading - gives the handler a chance to do something clever to get a playable track. virtual LoadResult StartLoading(const QUrl &url) { return LoadResult(url); } - // Called by the player when a song finishes - gives the handler a chance to - // get another track to play. + // Called by the player when a song finishes - gives the handler a chance to get another track to play. virtual LoadResult LoadNext(const QUrl &url) { return LoadResult(url); } // Functions to be warned when something happen to a track handled by UrlHandler. @@ -86,4 +83,3 @@ signals: }; #endif // URLHANDLER_H - diff --git a/src/core/utilities.cpp b/src/core/utilities.cpp index 2b88f5a7..fded4840 100644 --- a/src/core/utilities.cpp +++ b/src/core/utilities.cpp @@ -23,22 +23,40 @@ #include #include +#include #include +#include +#include +#include +#include +#include +#include +#include +#include +#include #include #include #include #include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #include +#include #include -#include #include -#include #include -#include +#include #include +#include +#include +#include #ifdef Q_OS_LINUX #include @@ -56,23 +74,25 @@ #ifdef Q_OS_DARWIN #include + #include "CoreServices/CoreServices.h" - #include "IOKit/ps/IOPowerSources.h" #include "IOKit/ps/IOPSKeys.h" + #include "IOKit/ps/IOPowerSources.h" #elif defined(Q_OS_WIN32) #include #endif -#include "utilities.h" -#include "core/application.h" #include "core/logging.h" -#include "timeconstants.h" + +#include "utilities.h" #include "sha2.h" +#include "timeconstants.h" +#include "application.h" #ifdef Q_OS_DARWIN - #include "core/mac_startup.h" - #include "core/mac_utilities.h" - #include "core/scoped_cftyperef.h" + #include "mac_startup.h" + #include "mac_utilities.h" + #include "scoped_cftyperef.h" #endif namespace Utilities { @@ -379,8 +399,7 @@ void OpenInFileBrowser(const QList &urls) { dirs.insert(directory); qLog(Debug) << path; #ifdef Q_OS_DARWIN - // revealing multiple files in the finder only opens one window, - // so it also makes sense to reveal at most one per directory + // Revealing multiple files in the finder only opens one window, so it also makes sense to reveal at most one per directory RevealFileInFinder(path); #elif defined(Q_OS_WIN32) ShowFileInExplorer(path); @@ -407,8 +426,7 @@ QByteArray Hmac(const QByteArray &key, const QByteArray &data, HashFunction meth return QCryptographicHash::hash(outer_padding + QCryptographicHash::hash(inner_padding + data, QCryptographicHash::Md5), QCryptographicHash::Md5); } else if (Sha1_Algo == method) { - return - QCryptographicHash::hash(outer_padding + QCryptographicHash::hash(inner_padding + data, QCryptographicHash::Sha1), QCryptographicHash::Sha1); + return QCryptographicHash::hash(outer_padding + QCryptographicHash::hash(inner_padding + data, QCryptographicHash::Sha1), QCryptographicHash::Sha1); } else { // Sha256_Algo, currently default return Sha256(outer_padding + Sha256(inner_padding + data)); @@ -473,6 +491,8 @@ QByteArray Sha1CoverHash(const QString &artist, const QString &album) { QCryptographicHash hash(QCryptographicHash::Sha1); hash.addData(artist.toLower().toUtf8().constData()); hash.addData(album.toLower().toUtf8().constData()); + + //qLog(Debug) << artist << album << hash.result(); return hash.result(); @@ -538,8 +558,7 @@ bool ParseUntilElement(QXmlStreamReader *reader, const QString &name) { QDateTime ParseRFC822DateTime(const QString &text) { - QRegExp regexp( - "(\\d{1,2}) (\\w{3,12}) (\\d+) (\\d{1,2}):(\\d{1,2}):(\\d{1,2})"); + QRegExp regexp("(\\d{1,2}) (\\w{3,12}) (\\d+) (\\d{1,2}):(\\d{1,2}):(\\d{1,2})"); if (regexp.indexIn(text) == -1) { return QDateTime(); } @@ -622,11 +641,9 @@ QString DecodeHtmlEntities(const QString &text) { int SetThreadIOPriority(IoPriority priority) { #ifdef Q_OS_LINUX - return syscall(SYS_ioprio_set, IOPRIO_WHO_PROCESS, GetThreadId(), - 4 | priority << IOPRIO_CLASS_SHIFT); + return syscall(SYS_ioprio_set, IOPRIO_WHO_PROCESS, GetThreadId(), 4 | priority << IOPRIO_CLASS_SHIFT); #elif defined(Q_OS_DARWIN) - return setpriority(PRIO_DARWIN_THREAD, 0, - priority == IOPRIO_CLASS_IDLE ? PRIO_DARWIN_BG : 0); + return setpriority(PRIO_DARWIN_THREAD, 0, priority == IOPRIO_CLASS_IDLE ? PRIO_DARWIN_BG : 0); #else return 0; #endif diff --git a/src/core/utilities.h b/src/core/utilities.h index 54737c5e..734a4553 100644 --- a/src/core/utilities.h +++ b/src/core/utilities.h @@ -24,19 +24,24 @@ #include "config.h" #include +#include -#include +#include +#include +#include +#include #include -#include -#include #include +#include +#include +#include +#include #include +#include #include - -class QIODevice; -class QMouseEvent; -class QXmlStreamReader; -struct QMetaObject; +#include +#include +#include namespace Utilities { QString PrettyTime(int seconds); @@ -77,25 +82,21 @@ QByteArray Sha256(const QByteArray &data); QByteArray Sha1File(QFile &file); QByteArray Sha1CoverHash(const QString &artist, const QString &album); -// Picks an unused ephemeral port number. Doesn't hold the port open so -// there's the obvious race condition +// Picks an unused ephemeral port number. Doesn't hold the port open so there's the obvious race condition quint16 PickUnusedPort(); -// Forwards a mouse event to a different widget, remapping the event's widget -// coordinates relative to those of the target widget. +// Forwards a mouse event to a different widget, remapping the event's widget coordinates relative to those of the target widget. void ForwardMouseEvent(const QMouseEvent *e, QWidget *target); // Checks if the mouse event was inside the widget's rectangle. bool IsMouseEventInWidget(const QMouseEvent *e, const QWidget *widget); -// Reads all children of the current element, and returns with the stream -// reader either on the EndElement for the current element, or the end of the -// file - whichever came first. +// Reads all children of the current element, +// and returns with the stream reader either on the EndElement for the current element, or the end of the file - whichever came first. void ConsumeCurrentElement(QXmlStreamReader *reader); // Advances the stream reader until it finds an element with the given name. -// Returns false if the end of the document was reached before finding a -// matching element. +// Returns false if the end of the document was reached before finding a matching element. bool ParseUntilElement(QXmlStreamReader *reader, const QString &name); // Parses a string containing an RFC822 time and date. @@ -105,8 +106,7 @@ QDateTime ParseRFC822DateTime(const QString &text); QString DecodeHtmlEntities(const QString &text); // Shortcut for getting a Qt-aware enum value as a string. -// Pass in the QMetaObject of the class that owns the enum, the string name of -// the enum and a valid value from that enum. +// Pass in the QMetaObject of the class that owns the enum, the string name of the enum and a valid value from that enum. const char *EnumToString(const QMetaObject &meta, const char *name, int value); QStringList Prepend(const QString &text, const QStringList &list); @@ -172,4 +172,3 @@ class ScopedWCharArray { }; #endif // UTILITIES_H - diff --git a/src/core/windows7thumbbar.cpp b/src/core/windows7thumbbar.cpp index 6584e3f7..8acea663 100644 --- a/src/core/windows7thumbbar.cpp +++ b/src/core/windows7thumbbar.cpp @@ -20,13 +20,13 @@ #include "config.h" +#include +#include +#include +#include #include #include -#include "windows7thumbbar.h" - -#include "core/logging.h" - #ifdef Q_OS_WIN32 #ifndef _WIN32_WINNT #define _WIN32_WINNT 0x0600 @@ -34,13 +34,15 @@ #include #include #include -extern HICON qt_pixmapToWinHICON(const QPixmap &p); + extern HICON qt_pixmapToWinHICON(const QPixmap &p); #endif // Q_OS_WIN32 +#include "core/logging.h" +#include "windows7thumbbar.h" + const int Windows7ThumbBar::kIconSize = 16; const int Windows7ThumbBar::kMaxButtonCount = 7; - Windows7ThumbBar::Windows7ThumbBar(QWidget *widget) : QObject(widget), widget_(widget), diff --git a/src/core/windows7thumbbar.h b/src/core/windows7thumbbar.h index 4589b0fa..9490942d 100644 --- a/src/core/windows7thumbbar.h +++ b/src/core/windows7thumbbar.h @@ -23,8 +23,11 @@ #include "config.h" -#include +#include #include +#include +#include +#include #ifndef Q_OS_WIN32 typedef void MSG; @@ -34,15 +37,13 @@ class Windows7ThumbBar : public QObject { Q_OBJECT public: - // Creates a list of buttons in the taskbar icon for this window. Does - // nothing and is safe to use on other operating systems too. + // Creates a list of buttons in the taskbar icon for this window. Does nothing and is safe to use on other operating systems too. Windows7ThumbBar(QWidget *widget = 0); static const int kIconSize; static const int kMaxButtonCount; - // You must call this in the parent widget's constructor before returning - // to the event loop. If an action is nullptr it becomes a spacer. + // You must call this in the parent widget's constructor before returning to the event loop. If an action is nullptr it becomes a spacer. void SetActions(const QList &actions); // Call this from the parent's winEvent() function. @@ -58,7 +59,7 @@ private: unsigned int button_created_message_id_; // Really an ITaskbarList3* but I don't want to have to include windows.h here - void* taskbar_list_; + void *taskbar_list_; }; #endif // WINDOWS7THUMBBAR_H diff --git a/src/covermanager/albumcoverchoicecontroller.cpp b/src/covermanager/albumcoverchoicecontroller.cpp index 9909562d..82d1f3b2 100644 --- a/src/covermanager/albumcoverchoicecontroller.cpp +++ b/src/covermanager/albumcoverchoicecontroller.cpp @@ -20,33 +20,43 @@ #include "config.h" -#include -#include +#include +#include #include -#include -#include -#include -#include +#include +#include #include -#include -#include +#include #include +#include +#include +#include +#include #include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include -#include "covermanager/albumcoverchoicecontroller.h" - -#include "core/application.h" -#include "core/logging.h" #include "core/utilities.h" +#include "core/song.h" #include "core/iconloader.h" -#include "collection/collectionbackend.h" +#include "core/application.h" -#include "covermanager/albumcoverfetcher.h" -#include "covermanager/albumcoverloader.h" -#include "covermanager/currentartloader.h" -#include "covermanager/albumcovermanager.h" -#include "covermanager/albumcoversearcher.h" -#include "covermanager/coverfromurldialog.h" +#include "collection/collectionbackend.h" +#include "albumcoverchoicecontroller.h" +#include "albumcoverfetcher.h" +#include "albumcoverloader.h" +#include "albumcoversearcher.h" +#include "coverfromurldialog.h" +#include "currentartloader.h" const char *AlbumCoverChoiceController::kLoadImageFileFilter = QT_TR_NOOP("Images (*.png *.jpg *.jpeg *.bmp *.gif *.xpm *.pbm *.pgm *.ppm *.xbm)"); const char *AlbumCoverChoiceController::kSaveImageFileFilter = QT_TR_NOOP("Images (*.png *.jpg *.jpeg *.bmp *.xpm *.pbm *.ppm *.xbm)"); @@ -134,18 +144,16 @@ void AlbumCoverChoiceController::SaveCoverToFile(const Song &song, const QImage QString AlbumCoverChoiceController::GetInitialPathForFileDialog(const Song &song, const QString &filename) { - // art automatic is first to show user which cover the album may be - // using now; the song is using it if there's no manual path but we - // cannot use manual path here because it can contain cached paths + // Art automatic is first to show user which cover the album may be using now; + // The song is using it if there's no manual path but we cannot use manual path here because it can contain cached paths if (!song.art_automatic().isEmpty() && !song.has_embedded_cover()) { return song.art_automatic(); - // if no automatic art, start in the song's folder + // If no automatic art, start in the song's folder } else if (!song.url().isEmpty() && song.url().toLocalFile().contains('/')) { return song.url().toLocalFile().section('/', 0, -2) + filename; - - // fallback - start in home + // Fallback - start in home } else { return QDir::home().absolutePath() + filename; @@ -172,7 +180,7 @@ QString AlbumCoverChoiceController::LoadCoverFromURL(Song *song) { QString AlbumCoverChoiceController::SearchForCover(Song *song) { QString album = song->effective_album(); - album = album.remove(QRegExp(" ?-? ((\\(|\\[)?)(Disc|CD) ?([0-9]{1,2})((\\)|\\])?)$")); + album.remove(Song::kCoverRemoveDisc); // Get something sensible to stick in the search box QImage image = cover_searcher_->Exec(song->effective_albumartist(), album); @@ -208,16 +216,16 @@ void AlbumCoverChoiceController::ShowCover(const Song &song) { QLabel *label = new QLabel(dialog); label->setPixmap(AlbumCoverLoader::TryLoadPixmap(song.art_automatic(), song.art_manual(), song.url().toLocalFile())); - // add (WxHpx) to the title before possibly resizing + // Add (WxHpx) to the title before possibly resizing title_text += " (" + QString::number(label->pixmap()->width()) + "x" + QString::number(label->pixmap()->height()) + "px)"; - // if the cover is larger than the screen, resize the window 85% seems to be enough to account for title bar and taskbar etc. + // If the cover is larger than the screen, resize the window 85% seems to be enough to account for title bar and taskbar etc. QDesktopWidget desktop; int current_screen = desktop.screenNumber(this); int desktop_height = desktop.screenGeometry(current_screen).height(); int desktop_width = desktop.screenGeometry(current_screen).width(); - // resize differently if monitor is in portrait mode + // Resize differently if monitor is in portrait mode if (desktop_width < desktop_height) { const int new_width = (double)desktop_width * 0.95; if (new_width < label->pixmap()->width()) { @@ -276,8 +284,11 @@ void AlbumCoverChoiceController::SaveCover(Song *song, const QString &cover) { QString AlbumCoverChoiceController::SaveCoverInCache(const QString &artist, const QString &album, const QImage &image) { + QString album2(album); + album2.remove(Song::kCoverRemoveDisc); + // Hash the artist and album into a filename for the image - QString filename(Utilities::Sha1CoverHash(artist, album).toHex() + ".jpg"); + QString filename(Utilities::Sha1CoverHash(artist, album2).toHex() + ".jpg"); QString path(AlbumCoverLoader::ImageCacheDir() + "/" + filename); // Make sure this directory exists first diff --git a/src/covermanager/albumcoverchoicecontroller.h b/src/covermanager/albumcoverchoicecontroller.h index 348d6fdf..a84a7256 100644 --- a/src/covermanager/albumcoverchoicecontroller.h +++ b/src/covermanager/albumcoverchoicecontroller.h @@ -23,18 +23,25 @@ #include "config.h" -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +class Song; +class Application; class AlbumCoverFetcher; class AlbumCoverSearcher; -class Application; class CoverFromURLDialog; -class QFileDialog; -class Song; - struct CoverSearchStatistics; // Controller for the common album cover related menu options. @@ -70,23 +77,19 @@ class AlbumCoverChoiceController : public QWidget { // 5. showing the cover in original size QList GetAllActions(); - // All of the methods below require a currently selected song as an - // input parameter. Also - LoadCoverFromFile, LoadCoverFromURL, - // SearchForCover, UnsetCover and SaveCover all update manual path - // of the given song in collection to the new cover. + // All of the methods below require a currently selected song as an input parameter. + // Also - LoadCoverFromFile, LoadCoverFromURL, SearchForCover, UnsetCover and SaveCover all update manual path of the given song in collection to the new cover. - // Lets the user choose a cover from disk. If no cover will be chosen or the chosen - // cover will not be a proper image, this returns an empty string. Otherwise, the - // path to the chosen cover will be returned. + // Lets the user choose a cover from disk. If no cover will be chosen or the chosen cover will not be a proper image, this returns an empty string. + // Otherwise, the path to the chosen cover will be returned. QString LoadCoverFromFile(Song *song); - // Shows a dialog that allows user to save the given image on disk. The image - // is supposed to be the cover of the given song's album. + // Shows a dialog that allows user to save the given image on disk. + // The image is supposed to be the cover of the given song's album. void SaveCoverToFile(const Song &song, const QImage &image); - // Downloads the cover from an URL given by user. This returns the downloaded image - // or null image if something went wrong for example when user cancelled the - // dialog. + // Downloads the cover from an URL given by user. + // This returns the downloaded image or null image if something went wrong for example when user cancelled the dialog. QString LoadCoverFromURL(Song *song); // Lets the user choose a cover among all that have been found on last.fm. @@ -108,8 +111,7 @@ class AlbumCoverChoiceController : public QWidget { // Saves the cover that the user picked through a drag and drop operation. QString SaveCover(Song *song, const QDropEvent *e); - // Saves the given image in cache as a cover for 'artist' - 'album'. - // The method returns path of the cached image. + // Saves the given image in cache as a cover for 'artist' - 'album'. The method returns path of the cached image. QString SaveCoverInCache(const QString &artist, const QString &album, const QImage &image); static bool CanAcceptDrag(const QDragEnterEvent *e); diff --git a/src/covermanager/albumcoverexport.cpp b/src/covermanager/albumcoverexport.cpp index cdf9a626..554b74aa 100644 --- a/src/covermanager/albumcoverexport.cpp +++ b/src/covermanager/albumcoverexport.cpp @@ -20,11 +20,18 @@ #include "config.h" +#include +#include +#include +#include +#include +#include +#include +#include + #include "albumcoverexport.h" #include "ui_albumcoverexport.h" -#include - const char *AlbumCoverExport::kSettingsGroup = "AlbumCoverExport"; AlbumCoverExport::AlbumCoverExport(QWidget *parent) : QDialog(parent), ui_(new Ui_AlbumCoverExport) { @@ -42,7 +49,7 @@ AlbumCoverExport::DialogResult AlbumCoverExport::Exec() { QSettings s; s.beginGroup(kSettingsGroup); - // restore last accepted settings + // Restore last accepted settings ui_->fileName->setText(s.value("fileName", "cover").toString()); ui_->doNotOverwrite->setChecked(s.value("overwrite", OverwriteMode_None).toInt() == OverwriteMode_None); ui_->overwriteAll->setChecked(s.value("overwrite", OverwriteMode_All).toInt() == OverwriteMode_All); diff --git a/src/covermanager/albumcoverexport.h b/src/covermanager/albumcoverexport.h index 156c7b88..17de071e 100644 --- a/src/covermanager/albumcoverexport.h +++ b/src/covermanager/albumcoverexport.h @@ -23,7 +23,12 @@ #include "config.h" +#include + +#include +#include #include +#include class Ui_AlbumCoverExport; diff --git a/src/covermanager/albumcoverexporter.cpp b/src/covermanager/albumcoverexporter.cpp index 162b6c32..5af83da4 100644 --- a/src/covermanager/albumcoverexporter.cpp +++ b/src/covermanager/albumcoverexporter.cpp @@ -20,12 +20,12 @@ #include "config.h" -#include +#include #include +#include "core/song.h" #include "albumcoverexporter.h" #include "coverexportrunnable.h" -#include "core/song.h" const int AlbumCoverExporter::kMaxConcurrentRequests = 3; diff --git a/src/covermanager/albumcoverexporter.h b/src/covermanager/albumcoverexporter.h index ebe6f2e6..36474d2a 100644 --- a/src/covermanager/albumcoverexporter.h +++ b/src/covermanager/albumcoverexporter.h @@ -23,15 +23,15 @@ #include "config.h" -#include "coverexportrunnable.h" -#include "core/song.h" -#include "covermanager/albumcoverexport.h" - #include +#include #include -#include +#include -class QThreadPool; +#include "albumcoverexport.h" + +class Song; +class CoverExportRunnable; class AlbumCoverExporter : public QObject { Q_OBJECT diff --git a/src/covermanager/albumcoverfetcher.cpp b/src/covermanager/albumcoverfetcher.cpp index fdf26a81..cc19452a 100644 --- a/src/covermanager/albumcoverfetcher.cpp +++ b/src/covermanager/albumcoverfetcher.cpp @@ -20,14 +20,18 @@ #include "config.h" +#include +#include #include +#include #include -#include +#include +#include +#include "core/network.h" +#include "core/song.h" #include "albumcoverfetcher.h" #include "albumcoverfetchersearch.h" -#include "core/network.h" -#include "core/logging.h" const int AlbumCoverFetcher::kMaxConcurrentRequests = 5; @@ -43,12 +47,10 @@ AlbumCoverFetcher::AlbumCoverFetcher(CoverProviders *cover_providers, QObject *p quint64 AlbumCoverFetcher::FetchAlbumCover(const QString &artist, const QString &album, bool fetchall) { - QString album2(album); - album2 = album2.remove(QRegExp(" ?-? ((\\(|\\[)?)(Disc|CD) ?([0-9]{1,2})((\\)|\\])?)$")); - CoverSearchRequest request; request.artist = artist; - request.album = album2; + request.album = album; + request.album.remove(Song::kCoverRemoveDisc); request.search = false; request.id = next_id_++; request.fetchall = fetchall; @@ -60,12 +62,10 @@ quint64 AlbumCoverFetcher::FetchAlbumCover(const QString &artist, const QString quint64 AlbumCoverFetcher::SearchForCovers(const QString &artist, const QString &album) { - QString album2(album); - album2 = album2.remove(QRegExp(" ?-? ((\\(|\\[)?)(Disc|CD) ?([0-9]{1,2})((\\)|\\])?)$")); - CoverSearchRequest request; request.artist = artist; - request.album = album2; + request.album = album; + request.album.remove(Song::kCoverRemoveDisc); request.search = true; request.id = next_id_++; request.fetchall = false; @@ -108,7 +108,7 @@ void AlbumCoverFetcher::StartRequests() { CoverSearchRequest request = queued_requests_.dequeue(); - // search objects are this fetcher's children so worst case scenario - they get deleted with it + // Search objects are this fetcher's children so worst case scenario - they get deleted with it AlbumCoverFetcherSearch *search = new AlbumCoverFetcherSearch(request, network_, this); active_requests_.insert(request.id, search); diff --git a/src/covermanager/albumcoverfetcher.h b/src/covermanager/albumcoverfetcher.h index 4846bada..47565fa4 100644 --- a/src/covermanager/albumcoverfetcher.h +++ b/src/covermanager/albumcoverfetcher.h @@ -23,60 +23,61 @@ #include "config.h" -#include "coversearchstatistics.h" +#include -#include -#include -#include -#include -#include +#include #include #include +#include +#include +#include +#include +#include +#include #include +#include +#include +#include -class QNetworkReply; -class QString; - -class AlbumCoverFetcherSearch; class CoverProviders; +class AlbumCoverFetcherSearch; +struct CoverSearchStatistics; // This class represents a single search-for-cover request. It identifies and describes the request. struct CoverSearchRequest { - // an unique (for one AlbumCoverFetcher) request identifier + // An unique (for one AlbumCoverFetcher) request identifier quint64 id; - // a search query + // A search query QString artist; QString album; - // is this only a search request or should we also fetch the first cover that's found? + // Is this only a search request or should we also fetch the first cover that's found? bool search; - // is the request part of fetchall (fetching all missing covers) + // Is the request part of fetchall (fetching all missing covers) bool fetchall; }; // This structure represents a single result of some album's cover search request. // It contains an URL that leads to a found cover plus its description (usually the "artist - album" string). struct CoverSearchResult { - // used for grouping in the user interface. This is set automatically - don't set it manually in your cover provider. + // Used for grouping in the user interface. This is set automatically - don't set it manually in your cover provider. QString provider; - // description of this result (we suggest using the "artist - album" format) + // Description of this result (we suggest using the "artist - album" format) QString description; - // an URL of a cover image described by this CoverSearchResult + // An URL of a cover image described by this CoverSearchResult QUrl image_url; }; Q_DECLARE_METATYPE(CoverSearchResult); -// This is a complete result of a single search request (a list of results, each -// describing one image, actually). +// This is a complete result of a single search request (a list of results, each describing one image, actually). typedef QList CoverSearchResults; Q_DECLARE_METATYPE(QList); -// This class searches for album covers for a given query or artist/album and -// returns URLs. It's NOT thread-safe. +// This class searches for album covers for a given query or artist/album and returns URLs. It's NOT thread-safe. class AlbumCoverFetcher : public QObject { Q_OBJECT diff --git a/src/covermanager/albumcoverfetchersearch.cpp b/src/covermanager/albumcoverfetchersearch.cpp index bd0e82fa..2c782d85 100644 --- a/src/covermanager/albumcoverfetchersearch.cpp +++ b/src/covermanager/albumcoverfetchersearch.cpp @@ -20,21 +20,28 @@ #include "config.h" -#include "albumcoverfetchersearch.h" - +#include #include -#include -#include +#include +#include #include +#include +#include +#include +#include +#include +#include +#include #include -#include "albumcoverfetcher.h" -#include "coverprovider.h" -#include "coverproviders.h" #include "core/closure.h" #include "core/logging.h" #include "core/network.h" +#include "albumcoverfetcher.h" +#include "albumcoverfetchersearch.h" +#include "coverprovider.h" +#include "coverproviders.h" const int AlbumCoverFetcherSearch::kSearchTimeoutMs = 12000; const int AlbumCoverFetcherSearch::kImageLoadTimeoutMs = 3000; @@ -84,7 +91,7 @@ void AlbumCoverFetcherSearch::Start(CoverProviders *cover_providers) { } } - // end this search before it even began if there are no providers... + // End this search before it even began if there are no providers... if (pending_requests_.isEmpty()) { TerminateSearch(); } @@ -111,7 +118,7 @@ void AlbumCoverFetcherSearch::ProviderSearchFinished(int id, const QListname()]++; - // do we have more providers left? + // Do we have more providers left? if (!pending_requests_.isEmpty()) { return; } @@ -125,13 +132,13 @@ void AlbumCoverFetcherSearch::AllProvidersFinished() { return; } - // if we only wanted to do the search then we're done + // If we only wanted to do the search then we're done if (request_.search) { emit SearchFinished(request_.id, results_); return; } - // no results? + // No results? if (results_.isEmpty()) { statistics_.missing_images_++; emit AlbumCoverFetched(request_.id, QImage()); @@ -139,10 +146,8 @@ void AlbumCoverFetcherSearch::AllProvidersFinished() { } // Now we have to load some images and figure out which one is the best. - // We'll sort the list of results by category, then load the first few images - // from each category and use some heuristics to score them. If no images - // are good enough we'll keep loading more images until we find one that is - // or we run out of results. + // We'll sort the list of results by category, then load the first few images from each category and use some heuristics to score them. + // If no images are good enough we'll keep loading more images until we find one that is or we run out of results. qStableSort(results_.begin(), results_.end(), CompareProviders); FetchMoreImages(); @@ -205,8 +210,7 @@ void AlbumCoverFetcherSearch::ProviderCoverFetchFinished(RedirectFollower *reply } if (pending_image_loads_.isEmpty()) { - // We've fetched everything we wanted to fetch for now, check if we have an - // image that's good enough. + // We've fetched everything we wanted to fetch for now, check if we have an image that's good enough. float best_score = 0.0; if (!candidate_images_.isEmpty()) { diff --git a/src/covermanager/albumcoverfetchersearch.h b/src/covermanager/albumcoverfetchersearch.h index 00fc0fbc..4a6dae78 100644 --- a/src/covermanager/albumcoverfetchersearch.h +++ b/src/covermanager/albumcoverfetchersearch.h @@ -23,21 +23,28 @@ #include "config.h" -#include "albumcoverfetcher.h" +#include -#include +#include #include +#include +#include +#include +#include +#include +#include + +#include "albumcoverfetcher.h" +#include "coversearchstatistics.h" class CoverProvider; class CoverProviders; class NetworkTimeouts; -class NetworkAccessManager; class RedirectFollower; -// This class encapsulates a single search for covers initiated by an -// AlbumCoverFetcher. The search engages all of the known cover providers. -// AlbumCoverFetcherSearch signals search results to an interested -// AlbumCoverFetcher when all of the providers have done their part. +// This class encapsulates a single search for covers initiated by an AlbumCoverFetcher. +// The search engages all of the known cover providers. +// AlbumCoverFetcherSearch signals search results to an interested AlbumCoverFetcher when all of the providers have done their part. class AlbumCoverFetcherSearch : public QObject { Q_OBJECT @@ -46,8 +53,7 @@ class AlbumCoverFetcherSearch : public QObject { void Start(CoverProviders *cover_providers); - // Cancels all pending requests. No Finished signals will be emitted, and it - // is the caller's responsibility to delete the AlbumCoverFetcherSearch. + // Cancels all pending requests. No Finished signals will be emitted, and it is the caller's responsibility to delete the AlbumCoverFetcherSearch. void Cancel(); CoverSearchStatistics statistics() const { return statistics_; } diff --git a/src/covermanager/albumcoverloader.cpp b/src/covermanager/albumcoverloader.cpp index a83a660e..074b08fb 100644 --- a/src/covermanager/albumcoverloader.cpp +++ b/src/covermanager/albumcoverloader.cpp @@ -20,24 +20,30 @@ #include "config.h" -#include "albumcoverloader.h" - -#include +#include +#include +#include +#include #include +#include +#include +#include +#include #include -#include +#include #include -#include #include #include #include -#include +#include +#include -#include "config.h" #include "core/closure.h" -#include "core/logging.h" #include "core/network.h" +#include "core/song.h" #include "core/tagreaderclient.h" +#include "albumcoverloader.h" +#include "albumcoverloaderoptions.h" AlbumCoverLoader::AlbumCoverLoader(QObject *parent) : QObject(parent), @@ -171,7 +177,7 @@ AlbumCoverLoader::TryLoadResult AlbumCoverLoader::TryLoadImage(const Task &task) if (filename.toLower().startsWith("http://") || filename.toLower().startsWith("https://")) { QUrl url(filename); - QNetworkReply* reply = network_->get(QNetworkRequest(url)); + QNetworkReply *reply = network_->get(QNetworkRequest(url)); NewClosure(reply, SIGNAL(finished()), this, SLOT(RemoteFetchFinished(QNetworkReply*)), reply); remote_tasks_.insert(reply, task); @@ -201,7 +207,7 @@ void AlbumCoverLoader::RemoteFetchFinished(QNetworkReply *reply) { } QNetworkRequest request = reply->request(); request.setUrl(redirect.toUrl()); - QNetworkReply* redirected_reply = network_->get(request); + QNetworkReply *redirected_reply = network_->get(request); NewClosure(redirected_reply, SIGNAL(finished()), this, SLOT(RemoteFetchFinished(QNetworkReply*)), redirected_reply); remote_tasks_.insert(redirected_reply, task); diff --git a/src/covermanager/albumcoverloader.h b/src/covermanager/albumcoverloader.h index 956308b3..2a194e8f 100644 --- a/src/covermanager/albumcoverloader.h +++ b/src/covermanager/albumcoverloader.h @@ -23,17 +23,24 @@ #include "config.h" -#include "albumcoverloaderoptions.h" -#include "core/song.h" +#include -#include -#include +#include #include +#include #include -#include +#include +#include +#include +#include +#include +#include +#include "core/song.h" +#include "albumcoverloaderoptions.h" + +class Song; class NetworkAccessManager; -class QNetworkReply; class AlbumCoverLoader : public QObject { Q_OBJECT @@ -60,7 +67,7 @@ signals: protected slots: void ProcessTasks(); - void RemoteFetchFinished(QNetworkReply* reply); + void RemoteFetchFinished(QNetworkReply *reply); protected: enum State { @@ -90,8 +97,8 @@ signals: QImage image; }; - void ProcessTask(Task* task); - void NextState(Task* task); + void ProcessTask(Task *task); + void NextState(Task *task); TryLoadResult TryLoadImage(const Task &task); bool stop_requested_; diff --git a/src/covermanager/albumcoverloaderoptions.cpp b/src/covermanager/albumcoverloaderoptions.cpp index a9fabaa7..5dca642f 100644 --- a/src/covermanager/albumcoverloaderoptions.cpp +++ b/src/covermanager/albumcoverloaderoptions.cpp @@ -1,2 +1 @@ -#include "config.h" #include "albumcoverloaderoptions.h" diff --git a/src/covermanager/albumcoverloaderoptions.h b/src/covermanager/albumcoverloaderoptions.h index e04242c8..91171eee 100644 --- a/src/covermanager/albumcoverloaderoptions.h +++ b/src/covermanager/albumcoverloaderoptions.h @@ -23,6 +23,7 @@ #include "config.h" +#include #include struct AlbumCoverLoaderOptions { diff --git a/src/covermanager/albumcovermanager.cpp b/src/covermanager/albumcovermanager.cpp index ff0ccb30..d9945420 100644 --- a/src/covermanager/albumcovermanager.cpp +++ b/src/covermanager/albumcovermanager.cpp @@ -15,47 +15,71 @@ * * You should have received a copy of the GNU General Public License * along with Strawberry. If not, see . - * + * */ #include "config.h" +#include + +#include +#include +#include +#include +#include +#include +#include +#include #include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #include #include -#include #include -#include #include +#include +#include +#include +#include +#include #include -#include -#include - -#include "albumcovermanager.h" -#include "albumcoversearcher.h" -#include "ui_albumcovermanager.h" #include "core/application.h" -#include "core/logging.h" -#include "core/utilities.h" #include "core/iconloader.h" -#include "covermanager/albumcoverexporter.h" -#include "covermanager/albumcoverfetcher.h" -#include "covermanager/albumcoverloader.h" -#include "covermanager/coverproviders.h" -#include "covermanager/coversearchstatisticsdialog.h" +#include "core/utilities.h" +#include "widgets/forcescrollperpixel.h" +#include "3rdparty/qocoa/qsearchfield.h" +#include "collection/sqlrow.h" #include "collection/collectionbackend.h" #include "collection/collectionquery.h" -#include "collection/sqlrow.h" #include "playlist/songmimedata.h" -#include "widgets/forcescrollperpixel.h" -#include "covermanager/albumcoverchoicecontroller.h" -#include "covermanager/albumcoverexport.h" +#include "coverproviders.h" +#include "albumcovermanager.h" +#include "albumcoversearcher.h" +#include "albumcoverchoicecontroller.h" +#include "albumcoverexport.h" +#include "albumcoverexporter.h" +#include "albumcoverfetcher.h" +#include "albumcoverloader.h" +#include "albumcovermanagerlist.h" +#include "coversearchstatistics.h" +#include "coversearchstatisticsdialog.h" + +#include "ui_albumcovermanager.h" const char *AlbumCoverManager::kSettingsGroup = "CoverManager"; @@ -255,7 +279,7 @@ static bool CompareAlbumNameNocase(const CollectionBackend::Album &left, const C } void AlbumCoverManager::Reset() { - + EnableCoversButtons(); ui_->artists->clear(); @@ -598,7 +622,7 @@ void AlbumCoverManager::SaveCoverToFile() { QImage image; - // load the image from disk + // Load the image from disk if (song.has_manually_unset_cover()) { image = no_cover_image_; } @@ -643,9 +667,9 @@ void AlbumCoverManager::SearchForCover() { QString cover = album_cover_choice_controller_->SearchForCover(&song); if (cover.isEmpty()) return; - // force the found cover on all of the selected items + // Force the found cover on all of the selected items for (QListWidgetItem *current : context_menu_items_) { - // don't save the first one twice + // Don't save the first one twice if (current != item) { Song current_song = ItemAsSong(current); album_cover_choice_controller_->SaveCover(¤t_song, cover); @@ -665,12 +689,12 @@ void AlbumCoverManager::UnsetCover() { QString cover = album_cover_choice_controller_->UnsetCover(&song); - // force the 'none' cover on all of the selected items + // Force the 'none' cover on all of the selected items for (QListWidgetItem *current : context_menu_items_) { current->setIcon(no_cover_item_icon_); current->setData(Role_PathManual, cover); - // don't save the first one twice + // Don't save the first one twice if (current != item) { Song current_song = ItemAsSong(current); album_cover_choice_controller_->SaveCover(¤t_song, cover); @@ -824,7 +848,7 @@ void AlbumCoverManager::UpdateExportStatus(int exported, int skipped, int max) { .arg(skipped); statusBar()->showMessage(message); - // end of the current process + // End of the current process if (exported + skipped >= max) { QTimer::singleShot(2000, statusBar(), SLOT(clearMessage())); @@ -865,7 +889,7 @@ QImage AlbumCoverManager::GenerateNoCoverImage(const QIcon &no_cover_icon) const } -bool AlbumCoverManager::ItemHasCover(const QListWidgetItem& item) const { +bool AlbumCoverManager::ItemHasCover(const QListWidgetItem &item) const { return item.icon().cacheKey() != no_cover_item_icon_.cacheKey(); } diff --git a/src/covermanager/albumcovermanager.h b/src/covermanager/albumcovermanager.h index c99a9dd0..de7dd6ee 100644 --- a/src/covermanager/albumcovermanager.h +++ b/src/covermanager/albumcovermanager.h @@ -23,29 +23,41 @@ #include "config.h" +#include + +#include +#include +#include #include +#include +#include +#include +#include +#include +#include +#include #include -#include +#include +#include +#include +#include +#include +#include #include "core/song.h" -#include "covermanager/albumcoverloaderoptions.h" -#include "covermanager/coversearchstatistics.h" +#include "albumcoverloaderoptions.h" +#include "coversearchstatistics.h" +class Application; +class CollectionBackend; +class SongMimeData; class AlbumCoverChoiceController; class AlbumCoverExport; class AlbumCoverExporter; class AlbumCoverFetcher; class AlbumCoverSearcher; -class Application; -class CollectionBackend; -class SongMimeData; -class Ui_CoverManager; -class QListWidgetItem; -class QMenu; -class QNetworkAccessManager; -class QPushButton; -class QProgressBar; +class Ui_CoverManager; class AlbumCoverManager : public QMainWindow { Q_OBJECT @@ -130,13 +142,9 @@ class AlbumCoverManager : public QMainWindow { QString InitialPathForOpenCoverDialog(const QString &path_automatic, const QString &first_file_name) const; QString EffectiveAlbumArtistName(const QListWidgetItem &item) const; - // Returns the selected element in form of a Song ready to be used - // by AlbumCoverChoiceController or invalid song if there's nothing - // or multiple elements selected. + // Returns the selected element in form of a Song ready to be used by AlbumCoverChoiceController or invalid song if there's nothing or multiple elements selected. Song GetSingleSelectionAsSong(); - // Returns the first of the selected elements in form of a Song ready - // to be used by AlbumCoverChoiceController or invalid song if there's nothing - // selected. + // Returns the first of the selected elements in form of a Song ready to be used by AlbumCoverChoiceController or invalid song if there's nothing selected. Song GetFirstSelectedAsSong(); Song ItemAsSong(QListWidgetItem *item); diff --git a/src/covermanager/albumcovermanagerlist.cpp b/src/covermanager/albumcovermanagerlist.cpp index 388a33ce..05e31cc3 100644 --- a/src/covermanager/albumcovermanagerlist.cpp +++ b/src/covermanager/albumcovermanagerlist.cpp @@ -20,16 +20,22 @@ #include "config.h" -#include "albumcovermanagerlist.h" - #include -#include +#include +#include +#include +#include +#include +#include #include +#include -#include "albumcovermanager.h" +#include "core/song.h" #include "collection/collectionbackend.h" #include "playlist/songmimedata.h" +#include "albumcovermanager.h" +#include "albumcovermanagerlist.h" AlbumCoverManagerList::AlbumCoverManagerList(QWidget *parent) : QListWidget(parent), manager_(nullptr) {} @@ -62,9 +68,8 @@ QMimeData *AlbumCoverManagerList::mimeData(const QList items) void AlbumCoverManagerList::dropEvent(QDropEvent *e) { - // Set movement to Static just for this dropEvent so the user can't move the - // album covers. If it's set to Static all the time then the user can't even - // drag to the playlist + // Set movement to Static just for this dropEvent so the user can't move the album covers. + // If it's set to Static all the time then the user can't even drag to the playlist QListWidget::Movement old_movement = movement(); setMovement(QListWidget::Static); QListWidget::dropEvent(e); diff --git a/src/covermanager/albumcovermanagerlist.h b/src/covermanager/albumcovermanagerlist.h index 01432051..65bab4d9 100644 --- a/src/covermanager/albumcovermanagerlist.h +++ b/src/covermanager/albumcovermanagerlist.h @@ -23,7 +23,14 @@ #include "config.h" +#include +#include +#include #include +#include +#include +#include +#include class AlbumCoverManager; @@ -32,7 +39,7 @@ class AlbumCoverManagerList : public QListWidget { public: AlbumCoverManagerList(QWidget *parent = nullptr); - void set_cover_manager(AlbumCoverManager* manager) { manager_ = manager; } + void set_cover_manager(AlbumCoverManager *manager) { manager_ = manager; } protected: QMimeData *mimeData(const QList items) const; diff --git a/src/covermanager/albumcoversearcher.cpp b/src/covermanager/albumcoversearcher.cpp index 0cade7b4..6e248872 100644 --- a/src/covermanager/albumcoversearcher.cpp +++ b/src/covermanager/albumcoversearcher.cpp @@ -20,20 +20,43 @@ #include "config.h" -#include "albumcoversearcher.h" -#include "ui_albumcoversearcher.h" +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + #include "core/application.h" -#include "core/logging.h" #include "core/utilities.h" -#include "covermanager/albumcoverfetcher.h" -#include "covermanager/albumcoverloader.h" +#include "widgets/busyindicator.h" #include "widgets/forcescrollperpixel.h" #include "widgets/groupediconview.h" - -#include -#include -#include -#include +#include "3rdparty/qocoa/qsearchfield.h" +#include "albumcoversearcher.h" +#include "albumcoverfetcher.h" +#include "albumcoverloader.h" +#include "ui_albumcoversearcher.h" const int SizeOverlayDelegate::kMargin = 4; const int SizeOverlayDelegate::kPaddingX = 3; diff --git a/src/covermanager/albumcoversearcher.h b/src/covermanager/albumcoversearcher.h index 2d504aab..203399f6 100644 --- a/src/covermanager/albumcoversearcher.h +++ b/src/covermanager/albumcoversearcher.h @@ -23,20 +23,29 @@ #include "config.h" +#include +#include +#include #include +#include +#include +#include +#include +#include #include +#include +#include #include +#include +#include -#include "covermanager/albumcoverfetcher.h" -#include "covermanager/albumcoverloaderoptions.h" - -class AlbumCoverLoader; -class Application; -class Ui_AlbumCoverSearcher; +#include "albumcoverfetcher.h" +#include "albumcoverloaderoptions.h" class QModelIndex; -class QStandardItem; -class QStandardItemModel; + +class Application; +class Ui_AlbumCoverSearcher; class SizeOverlayDelegate : public QStyledItemDelegate { public: diff --git a/src/covermanager/amazoncoverprovider.cpp b/src/covermanager/amazoncoverprovider.cpp index aa749258..f12f5cc9 100644 --- a/src/covermanager/amazoncoverprovider.cpp +++ b/src/covermanager/amazoncoverprovider.cpp @@ -21,19 +21,30 @@ #include "config.h" -#include +#include +#include #include -#include +#include +#include +#include +#include +#include #include -#include +#include #include - -#include "amazoncoverprovider.h" +#include +#include +#include +#include +#include +#include #include "core/closure.h" #include "core/logging.h" #include "core/network.h" #include "core/utilities.h" +#include "coverprovider.h" +#include "amazoncoverprovider.h" const char *AmazonCoverProvider::kUrl = "http://ecs.amazonaws.com/onca/xml"; const char *AmazonCoverProvider::kAssociateTag = "jonas052-20"; @@ -54,7 +65,6 @@ bool AmazonCoverProvider::StartSearch(const QString &artist, const QString &albu // Must be sorted by parameter name ArgList args = ArgList() << Arg("AWSAccessKeyId", QByteArray::fromBase64(kAccessKeyB64)) - //<< Arg("AWSAccessKeyId", kAccessKey) << Arg("AssociateTag", kAssociateTag) << Arg("Keywords", artist + " " + album) << Arg("Operation", "ItemSearch") @@ -78,7 +88,6 @@ bool AmazonCoverProvider::StartSearch(const QString &artist, const QString &albu // Sign the request const QByteArray data_to_sign = QString("GET\n%1\n%2\n%3").arg(url.host(), url.path(), query_items.join("&")).toUtf8(); - //const QByteArray signature(Utilities::HmacSha256(kSecretAccessKey, data_to_sign)); const QByteArray signature(Utilities::HmacSha256(QByteArray::fromBase64(kSecretAccessKeyB64), data_to_sign)); // Add the signature to the request @@ -92,24 +101,17 @@ bool AmazonCoverProvider::StartSearch(const QString &artist, const QString &albu NewClosure(reply, SIGNAL(finished()), this, SLOT(QueryFinished(QNetworkReply*, int)), reply, id); return true; + } void AmazonCoverProvider::QueryError(QNetworkReply::NetworkError error, QNetworkReply *reply, int id) { - - //qLog(Debug) << __PRETTY_FUNCTION__; - - } void AmazonCoverProvider::QueryFinished(QNetworkReply *reply, int id) { - //qLog(Debug) << __PRETTY_FUNCTION__; - reply->deleteLater(); QString data=(QString)reply->readAll(); - - //qDebug() << data; CoverSearchResults results; @@ -129,8 +131,6 @@ void AmazonCoverProvider::QueryFinished(QNetworkReply *reply, int id) { void AmazonCoverProvider::ReadItem(QXmlStreamReader *reader, CoverSearchResults *results) { - //qLog(Debug) << __PRETTY_FUNCTION__ << "name: " << reader->name() << " text: " << reader->text(); - while (!reader->atEnd()) { switch (reader->readNext()) { case QXmlStreamReader::StartElement: @@ -153,8 +153,6 @@ void AmazonCoverProvider::ReadItem(QXmlStreamReader *reader, CoverSearchResults void AmazonCoverProvider::ReadLargeImage(QXmlStreamReader *reader, CoverSearchResults *results) { - //qLog(Debug) << __PRETTY_FUNCTION__; - while (!reader->atEnd()) { switch (reader->readNext()) { case QXmlStreamReader::StartElement: diff --git a/src/covermanager/amazoncoverprovider.h b/src/covermanager/amazoncoverprovider.h index f1e39e7d..e0d185ac 100644 --- a/src/covermanager/amazoncoverprovider.h +++ b/src/covermanager/amazoncoverprovider.h @@ -24,12 +24,16 @@ #include "config.h" -#include +#include + +#include +#include #include +#include +#include #include "coverprovider.h" - -class QNetworkAccessManager; +#include "albumcoverfetcher.h" class AmazonCoverProvider : public CoverProvider { Q_OBJECT diff --git a/src/covermanager/coverexportrunnable.cpp b/src/covermanager/coverexportrunnable.cpp index ceb751b8..c2b9cd2c 100644 --- a/src/covermanager/coverexportrunnable.cpp +++ b/src/covermanager/coverexportrunnable.cpp @@ -21,12 +21,14 @@ #include "config.h" #include +#include +#include +#include #include +#include -#include "albumcoverexporter.h" #include "core/song.h" #include "core/tagreaderclient.h" - #include "coverexportrunnable.h" CoverExportRunnable::CoverExportRunnable(const AlbumCoverExport::DialogResult &dialog_result, const Song &song) @@ -36,7 +38,7 @@ void CoverExportRunnable::run() { QString cover_path = GetCoverPath(); - // manually unset? + // Manually unset? if (cover_path.isEmpty()) { EmitCoverSkipped(); } @@ -69,9 +71,7 @@ QString CoverExportRunnable::GetCoverPath() { } // Exports a single album cover using a "save QImage to file" approach. -// For performance reasons this method will be invoked only if loading -// and in memory processing of images is necessary for current settings -// which means that: +// For performance reasons this method will be invoked only if loading and in memory processing of images is necessary for current settings which means that: // - either the force size flag is being used // - or the "overwrite smaller" mode is used // In all other cases, the faster ExportCover() method will be used. @@ -123,12 +123,10 @@ void CoverExportRunnable::ProcessAndExportCover() { return; } - // we're handling overwrite as remove + copy so we need to delete the old file - // first + // we're handling overwrite as remove + copy so we need to delete the old file first if (QFile::exists(new_file) && dialog_result_.overwrite_ != AlbumCoverExport::OverwriteMode_None) { - // if the mode is "overwrite smaller" then skip the cover if a bigger one - // is already available in the folder + // if the mode is "overwrite smaller" then skip the cover if a bigger one is already available in the folder if (dialog_result_.overwrite_ == AlbumCoverExport::OverwriteMode_Smaller) { QImage existing; existing.load(new_file); diff --git a/src/covermanager/coverexportrunnable.h b/src/covermanager/coverexportrunnable.h index 1c936d53..3a4414a3 100644 --- a/src/covermanager/coverexportrunnable.h +++ b/src/covermanager/coverexportrunnable.h @@ -25,9 +25,10 @@ #include #include +#include #include "core/song.h" -#include "covermanager/albumcoverexport.h" +#include "albumcoverexport.h" class AlbumCoverExporter; diff --git a/src/covermanager/coverfromurldialog.cpp b/src/covermanager/coverfromurldialog.cpp index 4fbce2fa..5292454e 100644 --- a/src/covermanager/coverfromurldialog.cpp +++ b/src/covermanager/coverfromurldialog.cpp @@ -20,23 +20,27 @@ #include "config.h" +#include +#include #include #include #include +#include #include #include #include - -#include "coverfromurldialog.h" -#include "ui_coverfromurldialog.h" +#include #include "core/network.h" -#include "covermanager/albumcoverloader.h" +#include "widgets/busyindicator.h" +#include "coverfromurldialog.h" +#include "ui_coverfromurldialog.h" CoverFromURLDialog::CoverFromURLDialog(QWidget *parent) : QDialog(parent), ui_(new Ui_CoverFromURLDialog), network_(new NetworkAccessManager(this)) { ui_->setupUi(this); ui_->busy->hide(); + } CoverFromURLDialog::~CoverFromURLDialog() { @@ -44,6 +48,7 @@ CoverFromURLDialog::~CoverFromURLDialog() { } QImage CoverFromURLDialog::Exec() { + // reset state ui_->url->setText("");; last_image_ = QImage(); @@ -53,6 +58,7 @@ QImage CoverFromURLDialog::Exec() { exec(); return last_image_; + } void CoverFromURLDialog::accept() { @@ -63,6 +69,7 @@ void CoverFromURLDialog::accept() { QNetworkReply *reply = network_->get(network_request); connect(reply, SIGNAL(finished()), SLOT(LoadCoverFromURLFinished())); + } void CoverFromURLDialog::LoadCoverFromURLFinished() { @@ -87,5 +94,6 @@ void CoverFromURLDialog::LoadCoverFromURLFinished() { else { QMessageBox::information(this, tr("Fetching cover error"), tr("The site you requested is not an image!")); } + } diff --git a/src/covermanager/coverfromurldialog.h b/src/covermanager/coverfromurldialog.h index ef0985e5..76b1de99 100644 --- a/src/covermanager/coverfromurldialog.h +++ b/src/covermanager/coverfromurldialog.h @@ -23,11 +23,13 @@ #include "config.h" +#include +#include #include +#include #include class NetworkAccessManager; -class Song; class Ui_CoverFromURLDialog; // Controller for a dialog which fetches covers from the given URL. @@ -38,8 +40,7 @@ class CoverFromURLDialog : public QDialog { CoverFromURLDialog(QWidget *parent = nullptr); ~CoverFromURLDialog(); - // Opens the dialog. This returns an image found at the URL chosen by user - // or null image if the dialog got rejected. + // Opens the dialog. This returns an image found at the URL chosen by user or null image if the dialog got rejected. QImage Exec(); private slots: diff --git a/src/covermanager/coverprovider.cpp b/src/covermanager/coverprovider.cpp index f3acf7f1..c792bc62 100644 --- a/src/covermanager/coverprovider.cpp +++ b/src/covermanager/coverprovider.cpp @@ -20,6 +20,9 @@ #include "config.h" +#include +#include + #include "coverprovider.h" CoverProvider::CoverProvider(const QString &name, const bool &fetchall, QObject *parent) diff --git a/src/covermanager/coverprovider.h b/src/covermanager/coverprovider.h index 1d2f8d5b..30f95d60 100644 --- a/src/covermanager/coverprovider.h +++ b/src/covermanager/coverprovider.h @@ -23,18 +23,16 @@ #include "config.h" -#include - -#include "albumcoverfetcher.h" -#include "coverproviders.h" +#include #include +#include +#include -class QNetworkReply; +struct CoverSearchResult; -// Each implementation of this interface downloads covers from one online -// service. There are no limitations on what this service might be - last.fm, -// Amazon, Google Images - you name it. +// Each implementation of this interface downloads covers from one online service. +// There are no limitations on what this service might be - last.fm, Amazon, Google Images - you name it. class CoverProvider : public QObject { Q_OBJECT @@ -45,9 +43,9 @@ public: QString name() const { return name_; } bool fetchall() const { return fetchall_; } - // Starts searching for covers matching the given query text. Returns true - // if the query has been started, or false if an error occurred. The provider - // should remember the ID and emit it along with the result when it finishes. + // Starts searching for covers matching the given query text. + // Returns true if the query has been started, or false if an error occurred. + // The provider should remember the ID and emit it along with the result when it finishes. virtual bool StartSearch(const QString &artist, const QString &album, int id) = 0; virtual void CancelSearch(int id) {} diff --git a/src/covermanager/coverproviders.cpp b/src/covermanager/coverproviders.cpp index e177a3e1..0f96a7ed 100644 --- a/src/covermanager/coverproviders.cpp +++ b/src/covermanager/coverproviders.cpp @@ -20,10 +20,14 @@ #include "config.h" -#include "coverprovider.h" -#include "coverproviders.h" +#include +#include +#include +#include #include "core/logging.h" +#include "coverprovider.h" +#include "coverproviders.h" CoverProviders::CoverProviders(QObject *parent) : QObject(parent) {} @@ -43,8 +47,7 @@ void CoverProviders::RemoveProvider(CoverProvider *provider) { if (!provider) return; - // It's not safe to dereference provider at this pointbecause it might have - // already been destroyed. + // It's not safe to dereference provider at this pointbecause it might have already been destroyed. QString name; diff --git a/src/covermanager/coverproviders.h b/src/covermanager/coverproviders.h index ab86fcec..6d7dbb9a 100644 --- a/src/covermanager/coverproviders.h +++ b/src/covermanager/coverproviders.h @@ -23,11 +23,16 @@ #include "config.h" -#include -#include -#include +#include + +#include +#include +#include +#include +#include +#include +#include -class AlbumCoverFetcherSearch; class CoverProvider; // This is a repository for cover providers. diff --git a/src/covermanager/coversearchstatistics.cpp b/src/covermanager/coversearchstatistics.cpp index 3994b2a5..5e2a90f8 100644 --- a/src/covermanager/coversearchstatistics.cpp +++ b/src/covermanager/coversearchstatistics.cpp @@ -20,6 +20,9 @@ #include "config.h" +#include +#include + #include "coversearchstatistics.h" CoverSearchStatistics::CoverSearchStatistics() @@ -35,10 +38,10 @@ CoverSearchStatistics &CoverSearchStatistics::operator +=(const CoverSearchStati network_requests_made_ += other.network_requests_made_; bytes_transferred_ += other.bytes_transferred_; - for (const QString& key : other.chosen_images_by_provider_.keys()) { + for (const QString &key : other.chosen_images_by_provider_.keys()) { chosen_images_by_provider_[key] += other.chosen_images_by_provider_[key]; } - for (const QString& key : other.total_images_by_provider_.keys()) { + for (const QString &key : other.total_images_by_provider_.keys()) { total_images_by_provider_[key] += other.total_images_by_provider_[key]; } diff --git a/src/covermanager/coversearchstatistics.h b/src/covermanager/coversearchstatistics.h index 35a771f0..a4150911 100644 --- a/src/covermanager/coversearchstatistics.h +++ b/src/covermanager/coversearchstatistics.h @@ -23,6 +23,7 @@ #include "config.h" +#include #include #include diff --git a/src/covermanager/coversearchstatisticsdialog.cpp b/src/covermanager/coversearchstatisticsdialog.cpp index 9cf2403b..19989406 100644 --- a/src/covermanager/coversearchstatisticsdialog.cpp +++ b/src/covermanager/coversearchstatisticsdialog.cpp @@ -20,8 +20,18 @@ #include "config.h" -#include "coversearchstatisticsdialog.h" +#include +#include +#include +#include +#include +#include +#include +#include + #include "core/utilities.h" +#include "coversearchstatistics.h" +#include "coversearchstatisticsdialog.h" #include "ui_coversearchstatisticsdialog.h" CoverSearchStatisticsDialog::CoverSearchStatisticsDialog(QWidget *parent) @@ -94,4 +104,3 @@ void CoverSearchStatisticsDialog::AddLine(const QString &label, const QString &v void CoverSearchStatisticsDialog::AddSpacer() { details_layout_->addSpacing(20); } - diff --git a/src/covermanager/coversearchstatisticsdialog.h b/src/covermanager/coversearchstatisticsdialog.h index 75e38fa5..ee8048ca 100644 --- a/src/covermanager/coversearchstatisticsdialog.h +++ b/src/covermanager/coversearchstatisticsdialog.h @@ -23,13 +23,14 @@ #include "config.h" +#include #include - -#include "coversearchstatistics.h" +#include +#include +#include class Ui_CoverSearchStatisticsDialog; - -class QVBoxLayout; +struct CoverSearchStatistics; class CoverSearchStatisticsDialog : public QDialog { Q_OBJECT diff --git a/src/covermanager/currentartloader.cpp b/src/covermanager/currentartloader.cpp index 12ea4086..c112ef7a 100644 --- a/src/covermanager/currentartloader.cpp +++ b/src/covermanager/currentartloader.cpp @@ -20,15 +20,20 @@ #include "config.h" -#include -#include -#include +#include + +#include +#include +#include +#include +#include +#include +#include -#include "currentartloader.h" #include "core/application.h" -#include "core/iconloader.h" -#include "covermanager/albumcoverloader.h" #include "playlist/playlistmanager.h" +#include "albumcoverloader.h" +#include "currentartloader.h" CurrentArtLoader::CurrentArtLoader(Application *app, QObject *parent) : QObject(parent), @@ -69,8 +74,7 @@ void CurrentArtLoader::TempArtLoaded(quint64 id, const QImage &image) { temp_art_->open(); image.save(temp_art_->fileName(), "JPEG"); - // Scale the image down to make a thumbnail. It's a bit crap doing it here - // since it's the GUI thread, but the alternative is hard. + // Scale the image down to make a thumbnail. It's a bit crap doing it here since it's the GUI thread, but the alternative is hard. temp_art_thumbnail_.reset(new QTemporaryFile(temp_file_pattern_)); temp_art_thumbnail_->open(); temp_art_thumbnail_->setAutoRemove(true); diff --git a/src/covermanager/currentartloader.h b/src/covermanager/currentartloader.h index 8eb65931..2dd990af 100644 --- a/src/covermanager/currentartloader.h +++ b/src/covermanager/currentartloader.h @@ -25,16 +25,17 @@ #include +#include #include +#include +#include +#include #include "core/song.h" -#include "covermanager/albumcoverloaderoptions.h" +#include "albumcoverloaderoptions.h" class Application; -class QImage; -class QTemporaryFile; - class CurrentArtLoader : public QObject { Q_OBJECT diff --git a/src/covermanager/discogscoverprovider.cpp b/src/covermanager/discogscoverprovider.cpp index a9394f7f..6a7bb564 100644 --- a/src/covermanager/discogscoverprovider.cpp +++ b/src/covermanager/discogscoverprovider.cpp @@ -21,24 +21,32 @@ #include "config.h" +#include #include -#include -#include #include +#include +#include +#include +#include #include +#include #include -#include -#include +#include #include +#include +#include +#include #include #include - -#include "discogscoverprovider.h" +#include #include "core/closure.h" #include "core/logging.h" #include "core/network.h" #include "core/utilities.h" +#include "coverprovider.h" +#include "albumcoverfetcher.h" +#include "discogscoverprovider.h" const char *DiscogsCoverProvider::kUrlSearch = "https://api.discogs.com/database/search"; const char *DiscogsCoverProvider::kUrlReleases = "https://api.discogs.com/releases"; diff --git a/src/covermanager/discogscoverprovider.h b/src/covermanager/discogscoverprovider.h index 91c5fb05..f25959c5 100644 --- a/src/covermanager/discogscoverprovider.h +++ b/src/covermanager/discogscoverprovider.h @@ -24,20 +24,25 @@ #include "config.h" -#include +#include + +#include +#include +#include +#include +#include #include #include "coverprovider.h" - -class QNetworkAccessManager; +#include "albumcoverfetcher.h" // This struct represents a single search-for-cover request. It identifies and describes the request. struct DiscogsCoverSearchContext { - // the unique request identifier + // The unique request identifier int id; - // the search query + // The search query QString artist; QString album; QString title; @@ -47,12 +52,11 @@ struct DiscogsCoverSearchContext { }; Q_DECLARE_METATYPE(DiscogsCoverSearchContext) -// This struct represents a single release request. It identifies and describes -// the request. +// This struct represents a single release request. It identifies and describes the request. struct DiscogsCoverReleaseContext { - int id; // the unique request identifier - int s_id; // the search request identifier + int id; // The unique request identifier + int s_id; // The search request identifier QString resource_url; }; diff --git a/src/covermanager/lastfmcompat.cpp b/src/covermanager/lastfmcompat.cpp index c37698d4..47bff6cb 100644 --- a/src/covermanager/lastfmcompat.cpp +++ b/src/covermanager/lastfmcompat.cpp @@ -20,8 +20,13 @@ #include "config.h" +#include + +#include +#include +#include + #include "lastfmcompat.h" -#include "core/logging.h" namespace lastfm { namespace compat { diff --git a/src/covermanager/lastfmcompat.h b/src/covermanager/lastfmcompat.h index ef050a6d..25299642 100644 --- a/src/covermanager/lastfmcompat.h +++ b/src/covermanager/lastfmcompat.h @@ -23,16 +23,22 @@ #include "config.h" +#include + +#include +#include +#include + #ifdef HAVE_LIBLASTFM1 -#include -#include -#include -#include +# include +# include +# include +# include #else -#include -#include -#include -#include +# include +# include +# include +# include #endif namespace lastfm { diff --git a/src/covermanager/lastfmcoverprovider.cpp b/src/covermanager/lastfmcoverprovider.cpp index d95ed188..0639fbc2 100644 --- a/src/covermanager/lastfmcoverprovider.cpp +++ b/src/covermanager/lastfmcoverprovider.cpp @@ -18,29 +18,22 @@ * */ -/* - -Application name Strawberry Music Player -API key 211990b4c96782c05d1536e7219eb56e -Shared secret 80fd738f49596e9709b1bf9319c444a8 -Registered to jonaskvinge - -*/ - #include "config.h" +#include +#include +#include +#include +#include +#include #include -#include - -#include "lastfmcoverprovider.h" -#include "lastfmcompat.h" - -#include "coverprovider.h" -#include "albumcoverfetcher.h" #include "core/closure.h" #include "core/network.h" -#include "core/logging.h" +#include "coverprovider.h" +#include "albumcoverfetcher.h" +#include "lastfmcompat.h" +#include "lastfmcoverprovider.h" const char *LastFmCoverProvider::kApiKey = "211990b4c96782c05d1536e7219eb56e"; const char *LastFmCoverProvider::kSecret = "80fd738f49596e9709b1bf9319c444a8"; diff --git a/src/covermanager/lastfmcoverprovider.h b/src/covermanager/lastfmcoverprovider.h index 46aa93e5..9f6482d5 100644 --- a/src/covermanager/lastfmcoverprovider.h +++ b/src/covermanager/lastfmcoverprovider.h @@ -23,18 +23,16 @@ #include "config.h" -#include -#include +#include + +#include +#include +#include +#include +#include -#include "albumcoverfetcher.h" #include "coverprovider.h" -#include -#include - -class QNetworkAccessManager; -class QNetworkReply; - // A built-in cover provider which fetches covers from last.fm. class LastFmCoverProvider : public CoverProvider { Q_OBJECT diff --git a/src/covermanager/musicbrainzcoverprovider.cpp b/src/covermanager/musicbrainzcoverprovider.cpp index c899a712..ad23220e 100644 --- a/src/covermanager/musicbrainzcoverprovider.cpp +++ b/src/covermanager/musicbrainzcoverprovider.cpp @@ -23,13 +23,21 @@ #include #include -#include +#include +#include +#include +#include +#include #include +#include +#include +#include +#include #include "core/closure.h" #include "core/network.h" -#include "core/logging.h" - +#include "albumcoverfetcher.h" +#include "coverprovider.h" #include "musicbrainzcoverprovider.h" using std::mem_fun; diff --git a/src/covermanager/musicbrainzcoverprovider.h b/src/covermanager/musicbrainzcoverprovider.h index ce0d9860..4f103fa2 100644 --- a/src/covermanager/musicbrainzcoverprovider.h +++ b/src/covermanager/musicbrainzcoverprovider.h @@ -23,13 +23,17 @@ #include "config.h" +#include + +#include +#include #include +#include +#include +#include #include "coverprovider.h" -class QNetworkAccessManager; -class QNetworkReply; - class MusicbrainzCoverProvider : public CoverProvider { Q_OBJECT public: diff --git a/src/dbus/metatypes.h b/src/dbus/metatypes.h index 2a09e698..37e528b6 100644 --- a/src/dbus/metatypes.h +++ b/src/dbus/metatypes.h @@ -2,6 +2,10 @@ #define DBUS_METATYPES_H #include +#include +#include +#include +#include #include Q_DECLARE_METATYPE(QList) diff --git a/src/device/afcdevice.cpp b/src/device/afcdevice.cpp index be7ce43b..761a542e 100644 --- a/src/device/afcdevice.cpp +++ b/src/device/afcdevice.cpp @@ -20,16 +20,20 @@ #include "config.h" +#include +#include +#include +#include +#include + +#include "core/application.h" +#include "core/utilities.h" #include "afcdevice.h" #include "afcfile.h" #include "afctransfer.h" #include "devicemanager.h" #include "gpodloader.h" #include "imobiledeviceconnection.h" -#include "core/application.h" -#include "core/utilities.h" - -#include AfcDevice::AfcDevice(const QUrl &url, DeviceLister* lister, const QString &unique_id, DeviceManager *manager, Application *app, int database_id, bool first_time) : GPodDevice(url, lister, unique_id, manager, app, database_id, first_time), transfer_(NULL) @@ -42,8 +46,7 @@ AfcDevice::~AfcDevice() { void AfcDevice::Init() { - // Make a new temporary directory for the iTunesDB. We copy it off the iPod - // so that libgpod can have a local directory to use. + // Make a new temporary directory for the iTunesDB. We copy it off the iPod so that libgpod can have a local directory to use. local_path_ = Utilities::MakeTempDir(); InitBackendDirectory(local_path_, first_time_, false); model_->Init(); @@ -69,10 +72,9 @@ void AfcDevice::CopyFinished(bool success) { } // Now load the songs from the local database - loader_ = new GPodLoader(local_path_, app_->task_manager(), backend_, - shared_from_this()); + loader_ = new GPodLoader(local_path_, app_->task_manager(), backend_, shared_from_this()); loader_->set_music_path_prefix("afc://" + url_.host()); - loader_->set_song_type(Song::Type_Stream); + //loader_->set_song_type(Song::Type_Stream); loader_->moveToThread(loader_thread_); connect(loader_, SIGNAL(Error(QString)), SIGNAL(Error(QString))); diff --git a/src/device/afcdevice.h b/src/device/afcdevice.h index 265f54a4..35b99f02 100644 --- a/src/device/afcdevice.h +++ b/src/device/afcdevice.h @@ -23,17 +23,18 @@ #include "config.h" -#include "gpoddevice.h" - -#include -#include - -#include - #include +#include +#include +#include +#include +#include +#include + +#include "gpoddevice.h" + class AfcTransfer; -class GPodLoader; class iMobileDeviceConnection; class AfcDevice : public GPodDevice { @@ -64,7 +65,7 @@ private: private: AfcTransfer *transfer_; - boost::scoped_ptr connection_; + std::shared_ptr connection_; QString local_path_; }; diff --git a/src/device/afcfile.cpp b/src/device/afcfile.cpp index 5280dae7..71300744 100644 --- a/src/device/afcfile.cpp +++ b/src/device/afcfile.cpp @@ -1,10 +1,15 @@ #include "config.h" +#include + +#include +#include +#include +#include + #include "afcfile.h" #include "imobiledeviceconnection.h" -#include - AfcFile::AfcFile(iMobileDeviceConnection *connection, const QString &path, QObject *parent) : QIODevice(parent), connection_(connection), @@ -34,8 +39,7 @@ bool AfcFile::open(QIODevice::OpenMode mode) { default: afc_mode = AFC_FOPEN_RW; } - afc_error_t err = afc_file_open( - connection_->afc(), path_.toUtf8().constData(), afc_mode, &handle_); + afc_error_t err = afc_file_open(connection_->afc(), path_.toUtf8().constData(), afc_mode, &handle_); if (err != AFC_E_SUCCESS) { return false; } diff --git a/src/device/afcfile.h b/src/device/afcfile.h index 36ef4365..6c4dec52 100644 --- a/src/device/afcfile.h +++ b/src/device/afcfile.h @@ -4,11 +4,13 @@ #include "config.h" #include - -#include - #include +#include +#include +#include +#include + class iMobileDeviceConnection; class AfcFile : public QIODevice { diff --git a/src/device/afctransfer.cpp b/src/device/afctransfer.cpp index cfbe4b63..42acb69d 100644 --- a/src/device/afctransfer.cpp +++ b/src/device/afctransfer.cpp @@ -20,26 +20,29 @@ #include "config.h" +#include + +#include +#include +#include +#include +#include + +#include "core/utilities.h" +#include "core/taskmanager.h" #include "afcfile.h" #include "afctransfer.h" #include "imobiledeviceconnection.h" -#include "core/taskmanager.h" -#include "core/utilities.h" -#include -#include - -#include - -AfcTransfer::AfcTransfer(const QString &uuid, const QString &local_destination, TaskManager *task_manager, boost::shared_ptr device) - : QObject(NULL), device_(device), task_manager_(task_manager), uuid_(uuid), local_destination_(local_destination) -{ +AfcTransfer::AfcTransfer(const QString &uuid, const QString &local_destination, TaskManager *task_manager, std::shared_ptr device) + : QObject(nullptr), device_(device), task_manager_(task_manager), uuid_(uuid), local_destination_(local_destination) { original_thread_ = thread(); important_directories_ << "/iTunes_Control/Artwork"; important_directories_ << "/iTunes_Control/Device"; important_directories_ << "/iTunes_Control/iTunes"; + } AfcTransfer::~AfcTransfer() { diff --git a/src/device/afctransfer.h b/src/device/afctransfer.h index 1fff548f..2659d61d 100644 --- a/src/device/afctransfer.h +++ b/src/device/afctransfer.h @@ -23,22 +23,23 @@ #include "config.h" +#include + #include +#include +#include +#include #include -#include - +class TaskManager; class ConnectedDevice; class iMobileDeviceConnection; -class TaskManager; - -class QIODevice; class AfcTransfer : public QObject { Q_OBJECT public: - AfcTransfer(const QString &uuid, const QString &local_destination, TaskManager *task_manager, boost::shared_ptr device); + AfcTransfer(const QString &uuid, const QString &local_destination, TaskManager *task_manager, std::shared_ptr device); ~AfcTransfer(); bool CopyToDevice(iMobileDeviceConnection *connection); @@ -57,14 +58,14 @@ private: bool CopyFileToDevice(iMobileDeviceConnection *c, const QString &path); private: - boost::shared_ptr device_; QThread *original_thread_; - + std::shared_ptr device_; TaskManager *task_manager_; QString uuid_; QString local_destination_; QStringList important_directories_; + }; #endif // AFCTRANSFER_H diff --git a/src/device/cddadevice.cpp b/src/device/cddadevice.cpp index d7f4abc2..135d5763 100644 --- a/src/device/cddadevice.cpp +++ b/src/device/cddadevice.cpp @@ -20,15 +20,18 @@ #include "config.h" -#include +#include +#include -#include "core/logging.h" - -#include "collection/collectionbackend.h" #include "collection/collectionmodel.h" - +#include "cddasongloader.h" +#include "connecteddevice.h" #include "cddadevice.h" +class Application; +class DeviceLister; +class DeviceManager; + CddaDevice::CddaDevice(const QUrl &url, DeviceLister *lister, const QString &unique_id, DeviceManager *manager, Application *app, int database_id, bool first_time) : ConnectedDevice(url, lister, unique_id, manager, app, database_id, first_time), cdda_song_loader_(url) { diff --git a/src/device/cddadevice.h b/src/device/cddadevice.h index a5ffd8bd..1988649a 100644 --- a/src/device/cddadevice.h +++ b/src/device/cddadevice.h @@ -23,16 +23,25 @@ #include "config.h" -#include +#include + +#include +#include +#include +#include // These must come after Qt includes #include #include +#include "core/song.h" +#include "core/musicstorage.h" #include "cddasongloader.h" #include "connecteddevice.h" -#include "core/song.h" -#include "musicbrainz/musicbrainzclient.h" + +class Application; +class DeviceLister; +class DeviceManager; class CddaDevice : public ConnectedDevice { Q_OBJECT diff --git a/src/device/cddalister.cpp b/src/device/cddalister.cpp index 63175c83..7fa20364 100644 --- a/src/device/cddalister.cpp +++ b/src/device/cddalister.cpp @@ -18,19 +18,24 @@ * */ -#include "config.h" +#include +#include #include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include // This must come after Qt includes #include +#include #include "cddalister.h" #include "core/logging.h" -#include "core/song.h" QStringList CddaLister::DeviceUniqueIDs() { return devices_list_; } diff --git a/src/device/cddalister.h b/src/device/cddalister.h index da611054..f90208e8 100644 --- a/src/device/cddalister.h +++ b/src/device/cddalister.h @@ -21,9 +21,17 @@ #ifndef CDDALISTER_H #define CDDALISTER_H -#include "config.h" +#include +#include + +#include +#include +#include +#include +#include #include +#include #include "devicelister.h" diff --git a/src/device/cddasongloader.cpp b/src/device/cddasongloader.cpp index c585399e..4ad9968d 100644 --- a/src/device/cddasongloader.cpp +++ b/src/device/cddasongloader.cpp @@ -20,11 +20,24 @@ #include "config.h" +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include + +#include #include #include #include "cddasongloader.h" - #include "core/logging.h" #include "core/timeconstants.h" diff --git a/src/device/cddasongloader.h b/src/device/cddasongloader.h index 150e46a6..b04a9c7d 100644 --- a/src/device/cddasongloader.h +++ b/src/device/cddasongloader.h @@ -23,19 +23,23 @@ #include "config.h" -#include +#include + #include +#include +#include #include -// These must come after Qt includes (issue 3247) +// These must come after Qt includes +#include #include +#include #include #include "core/song.h" #include "musicbrainz/musicbrainzclient.h" -// This class provides a (hopefully) nice, high level interface to get CD -// information and load tracks +// This class provides a (hopefully) nice, high level interface to get CD information and load tracks class CddaSongLoader : public QObject { Q_OBJECT @@ -46,8 +50,7 @@ class CddaSongLoader : public QObject { QObject *parent = nullptr); ~CddaSongLoader(); - // Load songs. - // Signals declared below will be emitted anytime new information will be available. + // Load songs. Signals declared below will be emitted anytime new information will be available. void LoadSongs(); bool HasChanged(); diff --git a/src/device/connecteddevice.cpp b/src/device/connecteddevice.cpp index 98f1c698..14329177 100644 --- a/src/device/connecteddevice.cpp +++ b/src/device/connecteddevice.cpp @@ -18,19 +18,22 @@ * */ -#include "config.h" +#include +#include +#include +#include +#include +#include +#include "core/logging.h" +#include "core/application.h" +#include "core/database.h" +#include "collection/collectionbackend.h" +#include "collection/collectionmodel.h" +#include "collection/directory.h" #include "connecteddevice.h" #include "devicelister.h" #include "devicemanager.h" -#include "core/application.h" -#include "core/database.h" -#include "core/logging.h" -#include "collection/collection.h" -#include "collection/collectionbackend.h" -#include "collection/collectionmodel.h" - -#include ConnectedDevice::ConnectedDevice(const QUrl &url, DeviceLister *lister, const QString &unique_id, DeviceManager *manager, Application *app, int database_id, bool first_time) : QObject(manager), @@ -73,10 +76,10 @@ void ConnectedDevice::InitBackendDirectory(const QString &mount_point, bool firs } else { if (rewrite_path) { - // This is a bit of a hack. The device might not be mounted at the same - // path each time, so if it's different we have to munge all the paths in - // the database to fix it. This can be done entirely in sqlite so it's - // relatively fast... + // This is a bit of a hack. + // The device might not be mounted at the same path each time, + // so if it's different we have to munge all the paths in the database to fix it. + // This can be done entirely in sqlite so it's relatively fast... // Get the directory it was mounted at last time. Devices only have one directory (the root). Directory dir = backend_->GetAllDirectories()[0]; diff --git a/src/device/connecteddevice.h b/src/device/connecteddevice.h index 2aac69e9..2d6fd7bd 100644 --- a/src/device/connecteddevice.h +++ b/src/device/connecteddevice.h @@ -24,20 +24,20 @@ #include "config.h" #include +#include #include -#include +#include #include #include "core/musicstorage.h" #include "core/song.h" class Application; -class Database; -class DeviceLister; -class DeviceManager; class CollectionBackend; class CollectionModel; +class DeviceLister; +class DeviceManager; class ConnectedDevice : public QObject, public virtual MusicStorage, @@ -49,8 +49,8 @@ class ConnectedDevice : public QObject, ~ConnectedDevice(); virtual void Init() = 0; - // For some devices (e.g. CD devices) we don't have callbacks to be notified - // when something change: we can call this method to refresh device's state + // For some devices (e.g. CD devices) we don't have callbacks to be notified when something change: + // we can call this method to refresh device's state virtual void Refresh() {} virtual TranscodeMode GetTranscodeMode() const; diff --git a/src/device/devicedatabasebackend.cpp b/src/device/devicedatabasebackend.cpp index 1f2b9171..07111db6 100644 --- a/src/device/devicedatabasebackend.cpp +++ b/src/device/devicedatabasebackend.cpp @@ -18,15 +18,21 @@ * */ -#include "config.h" +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include -#include "devicedatabasebackend.h" #include "core/database.h" #include "core/scopedtransaction.h" - -#include -#include -#include +#include "devicedatabasebackend.h" const int DeviceDatabaseBackend::kDeviceSchemaVersion = 0; diff --git a/src/device/devicedatabasebackend.h b/src/device/devicedatabasebackend.h index 5992ac10..59cd4be5 100644 --- a/src/device/devicedatabasebackend.h +++ b/src/device/devicedatabasebackend.h @@ -23,10 +23,15 @@ #include "config.h" +#include #include +#include +#include +#include +#include -#include "core/musicstorage.h" #include "core/song.h" +#include "core/musicstorage.h" class Database; diff --git a/src/device/devicekitlister.cpp b/src/device/devicekitlister.cpp index 73e6a34a..980d055d 100644 --- a/src/device/devicekitlister.cpp +++ b/src/device/devicekitlister.cpp @@ -18,22 +18,27 @@ * */ -#include - -#include - #include "config.h" -#include "devicekitlister.h" -#include "filesystemdevice.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + #include "core/logging.h" #include "core/utilities.h" #include "dbus/udisks.h" #include "dbus/udisksdevice.h" - -#ifdef HAVE_LIBGPOD -#include "gpoddevice.h" -#endif +#include "devicekitlister.h" DeviceKitLister::DeviceKitLister() {} DeviceKitLister::~DeviceKitLister() {} diff --git a/src/device/devicekitlister.h b/src/device/devicekitlister.h index 1d8d2b7e..09c2d560 100644 --- a/src/device/devicekitlister.h +++ b/src/device/devicekitlister.h @@ -24,14 +24,25 @@ #include "config.h" #include +#include +#include +#include #include +#include +#include +#include #include +#include +#ifdef HAVE_DBUS +# include +#endif +#include +#include #include "devicelister.h" class OrgFreedesktopUDisksInterface; - class QDBusObjectPath; class DeviceKitLister : public DeviceLister { diff --git a/src/device/devicelister.cpp b/src/device/devicelister.cpp index a8c3c2eb..337b7763 100644 --- a/src/device/devicelister.cpp +++ b/src/device/devicelister.cpp @@ -20,18 +20,21 @@ #include "config.h" +#ifdef HAVE_LIBGPOD +# include +#endif + +#include #include #include +#include +#include #include -#include -#include +#include +#include #include "devicelister.h" -#ifdef HAVE_LIBGPOD -#include -#endif - DeviceLister::DeviceLister() : thread_(nullptr) {} DeviceLister::~DeviceLister() { diff --git a/src/device/devicelister.h b/src/device/devicelister.h index 6ac93b1e..f04c966f 100644 --- a/src/device/devicelister.h +++ b/src/device/devicelister.h @@ -23,11 +23,16 @@ #include "config.h" -#include -#include +#include -class ConnectedDevice; -class DeviceManager; +#include +#include +#include +#include +#include +#include +#include +#include class DeviceLister : public QObject { Q_OBJECT @@ -36,12 +41,10 @@ class DeviceLister : public QObject { DeviceLister(); virtual ~DeviceLister(); - // Tries to start the thread and initialise the engine. This object will be - // moved to the new thread. + // Tries to start the thread and initialise the engine. This object will be moved to the new thread. void Start(); - // If two listers know about the same device, then the metadata will get - // taken from the one with the highest priority. + // If two listers know about the same device, then the metadata will get taken from the one with the highest priority. virtual int priority() const { return 100; } // Query information about the devices that are available. Must be thread-safe. @@ -87,7 +90,7 @@ signals: QStringList GuessIconForModel(const QString &vendor, const QString &model); protected: - QThread* thread_; + QThread *thread_; int next_mount_request_id_; private slots: diff --git a/src/device/devicemanager.cpp b/src/device/devicemanager.cpp index 230a7c9f..cc7aea8e 100644 --- a/src/device/devicemanager.cpp +++ b/src/device/devicemanager.cpp @@ -21,54 +21,71 @@ #include "config.h" #include +#include +#include #include +#include +#include +#include +#include +#include +#include #include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include #include +#include +#include +#include +#include +#include +#include +#include #include "devicemanager.h" -#include "devicedatabasebackend.h" -#include "devicekitlister.h" -#include "devicestatefiltermodel.h" -#include "filesystemdevice.h" #include "core/application.h" #include "core/concurrentrun.h" #include "core/database.h" +#include "core/iconloader.h" #include "core/logging.h" #include "core/musicstorage.h" #include "core/taskmanager.h" #include "core/utilities.h" -#include "core/iconloader.h" +#include "filesystemdevice.h" +#include "connecteddevice.h" +#include "devicelister.h" +#include "devicedatabasebackend.h" +#include "devicekitlister.h" +#include "devicestatefiltermodel.h" #if defined(HAVE_AUDIOCD) && defined(HAVE_GSTREAMER) -#include "cddalister.h" -#include "cddadevice.h" +# include "cddalister.h" +# include "cddadevice.h" #endif #if defined(Q_OS_DARWIN) and defined(HAVE_LIBMTP) -#include "macdevicelister.h" +# include "macdevicelister.h" #endif #ifdef HAVE_LIBGPOD -#include "gpoddevice.h" +# include "gpoddevice.h" #endif #ifdef HAVE_GIO -#include "giolister.h" +# include "giolister.h" #endif #ifdef HAVE_IMOBILEDEVICE # include "afcdevice.h" # include "ilister.h" #endif #ifdef HAVE_LIBMTP -#include "mtpdevice.h" +# include "mtpdevice.h" #endif #ifdef HAVE_UDISKS2 -#include "udisks2lister.h" +# include "udisks2lister.h" #endif using std::bind; @@ -195,8 +212,7 @@ DeviceManager::DeviceManager(Application *app, QObject *parent) backend_->moveToThread(app_->database()->thread()); backend_->Init(app_->database()); - // This reads from the database and contends on the database mutex, which can - // be very slow on startup. + // This reads from the database and contends on the database mutex, which can be very slow on startup. ConcurrentRun::Run(&thread_pool_, bind(&DeviceManager::LoadAllDevices, this)); // This proxy model only shows connected devices @@ -445,8 +461,7 @@ void DeviceManager::PhysicalDeviceAdded(const QString &id) { DeviceInfo &info = devices_[i]; info.backends_ << DeviceInfo::Backend(lister, id); - // If the user hasn't saved the device in the DB yet then overwrite the - // device's name and icon etc. + // If the user hasn't saved the device in the DB yet then overwrite the device's name and icon etc. if (info.database_id_ == -1 && info.BestBackend()->lister_ == lister) { info.friendly_name_ = lister->MakeFriendlyName(id); info.size_ = lister->DeviceCapacity(id); @@ -578,9 +593,8 @@ std::shared_ptr DeviceManager::Connect(int row) { break; } - // If we get here it means that this URL scheme wasn't supported. If it - // was "ipod" or "mtp" then the user compiled out support and the device - // won't work properly. + // If we get here it means that this URL scheme wasn't supported. + // If it was "ipod" or "mtp" then the user compiled out support and the device won't work properly. if (url.scheme() == "mtp" || url.scheme() == "gphoto2") { if (QMessageBox::critical(nullptr, tr("This device will not work properly"), tr("This is an MTP device, but you compiled Strawberry without libmtp support.") + " " + @@ -636,8 +650,7 @@ std::shared_ptr DeviceManager::Connect(int row) { } -std::shared_ptr DeviceManager::GetConnectedDevice(int row) - const { +std::shared_ptr DeviceManager::GetConnectedDevice(int row) const { return devices_[row].device_; } @@ -686,8 +699,7 @@ void DeviceManager::Forget(int row) { endRemoveRows(); } else { - // It's still attached, set the name and icon back to what they were - // originally + // It's still attached, set the name and icon back to what they were originally const QString id = info.BestBackend()->unique_id_; info.friendly_name_ = info.BestBackend()->lister_->MakeFriendlyName(id); diff --git a/src/device/devicemanager.h b/src/device/devicemanager.h index ae1435e8..315231bb 100644 --- a/src/device/devicemanager.h +++ b/src/device/devicemanager.h @@ -25,20 +25,31 @@ #include -#include -#include +#include +#include +#include #include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include -#include "devicedatabasebackend.h" - +#include "core/song.h" +#include "core/musicstorage.h" #include "collection/collectionmodel.h" +#include "devicedatabasebackend.h" class Application; class ConnectedDevice; -class Database; class DeviceLister; class DeviceStateFilterModel; -class TaskManager; class DeviceManager : public QAbstractListModel { Q_OBJECT @@ -124,8 +135,7 @@ signals: DeviceInfo(); // A device can be discovered in different ways (devicekit, gio, etc.) - // Sometimes the same device is discovered more than once. In this case - // the device will have multiple "backends". + // Sometimes the same device is discovered more than once. In this case the device will have multiple "backends". struct Backend { Backend(DeviceLister *lister = nullptr, const QString &id = QString()) : lister_(lister), unique_id_(id) {} diff --git a/src/device/deviceproperties.cpp b/src/device/deviceproperties.cpp index 5278b906..3a64bf02 100644 --- a/src/device/deviceproperties.cpp +++ b/src/device/deviceproperties.cpp @@ -20,22 +20,45 @@ #include "config.h" -#include "deviceproperties.h" -#include "ui_deviceproperties.h" - #include #include -#include -#include +#include +#include +#include +#include #include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "core/closure.h" +#include "core/iconloader.h" +#include "core/musicstorage.h" +#include "widgets/freespacebar.h" #include "connecteddevice.h" #include "devicelister.h" #include "devicemanager.h" -#include "core/utilities.h" -#include "core/iconloader.h" +#include "deviceproperties.h" #include "transcoder/transcoder.h" +#include "ui_deviceproperties.h" DeviceProperties::DeviceProperties(QWidget *parent) : QDialog(parent), @@ -182,12 +205,10 @@ void DeviceProperties::UpdateFormats() { QString id = index_.data(DeviceManager::Role_UniqueId).toString(); DeviceLister *lister = manager_->GetLister(index_.row()); - std::shared_ptr device = - manager_->GetConnectedDevice(index_.row()); + std::shared_ptr device = manager_->GetConnectedDevice(index_.row()); // Transcode mode - MusicStorage::TranscodeMode mode = MusicStorage::TranscodeMode( - index_.data(DeviceManager::Role_TranscodeMode).toInt()); + MusicStorage::TranscodeMode mode = MusicStorage::TranscodeMode(index_.data(DeviceManager::Role_TranscodeMode).toInt()); switch (mode) { case MusicStorage::Transcode_Always: ui_->transcode_all->setChecked(true); @@ -288,8 +309,8 @@ void DeviceProperties::UpdateFormatsFinished(QFuture future) { // Set the format combobox item TranscoderPreset preset = Transcoder::PresetForFileType(Song::FileType(index_.data(DeviceManager::Role_TranscodeFormat).toInt())); if (preset.type_ == Song::Type_Unknown) { - // The user hasn't chosen a format for this device yet, so work our way down - // a list of some preferred formats, picking the first one that is supported + // The user hasn't chosen a format for this device yet, + // so work our way down a list of some preferred formats, picking the first one that is supported preset = Transcoder::PresetForFileType(Transcoder::PickBestFormat(supported_formats_)); } ui_->transcode_format->setCurrentIndex(ui_->transcode_format->findText(preset.name_)); diff --git a/src/device/deviceproperties.h b/src/device/deviceproperties.h index 486469a3..f2d81858 100644 --- a/src/device/deviceproperties.h +++ b/src/device/deviceproperties.h @@ -23,9 +23,16 @@ #include "config.h" +#include + +#include #include +#include #include +#include #include +#include +#include #include "core/song.h" diff --git a/src/device/devicestatefiltermodel.cpp b/src/device/devicestatefiltermodel.cpp index 125daa80..53049c34 100644 --- a/src/device/devicestatefiltermodel.cpp +++ b/src/device/devicestatefiltermodel.cpp @@ -20,6 +20,12 @@ #include "config.h" +#include +#include +#include +#include + +#include "devicemanager.h" #include "devicestatefiltermodel.h" DeviceStateFilterModel::DeviceStateFilterModel(QObject *parent, DeviceManager::State state) @@ -39,7 +45,7 @@ void DeviceStateFilterModel::ProxyRowCountChanged() { emit IsEmptyChanged(rowCount() == 0); } -void DeviceStateFilterModel::setSourceModel(QAbstractItemModel* sourceModel) { +void DeviceStateFilterModel::setSourceModel(QAbstractItemModel *sourceModel) { QSortFilterProxyModel::setSourceModel(sourceModel); setDynamicSortFilter(true); setSortCaseSensitivity(Qt::CaseInsensitive); diff --git a/src/device/devicestatefiltermodel.h b/src/device/devicestatefiltermodel.h index fab70165..a8def71c 100644 --- a/src/device/devicestatefiltermodel.h +++ b/src/device/devicestatefiltermodel.h @@ -23,7 +23,13 @@ #include "config.h" +#include + +#include +#include #include +#include +#include #include "devicemanager.h" diff --git a/src/device/deviceview.cpp b/src/device/deviceview.cpp index 88820bdb..5288c210 100644 --- a/src/device/deviceview.cpp +++ b/src/device/deviceview.cpp @@ -22,30 +22,50 @@ #include +#include #include -#include -#include -#include -#include -#include +#include +#include +#include #include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include -#include "deviceview.h" - -#include "connecteddevice.h" -#include "devicelister.h" -#include "devicemanager.h" -#include "deviceproperties.h" +#include "core/logging.h" +#include "core/iconloader.h" #include "core/application.h" #include "core/deletefiles.h" #include "core/mergedproxymodel.h" #include "core/mimedata.h" -#include "core/iconloader.h" +#include "core/musicstorage.h" +#include "dialogs/organisedialog.h" +#include "dialogs/organiseerrordialog.h" #include "collection/collectiondirectorymodel.h" #include "collection/collectionmodel.h" #include "collection/collectionview.h" -#include "dialogs/organisedialog.h" -#include "dialogs/organiseerrordialog.h" +#include "connecteddevice.h" +#include "devicelister.h" +#include "devicemanager.h" +#include "deviceproperties.h" +#include "deviceview.h" const int DeviceItemDelegate::kIconPadding = 6; diff --git a/src/device/deviceview.h b/src/device/deviceview.h index 021654c7..2efdf05e 100644 --- a/src/device/deviceview.h +++ b/src/device/deviceview.h @@ -24,20 +24,30 @@ #include "config.h" #include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #include "core/song.h" #include "collection/collectionview.h" #include "widgets/autoexpandingtreeview.h" -class QAction; -class QMenu; -class QSortFilterProxyModel; - class Application; -class DeviceManager; class DeviceProperties; -class CollectionModel; class MergedProxyModel; +class OrganiseDialog; class DeviceItemDelegate : public CollectionItemDelegate { public: diff --git a/src/device/deviceviewcontainer.cpp b/src/device/deviceviewcontainer.cpp index 68d5d09a..62299a0f 100644 --- a/src/device/deviceviewcontainer.cpp +++ b/src/device/deviceviewcontainer.cpp @@ -20,11 +20,20 @@ #include "config.h" -#include "deviceviewcontainer.h" -#include "ui_deviceviewcontainer.h" +#include +#include +#include +#include +#include +#include +#include +#include #include "core/iconloader.h" +#include "deviceviewcontainer.h" +#include "ui_deviceviewcontainer.h" + DeviceViewContainer::DeviceViewContainer(QWidget *parent) : QWidget(parent), ui_(new Ui::DeviceViewContainer), loaded_icons_(false) { ui_->setupUi(this); diff --git a/src/device/deviceviewcontainer.h b/src/device/deviceviewcontainer.h index 0f90d8f0..8b641f45 100644 --- a/src/device/deviceviewcontainer.h +++ b/src/device/deviceviewcontainer.h @@ -23,7 +23,12 @@ #include "config.h" +#include + +#include #include +#include +#include namespace Ui { class DeviceViewContainer; diff --git a/src/device/filesystemdevice.cpp b/src/device/filesystemdevice.cpp index bb533a47..b6319b17 100644 --- a/src/device/filesystemdevice.cpp +++ b/src/device/filesystemdevice.cpp @@ -20,16 +20,20 @@ #include "config.h" -#include "devicelister.h" -#include "devicemanager.h" -#include "filesystemdevice.h" +#include +#include +#include +#include + #include "core/application.h" #include "collection/collectionbackend.h" #include "collection/collectionmodel.h" #include "collection/collectionwatcher.h" +#include "connecteddevice.h" +#include "devicemanager.h" +#include "filesystemdevice.h" -#include -#include +class DeviceLister; FilesystemDevice::FilesystemDevice(const QUrl &url, DeviceLister *lister, const QString &unique_id, DeviceManager *manager, Application *app, int database_id, bool first_time) : FilesystemMusicStorage(url.toLocalFile()), ConnectedDevice(url, lister, unique_id, manager, app, database_id, first_time), watcher_(new CollectionWatcher), watcher_thread_(new QThread(this)) diff --git a/src/device/filesystemdevice.h b/src/device/filesystemdevice.h index 38499e71..e5537fd7 100644 --- a/src/device/filesystemdevice.h +++ b/src/device/filesystemdevice.h @@ -23,11 +23,21 @@ #include "config.h" -#include "connecteddevice.h" -#include "core/filesystemmusicstorage.h" +#include -class DeviceManager; +#include +#include +#include +#include +#include + +#include "core/filesystemmusicstorage.h" +#include "connecteddevice.h" + +class Application; class CollectionWatcher; +class DeviceLister; +class DeviceManager; class FilesystemDevice : public ConnectedDevice, public virtual FilesystemMusicStorage { Q_OBJECT diff --git a/src/device/giolister.cpp b/src/device/giolister.cpp index aef774ac..6390f19e 100644 --- a/src/device/giolister.cpp +++ b/src/device/giolister.cpp @@ -21,15 +21,21 @@ #include "config.h" #include -#include +#include +#include +#include -#include +#include +#include +#include #include -#include +#include +#include -#include "giolister.h" #include "core/logging.h" #include "core/signalchecker.h" +#include "devicelister.h" +#include "giolister.h" using std::placeholders::_1; using std::placeholders::_2; @@ -291,7 +297,7 @@ void GioLister::MountAdded(GMount *mount) { QMutexLocker l(&mutex_); // The volume might already exist - either mounted or unmounted. - for (const QString& id : devices_.keys()) { + for (const QString &id : devices_.keys()) { if (devices_[id].volume == info.volume) { old_id = id; break; @@ -333,9 +339,7 @@ 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; @@ -391,8 +395,8 @@ void GioLister::DeviceInfo::ReadMountInfo(GMount *mount) { mount_path = ConvertAndFree(g_file_get_path(root)); mount_uri = ConvertAndFree(g_file_get_uri(root)); - // Do a sanity check to make sure the root is actually this mount - when a - // device is unmounted GIO sends a changed signal before the removed signal, + // Do a sanity check to make sure the root is actually this mount + // when a device is unmounted GIO sends a changed signal before the removed signal, // and we end up reading information about the / filesystem by mistake. GError *error = nullptr; GMount *actual_mount = g_file_find_enclosing_mount(root, nullptr, &error); diff --git a/src/device/giolister.h b/src/device/giolister.h index d5d8ffd2..a335ed1c 100644 --- a/src/device/giolister.h +++ b/src/device/giolister.h @@ -23,18 +23,28 @@ #include "config.h" -#include "devicelister.h" -#include "core/scopedgobject.h" - // Work around compile issue with glib >= 2.25 #ifdef signals #undef signals #endif +#include +#include #include +#include +#include #include +#include +#include +#include +#include +#include #include +#include + +#include "core/scopedgobject.h" +#include "devicelister.h" class GioLister : public DeviceLister { Q_OBJECT diff --git a/src/device/gpoddevice.cpp b/src/device/gpoddevice.cpp index 814d3af1..00707661 100644 --- a/src/device/gpoddevice.cpp +++ b/src/device/gpoddevice.cpp @@ -20,20 +20,30 @@ #include "config.h" +#include #include +#include +#include +#include +#include #include #include -#include +#include +#include +#include #include -#include "devicemanager.h" -#include "gpoddevice.h" -#include "gpodloader.h" #include "core/logging.h" #include "core/application.h" #include "collection/collectionbackend.h" #include "collection/collectionmodel.h" +#include "connecteddevice.h" +#include "gpoddevice.h" +#include "gpodloader.h" + +class DeviceLister; +class DeviceManager; GPodDevice::GPodDevice(const QUrl &url, DeviceLister *lister, const QString &unique_id, DeviceManager *manager, Application *app, int database_id, bool first_time) : ConnectedDevice(url, lister, unique_id, manager, app, database_id, first_time), diff --git a/src/device/gpoddevice.h b/src/device/gpoddevice.h index d6bc81c1..c3fed709 100644 --- a/src/device/gpoddevice.h +++ b/src/device/gpoddevice.h @@ -23,14 +23,25 @@ #include "config.h" -#include "connecteddevice.h" -#include "core/musicstorage.h" - -#include -#include - +#include #include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "core/song.h" +#include "core/musicstorage.h" +#include "connecteddevice.h" + +class Application; +class DeviceLister; +class DeviceManager; class GPodLoader; class GPodDevice : public ConnectedDevice, public virtual MusicStorage { diff --git a/src/device/gpodloader.cpp b/src/device/gpodloader.cpp index c1dbacfb..b8707c1e 100644 --- a/src/device/gpodloader.cpp +++ b/src/device/gpodloader.cpp @@ -20,17 +20,20 @@ #include "config.h" +#include #include +#include #include +#include +#include #include -#include "connecteddevice.h" -#include "gpodloader.h" +#include "collection/collectionbackend.h" #include "core/logging.h" #include "core/song.h" #include "core/taskmanager.h" -#include "collection/collectionbackend.h" +#include "gpodloader.h" GPodLoader::GPodLoader(const QString &mount_point, TaskManager *task_manager, CollectionBackend *backend, std::shared_ptr device) : QObject(nullptr), diff --git a/src/device/gpodloader.h b/src/device/gpodloader.h index 66f2b1f0..0469d4a9 100644 --- a/src/device/gpodloader.h +++ b/src/device/gpodloader.h @@ -24,16 +24,17 @@ #include "config.h" #include - #include #include +#include +#include #include "core/song.h" -class ConnectedDevice; -class CollectionBackend; class TaskManager; +class CollectionBackend; +class ConnectedDevice; class GPodLoader : public QObject { Q_OBJECT diff --git a/src/device/ilister.cpp b/src/device/ilister.cpp index b54ce73d..38110b22 100644 --- a/src/device/ilister.cpp +++ b/src/device/ilister.cpp @@ -20,10 +20,14 @@ #include "config.h" +#include +#include +#include +#include #include +#include #include -#include "config.h" #include "ilister.h" #include "imobiledeviceconnection.h" diff --git a/src/device/ilister.h b/src/device/ilister.h index f52a6187..4a7def1a 100644 --- a/src/device/ilister.h +++ b/src/device/ilister.h @@ -25,7 +25,13 @@ #include +#include +#include #include +#include +#include +#include +#include #include "devicelister.h" diff --git a/src/device/imobiledeviceconnection.cpp b/src/device/imobiledeviceconnection.cpp index 09d8c3ee..ddd41174 100644 --- a/src/device/imobiledeviceconnection.cpp +++ b/src/device/imobiledeviceconnection.cpp @@ -23,13 +23,17 @@ #include #include +#include +#include +#include +#include #include #include -#include "imobiledeviceconnection.h" #include "core/logging.h" +#include "imobiledeviceconnection.h" -iMobileDeviceConnection::iMobileDeviceConnection(const QString &uuid) : device_(NULL), afc_(NULL), afc_port_(0) { +iMobileDeviceConnection::iMobileDeviceConnection(const QString &uuid) : device_(nullptr), afc_(nullptr), afc_port_(0) { idevice_error_t err = idevice_new(&device_, uuid.toUtf8().constData()); if (err != IDEVICE_E_SUCCESS) { @@ -38,6 +42,7 @@ iMobileDeviceConnection::iMobileDeviceConnection(const QString &uuid) : device_( } lockdownd_client_t lockdown; + lockdownd_service_descriptor_t lockdown_service_desc; QByteArray label_ascii = QCoreApplication::applicationName().toLatin1(); const char *label = label_ascii.constData(); @@ -47,14 +52,14 @@ iMobileDeviceConnection::iMobileDeviceConnection(const QString &uuid) : device_( return; } - lockdown_err = lockdownd_start_service(lockdown, "com.apple.afc", &afc_port_); + lockdown_err = lockdownd_start_service(lockdown, "com.apple.afc", &lockdown_service_desc); if (lockdown_err != LOCKDOWN_E_SUCCESS) { qLog(Warning) << "lockdown error:" << lockdown_err; lockdownd_client_free(lockdown); return; } - afc_error_t afc_err = afc_client_new(device_, afc_port_, &afc_); + afc_error_t afc_err = afc_client_new(device_, lockdown_service_desc, &afc_); if (afc_err != 0) { qLog(Warning) << "afc error:" << afc_err; lockdownd_client_free(lockdown); @@ -197,8 +202,7 @@ bool iMobileDeviceConnection::Exists(const QString &path) { QString iMobileDeviceConnection::GetUnusedFilename(Itdb_iTunesDB *itdb, const Song &metadata) { - // This function does the same as itdb_cp_get_dest_filename, except it - // accesses the device's filesystem through imobiledevice. + // This function does the same as itdb_cp_get_dest_filename, except it accesses the device's filesystem through imobiledevice. // Get the total number of F.. directories int total_musicdirs = 0; @@ -231,8 +235,7 @@ QString iMobileDeviceConnection::GetUnusedFilename(Itdb_iTunesDB *itdb, const So extension = "mp3"; // Loop until we find an unused filename. - // Use the same naming convention as libgpod, which is - // "libgpod" + 6-digit random number + // Use the same naming convention as libgpod, which is "libgpod" + 6-digit random number static const int kRandMax = 999999; QString filename; forever { diff --git a/src/device/imobiledeviceconnection.h b/src/device/imobiledeviceconnection.h index 4e292c80..58d2f441 100644 --- a/src/device/imobiledeviceconnection.h +++ b/src/device/imobiledeviceconnection.h @@ -30,8 +30,9 @@ #include #include -#include #include +#include +#include #include "core/song.h" @@ -56,7 +57,6 @@ private: idevice_t device_; afc_client_t afc_; - uint16_t afc_port_; }; diff --git a/src/device/macdevicelister.h b/src/device/macdevicelister.h index a88c2096..a0aa5c63 100644 --- a/src/device/macdevicelister.h +++ b/src/device/macdevicelister.h @@ -3,14 +3,19 @@ #include "config.h" -#include -#include -#include - #include #include #include +#include +#include +#include +#include +#include +#include +#include +#include + #include "devicelister.h" class MacDeviceLister : public DeviceLister { diff --git a/src/device/mtpconnection.cpp b/src/device/mtpconnection.cpp index c8613cd5..4d1b413c 100644 --- a/src/device/mtpconnection.cpp +++ b/src/device/mtpconnection.cpp @@ -20,12 +20,17 @@ #include "config.h" -#include -#include -#include +#include + +#include +#include +#include +#include +#include +#include -#include "mtpconnection.h" #include "core/logging.h" +#include "mtpconnection.h" MtpConnection::MtpConnection(const QUrl &url) : device_(nullptr) { diff --git a/src/device/mtpconnection.h b/src/device/mtpconnection.h index f7e6cd70..53c117ce 100644 --- a/src/device/mtpconnection.h +++ b/src/device/mtpconnection.h @@ -23,8 +23,10 @@ #include "config.h" +#include #include +#include #include class MtpConnection { diff --git a/src/device/mtpdevice.cpp b/src/device/mtpdevice.cpp index 9b3bf358..cb7c2af6 100644 --- a/src/device/mtpdevice.cpp +++ b/src/device/mtpdevice.cpp @@ -21,18 +21,31 @@ #include "config.h" #include +#include +#include -#include +#include #include +#include +#include +#include +#include +#include +#include +#include -#include "devicemanager.h" +#include "collection/collectionmodel.h" +#include "collection/collectionbackend.h" +#include "core/logging.h" +#include "core/application.h" +#include "core/musicstorage.h" +#include "connecteddevice.h" #include "mtpconnection.h" #include "mtpdevice.h" #include "mtploader.h" -#include "core/application.h" -#include "core/logging.h" -#include "collection/collectionbackend.h" -#include "collection/collectionmodel.h" + +class DeviceLister; +class DeviceManager; bool MtpDevice::sInitialisedLibMTP = false; @@ -95,10 +108,12 @@ bool MtpDevice::StartCopy(QList *supported_types) { } static int ProgressCallback(uint64_t const sent, uint64_t const total, void const *const data) { + const MusicStorage::CopyJob *job = reinterpret_cast(data); job->progress_(float(sent) / total); return 0; + } bool MtpDevice::CopyToStorage(const CopyJob &job) { diff --git a/src/device/mtpdevice.h b/src/device/mtpdevice.h index 0cfec959..672c8cf4 100644 --- a/src/device/mtpdevice.h +++ b/src/device/mtpdevice.h @@ -24,16 +24,25 @@ #include "config.h" #include +#include +#include +#include #include -#include +#include +#include +#include +#include +#include "core/song.h" #include "connecteddevice.h" -struct LIBMTP_mtpdevice_struct; - +class Application; +class DeviceLister; +class DeviceManager; class MtpConnection; class MtpLoader; +struct LIBMTP_mtpdevice_struct; class MtpDevice : public ConnectedDevice { Q_OBJECT diff --git a/src/device/mtploader.cpp b/src/device/mtploader.cpp index 24ef61f4..e4e2179e 100644 --- a/src/device/mtploader.cpp +++ b/src/device/mtploader.cpp @@ -20,17 +20,16 @@ #include "config.h" -#include "mtploader.h" - #include -#include "connecteddevice.h" -#include "mtpconnection.h" -#include "core/song.h" -#include "core/taskmanager.h" -#include "core/logging.h" +#include +#include +#include "core/taskmanager.h" +#include "core/song.h" #include "collection/collectionbackend.h" +#include "mtpconnection.h" +#include "mtploader.h" MtpLoader::MtpLoader(const QUrl &url, TaskManager *task_manager, CollectionBackend *backend, std::shared_ptr device) : QObject(nullptr), diff --git a/src/device/mtploader.h b/src/device/mtploader.h index aac826d4..5bf51b6c 100644 --- a/src/device/mtploader.h +++ b/src/device/mtploader.h @@ -24,13 +24,16 @@ #include "config.h" #include +#include #include +#include +#include #include -class ConnectedDevice; -class CollectionBackend; class TaskManager; +class CollectionBackend; +class ConnectedDevice; class MtpLoader : public QObject { Q_OBJECT @@ -52,7 +55,7 @@ signals: private: std::shared_ptr device_; - QThread* original_thread_; + QThread *original_thread_; QUrl url_; TaskManager *task_manager_; diff --git a/src/device/udisks2lister.cpp b/src/device/udisks2lister.cpp index 4c68cd86..5cab88bf 100644 --- a/src/device/udisks2lister.cpp +++ b/src/device/udisks2lister.cpp @@ -17,9 +17,23 @@ #include "config.h" -#include "udisks2lister.h" - +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #include +#include +#include +#include +#include +#include +#include #include "core/logging.h" #include "core/utilities.h" @@ -29,6 +43,8 @@ #include "dbus/udisks2filesystem.h" #include "dbus/udisks2job.h" +#include "udisks2lister.h" + constexpr char Udisks2Lister::udisks2_service_[]; Udisks2Lister::Udisks2Lister() {} @@ -141,9 +157,7 @@ void Udisks2Lister::UnmountDevice(const QString &id) { void Udisks2Lister::UpdateDeviceFreeSpace(const QString &id) { QWriteLocker locker(&device_data_lock_); - device_data_[id].free_space = - Utilities::FileSystemFreeSpace(device_data_[id].mount_paths.at(0)); - + device_data_[id].free_space = Utilities::FileSystemFreeSpace(device_data_[id].mount_paths.at(0)); emit DeviceChanged(id); } diff --git a/src/device/udisks2lister.h b/src/device/udisks2lister.h index 4a7fe4a2..74a6efc9 100644 --- a/src/device/udisks2lister.h +++ b/src/device/udisks2lister.h @@ -21,11 +21,22 @@ #include "config.h" #include +#include -#include +#include +#include #include +#include +#include +#include #include +#include #include +#include +#include +#include +#include +#include #include "dbus/metatypes.h" #include "devicelister.h" diff --git a/src/dialogs/about.cpp b/src/dialogs/about.cpp index 528dc792..e27bafce 100644 --- a/src/dialogs/about.cpp +++ b/src/dialogs/about.cpp @@ -21,12 +21,21 @@ #include "config.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + #include "about.h" #include "ui_about.h" -#include -#include - About::About(QWidget *parent):QDialog(parent) { authors_ \ diff --git a/src/dialogs/about.h b/src/dialogs/about.h index 8074a165..93266ab2 100644 --- a/src/dialogs/about.h +++ b/src/dialogs/about.h @@ -23,7 +23,13 @@ #include "config.h" +#include + +#include +#include #include +#include +#include #include "ui_about.h" @@ -36,7 +42,7 @@ class About : public QDialog { struct Person { Person(const QString &n, const QString &e = QString()) : name(n), email(e) {} - bool operator<(const Person& other) const { return name < other.name; } + bool operator<(const Person &other) const { return name < other.name; } QString name; QString email; diff --git a/src/dialogs/console.cpp b/src/dialogs/console.cpp index f99a1d0a..6f47b933 100644 --- a/src/dialogs/console.cpp +++ b/src/dialogs/console.cpp @@ -20,14 +20,22 @@ #include "config.h" +#include +#include +#include +#include +#include +#include #include -#include #include #include #include +#include +#include +#include +#include #include "console.h" - #include "core/application.h" #include "core/database.h" diff --git a/src/dialogs/console.h b/src/dialogs/console.h index 097da219..9673ed78 100644 --- a/src/dialogs/console.h +++ b/src/dialogs/console.h @@ -23,7 +23,10 @@ #include "config.h" +#include +#include #include +#include #include "ui_console.h" diff --git a/src/dialogs/edittagdialog.cpp b/src/dialogs/edittagdialog.cpp index 1508af2c..5add171d 100644 --- a/src/dialogs/edittagdialog.cpp +++ b/src/dialogs/edittagdialog.cpp @@ -20,34 +20,69 @@ #include "config.h" +#include +#include #include -#include -#include +#include +#include #include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #include +#include +#include +#include #include #include -#include #include -#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #include -#include "edittagdialog.h" -#include "trackselectiondialog.h" -#include "ui_edittagdialog.h" #include "core/application.h" +#include "core/closure.h" +#include "core/iconloader.h" #include "core/logging.h" #include "core/tagreaderclient.h" #include "core/utilities.h" -#include "collection/collection.h" +#include "widgets/busyindicator.h" +#include "widgets/lineedit.h" #include "collection/collectionbackend.h" +#include "playlist/playlist.h" #include "playlist/playlistdelegates.h" -#include "covermanager/albumcovermanager.h" +#include "musicbrainz/tagfetcher.h" +#include "covermanager/albumcoverchoicecontroller.h" #include "covermanager/albumcoverloader.h" #include "covermanager/coverproviders.h" -#include "covermanager/albumcoverchoicecontroller.h" -#include "covermanager/coverfromurldialog.h" +#include "edittagdialog.h" +#include "trackselectiondialog.h" +#include "ui_edittagdialog.h" const char *EditTagDialog::kHintText = QT_TR_NOOP("(different across multiple songs)"); const char *EditTagDialog::kSettingsGroup = "EditTagDialog"; @@ -129,7 +164,7 @@ EditTagDialog::EditTagDialog(Application *app, QWidget *parent) // Pretend the summary text is just a label ui_->summary->setMaximumHeight(ui_->art->height() - ui_->summary_art_button->height() - 4); - connect(ui_->song_list->selectionModel(), SIGNAL(selectionChanged(QItemSelection,QItemSelection)), SLOT(SelectionChanged())); + connect(ui_->song_list->selectionModel(), SIGNAL(selectionChanged(QItemSelection, QItemSelection)), SLOT(SelectionChanged())); connect(ui_->button_box, SIGNAL(clicked(QAbstractButton*)), SLOT(ButtonClicked(QAbstractButton*))); //connect(ui_->rating, SIGNAL(RatingChanged(float)), SLOT(SongRated(float))); connect(ui_->playcount_reset, SIGNAL(clicked()), SLOT(ResetPlayCounts())); @@ -644,8 +679,7 @@ void EditTagDialog::UpdateCoverOf(const Song &selected, const QModelIndexList &s UpdateSummaryTab(selected); - // Now check if we have any other songs cached that share that artist and - // album (and would therefore be changed as well) + // Now check if we have any other songs cached that share that artist and album (and would therefore be changed as well) for (int i = 0; i < data_.count(); ++i) { if (i == sel.first().row()) // Already changed this one continue; diff --git a/src/dialogs/edittagdialog.h b/src/dialogs/edittagdialog.h index 8d1eba9b..4bcd4c48 100644 --- a/src/dialogs/edittagdialog.h +++ b/src/dialogs/edittagdialog.h @@ -23,26 +23,38 @@ #include "config.h" +#include + +#include +#include #include +#include +#include #include +#include +#include +#include +#include +#include +#include +#include +#include +#include #include "core/song.h" -#include "covermanager/albumcoverloaderoptions.h" -#include "musicbrainz/tagfetcher.h" #include "playlist/playlistitem.h" -#include "widgets/lineedit.h" -#include "trackselectiondialog.h" +#include "covermanager/albumcoverloaderoptions.h" + +class QEvent; +class QShowEvent; +class QHideEvent; class Application; +class TagFetcher; class AlbumCoverChoiceController; -class CollectionBackend; +class TrackSelectionDialog; class Ui_EditTagDialog; -class QAbstractButton; -class QItemSelection; -class QLabel; -class QPushButton; - class EditTagDialog : public QDialog { Q_OBJECT diff --git a/src/dialogs/errordialog.cpp b/src/dialogs/errordialog.cpp index 4b6de0e3..821c52f2 100644 --- a/src/dialogs/errordialog.cpp +++ b/src/dialogs/errordialog.cpp @@ -20,9 +20,20 @@ #include "config.h" +#include +#include +#include +#include +#include +#include +#include +#include + #include "errordialog.h" #include "ui_errordialog.h" +class QHideEvent; + ErrorDialog::ErrorDialog(QWidget *parent) : QDialog(parent), ui_(new Ui_ErrorDialog) @@ -64,7 +75,7 @@ void ErrorDialog::hideEvent(QHideEvent *) { void ErrorDialog::UpdateContent() { QString html; - for (const QString& message : current_messages_) { + for (const QString &message : current_messages_) { if (!html.isEmpty()) html += "
"; html += message.toHtmlEscaped(); diff --git a/src/dialogs/errordialog.h b/src/dialogs/errordialog.h index d5540e7c..bd06b3ba 100644 --- a/src/dialogs/errordialog.h +++ b/src/dialogs/errordialog.h @@ -23,8 +23,13 @@ #include "config.h" +#include #include +#include +#include +#include +class QHideEvent; class Ui_ErrorDialog; class ErrorDialog : public QDialog { @@ -35,7 +40,7 @@ class ErrorDialog : public QDialog { ~ErrorDialog(); public slots: - void ShowMessage(const QString& message); + void ShowMessage(const QString &message); protected: void hideEvent(QHideEvent *); diff --git a/src/dialogs/organisedialog.cpp b/src/dialogs/organisedialog.cpp index f953d912..50edb1be 100644 --- a/src/dialogs/organisedialog.cpp +++ b/src/dialogs/organisedialog.cpp @@ -20,28 +20,48 @@ #include "config.h" -#include "organisedialog.h" -#include "ui_organisedialog.h" - #include +#include +#include +#include +#include +#include +#include +#include #include #include -#include +#include +#include +#include +#include +#include +#include #include +#include +#include +#include +#include +#include #include -#include -#include #include -#include -#include +#include +#include +#include +#include +#include -#include "organiseerrordialog.h" +#include "core/closure.h" +#include "core/iconloader.h" #include "core/musicstorage.h" #include "core/organise.h" #include "core/tagreaderclient.h" #include "core/utilities.h" -#include "core/iconloader.h" +#include "widgets/freespacebar.h" +#include "widgets/linetextedit.h" +#include "organisedialog.h" +#include "organiseerrordialog.h" +#include "ui_organisedialog.h" const char *OrganiseDialog::kDefaultFormat = "%artist/%album{ (Disc %disc)}/{%track - }%title.%extension"; const char *OrganiseDialog::kSettingsGroup = "OrganiseDialog"; diff --git a/src/dialogs/organisedialog.h b/src/dialogs/organisedialog.h index 1c12c0e3..c3e61658 100644 --- a/src/dialogs/organisedialog.h +++ b/src/dialogs/organisedialog.h @@ -24,23 +24,32 @@ #include "config.h" #include +#include +#include +#include +#include #include +#include #include -#include +#include +#include +#include +#include #include +#include +#include "core/song.h" #include "core/organise.h" #include "core/organiseformat.h" -#include "core/song.h" -class CollectionWatcher; -class OrganiseErrorDialog; +class QResizeEvent; +class QShowEvent; + class TaskManager; +class OrganiseErrorDialog; class Ui_OrganiseDialog; -class QAbstractItemModel; - class OrganiseDialog : public QDialog { Q_OBJECT @@ -56,8 +65,7 @@ class OrganiseDialog : public QDialog { void SetDestinationModel(QAbstractItemModel *model, bool devices = false); // These functions return true if any songs were actually added to the dialog. - // SetSongs returns immediately, SetUrls and SetFilenames load the songs in - // the background. + // SetSongs returns immediately, SetUrls and SetFilenames load the songs in the background. bool SetSongs(const SongList &songs); bool SetUrls(const QList &urls); bool SetFilenames(const QStringList &filenames); diff --git a/src/dialogs/organiseerrordialog.cpp b/src/dialogs/organiseerrordialog.cpp index 457538d4..9667d978 100644 --- a/src/dialogs/organiseerrordialog.cpp +++ b/src/dialogs/organiseerrordialog.cpp @@ -20,7 +20,15 @@ #include "config.h" +#include +#include +#include +#include +#include +#include #include +#include +#include #include "organiseerrordialog.h" #include "ui_organiseerrordialog.h" diff --git a/src/dialogs/organiseerrordialog.h b/src/dialogs/organiseerrordialog.h index 795e478e..8c24b81c 100644 --- a/src/dialogs/organiseerrordialog.h +++ b/src/dialogs/organiseerrordialog.h @@ -23,7 +23,11 @@ #include "config.h" +#include #include +#include +#include +#include #include "core/song.h" diff --git a/src/dialogs/trackselectiondialog.cpp b/src/dialogs/trackselectiondialog.cpp index 17e3beff..2cd8b96d 100644 --- a/src/dialogs/trackselectiondialog.cpp +++ b/src/dialogs/trackselectiondialog.cpp @@ -20,22 +20,39 @@ #include "config.h" +#include +#include +#include +#include +#include +#include #include +#include #include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #include #include +#include +#include #include -#include -#include #include +#include "core/iconloader.h" +#include "core/logging.h" +#include "core/tagreaderclient.h" +#include "widgets/busyindicator.h" #include "trackselectiondialog.h" #include "ui_trackselectiondialog.h" -#include "core/tagreaderclient.h" -#include "core/iconloader.h" - - TrackSelectionDialog::TrackSelectionDialog(QWidget *parent) : QDialog(parent), ui_(new Ui_TrackSelectionDialog), diff --git a/src/dialogs/trackselectiondialog.h b/src/dialogs/trackselectiondialog.h index 2b776fec..ae785c18 100644 --- a/src/dialogs/trackselectiondialog.h +++ b/src/dialogs/trackselectiondialog.h @@ -21,14 +21,20 @@ #ifndef TRACKSELECTIONDIALOG_H #define TRACKSELECTIONDIALOG_H -#include "config.h" +#include +#include #include +#include +#include +#include +#include +#include +#include "config.h" #include "core/song.h" class Ui_TrackSelectionDialog; -class QTreeWidget; class TrackSelectionDialog : public QDialog { Q_OBJECT diff --git a/src/engine/alsadevicefinder.cpp b/src/engine/alsadevicefinder.cpp index 8608557b..14fe53ee 100644 --- a/src/engine/alsadevicefinder.cpp +++ b/src/engine/alsadevicefinder.cpp @@ -20,14 +20,19 @@ #include "config.h" #include -#include -#include +#include #include -#include "alsadevicefinder.h" +#include +#include +#include +#include #include +#include "devicefinder.h" +#include "alsadevicefinder.h" + AlsaDeviceFinder::AlsaDeviceFinder() : DeviceFinder("alsa") { diff --git a/src/engine/alsadevicefinder.h b/src/engine/alsadevicefinder.h index 14357aa0..7749dc25 100644 --- a/src/engine/alsadevicefinder.h +++ b/src/engine/alsadevicefinder.h @@ -22,7 +22,10 @@ #include "config.h" -#include "engine/devicefinder.h" +#include +#include + +#include "devicefinder.h" class AlsaDeviceFinder : public DeviceFinder { public: diff --git a/src/engine/devicefinder.cpp b/src/engine/devicefinder.cpp index 62a73ab0..fe9f03c5 100644 --- a/src/engine/devicefinder.cpp +++ b/src/engine/devicefinder.cpp @@ -19,9 +19,9 @@ #include "config.h" -#include "devicefinder.h" +#include -#include "core/logging.h" +#include "devicefinder.h" DeviceFinder::DeviceFinder(const QString &name): name_(name) { } diff --git a/src/engine/devicefinder.h b/src/engine/devicefinder.h index d2f44f5b..eb59921d 100644 --- a/src/engine/devicefinder.h +++ b/src/engine/devicefinder.h @@ -23,8 +23,11 @@ #include "config.h" -#include +#include + +#include #include +#include // Finds audio output devices class DeviceFinder { diff --git a/src/engine/directsounddevicefinder.cpp b/src/engine/directsounddevicefinder.cpp index 7aeec1f0..41f9a516 100644 --- a/src/engine/directsounddevicefinder.cpp +++ b/src/engine/directsounddevicefinder.cpp @@ -26,9 +26,13 @@ #include +#include +#include +#include #include #include "directsounddevicefinder.h" +#include "core/logging.h" DirectSoundDeviceFinder::DirectSoundDeviceFinder() : DeviceFinder("directsoundsink") { @@ -45,8 +49,9 @@ BOOL DirectSoundDeviceFinder::EnumerateCallback(LPGUID guid, LPCSTR description, State *state = reinterpret_cast(state_voidptr); Device dev; - dev.description = QString::fromUtf8(description); - if (guid) dev.value = QUuid(*guid).toByteArray(); + dev.description = QString::fromLatin1(description); + //if (guid) dev.value = QUuid(*guid).toByteArray(); + if (guid) dev.value = QUuid(*guid).toString(); else dev.value = QVariant(); dev.iconname = GuessIconName(dev.description); state->devices.append(dev); diff --git a/src/engine/directsounddevicefinder.h b/src/engine/directsounddevicefinder.h index 6c0f24cc..d3b5fec8 100644 --- a/src/engine/directsounddevicefinder.h +++ b/src/engine/directsounddevicefinder.h @@ -25,7 +25,7 @@ #include -#include "engine/devicefinder.h" +#include "devicefinder.h" class DirectSoundDeviceFinder : public DeviceFinder { public: diff --git a/src/engine/engine_fwd.h b/src/engine/engine_fwd.h index 6159d03e..8102056c 100644 --- a/src/engine/engine_fwd.h +++ b/src/engine/engine_fwd.h @@ -1,8 +1,6 @@ #ifndef ENGINE_FWD_H #define ENGINE_FWD_H -#include - /// Used by eg engineobserver.h, and thus we reduce header dependencies on enginebase.h namespace Engine { diff --git a/src/engine/enginebase.cpp b/src/engine/enginebase.cpp index 5565fbeb..09462086 100644 --- a/src/engine/enginebase.cpp +++ b/src/engine/enginebase.cpp @@ -23,13 +23,14 @@ #include "config.h" #include + +#include +#include #include -#include "enginebase.h" -#include "enginedevice.h" #include "core/timeconstants.h" -#include "core/logging.h" - +#include "engine_fwd.h" +#include "enginebase.h" #include "settings/playbacksettingspage.h" Engine::Base::Base() diff --git a/src/engine/enginebase.h b/src/engine/enginebase.h index e0d882f1..68b71b5f 100644 --- a/src/engine/enginebase.h +++ b/src/engine/enginebase.h @@ -25,22 +25,25 @@ #include "config.h" -#include #include - +#include #include +#include -#include +#include #include +#include +#include +#include #include -#include -#include -#include "enginetype.h" #include "engine_fwd.h" +#include "enginetype.h" namespace Engine { +struct SimpleMetaBundle; + typedef std::vector Scope; class Base : public QObject { @@ -72,10 +75,8 @@ class Base : public QObject { end_nanosec_ = end_nanosec; } - // Plays a media stream represented with the URL 'u' from the given 'beginning' - // to the given 'end' (usually from 0 to a song's length). Both markers - // should be passed in nanoseconds. 'end' can be negative, indicating that the - // real length of 'u' stream is unknown. + // Plays a media stream represented with the URL 'u' from the given 'beginning' to the given 'end' (usually from 0 to a song's length). + // Both markers should be passed in nanoseconds. 'end' can be negative, indicating that the real length of 'u' stream is unknown. bool Play(const QUrl &u, TrackChangeFlags c, bool force_stop_at_end, quint64 beginning_nanosec, qint64 end_nanosec); void SetVolume(uint value); @@ -90,6 +91,9 @@ class Base : public QObject { bool crossfade_same_album() const { return crossfade_same_album_; } static const int kScopeSize = 1024; + + virtual void SetVolumeSW(uint percent) = 0; + static uint MakeVolumeLogarithmic(uint volume); struct OutputDetails { QString name; @@ -131,8 +135,6 @@ signals: protected: Base(); - virtual void SetVolumeSW(uint percent) = 0; - static uint MakeVolumeLogarithmic(uint volume); void EmitAboutToEnd(); protected: @@ -164,8 +166,6 @@ signals: Q_DISABLE_COPY(Base); }; -//Q_DECLARE_METATYPE(EngineBase::PluginDetails); -Q_DECLARE_METATYPE(EngineBase::OutputDetails); struct SimpleMetaBundle { QString title; @@ -183,4 +183,6 @@ struct SimpleMetaBundle { } // namespace +Q_DECLARE_METATYPE(EngineBase::OutputDetails); + #endif diff --git a/src/engine/enginedevice.cpp b/src/engine/enginedevice.cpp index 45853f4d..cd253d50 100644 --- a/src/engine/enginedevice.cpp +++ b/src/engine/enginedevice.cpp @@ -20,50 +20,41 @@ #include "config.h" -#include "enginedevice.h" -#include "devicefinder.h" +#include +#include +#include +#include +#include #include "core/logging.h" - -#include -#include +#include "devicefinder.h" +#include "enginedevice.h" #ifdef Q_OS_LINUX - #include "engine/alsadevicefinder.h" +# include "alsadevicefinder.h" #endif #ifdef HAVE_LIBPULSE - #include "engine/pulsedevicefinder.h" +# include "pulsedevicefinder.h" #endif #ifdef Q_OS_DARWIN - #include "engine/osxdevicefinder.h" +# include "osxdevicefinder.h" #endif #ifdef Q_OS_WIN32 - #include "engine/directsounddevicefinder.h" +# include "directsounddevicefinder.h" #endif -#include "settings/backendsettingspage.h" - EngineDevice::EngineDevice(QObject *parent) : QObject(parent) { - - //qLog(Debug) << __PRETTY_FUNCTION__; - } EngineDevice::~EngineDevice() { - - //qLog(Debug) << __PRETTY_FUNCTION__; - qDeleteAll(device_finders_); - } void EngineDevice::Init() { - //qLog(Debug) << __PRETTY_FUNCTION__; - QList device_finders; #ifdef Q_OS_LINUX diff --git a/src/engine/enginedevice.h b/src/engine/enginedevice.h index 9217471a..57244e5b 100644 --- a/src/engine/enginedevice.h +++ b/src/engine/enginedevice.h @@ -23,11 +23,9 @@ #include "config.h" -#include -#include - -#include "enginebase.h" -#include "devicefinder.h" +#include +#include +#include class DeviceFinder; diff --git a/src/engine/enginetype.cpp b/src/engine/enginetype.cpp index ab96ee54..a3981158 100644 --- a/src/engine/enginetype.cpp +++ b/src/engine/enginetype.cpp @@ -19,8 +19,8 @@ #include "config.h" -#include #include +#include #include "enginetype.h" diff --git a/src/engine/enginetype.h b/src/engine/enginetype.h index 5138cd99..21a1edf9 100644 --- a/src/engine/enginetype.h +++ b/src/engine/enginetype.h @@ -22,8 +22,8 @@ #include "config.h" +#include #include -#include namespace Engine { @@ -34,11 +34,11 @@ enum EngineType { Xine, Phonon }; -Q_DECLARE_METATYPE(Engine::EngineType); QString EngineNameFromType(Engine::EngineType enginetype); Engine::EngineType EngineTypeFromName(QString enginename); } +Q_DECLARE_METATYPE(Engine::EngineType); #endif diff --git a/src/engine/bufferconsumer.h b/src/engine/gstbufferconsumer.h similarity index 80% rename from src/engine/bufferconsumer.h rename to src/engine/gstbufferconsumer.h index 358d83d1..33f6512e 100644 --- a/src/engine/bufferconsumer.h +++ b/src/engine/gstbufferconsumer.h @@ -18,8 +18,8 @@ * */ -#ifndef BUFFERCONSUMER_H -#define BUFFERCONSUMER_H +#ifndef GSTBUFFERCONSUMER_H +#define GSTBUFFERCONSUMER_H #include "config.h" @@ -27,14 +27,13 @@ class GstEnginePipeline; -class BufferConsumer { +class GstBufferConsumer { public: - virtual ~BufferConsumer() {} + virtual ~GstBufferConsumer() {} // This is called in some unspecified GStreamer thread. - // Ownership of the buffer is transferred to the BufferConsumer and it should - // gst_buffer_unref it. - virtual void ConsumeBuffer(GstBuffer* buffer, int pipeline_id) = 0; + // Ownership of the buffer is transferred to the BufferConsumer and it should gst_buffer_unref it. + virtual void ConsumeBuffer(GstBuffer *buffer, int pipeline_id) = 0; }; -#endif // BUFFERCONSUMER_H +#endif // GSTBUFFERCONSUMER_H diff --git a/src/engine/gstelementdeleter.cpp b/src/engine/gstelementdeleter.cpp index 3cdb0ced..11cd9aab 100644 --- a/src/engine/gstelementdeleter.cpp +++ b/src/engine/gstelementdeleter.cpp @@ -18,9 +18,9 @@ * */ -#include "config.h" +#include -#include +#include "config.h" #include "gstelementdeleter.h" diff --git a/src/engine/gstelementdeleter.h b/src/engine/gstelementdeleter.h index 92a0ba67..cc3b5946 100644 --- a/src/engine/gstelementdeleter.h +++ b/src/engine/gstelementdeleter.h @@ -18,14 +18,15 @@ * */ -#ifndef GSTBINDELETER_H -#define GSTBINDELETER_H +#ifndef GSTELEMENTDELETER_H +#define GSTELEMENTDELETER_H #include "config.h" #include #include +#include class GstElementDeleter : public QObject { Q_OBJECT @@ -33,16 +34,14 @@ class GstElementDeleter : public QObject { public: GstElementDeleter(QObject *parent = nullptr); - // If you call this function with any gstreamer element, the element will get - // deleted in the main thread. This is useful if you need to delete an - // element from its own callback. - // It's in a separate object so *your* object (GstEnginePipeline) can be - // destroyed, and the element that you scheduled for deletion is still - // deleted later regardless. + // If you call this function with any gstreamer element, the element will get deleted in the main thread. + // This is useful if you need to delete an element from its own callback. + // It's in a separate object so *your* object (GstEnginePipeline) can be destroyed, + // and the element that you scheduled for deletion is still deleted later regardless. void DeleteElementLater(GstElement *element); private slots: void DeleteElement(GstElement *element); }; -#endif // GSTBINDELETER_H +#endif // GSTELEMENTDELETER_H diff --git a/src/engine/gstengine.cpp b/src/engine/gstengine.cpp index 89b25d99..6cb785d6 100644 --- a/src/engine/gstengine.cpp +++ b/src/engine/gstengine.cpp @@ -21,55 +21,65 @@ #include "config.h" -#include -#include +#include +#include +#include +#include +#include #include -#include +#include #include #include -#include -#include -#include - +#include #include #include #include -#include -#include -#include -#include +#include #include +#include +#include +#include +#include +#include +#include +#include +#include #include +#include +#include +#include +#include +#include -#include "enginetype.h" -#include "enginebase.h" - -#include "gstengine.h" - -#include "devicefinder.h" -#include "gstenginepipeline.h" #include "core/closure.h" +#include "core/utilities.h" #include "core/logging.h" #include "core/taskmanager.h" #include "core/timeconstants.h" -#include "core/utilities.h" +#include "enginebase.h" +#include "enginetype.h" +#include "gstengine.h" +#include "gstenginepipeline.h" +#include "gstbufferconsumer.h" +#ifdef HAVE_IMOBILEDEVICE_ // FIXME +# include "ext/gstafc/gstafcsrc.h" +#endif #ifdef Q_OS_LINUX - #include "engine/alsadevicefinder.h" +# include "alsadevicefinder.h" #endif #ifdef HAVE_LIBPULSE - #include "engine/pulsedevicefinder.h" +# include "pulsedevicefinder.h" #endif #ifdef Q_OS_DARWIN - #include "engine/osxdevicefinder.h" +# include "osxdevicefinder.h" #endif - #ifdef Q_OS_WIN32 - #include "engine/directsounddevicefinder.h" +# include "directsounddevicefinder.h" #endif #include "settings/backendsettingspage.h" @@ -117,7 +127,7 @@ GstEngine::GstEngine(TaskManager *task_manager) #ifdef Q_OS_DARWIN QDir resources_dir(mac::GetResourcesPath()); QString ca_cert_path = resources_dir.filePath("cacert.pem"); - GError* error = nullptr; + GError *error = nullptr; tls_database_ = g_tls_file_database_new(ca_cert_path.toUtf8().data(), &error); #endif @@ -149,6 +159,10 @@ void GstEngine::InitialiseGStreamer() { gst_init(nullptr, nullptr); gst_pb_utils_init(); +#ifdef HAVE_IMOBILEDEVICE_ // FIXME + afcsrc_register_static(); +#endif + } void GstEngine::SetEnvironment() { @@ -162,7 +176,7 @@ void GstEngine::SetEnvironment() { scanner_path = QCoreApplication::applicationDirPath() + "/../PlugIns/gst-plugin-scanner"; plugin_path = QCoreApplication::applicationDirPath() + "/../PlugIns/gstreamer"; #elif defined(Q_OS_WIN32) - plugin_path = QCoreApplication::applicationDirPath() + "/gstreamer-plugins"; + plugin_path = QDir::toNativeSeparators(QCoreApplication::applicationDirPath() + "/gstreamer-plugins"); #endif #if defined(Q_OS_WIN32) || defined(Q_OS_DARWIN) @@ -301,6 +315,7 @@ const Engine::Scope &GstEngine::scope(int chunk_length) { } return scope_; + } void GstEngine::UpdateScope(int chunk_length) { @@ -348,6 +363,7 @@ void GstEngine::UpdateScope(int chunk_length) { gst_buffer_unref(latest_buffer_); latest_buffer_ = nullptr; } + } void GstEngine::StartPreloading(const QUrl &url, bool force_stop_at_end, qint64 beginning_nanosec, qint64 end_nanosec) { @@ -464,6 +480,7 @@ void GstEngine::StartFadeoutPause() { } connect(fadeout_pause_pipeline_.get(), SIGNAL(FaderFinished()), SLOT(FadeoutPauseFinished())); is_fading_out_to_pause_ = true; + } bool GstEngine::Play(quint64 offset_nanosec) { @@ -480,6 +497,7 @@ bool GstEngine::Play(quint64 offset_nanosec) { } return true; + } void GstEngine::PlayDone(QFuture future, const quint64 offset_nanosec, const int pipeline_id) { @@ -517,6 +535,7 @@ void GstEngine::PlayDone(QFuture future, const quint64 off emit StateChanged(Engine::Playing); // we've successfully started playing a media stream with this url emit ValidSongRequested(url_); + } void GstEngine::Stop(bool stop_after) { @@ -541,6 +560,7 @@ void GstEngine::Stop(bool stop_after) { current_pipeline_.reset(); BufferingFinished(); emit StateChanged(Engine::Empty); + } void GstEngine::FadeoutFinished() { @@ -549,6 +569,7 @@ void GstEngine::FadeoutFinished() { } void GstEngine::FadeoutPauseFinished() { + fadeout_pause_pipeline_->SetState(GST_STATE_PAUSED); current_pipeline_->SetState(GST_STATE_PAUSED); emit StateChanged(Engine::Paused); @@ -560,6 +581,7 @@ void GstEngine::FadeoutPauseFinished() { fadeout_pipeline_.reset(); emit FadeoutFinishedSignal(); + } void GstEngine::Pause() { @@ -586,6 +608,7 @@ void GstEngine::Pause() { StopTimers(); } } + } void GstEngine::Unpause() { @@ -792,7 +815,7 @@ shared_ptr GstEngine::CreatePipeline() { ret->set_mono_playback(mono_playback_); ret->AddBufferConsumer(this); - for (BufferConsumer *consumer : buffer_consumers_) { + for (GstBufferConsumer *consumer : buffer_consumers_) { ret->AddBufferConsumer(consumer); } @@ -832,12 +855,12 @@ bool GstEngine::ALSADeviceSupport(const QString &name) { } -void GstEngine::AddBufferConsumer(BufferConsumer *consumer) { +void GstEngine::AddBufferConsumer(GstBufferConsumer *consumer) { buffer_consumers_ << consumer; if (current_pipeline_) current_pipeline_->AddBufferConsumer(consumer); } -void GstEngine::RemoveBufferConsumer(BufferConsumer *consumer) { +void GstEngine::RemoveBufferConsumer(GstBufferConsumer *consumer) { buffer_consumers_.removeAll(consumer); if (current_pipeline_) current_pipeline_->RemoveBufferConsumer(consumer); } diff --git a/src/engine/gstengine.h b/src/engine/gstengine.h index 17fc221f..fa9a4446 100644 --- a/src/engine/gstengine.h +++ b/src/engine/gstengine.h @@ -1,7 +1,7 @@ /*************************************************************************** * Copyright (C) 2003-2005 by Mark Kretschmann * * Copyright (C) 2005 by Jakub Stachowski * - * Portions Copyright (C) 2006 Paul Cifarelli * + * Copyright (C) 2006 Paul Cifarelli * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * @@ -25,25 +25,28 @@ #include "config.h" #include +#include #include +#include +#include #include -#include +#include #include +#include #include -#include +#include +#include #include -#include "bufferconsumer.h" -#include "enginebase.h" #include "core/timeconstants.h" +#include "engine_fwd.h" +#include "enginebase.h" +#include "gstbufferconsumer.h" -class QTimer; -class QTimerEvent; - -class GstEnginePipeline; class TaskManager; +class GstEnginePipeline; #ifdef Q_OS_DARWIN struct _GTlsDatabase; @@ -55,7 +58,7 @@ typedef struct _GTlsDatabase GTlsDatabase; * @short GStreamer engine plugin * @author Mark Kretschmann */ -class GstEngine : public Engine::Base, public BufferConsumer { +class GstEngine : public Engine::Base, public GstBufferConsumer { Q_OBJECT public: @@ -112,8 +115,8 @@ class GstEngine : public Engine::Base, public BufferConsumer { void ReloadSettings(); - void AddBufferConsumer(BufferConsumer *consumer); - void RemoveBufferConsumer(BufferConsumer *consumer); + void AddBufferConsumer(GstBufferConsumer *consumer); + void RemoveBufferConsumer(GstBufferConsumer *consumer); #ifdef Q_OS_DARWIN GTlsDatabase *tls_database() const { return tls_database_; } @@ -172,7 +175,7 @@ class GstEngine : public Engine::Base, public BufferConsumer { std::shared_ptr fadeout_pause_pipeline_; QUrl preloaded_url_; - QList buffer_consumers_; + QList buffer_consumers_; GstBuffer *latest_buffer_; diff --git a/src/engine/gstenginepipeline.cpp b/src/engine/gstenginepipeline.cpp index 6bcf04e0..0337c671 100644 --- a/src/engine/gstenginepipeline.cpp +++ b/src/engine/gstenginepipeline.cpp @@ -20,28 +20,32 @@ #include "config.h" -#include +#include +#include +#include +#include +#include +#include #include -#include -#include +#include #include +#include #include #include -#include -#include +#include #include -#include +#include -#include "bufferconsumer.h" -#include "gstelementdeleter.h" -#include "gstengine.h" -#include "gstenginepipeline.h" #include "core/concurrentrun.h" #include "core/logging.h" -#include "core/mac_startup.h" #include "core/signalchecker.h" -#include "core/utilities.h" +#include "core/timeconstants.h" +#include "enginebase.h" +#include "gstengine.h" +#include "gstenginepipeline.h" +#include "gstbufferconsumer.h" +#include "gstelementdeleter.h" const int GstEnginePipeline::kGstStateTimeoutNanosecs = 10000000; const int GstEnginePipeline::kFaderFudgeMsec = 2000; @@ -112,11 +116,12 @@ void GstEnginePipeline::set_output_device(const QString &sink, const QVariant &d } void GstEnginePipeline::set_replaygain(bool enabled, int mode, float preamp, bool compression) { - + rg_enabled_ = enabled; rg_mode_ = mode; rg_preamp_ = preamp; rg_compression_ = compression; + } void GstEnginePipeline::set_buffer_duration_nanosec(qint64 buffer_duration_nanosec) { @@ -203,13 +208,10 @@ bool GstEnginePipeline::InitAudioBin() { if (device_.toString().isEmpty()) break; g_object_set(G_OBJECT(audiosink_), "device", device_.toString().toUtf8().constData(), nullptr); break; -#ifdef Q_OS_WIN32 case QVariant::ByteArray: { - GUID guid = QUuid(device_.toByteArray()); - g_object_set(G_OBJECT(audiosink_), "device", &guid, nullptr); + g_object_set(G_OBJECT(audiosink_), "device", device_.toByteArray().constData(), nullptr); break; } -#endif // Q_OS_WIN32 default: qLog(Warning) << "Unknown device type" << device_; break; @@ -536,8 +538,8 @@ void GstEnginePipeline::ElementMessageReceived(GstMessage *msg) { void GstEnginePipeline::ErrorMessageReceived(GstMessage *msg) { - GError *error; - gchar *debugs; + GError *error = nullptr; + gchar *debugs = nullptr; gst_message_parse_error(msg, &error, &debugs); QString message = QString::fromLocal8Bit(error->message); @@ -736,13 +738,13 @@ GstPadProbeReturn GstEnginePipeline::HandoffCallback(GstPad*, GstPadProbeInfo *i GstEnginePipeline *instance = reinterpret_cast(self); GstBuffer *buf = gst_pad_probe_info_get_buffer(info); - QList consumers; + QList consumers; { QMutexLocker l(&instance->buffer_consumers_mutex_); consumers = instance->buffer_consumers_; } - for (BufferConsumer *consumer : consumers) { + for (GstBufferConsumer *consumer : consumers) { gst_buffer_ref(buf); consumer->ConsumeBuffer(buf, instance->id()); } @@ -1038,12 +1040,12 @@ void GstEnginePipeline::timerEvent(QTimerEvent *e) { } -void GstEnginePipeline::AddBufferConsumer(BufferConsumer *consumer) { +void GstEnginePipeline::AddBufferConsumer(GstBufferConsumer *consumer) { QMutexLocker l(&buffer_consumers_mutex_); buffer_consumers_ << consumer; } -void GstEnginePipeline::RemoveBufferConsumer(BufferConsumer *consumer) { +void GstEnginePipeline::RemoveBufferConsumer(GstBufferConsumer *consumer) { QMutexLocker l(&buffer_consumers_mutex_); buffer_consumers_.removeAll(consumer); } diff --git a/src/engine/gstenginepipeline.h b/src/engine/gstenginepipeline.h index 4f6c3ab3..a0a17401 100644 --- a/src/engine/gstenginepipeline.h +++ b/src/engine/gstenginepipeline.h @@ -24,25 +24,32 @@ #include "config.h" #include - +#include +#include +#include +#include #include -#include -#include -#include +#include #include +#include #include +#include #include +#include #include +#include #include +#include +#include -#include "engine_fwd.h" - -class GstElementDeleter; class GstEngine; -class BufferConsumer; +class GstBufferConsumer; +class GstElementDeleter; -struct GstQueue; +namespace Engine { +struct SimpleMetaBundle; +} // namespace Engine struct GstPlayBin; class GstEnginePipeline : public QObject { @@ -66,9 +73,9 @@ class GstEnginePipeline : public QObject { bool InitFromUrl(const QByteArray &url, qint64 end_nanosec); bool InitFromString(const QString &pipeline); - // BufferConsumers get fed audio data. Thread-safe. - void AddBufferConsumer(BufferConsumer *consumer); - void RemoveBufferConsumer(BufferConsumer *consumer); + // GstBufferConsumers get fed audio data. Thread-safe. + void AddBufferConsumer(GstBufferConsumer *consumer); + void RemoveBufferConsumer(GstBufferConsumer *consumer); void RemoveAllBufferConsumers(); // Control the music playback @@ -176,7 +183,7 @@ signals: QVariant device_; // These get called when there is a new audio buffer available - QList buffer_consumers_; + QList buffer_consumers_; QMutex buffer_consumers_mutex_; qint64 segment_start_; bool segment_start_received_; diff --git a/src/engine/osxdevicefinder.cpp b/src/engine/osxdevicefinder.cpp index dd9373c6..3af8722f 100644 --- a/src/engine/osxdevicefinder.cpp +++ b/src/engine/osxdevicefinder.cpp @@ -24,6 +24,9 @@ #include +#include +#include + #include "osxdevicefinder.h" #include "core/logging.h" #include "core/scoped_cftyperef.h" diff --git a/src/engine/osxdevicefinder.h b/src/engine/osxdevicefinder.h index bd46c652..74a83741 100644 --- a/src/engine/osxdevicefinder.h +++ b/src/engine/osxdevicefinder.h @@ -23,7 +23,9 @@ #include "config.h" -#include "engine/devicefinder.h" +#include + +#include "devicefinder.h" class OsxDeviceFinder : public DeviceFinder { public: @@ -34,4 +36,3 @@ class OsxDeviceFinder : public DeviceFinder { }; #endif // OSXDEVICEFINDER_H - diff --git a/src/engine/phononengine.cpp b/src/engine/phononengine.cpp index 7381dd66..40a0d51d 100644 --- a/src/engine/phononengine.cpp +++ b/src/engine/phononengine.cpp @@ -16,12 +16,14 @@ #include "config.h" +#include +#include #include #include "phononengine.h" #include "core/logging.h" -#include "core/taskmanager.h" +#include "taskmanager.h" PhononEngine::PhononEngine(TaskManager *task_manager) : media_object_(new Phonon::MediaObject(this)), @@ -63,8 +65,7 @@ bool PhononEngine::Load(const QUrl &url, Engine::TrackChangeFlags change, bool f bool PhononEngine::Play(quint64 offset_nanosec) { - // The seek happens in PhononStateChanged - phonon doesn't seem to change - // currentTime() if we seek before we start playing :S + // The seek happens in PhononStateChanged - phonon doesn't seem to change currentTime() if we seek before we start playing :S seek_offset_ = offset_nanosec; media_object_->play(); @@ -144,16 +145,12 @@ void PhononEngine::StateTimeoutExpired() { qint64 PhononEngine::position_nanosec() const { - //qLog(Debug) << __PRETTY_FUNCTION__; - return 0; } qint64 PhononEngine::length_nanosec() const { - //qLog(Debug) << __PRETTY_FUNCTION__; - return 0; } diff --git a/src/engine/phononengine.h b/src/engine/phononengine.h index 8bc5bc9b..3d500dd0 100644 --- a/src/engine/phononengine.h +++ b/src/engine/phononengine.h @@ -19,11 +19,15 @@ #include "config.h" -#include "enginebase.h" - #include #include +#include +#include +#include + +#include "enginebase.h" + class QTimer; class TaskManager; @@ -49,7 +53,7 @@ class PhononEngine : public Engine::Base { uint length() const; void Seek(quint64 offset_nanosec); - + qint64 position_nanosec() const; qint64 length_nanosec() const; diff --git a/src/engine/pulsedevicefinder.cpp b/src/engine/pulsedevicefinder.cpp index a5c09c2c..fe224397 100644 --- a/src/engine/pulsedevicefinder.cpp +++ b/src/engine/pulsedevicefinder.cpp @@ -20,14 +20,19 @@ #include "config.h" -#include - #include +#include #include #include +#include + +#include +#include +#include #include "core/logging.h" -#include "engine/pulsedevicefinder.h" +#include "devicefinder.h" +#include "pulsedevicefinder.h" PulseDeviceFinder::PulseDeviceFinder() : DeviceFinder("pulseaudio"), mainloop_(nullptr), context_(nullptr) { } diff --git a/src/engine/pulsedevicefinder.h b/src/engine/pulsedevicefinder.h index 81a1fc2b..c1c5789a 100644 --- a/src/engine/pulsedevicefinder.h +++ b/src/engine/pulsedevicefinder.h @@ -23,14 +23,14 @@ #include "config.h" -#include -#include - +#include #include #include #include -#include "engine/devicefinder.h" +#include + +#include "devicefinder.h" class PulseDeviceFinder : public DeviceFinder { public: diff --git a/src/engine/vlcengine.cpp b/src/engine/vlcengine.cpp index 0441afb3..5a60ac13 100644 --- a/src/engine/vlcengine.cpp +++ b/src/engine/vlcengine.cpp @@ -16,20 +16,21 @@ #include "config.h" -#include +#include +#include -#include -#include -#include -#include +#include +#include +#include +#include +#include "engine_fwd.h" +#include "enginebase.h" +#include "enginetype.h" #include "vlcengine.h" #include "vlcscopedref.h" -#include "core/taskmanager.h" -#include "core/logging.h" - -VLCEngine* VLCEngine::sInstance = NULL; +VLCEngine *VLCEngine::sInstance = NULL; VLCEngine::VLCEngine(TaskManager *task_manager) : instance_(NULL), @@ -38,10 +39,8 @@ VLCEngine::VLCEngine(TaskManager *task_manager) state_(Engine::Empty) { - //qLog(Debug) << __PRETTY_FUNCTION__; - #if 1 - static const char * const args[] = { + static const char *const args[] = { "-I", "dummy", // Don't use any interface "--ignore-config", // Don't use VLC's config "--extraintf=logger", // log anything @@ -71,7 +70,7 @@ VLCEngine::VLCEngine(TaskManager *task_manager) HandleErrors(); // Add event handlers - libvlc_event_manager_t* player_em = libvlc_media_player_event_manager(player_); + libvlc_event_manager_t *player_em = libvlc_media_player_event_manager(player_); HandleErrors(); AttachCallback(player_em, libvlc_MediaPlayerEncounteredError, StateChangedCallback); @@ -89,27 +88,23 @@ VLCEngine::VLCEngine(TaskManager *task_manager) VLCEngine::~VLCEngine() { - //qLog(Debug) << __PRETTY_FUNCTION__; - libvlc_media_player_stop(player_); libvlc_media_player_release(player_); libvlc_release(instance_); HandleErrors(); + } -void VLCEngine::AttachCallback(libvlc_event_manager_t* em, libvlc_event_type_t type, libvlc_callback_t callback) { - - //qLog(Debug) << __PRETTY_FUNCTION__; +void VLCEngine::AttachCallback(libvlc_event_manager_t *em, libvlc_event_type_t type, libvlc_callback_t callback) { libvlc_event_attach(em, type, callback, this); HandleErrors(); + } -void VLCEngine::StateChangedCallback(const libvlc_event_t* e, void* data) { +void VLCEngine::StateChangedCallback(const libvlc_event_t *e, void *data) { - //qLog(Debug) << __PRETTY_FUNCTION__; - - VLCEngine* engine = reinterpret_cast(data); + VLCEngine *engine = reinterpret_cast(data); switch (e->type) { case libvlc_MediaPlayerNothingSpecial: @@ -135,11 +130,10 @@ void VLCEngine::StateChangedCallback(const libvlc_event_t* e, void* data) { } emit engine->StateChanged(engine->state_); + } bool VLCEngine::Init() { - - //qLog(Debug) << __PRETTY_FUNCTION__; type_ = Engine::VLC; @@ -148,16 +142,12 @@ bool VLCEngine::Init() { bool VLCEngine::CanDecode(const QUrl &url) { - //qLog(Debug) << __PRETTY_FUNCTION__; - // TODO return true; } bool VLCEngine::Load(const QUrl &url, Engine::TrackChangeFlags change, bool force_stop_at_end, quint64 beginning_nanosec, qint64 end_nanosec) { - //qLog(Debug) << __PRETTY_FUNCTION__; - // Create the media object VlcScopedRef media(libvlc_media_new_location(instance_, url.toEncoded().constData())); //if (libvlc_exception_raised(&exception_)) @@ -168,11 +158,10 @@ bool VLCEngine::Load(const QUrl &url, Engine::TrackChangeFlags change, bool forc //return false; return true; + } bool VLCEngine::Play(quint64 offset_nanosec) { - - //qLog(Debug) << __PRETTY_FUNCTION__; libvlc_media_player_play(player_); //if (libvlc_exception_raised(&exception_)) @@ -187,31 +176,23 @@ bool VLCEngine::Play(quint64 offset_nanosec) { void VLCEngine::Stop(bool stop_after) { - //qLog(Debug) << __PRETTY_FUNCTION__; - libvlc_media_player_stop(player_); HandleErrors(); } void VLCEngine::Pause() { - //qLog(Debug) << __PRETTY_FUNCTION__; - libvlc_media_player_pause(player_); HandleErrors(); } void VLCEngine::Unpause() { - //qLog(Debug) << __PRETTY_FUNCTION__; - libvlc_media_player_play(player_); HandleErrors(); } uint VLCEngine::position() const { - - //qLog(Debug) << __PRETTY_FUNCTION__; //bool is_playing = libvlc_media_player_is_playing(player_, const_cast(&exception_)); bool is_playing = libvlc_media_player_is_playing(player_); @@ -229,8 +210,6 @@ uint VLCEngine::position() const { } uint VLCEngine::length() const { - - //qLog(Debug) << __PRETTY_FUNCTION__; //bool is_playing = libvlc_media_player_is_playing(player_, const_cast(&exception_)); bool is_playing = libvlc_media_player_is_playing(player_); @@ -248,8 +227,6 @@ uint VLCEngine::length() const { } void VLCEngine::Seek(quint64 offset_nanosec) { - - //qLog(Debug) << __PRETTY_FUNCTION__; uint len = length(); if (len == 0) @@ -264,15 +241,11 @@ void VLCEngine::Seek(quint64 offset_nanosec) { void VLCEngine::SetVolumeSW(uint percent) { - //qLog(Debug) << __PRETTY_FUNCTION__; - libvlc_audio_set_volume(player_, percent); HandleErrors(); } void VLCEngine::HandleErrors() const { - - //qLog(Debug) << __PRETTY_FUNCTION__; //if (libvlc_exception_raised(&exception_)) { //qFatal("libvlc error: %s", libvlc_exception_get_message(&exception_)); @@ -280,9 +253,7 @@ void VLCEngine::HandleErrors() const { } -void VLCEngine::SetScopeData(float* data, int size) { - - //qLog(Debug) << __PRETTY_FUNCTION__; +void VLCEngine::SetScopeData(float *data, int size) { if (!sInstance) return; @@ -297,8 +268,6 @@ void VLCEngine::SetScopeData(float* data, int size) { } const Engine::Scope& VLCEngine::Scope() { - - //qLog(Debug) << __PRETTY_FUNCTION__; QMutexLocker l(&scope_mutex_); @@ -319,17 +288,12 @@ const Engine::Scope& VLCEngine::Scope() { qint64 VLCEngine::position_nanosec() const { - //qLog(Debug) << __PRETTY_FUNCTION__; - return 0; } qint64 VLCEngine::length_nanosec() const { - //qLog(Debug) << __PRETTY_FUNCTION__; - return 0; } - diff --git a/src/engine/vlcengine.h b/src/engine/vlcengine.h index af1049fd..f0a4d76b 100644 --- a/src/engine/vlcengine.h +++ b/src/engine/vlcengine.h @@ -19,14 +19,21 @@ #include "config.h" +#include +#include +#include + +#include +#include +#include +#include +#include + +#include "engine_fwd.h" #include "enginebase.h" -#include -#include +struct libvlc_event_t; -#include - -class QTimer; class TaskManager; class VLCEngine : public Engine::Base { diff --git a/src/engine/xineengine.cpp b/src/engine/xineengine.cpp index 78356098..df4a7045 100644 --- a/src/engine/xineengine.cpp +++ b/src/engine/xineengine.cpp @@ -16,30 +16,40 @@ #include "config.h" +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "core/logging.h" +#include "engine_fwd.h" +#include "enginebase.h" +#include "enginetype.h" #include "xineengine.h" #include "xinescope.h" -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "enginetype.h" -#include "enginebase.h" - -#include "core/logging.h" - extern "C" { +#include #include } @@ -81,15 +91,11 @@ XineEngine::XineEngine(TaskManager *task_manager) , equalizerEnabled_( false ) , prune_(NULL) { - - //qLog(Debug) << __PRETTY_FUNCTION__; ReloadSettings(); } XineEngine::~XineEngine() { - - //qLog(Debug) << __PRETTY_FUNCTION__; // Wait until the fader thread is done if( s_fader ) { @@ -133,8 +139,6 @@ void XineEngine::ReloadSettings() { QSettings s; - //qLog(Debug) << __PRETTY_FUNCTION__; - Engine::Base::ReloadSettings(); s.beginGroup(BackendSettingsPage::kSettingsGroup); @@ -153,8 +157,6 @@ void XineEngine::ReloadSettings() { bool XineEngine::Init() { - //qLog(Debug) << __PRETTY_FUNCTION__; - type_ = Engine::Xine; #ifdef Q_OS_WIN32 @@ -195,8 +197,6 @@ bool XineEngine::Init() { bool XineEngine::makeNewStream() { - //qLog(Debug) << __PRETTY_FUNCTION__; - audioPort_ = xine_open_audio_driver(xine_, currentAudioPlugin_.toLocal8Bit().constData(), NULL); if( !audioPort_ ) { //TODO make engine method that is the same but parents the dialog for us @@ -215,10 +215,7 @@ bool XineEngine::makeNewStream() { if( eventQueue_ ) xine_event_dispose_queue( eventQueue_ ); - xine_event_create_listener_thread( - eventQueue_ = xine_event_new_queue( stream_ ), - &XineEngine::XineEventListener, - (void*)this ); + xine_event_create_listener_thread(eventQueue_ = xine_event_new_queue( stream_ ), &XineEngine::XineEventListener, (void*)this ); #ifndef XINE_SAFE_MODE //implemented in xine-scope.h @@ -240,8 +237,6 @@ bool XineEngine::makeNewStream() { // Makes sure an audio port and a stream exist. bool XineEngine::ensureStream() { - //qLog(Debug) << __PRETTY_FUNCTION__; - if(!stream_) return makeNewStream(); return true; @@ -249,8 +244,6 @@ bool XineEngine::ensureStream() { } bool XineEngine::Load(const QUrl &url, Engine::TrackChangeFlags change, bool force_stop_at_end, quint64 beginning_nanosec, qint64 end_nanosec) { - - //qLog(Debug) << __PRETTY_FUNCTION__; if( !ensureStream() ) return false; @@ -301,10 +294,6 @@ bool XineEngine::Load(const QUrl &url, Engine::TrackChangeFlags change, bool for } else { -#ifdef XINE_PARAM_GAPLESS_SWITCH - //if ( xine_check_version(1,1,1) && !(xfadeLength_ > 0) ) - //xine_set_param( stream_, XINE_PARAM_GAPLESS_SWITCH, 0); -#endif } // FAILURE to load! @@ -315,8 +304,6 @@ bool XineEngine::Load(const QUrl &url, Engine::TrackChangeFlags change, bool for } bool XineEngine::Play(quint64 offset_nanosec) { - - //qLog(Debug) << __PRETTY_FUNCTION__; if( !ensureStream() ) return false; @@ -345,8 +332,6 @@ bool XineEngine::Play(quint64 offset_nanosec) { } void XineEngine::determineAndShowErrorMessage() { - - //qLog(Debug) << __PRETTY_FUNCTION__; QString body; @@ -396,8 +381,6 @@ void XineEngine::determineAndShowErrorMessage() { } void XineEngine::Stop(bool stop_after) { - - //qLog(Debug) << __PRETTY_FUNCTION__; if( s_fader && s_fader->isRunning()) s_fader->resume(); // safety call if the engine is in the pause state @@ -425,8 +408,6 @@ void XineEngine::Stop(bool stop_after) { } void XineEngine::Pause() { - - //qLog(Debug) << __PRETTY_FUNCTION__; if ( !stream_ ) return; @@ -444,8 +425,6 @@ void XineEngine::Pause() { } void XineEngine::Unpause() { - - //qLog(Debug) << __PRETTY_FUNCTION__; if ( !stream_ ) return; @@ -461,8 +440,6 @@ void XineEngine::Unpause() { } Engine::State XineEngine::state() const { - - //qLog(Debug) << __PRETTY_FUNCTION__; if ( !stream_ || fadeOutRunning_ ) return Engine::Empty; @@ -512,8 +489,6 @@ uint XineEngine::position() const { } uint XineEngine::length() const { - - //qLog(Debug) << __PRETTY_FUNCTION__; if ( !stream_ ) return 0; @@ -539,8 +514,6 @@ uint XineEngine::length() const { void XineEngine::Seek(quint64 offset_nanosec) { - //qLog(Debug) << __PRETTY_FUNCTION__; - if( !ensureStream() ) return; @@ -562,8 +535,6 @@ void XineEngine::SetVolumeSW( uint vol ) { } void XineEngine::fadeOut( uint fadeLength, bool* terminate, bool exiting ) { - - //qLog(Debug) << __PRETTY_FUNCTION__; if( fadeOutRunning_ ) //Let us not start another fadeout... return; @@ -608,8 +579,6 @@ void XineEngine::fadeOut( uint fadeLength, bool* terminate, bool exiting ) { } void XineEngine::setEqualizerEnabled( bool enable ) { - - //qLog(Debug) << __PRETTY_FUNCTION__; if ( !stream_ ) return; @@ -637,8 +606,6 @@ pre: (-100..100) post: (1..200) - (1 = down, 100 = middle, 200 = up, 0 = off) */ void XineEngine::setEqualizerParameters( int preamp, const QList &gains ) { - - //qLog(Debug) << __PRETTY_FUNCTION__; if ( !stream_ ) return; @@ -663,8 +630,6 @@ void XineEngine::setEqualizerParameters( int preamp, const QList &gains ) { } bool XineEngine::CanDecode( const QUrl &url ) { - - //qLog(Debug) << __PRETTY_FUNCTION__; static QStringList list; if (list.isEmpty()) { @@ -702,8 +667,7 @@ bool XineEngine::CanDecode( const QUrl &url ) { QString path = url.path(); - // partial downloads from Konqi and other browsers - // tend to have a .part extension + // partial downloads from Konqi and other browsers tend to have a .part extension if (path.endsWith( ".part" )) path = path.left( path.length() - 5 ); @@ -713,8 +677,6 @@ bool XineEngine::CanDecode( const QUrl &url ) { } const Engine::Scope & XineEngine::scope(int chunk_length) { - - //qLog(Debug) << __PRETTY_FUNCTION__; if( !post_ || !stream_ || xine_get_status( stream_ ) != XINE_STATUS_PLAY ) return scope_; @@ -780,8 +742,6 @@ const Engine::Scope & XineEngine::scope(int chunk_length) { } void XineEngine::PruneScope() { - - //qLog(Debug) << __PRETTY_FUNCTION__; if (!stream_) return; @@ -818,8 +778,6 @@ void XineEngine::PruneScope() { } bool XineEngine::event( QEvent *e ) { - - //qLog(Debug) << __PRETTY_FUNCTION__; #define message static_cast(static_cast(e)->data()) #if 0 @@ -870,8 +828,6 @@ bool XineEngine::event( QEvent *e ) { //SLOT void XineEngine::playlistChanged() { - - //qLog(Debug) << __PRETTY_FUNCTION__; // TODO /*#ifdef XINE_PARAM_EARLY_FINISHED_EVENT @@ -896,8 +852,6 @@ static time_t last_error_time = 0; // hysteresis on xine errors static int last_error = XINE_MSG_NO_ERROR; void XineEngine::XineEventListener( void *p, const xine_event_t* xineEvent ) { - - //qLog(Debug) << __PRETTY_FUNCTION__; time_t current; @@ -917,16 +871,6 @@ void XineEngine::XineEventListener( void *p, const xine_event_t* xineEvent ) { case XINE_EVENT_UI_PLAYBACK_FINISHED: qDebug() << "XINE_EVENT_UI_PLAYBACK_FINISHED"; - -#ifdef XINE_PARAM_GAPLESS_SWITCH - // TODO - /*if ( xine_check_version(1,1,1) && xe->url_.isLocalFile() //Remote media break with gapless - //don't prepare for a track that isn't coming - && Playlist::instance() - && Playlist::instance()->isTrackAfter() - && !AmarokConfig::crossfade() ) - xine_set_param( xe->stream_, XINE_PARAM_GAPLESS_SWITCH, 1);*/ -#endif //emit signal from GUI thread QApplication::postEvent( xe, new XineEvent(XineEvent::PlaybackFinished) ); break; @@ -934,10 +878,8 @@ void XineEngine::XineEventListener( void *p, const xine_event_t* xineEvent ) { case XINE_EVENT_PROGRESS: { xine_progress_data_t* pd = (xine_progress_data_t*)xineEvent->data; - QString - msg = "%1 %2%"; - msg = msg.arg( QString::fromUtf8( pd->description ) ) - .arg( QString::number(pd->percent) + QLocale::system().percent() ); + QString msg = "%1 %2%"; + msg = msg.arg( QString::fromUtf8( pd->description ) ).arg( QString::number(pd->percent) + QLocale::system().percent() ); XineEvent *e = new XineEvent( XineEvent::StatusMessage ); e->setData( new QString( msg ) ); @@ -950,8 +892,7 @@ void XineEngine::XineEventListener( void *p, const xine_event_t* xineEvent ) { /// xine has read the stream and found it actually links to something else /// so we need to play that instead - QString message = QString::fromUtf8( - static_cast(xineEvent->data)->mrl); + QString message = QString::fromUtf8(static_cast(xineEvent->data)->mrl); XineEvent *e = new XineEvent( XineEvent::Redirecting ); e->setData( new QString( message ) ); @@ -1088,36 +1029,24 @@ XineEngine::fetchMetaData() const bool XineEngine::metaDataForUrl(const QUrl &url, Engine::SimpleMetaBundle &b) { - //qLog(Debug) << __PRETTY_FUNCTION__; - bool result = false; xine_stream_t* tmpstream = xine_stream_new(xine_, NULL, NULL); if (xine_open(tmpstream, QFile::encodeName(url.toString()))) { QString audioCodec = QString::fromUtf8(xine_get_meta_info(tmpstream, XINE_META_INFO_SYSTEMLAYER)); if (audioCodec == "CDDA") { - QString title = QString::fromUtf8( - xine_get_meta_info(tmpstream, XINE_META_INFO_TITLE)); + QString title = QString::fromUtf8(xine_get_meta_info(tmpstream, XINE_META_INFO_TITLE)); if ((!title.isNull()) && (!title.isEmpty())) { //no meta info b.title = title; - b.artist = - QString::fromUtf8( - xine_get_meta_info(tmpstream, XINE_META_INFO_ARTIST)); - b.album = - QString::fromUtf8( - xine_get_meta_info(tmpstream, XINE_META_INFO_ALBUM)); - b.genre = - QString::fromUtf8( - xine_get_meta_info(tmpstream, XINE_META_INFO_GENRE)); - b.year = - QString::fromUtf8( - xine_get_meta_info(tmpstream, XINE_META_INFO_YEAR)); - b.tracknr = - QString::fromUtf8( - xine_get_meta_info(tmpstream, XINE_META_INFO_TRACK_NUMBER)); + b.artist = QString::fromUtf8(xine_get_meta_info(tmpstream, XINE_META_INFO_ARTIST)); + b.album = QString::fromUtf8(xine_get_meta_info(tmpstream, XINE_META_INFO_ALBUM)); + b.genre = QString::fromUtf8(xine_get_meta_info(tmpstream, XINE_META_INFO_GENRE)); + b.year = QString::fromUtf8(xine_get_meta_info(tmpstream, XINE_META_INFO_YEAR)); + b.tracknr = QString::fromUtf8(xine_get_meta_info(tmpstream, XINE_META_INFO_TRACK_NUMBER)); if( b.tracknr.isEmpty() ) b.tracknr = QFileInfo(url.path()).fileName(); - } else { + } + else { b.title = QString("Track %1").arg(QFileInfo(url.path()).fileName()); b.album = "AudioCD"; } @@ -1127,8 +1056,7 @@ bool XineEngine::metaDataForUrl(const QUrl &url, Engine::SimpleMetaBundle &b) { result = true; int samplerate = xine_get_stream_info( tmpstream, XINE_STREAM_INFO_AUDIO_SAMPLERATE ); - // xine would provide a XINE_STREAM_INFO_AUDIO_BITRATE, but unfortunately not for CDDA or WAV - // so we calculate the bitrate by our own + // xine would provide a XINE_STREAM_INFO_AUDIO_BITRATE, but unfortunately not for CDDA or WAV so we calculate the bitrate by our own int bitsPerSample = xine_get_stream_info( tmpstream, XINE_STREAM_INFO_AUDIO_BITS ); int nbrChannels = xine_get_stream_info( tmpstream, XINE_STREAM_INFO_AUDIO_CHANNELS ); int bitrate = (samplerate * bitsPerSample * nbrChannels) / 1000; @@ -1146,8 +1074,6 @@ bool XineEngine::metaDataForUrl(const QUrl &url, Engine::SimpleMetaBundle &b) { } bool XineEngine::getAudioCDContents(const QString &device, QList &urls) { - - //qLog(Debug) << __PRETTY_FUNCTION__; const char * const *xine_urls = NULL; int num; @@ -1205,8 +1131,6 @@ Fader::Fader( XineEngine *engine, uint fadeMs ) , terminated_( false ) { - //qLog(Debug) << __PRETTY_FUNCTION__; - if( engine->makeNewStream() ) { increase_ = engine->stream_; @@ -1219,8 +1143,6 @@ Fader::Fader( XineEngine *engine, uint fadeMs ) } Fader::~Fader() { - - //qLog(Debug) << __PRETTY_FUNCTION__; wait(); @@ -1237,8 +1159,6 @@ Fader::~Fader() { } void Fader::run() { - - //qLog(Debug) << __PRETTY_FUNCTION__; // do a volume change in 100 steps (or every 10ms) uint stepsCount = fadeLength_ < 1000 ? fadeLength_ / 10 : 100; @@ -1246,8 +1166,7 @@ void Fader::run() { float mix = 0.0; float elapsedUs = 0.0; - while ( mix < 1.0 ) - { + while ( mix < 1.0 ) { if ( terminated_ ) break; // sleep a constant amount of time @@ -1322,8 +1241,6 @@ OutFader::~OutFader() { } void OutFader::run() { - - //qLog(Debug) << __PRETTY_FUNCTION__; engine_->fadeOut( fadeLength_, &terminated_ ); @@ -1336,8 +1253,6 @@ void OutFader::run() { void OutFader::finish() { - //qLog(Debug) << __PRETTY_FUNCTION__; - terminated_ = true; } @@ -1347,8 +1262,6 @@ PruneScopeThread::PruneScopeThread(XineEngine *parent) } void PruneScopeThread::run() { - - //qLog(Debug) << __PRETTY_FUNCTION__; QTimer timer; connect(&timer, SIGNAL(timeout()), engine_, SLOT(PruneScope()), Qt::DirectConnection); @@ -1367,8 +1280,6 @@ qint64 XineEngine::length_nanosec() const { EngineBase::PluginDetailsList XineEngine::GetPluginList() const { - //qLog(Debug) << __PRETTY_FUNCTION__; - PluginDetailsList ret; const char *const *plugins = xine_list_audio_output_plugins(xine_); @@ -1398,8 +1309,6 @@ EngineBase::PluginDetailsList XineEngine::GetPluginList() const { EngineBase::OutputDetailsList XineEngine::GetOutputsList() const { - //qLog(Debug) << __PRETTY_FUNCTION__; - OutputDetailsList ret; PluginDetailsList plugins = GetPluginList(); diff --git a/src/engine/xineengine.h b/src/engine/xineengine.h index 1cdd431e..fa5253c2 100644 --- a/src/engine/xineengine.h +++ b/src/engine/xineengine.h @@ -13,20 +13,27 @@ #include "config.h" -#include "enginebase.h" +#include +#include +#include #include #include -#include -#include +#include +#include +#include extern "C" { + #include + #include + #include #include #include } -class XineConfigDialog; -//class DeviceFinder; +#include "engine_fwd.h" +#include "enginebase.h" + class TaskManager; class XineEvent : public QEvent { @@ -127,7 +134,6 @@ public: QMutex initMutex_; - //QSettings settings_; bool fadeoutOnExit_; bool fadeoutEnabled_; bool crossfadeEnabled_; diff --git a/src/engine/xinescope.c b/src/engine/xinescope.c index d844ca02..b1738d9a 100644 --- a/src/engine/xinescope.c +++ b/src/engine/xinescope.c @@ -17,8 +17,7 @@ typedef struct scope_plugin_s scope_plugin_t; -struct scope_plugin_s -{ +struct scope_plugin_s { post_plugin_t post; metronom_t metronom; @@ -30,9 +29,8 @@ struct scope_plugin_s * post plugin functions * *************************/ -static int -scope_port_open( xine_audio_port_t *port_gen, xine_stream_t *stream, uint32_t bits, uint32_t rate, int mode ) -{ +static int scope_port_open( xine_audio_port_t *port_gen, xine_stream_t *stream, uint32_t bits, uint32_t rate, int mode ) { + #define port ((post_audio_port_t*)port_gen) #define this ((scope_plugin_t*)((post_audio_port_t*)port_gen)->post) @@ -49,9 +47,8 @@ scope_port_open( xine_audio_port_t *port_gen, xine_stream_t *stream, uint32_t bi return port->original_port->open( port->original_port, stream, bits, rate, mode ); } -static void -scope_port_close( xine_audio_port_t *port_gen, xine_stream_t *stream ) -{ +static void scope_port_close( xine_audio_port_t *port_gen, xine_stream_t *stream ) { + MyNode *node; /* ensure the buffers are deleted during the next XineEngine::timerEvent() */ @@ -64,9 +61,7 @@ scope_port_close( xine_audio_port_t *port_gen, xine_stream_t *stream ) _x_post_dec_usage( port ); } -static void -scope_port_put_buffer( xine_audio_port_t *port_gen, audio_buffer_t *buf, xine_stream_t *stream ) -{ +static void scope_port_put_buffer( xine_audio_port_t *port_gen, audio_buffer_t *buf, xine_stream_t *stream ) { /* FIXME With 8-bit samples the scope won't work correctly. For a special 8-bit code path, the sample size could be checked like this: if( port->bits == 8 ) */ @@ -104,9 +99,7 @@ scope_port_put_buffer( xine_audio_port_t *port_gen, audio_buffer_t *buf, xine_st #undef this } -static void -scope_dispose( post_plugin_t *this ) -{ +static void scope_dispose( post_plugin_t *this ) { MyNode *list = ((scope_plugin_t*)this)->list; MyNode *prev; MyNode *node = list; @@ -131,9 +124,8 @@ scope_dispose( post_plugin_t *this ) * plugin init function * ************************/ -xine_post_t* -scope_plugin_new( xine_t *xine, xine_audio_port_t *audio_target ) -{ +xine_post_t* scope_plugin_new( xine_t *xine, xine_audio_port_t *audio_target ) { + scope_plugin_t *scope_plugin = calloc( 1, sizeof(scope_plugin_t) ); post_plugin_t *post_plugin = (post_plugin_t*)scope_plugin; @@ -169,20 +161,14 @@ scope_plugin_new( xine_t *xine, xine_audio_port_t *audio_target ) return &post_plugin->xine_post; } -MyNode* -scope_plugin_list( void *post ) -{ +MyNode* scope_plugin_list( void *post ) { return ((scope_plugin_t*)post)->list; } -int -scope_plugin_channels( void *post ) -{ +int scope_plugin_channels( void *post ) { return ((scope_plugin_t*)post)->channels; } -metronom_t* -scope_plugin_metronom( void *post ) -{ +metronom_t* scope_plugin_metronom( void *post ) { return &((scope_plugin_t*)post)->metronom; } diff --git a/src/equalizer/equalizer.cpp b/src/equalizer/equalizer.cpp index d32b617c..86853492 100644 --- a/src/equalizer/equalizer.cpp +++ b/src/equalizer/equalizer.cpp @@ -20,18 +20,34 @@ #include "config.h" -#include "equalizer.h" -#include "ui_equalizer.h" +#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #include -#include +#include +#include +#include +#include +#include +#include +#include +#include #include "core/iconloader.h" -#include "core/logging.h" +#include "equalizer.h" #include "equalizerslider.h" +#include "ui_equalizer.h" const char *Equalizer::kGainText[] = { "60", "170", "310", "600", "1k", "3k", "6k", "12k", "14k", "16k" }; @@ -40,8 +56,6 @@ const char *Equalizer::kSettingsGroup = "Equalizer"; Equalizer::Equalizer(QWidget *parent) : QDialog(parent), ui_(new Ui_Equalizer), loading_(false) { - //qLog(Debug) << __PRETTY_FUNCTION__; - ui_->setupUi(this); // Icons @@ -50,7 +64,7 @@ Equalizer::Equalizer(QWidget *parent) preamp_ = AddSlider(tr("Pre-amp")); - QFrame* line = new QFrame(ui_->slider_container); + QFrame *line = new QFrame(ui_->slider_container); line->setFrameShape(QFrame::VLine); line->setFrameShadow(QFrame::Sunken); ui_->slider_container->layout()->addWidget(line); @@ -68,7 +82,7 @@ Equalizer::Equalizer(QWidget *parent) connect(ui_->preset_del, SIGNAL(clicked()), SLOT(DelPreset())); connect(ui_->balance_slider, SIGNAL(valueChanged(int)), SLOT(StereoSliderChanged(int))); - QShortcut* close = new QShortcut(QKeySequence::Close, this); + QShortcut *close = new QShortcut(QKeySequence::Close, this); connect(close, SIGNAL(activated()), SLOT(close())); } @@ -78,8 +92,6 @@ Equalizer::~Equalizer() { } void Equalizer::ReloadSettings() { - - //qLog(Debug) << __PRETTY_FUNCTION__; QSettings s; s.beginGroup(kSettingsGroup); @@ -116,8 +128,6 @@ void Equalizer::ReloadSettings() { } void Equalizer::LoadDefaultPresets() { - - //qLog(Debug) << __PRETTY_FUNCTION__; AddPreset(QT_TRANSLATE_NOOP("Equalizer", "Custom"), Params(0, 0, 0, 0, 0, 0, 0, 0, 0, 0)); AddPreset(QT_TRANSLATE_NOOP("Equalizer", "Classical"), Params(0, 0, 0, 0, 0, 0, -40, -40, -40, -50)); @@ -220,9 +230,9 @@ void Equalizer::DelPreset() { } -EqualizerSlider* Equalizer::AddSlider(const QString &label) { +EqualizerSlider *Equalizer::AddSlider(const QString &label) { - EqualizerSlider* ret = new EqualizerSlider(label, ui_->slider_container); + EqualizerSlider *ret = new EqualizerSlider(label, ui_->slider_container); ui_->slider_container->layout()->addWidget(ret); connect(ret, SIGNAL(ValueChanged(int)), SLOT(ParametersChanged())); @@ -292,7 +302,7 @@ void Equalizer::Save() { } -void Equalizer::closeEvent(QCloseEvent* e) { +void Equalizer::closeEvent(QCloseEvent *e) { QString name = ui_->preset->currentText(); if (!presets_.contains(name)) return; diff --git a/src/equalizer/equalizer.h b/src/equalizer/equalizer.h index 4f859e62..1e604a19 100644 --- a/src/equalizer/equalizer.h +++ b/src/equalizer/equalizer.h @@ -23,9 +23,18 @@ #include "config.h" +#include + +#include #include -#include +#include +#include #include +#include +#include +#include + +class QCloseEvent; class EqualizerSlider; class Ui_Equalizer; @@ -34,7 +43,7 @@ class Equalizer : public QDialog { Q_OBJECT public: - Equalizer(QWidget* parent = nullptr); + Equalizer(QWidget *parent = nullptr); ~Equalizer(); static const int kBands = 10; diff --git a/src/equalizer/equalizerslider.cpp b/src/equalizer/equalizerslider.cpp index 6be103fb..f15d9303 100644 --- a/src/equalizer/equalizerslider.cpp +++ b/src/equalizer/equalizerslider.cpp @@ -20,6 +20,11 @@ #include "config.h" +#include +#include +#include + +#include "widgets/stickyslider.h" #include "equalizerslider.h" #include "ui_equalizerslider.h" diff --git a/src/equalizer/equalizerslider.h b/src/equalizer/equalizerslider.h index 4aad3c84..ab2b5b82 100644 --- a/src/equalizer/equalizerslider.h +++ b/src/equalizer/equalizerslider.h @@ -23,7 +23,9 @@ #include "config.h" +#include #include +#include class Ui_EqualizerSlider; diff --git a/src/globalshortcuts/globalshortcutbackend.cpp b/src/globalshortcuts/globalshortcutbackend.cpp index 5f1081c4..e992f895 100644 --- a/src/globalshortcuts/globalshortcutbackend.cpp +++ b/src/globalshortcuts/globalshortcutbackend.cpp @@ -20,8 +20,9 @@ #include "config.h" -#include "globalshortcutbackend.h" +#include +#include "globalshortcutbackend.h" #include "globalshortcuts.h" GlobalShortcutBackend::GlobalShortcutBackend(GlobalShortcuts *parent) @@ -37,4 +38,3 @@ void GlobalShortcutBackend::Unregister() { DoUnregister(); active_ = false; } - diff --git a/src/globalshortcuts/globalshortcutbackend.h b/src/globalshortcuts/globalshortcutbackend.h index 4f6ba3f7..c45e7775 100644 --- a/src/globalshortcuts/globalshortcutbackend.h +++ b/src/globalshortcuts/globalshortcutbackend.h @@ -23,6 +23,8 @@ #include "config.h" +#include +#include #include class GlobalShortcuts; @@ -51,4 +53,3 @@ signals: }; #endif // GLOBALSHORTCUTBACKEND_H - diff --git a/src/globalshortcuts/globalshortcutgrabber.cpp b/src/globalshortcuts/globalshortcutgrabber.cpp index acd6cf4f..902a257c 100644 --- a/src/globalshortcuts/globalshortcutgrabber.cpp +++ b/src/globalshortcuts/globalshortcutgrabber.cpp @@ -20,11 +20,20 @@ #include "config.h" +#include +#include +#include +#include +#include +#include +#include + #include "globalshortcutgrabber.h" #include "ui_globalshortcutgrabber.h" -#include -#include +class QShowEvent; +class QHideEvent; +class QKeyEvent; GlobalShortcutGrabber::GlobalShortcutGrabber(QWidget *parent) : QDialog(parent), ui_(new Ui::GlobalShortcutGrabber) { @@ -95,5 +104,3 @@ bool GlobalShortcutGrabber::event(QEvent *e) { void GlobalShortcutGrabber::UpdateText() { ui_->combo->setText("" + ret_.toString(QKeySequence::NativeText) + ""); } - - diff --git a/src/globalshortcuts/globalshortcutgrabber.h b/src/globalshortcuts/globalshortcutgrabber.h index b4262aca..d36f6a7a 100644 --- a/src/globalshortcuts/globalshortcutgrabber.h +++ b/src/globalshortcuts/globalshortcutgrabber.h @@ -23,7 +23,19 @@ #include "config.h" +#include + +#include +#include #include +#include +#include +#include +#include + +class QEvent; +class QHideEvent; +class QShowEvent; class MacMonitorWrapper; class Ui_GlobalShortcutGrabber; @@ -41,7 +53,7 @@ class GlobalShortcutGrabber : public QDialog { GlobalShortcutGrabber(QWidget *parent = nullptr); ~GlobalShortcutGrabber(); - QKeySequence GetKey(const QString& name); + QKeySequence GetKey(const QString &name); protected: bool event(QEvent *); diff --git a/src/globalshortcuts/globalshortcutgrabber.mm b/src/globalshortcuts/globalshortcutgrabber.mm index d60c2a56..f031a438 100644 --- a/src/globalshortcuts/globalshortcutgrabber.mm +++ b/src/globalshortcuts/globalshortcutgrabber.mm @@ -18,7 +18,7 @@ * */ - #include "config.h" +#include "config.h" #include "globalshortcutgrabber.h" diff --git a/src/globalshortcuts/globalshortcuts.cpp b/src/globalshortcuts/globalshortcuts.cpp index 3562c03e..0232e294 100644 --- a/src/globalshortcuts/globalshortcuts.cpp +++ b/src/globalshortcuts/globalshortcuts.cpp @@ -20,24 +20,23 @@ #include "config.h" +#include +#include +#include +#include +#include +#include +#ifdef QT_DBUS_LIB +# include +#endif + #include "globalshortcuts.h" +#include "globalshortcutbackend.h" #include "gnomeglobalshortcutbackend.h" -#include "macglobalshortcutbackend.h" #include "qxtglobalshortcutbackend.h" #include "settings/shortcutssettingspage.h" -#include "core/mac_startup.h" - -#include -#include -#include -#include - -#ifdef QT_DBUS_LIB -#include -#endif - -GlobalShortcuts::GlobalShortcuts(QWidget* parent) +GlobalShortcuts::GlobalShortcuts(QWidget *parent) : QWidget(parent), gnome_backend_(nullptr), system_backend_(nullptr), @@ -77,13 +76,13 @@ GlobalShortcuts::GlobalShortcuts(QWidget* parent) } -void GlobalShortcuts::AddShortcut(const QString& id, const QString& name, const char* signal, const QKeySequence& default_key) { +void GlobalShortcuts::AddShortcut(const QString &id, const QString &name, const char *signal, const QKeySequence &default_key) { Shortcut shortcut = AddShortcut(id, name, default_key); connect(shortcut.action, SIGNAL(triggered()), this, signal); } -GlobalShortcuts::Shortcut GlobalShortcuts::AddShortcut(const QString& id, const QString& name, const QKeySequence& default_key) { +GlobalShortcuts::Shortcut GlobalShortcuts::AddShortcut(const QString &id, const QString &name, const QKeySequence &default_key) { Shortcut shortcut; shortcut.action = new QAction(name, this); @@ -106,8 +105,7 @@ GlobalShortcuts::Shortcut GlobalShortcuts::AddShortcut(const QString& id, const bool GlobalShortcuts::IsGsdAvailable() const { #ifdef QT_DBUS_LIB - return QDBusConnection::sessionBus().interface()->isServiceRegistered( - GnomeGlobalShortcutBackend::kGsdService); + return QDBusConnection::sessionBus().interface()->isServiceRegistered(GnomeGlobalShortcutBackend::kGsdService); #else // QT_DBUS_LIB return false; #endif @@ -116,8 +114,7 @@ bool GlobalShortcuts::IsGsdAvailable() const { void GlobalShortcuts::ReloadSettings() { - // The actual shortcuts have been set in our actions for us by the config - // dialog already - we just need to reread the gnome settings. + // The actual shortcuts have been set in our actions for us by the config dialog already - we just need to reread the gnome settings. use_gnome_ = settings_.value("use_gnome", true).toBool(); Unregister(); diff --git a/src/globalshortcuts/globalshortcuts.h b/src/globalshortcuts/globalshortcuts.h index cf72915b..a908ebb2 100644 --- a/src/globalshortcuts/globalshortcuts.h +++ b/src/globalshortcuts/globalshortcuts.h @@ -23,22 +23,25 @@ #include "config.h" -#include -#include -#include -#include +#include -class QAction; -class QShortcut; +#include +#include +#include +#include +#include +#include +#include +#include +#include class GlobalShortcutBackend; -class QSignalMapper; class GlobalShortcuts : public QWidget { Q_OBJECT public: - explicit GlobalShortcuts(QWidget* parent = nullptr); + explicit GlobalShortcuts(QWidget *parent = nullptr); struct Shortcut { QString id; diff --git a/src/globalshortcuts/gnomeglobalshortcutbackend.cpp b/src/globalshortcuts/gnomeglobalshortcutbackend.cpp index c3ec5d8c..3601e388 100644 --- a/src/globalshortcuts/gnomeglobalshortcutbackend.cpp +++ b/src/globalshortcuts/gnomeglobalshortcutbackend.cpp @@ -20,23 +20,27 @@ #include "config.h" -#include "gnomeglobalshortcutbackend.h" -#include "globalshortcuts.h" -#include "core/closure.h" -#include "core/logging.h" +#ifdef QT_DBUS_LIB +# include +# include +# include +# include +# include +#endif +#include +#include +#include +#include #ifdef QT_DBUS_LIB #include "dbus/gnomesettingsdaemon.h" #endif -#include -#include -#include -#include - -#ifdef QT_DBUS_LIB -#include -#endif +#include "core/closure.h" +#include "core/logging.h" +#include "globalshortcuts.h" +#include "globalshortcuts/globalshortcutbackend.h" +#include "gnomeglobalshortcutbackend.h" const char *GnomeGlobalShortcutBackend::kGsdService = "org.gnome.SettingsDaemon"; const char *GnomeGlobalShortcutBackend::kGsdPath = "/org/gnome/SettingsDaemon/MediaKeys"; @@ -48,6 +52,7 @@ GnomeGlobalShortcutBackend::GnomeGlobalShortcutBackend(GlobalShortcuts *parent) is_connected_(false) {} bool GnomeGlobalShortcutBackend::DoRegister() { + #ifdef QT_DBUS_LIB qLog(Debug) << "registering"; // Check if the GSD service is available @@ -70,9 +75,11 @@ bool GnomeGlobalShortcutBackend::DoRegister() { qLog(Warning) << "dbus not available"; return false; #endif + } void GnomeGlobalShortcutBackend::RegisterFinished(QDBusPendingCallWatcher *watcher) { + #ifdef QT_DBUS_LIB QDBusMessage reply = watcher->reply(); watcher->deleteLater(); @@ -87,9 +94,11 @@ void GnomeGlobalShortcutBackend::RegisterFinished(QDBusPendingCallWatcher *watch qLog(Debug) << "registered"; #endif // QT_DBUS_LIB + } void GnomeGlobalShortcutBackend::DoUnregister() { + qLog(Debug) << "unregister"; #ifdef QT_DBUS_LIB // Check if the GSD service is available @@ -100,8 +109,9 @@ void GnomeGlobalShortcutBackend::DoUnregister() { is_connected_ = false; interface_->ReleaseMediaPlayerKeys(QCoreApplication::applicationName()); - disconnect(interface_, SIGNAL(MediaPlayerKeyPressed(QString,QString)), this, SLOT(GnomeMediaKeyPressed(QString,QString))); + disconnect(interface_, SIGNAL(MediaPlayerKeyPressed(QString, QString)), this, SLOT(GnomeMediaKeyPressed(QString, QString))); #endif + } void GnomeGlobalShortcutBackend::GnomeMediaKeyPressed(const QString&, const QString& key) { diff --git a/src/globalshortcuts/gnomeglobalshortcutbackend.h b/src/globalshortcuts/gnomeglobalshortcutbackend.h index 45094efd..5821e8b7 100644 --- a/src/globalshortcuts/gnomeglobalshortcutbackend.h +++ b/src/globalshortcuts/gnomeglobalshortcutbackend.h @@ -21,13 +21,16 @@ #ifndef GNOMEGLOBALSHORTCUTBACKEND_H #define GNOMEGLOBALSHORTCUTBACKEND_H -#include "config.h" +#include +#include +#include +#include "config.h" #include "globalshortcutbackend.h" -class OrgGnomeSettingsDaemonMediaKeysInterface; - class QDBusPendingCallWatcher; +class GlobalShortcuts; +class OrgGnomeSettingsDaemonMediaKeysInterface; class GnomeGlobalShortcutBackend : public GlobalShortcutBackend { Q_OBJECT diff --git a/src/globalshortcuts/macglobalshortcutbackend.h b/src/globalshortcuts/macglobalshortcutbackend.h index c979f145..702e7ab4 100644 --- a/src/globalshortcuts/macglobalshortcutbackend.h +++ b/src/globalshortcuts/macglobalshortcutbackend.h @@ -27,11 +27,12 @@ #include "globalshortcutbackend.h" -#include +#include #include +#include +#include class MacGlobalShortcutBackendPrivate; -class QAction; class MacGlobalShortcutBackend : public GlobalShortcutBackend { Q_OBJECT diff --git a/src/globalshortcuts/qxtglobalshortcutbackend.cpp b/src/globalshortcuts/qxtglobalshortcutbackend.cpp index 382a9a45..e04c6974 100644 --- a/src/globalshortcuts/qxtglobalshortcutbackend.cpp +++ b/src/globalshortcuts/qxtglobalshortcutbackend.cpp @@ -20,13 +20,17 @@ #include "config.h" -#include "globalshortcuts.h" -#include "qxtglobalshortcutbackend.h" -#include "qxtglobalshortcut.h" -#include "core/logging.h" - +#include +#include #include -#include +#include +#include + +#include "core/logging.h" +#include "globalshortcuts.h" +#include "globalshortcutbackend.h" +#include "qxtglobalshortcut.h" +#include "qxtglobalshortcutbackend.h" QxtGlobalShortcutBackend::QxtGlobalShortcutBackend(GlobalShortcuts* parent) : GlobalShortcutBackend(parent) {} diff --git a/src/globalshortcuts/qxtglobalshortcutbackend.h b/src/globalshortcuts/qxtglobalshortcutbackend.h index c371bcc8..acabe932 100644 --- a/src/globalshortcuts/qxtglobalshortcutbackend.h +++ b/src/globalshortcuts/qxtglobalshortcutbackend.h @@ -23,8 +23,13 @@ #include "config.h" +#include +#include +#include + #include "globalshortcutbackend.h" +class GlobalShortcuts; class QxtGlobalShortcut; class QxtGlobalShortcutBackend : public GlobalShortcutBackend { diff --git a/src/musicbrainz/acoustidclient.cpp b/src/musicbrainz/acoustidclient.cpp index 05351aa4..ecb25cd2 100644 --- a/src/musicbrainz/acoustidclient.cpp +++ b/src/musicbrainz/acoustidclient.cpp @@ -20,19 +20,29 @@ #include "config.h" -#include -#include +#include + +#include +#include +#include +#include +#include +#include #include +#include #include +#include +#include +#include +#include #include +#include #include #include -#include +#include #include "acoustidclient.h" - #include "core/closure.h" -#include "core/logging.h" #include "core/network.h" #include "core/timeconstants.h" @@ -47,7 +57,7 @@ AcoustidClient::AcoustidClient(QObject *parent) void AcoustidClient::SetTimeout(int msec) { timeouts_->SetTimeout(msec); } -void AcoustidClient::Start(int id, const QString& fingerprint, int duration_msec) { +void AcoustidClient::Start(int id, const QString &fingerprint, int duration_msec) { typedef QPair Param; diff --git a/src/musicbrainz/acoustidclient.h b/src/musicbrainz/acoustidclient.h index f3ac7787..e9da2a8d 100644 --- a/src/musicbrainz/acoustidclient.h +++ b/src/musicbrainz/acoustidclient.h @@ -23,25 +23,24 @@ #include "config.h" -#include #include +#include +#include +#include +#include +#include class NetworkTimeouts; -class QNetworkAccessManager; -class QNetworkReply; - class AcoustidClient : public QObject { Q_OBJECT // Gets a MBID from a Chromaprint fingerprint. - // A fingerprint identifies one particular encoding of a song and is created - // by Fingerprinter. An MBID identifies the actual song and can be passed to - // Musicbrainz to get metadata. + // A fingerprint identifies one particular encoding of a song and is created by Fingerprinter. + // An MBID identifies the actual song and can be passed to Musicbrainz to get metadata. // You can create one AcoustidClient and make multiple requests using it. - // IDs are provided by the caller when a request is started and included in - // the Finished signal - they have no meaning to AcoustidClient. + // IDs are provided by the caller when a request is started and included in the Finished signal - they have no meaning to AcoustidClient. public: AcoustidClient(QObject *parent = nullptr); @@ -49,16 +48,13 @@ class AcoustidClient : public QObject { // Network requests will be aborted after this interval. void SetTimeout(int msec); - // Starts a request and returns immediately. Finished() will be emitted - // later with the same ID. - void Start(int id, const QString& fingerprint, int duration_msec); + // Starts a request and returns immediately. Finished() will be emitted later with the same ID. + void Start(int id, const QString &fingerprint, int duration_msec); - // Cancels the request with the given ID. Finished() will never be emitted - // for that ID. Does nothing if there is no request with the given ID. + // Cancels the request with the given ID. Finished() will never be emitted for that ID. Does nothing if there is no request with the given ID. void Cancel(int id); - // Cancels all requests. Finished() will never be emitted for any pending - // requests. + // Cancels all requests. Finished() will never be emitted for any pending requests. void CancelAll(); signals: diff --git a/src/musicbrainz/chromaprinter.cpp b/src/musicbrainz/chromaprinter.cpp index 21f268bb..2daaf8bf 100644 --- a/src/musicbrainz/chromaprinter.cpp +++ b/src/musicbrainz/chromaprinter.cpp @@ -20,17 +20,26 @@ #include "config.h" -#include "chromaprinter.h" - -#include -#include -#include -#include -#include -#include - +#include +#include +#include +#include +#include #include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "chromaprinter.h" #include "core/logging.h" #include "core/signalchecker.h" @@ -95,8 +104,7 @@ QString Chromaprinter::CreateFingerprint() { GstAppSinkCallbacks callbacks; memset(&callbacks, 0, sizeof(callbacks)); callbacks.new_sample = NewBufferCallback; - gst_app_sink_set_callbacks(reinterpret_cast(sink), &callbacks, - this, nullptr); + gst_app_sink_set_callbacks(reinterpret_cast(sink), &callbacks, this, nullptr); g_object_set(G_OBJECT(sink), "sync", FALSE, nullptr); g_object_set(G_OBJECT(sink), "emit-signals", TRUE, nullptr); diff --git a/src/musicbrainz/chromaprinter.h b/src/musicbrainz/chromaprinter.h index 95c18b98..c0b03a7e 100644 --- a/src/musicbrainz/chromaprinter.h +++ b/src/musicbrainz/chromaprinter.h @@ -23,6 +23,7 @@ #include "config.h" +#include #include #include @@ -31,19 +32,18 @@ class Chromaprinter { // Creates a Chromaprint fingerprint from a song. - // Uses GStreamer to open and decode the file as PCM data and passes this - // to Chromaprint's code generator. The generated code can be used to identify - // a song via Acoustid. + // Uses GStreamer to open and decode the file as PCM data and passes this to Chromaprint's code generator. + // The generated code can be used to identify a song via Acoustid. // You should create one Chromaprinter for each file you want to fingerprint. // This class works well with QtConcurrentMap. public: - Chromaprinter(const QString& filename); + Chromaprinter(const QString &filename); ~Chromaprinter(); - // Creates a fingerprint from the song. This method is blocking, so you want - // to call it in another thread. Returns an empty string if no fingerprint - // could be created. + // Creates a fingerprint from the song. + // This method is blocking, so you want to call it in another thread. + // Returns an empty string if no fingerprint could be created. QString CreateFingerprint(); private: diff --git a/src/musicbrainz/musicbrainzclient.cpp b/src/musicbrainz/musicbrainzclient.cpp index d20cfdfb..88a04203 100644 --- a/src/musicbrainz/musicbrainzclient.cpp +++ b/src/musicbrainz/musicbrainzclient.cpp @@ -20,18 +20,29 @@ #include "config.h" -#include "musicbrainzclient.h" - -#include -#include +#include +#include +#include #include -#include +#include +#include +#include +#include +#include +#include #include +#include +#include +#include +#include +#include +#include #include "core/closure.h" #include "core/logging.h" #include "core/network.h" #include "core/utilities.h" +#include "musicbrainzclient.h" const char *MusicBrainzClient::kTrackUrl = "http://musicbrainz.org/ws/2/recording/"; const char *MusicBrainzClient::kDiscUrl = "http://musicbrainz.org/ws/2/discid/"; @@ -327,8 +338,7 @@ MusicBrainzClient::ResultList MusicBrainzClient::ParseTrack(QXmlStreamReader *re return ret; } -// Parse the artist. Multiple artists are joined together with the -// joinphrase from musicbrainz. +// Parse the artist. Multiple artists are joined together with the joinphrase from musicbrainz. void MusicBrainzClient::ParseArtist(QXmlStreamReader *reader, QString *artist) { QString join_phrase; @@ -394,10 +404,8 @@ MusicBrainzClient::ResultList MusicBrainzClient::UniqueResults(const ResultList& qSort(ret); } else { // KeepOriginalOrder - // Qt doesn't provide a ordered set (QSet "stores values in an unspecified - // order" according to Qt documentation). - // We might use std::set instead, but it's probably faster to use ResultList - // directly to avoid converting from one structure to another. + // Qt doesn't provide a ordered set (QSet "stores values in an unspecified order" according to Qt documentation). + // We might use std::set instead, but it's probably faster to use ResultList directly to avoid converting from one structure to another. for (const Result& res : results) { if (!ret.contains(res)) { ret << res; diff --git a/src/musicbrainz/musicbrainzclient.h b/src/musicbrainz/musicbrainzclient.h index c9b79466..9334460a 100644 --- a/src/musicbrainz/musicbrainzclient.h +++ b/src/musicbrainz/musicbrainzclient.h @@ -23,31 +23,36 @@ #include "config.h" -#include -#include +#include + +#include #include +#include +#include +#include +#include +#include +#include +#include +#include +#include #include +#include class NetworkTimeouts; -class QNetworkAccessManager; -class QNetworkReply; - class MusicBrainzClient : public QObject { Q_OBJECT // Gets metadata for a particular MBID. // An MBID is created from a fingerprint using MusicDnsClient. // You can create one MusicBrainzClient and make multiple requests using it. - // IDs are provided by the caller when a request is started and included in - // the Finished signal - they have no meaning to MusicBrainzClient. + // IDs are provided by the caller when a request is started and included in the Finished signal - they have no meaning to MusicBrainzClient. public: - // The second argument allows for specifying a custom network access - // manager. It is used in tests. The ownership of network - // is not transferred. - MusicBrainzClient(QObject* parent = nullptr, - QNetworkAccessManager* network = nullptr); + // The second argument allows for specifying a custom network access manager. + // It is used in tests. The ownership of network is not transferred. + MusicBrainzClient(QObject *parent = nullptr, QNetworkAccessManager *network = nullptr); struct Result { Result() : duration_msec_(0), track_(0), year_(-1) {} @@ -85,29 +90,24 @@ class MusicBrainzClient : public QObject { }; typedef QList ResultList; - // Starts a request and returns immediately. Finished() will be emitted - // later with the same ID. - void Start(int id, const QStringList& mbid); - void StartDiscIdRequest(const QString& discid); + // Starts a request and returns immediately. Finished() will be emitted later with the same ID. + void Start(int id, const QStringList &mbid); + void StartDiscIdRequest(const QString &discid); - // Cancels the request with the given ID. Finished() will never be emitted - // for that ID. Does nothing if there is no request with the given ID. + // Cancels the request with the given ID. Finished() will never be emitted for that ID. Does nothing if there is no request with the given ID. void Cancel(int id); - // Cancels all requests. Finished() will never be emitted for any pending - // requests. + // Cancels all requests. Finished() will never be emitted for any pending requests. void CancelAll(); signals: // Finished signal emitted when fechting songs tags void Finished(int id, const MusicBrainzClient::ResultList& result); // Finished signal emitted when fechting album's songs tags using DiscId - void Finished(const QString& artist, const QString album, - const MusicBrainzClient::ResultList& result); + void Finished(const QString& artist, const QString album, const MusicBrainzClient::ResultList& result); private slots: - // id identifies the track, and request_number means it's the - // 'request_number'th request for this track + // id identifies the track, and request_number means it's the 'request_number'th request for this track void RequestFinished(QNetworkReply* reply, int id, int request_number); void DiscIdRequestFinished(const QString& discid, QNetworkReply* reply); @@ -157,8 +157,7 @@ signals: } bool operator<(const Release& other) const { - // Compare status so that "best" status (e.g. Official) will be first - // when sorting a list of releases. + // Compare status so that "best" status (e.g. Official) will be first when sorting a list of releases. return status_ > other.status_; } @@ -203,8 +202,7 @@ signals: }; inline uint qHash(const MusicBrainzClient::Result& result) { - return qHash(result.album_) ^ qHash(result.artist_) ^ result.duration_msec_ ^ - qHash(result.title_) ^ result.track_ ^ result.year_; + return qHash(result.album_) ^ qHash(result.artist_) ^ result.duration_msec_ ^ qHash(result.title_) ^ result.track_ ^ result.year_; } #endif // MUSICBRAINZCLIENT_H diff --git a/src/musicbrainz/tagfetcher.cpp b/src/musicbrainz/tagfetcher.cpp index e460b3a5..21d6fc8a 100644 --- a/src/musicbrainz/tagfetcher.cpp +++ b/src/musicbrainz/tagfetcher.cpp @@ -20,19 +20,20 @@ #include "config.h" -#include "tagfetcher.h" +#include +#include +#include +#include +#include +#include +#include "core/timeconstants.h" #include "acoustidclient.h" #include "chromaprinter.h" #include "musicbrainzclient.h" -#include "core/timeconstants.h" +#include "tagfetcher.h" -#include -#include -#include -#include - -TagFetcher::TagFetcher(QObject* parent) +TagFetcher::TagFetcher(QObject *parent) : QObject(parent), fingerprint_watcher_(nullptr), acoustid_client_(new AcoustidClient(this)), diff --git a/src/musicbrainz/tagfetcher.h b/src/musicbrainz/tagfetcher.h index 9eb0badd..0c928597 100644 --- a/src/musicbrainz/tagfetcher.h +++ b/src/musicbrainz/tagfetcher.h @@ -23,19 +23,20 @@ #include "config.h" -#include "musicbrainzclient.h" -#include "core/song.h" - -#include #include +#include +#include +#include + +#include "core/song.h" +#include "musicbrainzclient.h" class AcoustidClient; class TagFetcher : public QObject { Q_OBJECT - // High level interface to Fingerprinter, AcoustidClient and - // MusicBrainzClient. + // High level interface to Fingerprinter, AcoustidClient and MusicBrainzClient. public: TagFetcher(QObject *parent = nullptr); diff --git a/src/playlist/playlist.cpp b/src/playlist/playlist.cpp index 19346489..ca577be3 100644 --- a/src/playlist/playlist.cpp +++ b/src/playlist/playlist.cpp @@ -20,45 +20,69 @@ #include "config.h" +#include +#include +#include #include #include -#include +#include +#include #include +#include -#include -#include +#include +#include #include -#include -#include -#include -#include -#include -#include -#include +#include #include -#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "core/application.h" +#include "core/closure.h" +#include "core/logging.h" +#include "core/mimedata.h" +#include "core/tagreaderclient.h" +#include "collection/collection.h" +#include "collection/collectionbackend.h" +#include "collection/collectionplaylistitem.h" #include "playlist.h" - +#include "playlistitem.h" +#include "playlistview.h" +#include "playlistsequence.h" #include "playlistbackend.h" #include "playlistfilter.h" #include "playlistitemmimedata.h" #include "playlistundocommands.h" -#include "playlistview.h" #include "queue.h" #include "songloaderinserter.h" #include "songmimedata.h" #include "songplaylistitem.h" -#include "core/application.h" -#include "core/closure.h" -#include "core/logging.h" -//#include "core/qhash_qurl.h" -#include "core/tagreaderclient.h" -#include "core/timeconstants.h" -#include "collection/collection.h" -#include "collection/collectionbackend.h" -#include "collection/collectionmodel.h" -#include "collection/collectionplaylistitem.h" +#include "tagreadermessages.pb.h" using std::placeholders::_1; using std::placeholders::_2; @@ -292,8 +316,7 @@ QVariant Playlist::data(const QModelIndex &index, int role) const { case Qt::ForegroundRole: if (data(index, Role_IsCurrent).toBool()) { - // Ignore any custom colours for the currently playing item - they might - // clash with the glowing current track indicator. + // Ignore any custom colours for the currently playing item - they might clash with the glowing current track indicator. return QVariant(); } @@ -307,8 +330,7 @@ QVariant Playlist::data(const QModelIndex &index, int role) const { case Qt::BackgroundRole: if (data(index, Role_IsCurrent).toBool()) { - // Ignore any custom colours for the currently playing item - they might - // clash with the glowing current track indicator. + // Ignore any custom colours for the currently playing item - they might clash with the glowing current track indicator. return QVariant(); } @@ -342,7 +364,7 @@ bool Playlist::setData(const QModelIndex &index, const QVariant &value, int role if (!set_column_value(song, (Column)index.column(), value)) return false; TagReaderReply *reply = TagReaderClient::Instance()->SaveFile( song.url().toLocalFile(), song); - NewClosure(reply, SIGNAL(Finished(bool)), this, SLOT(SongSaveComplete(TagReaderReply*,QPersistentModelIndex)), reply, QPersistentModelIndex(index)); + NewClosure(reply, SIGNAL(Finished(bool)), this, SLOT(SongSaveComplete(TagReaderReply*, QPersistentModelIndex)), reply, QPersistentModelIndex(index)); return true; @@ -409,13 +431,11 @@ int Playlist::NextVirtualIndex(int i, bool ignore_repeat_track) const { return i; } - // If we're not bothered about whether a song is on the same album then - // return the next virtual index, whatever it is. + // If we're not bothered about whether a song is on the same album then return the next virtual index, whatever it is. if (!album_only) { ++i; - // Advance i until we find any track that is in the filter, skipping - // the selected to be skipped + // Advance i until we find any track that is in the filter, skipping the selected to be skipped while (i < virtual_items_.count() && (!FilterContainsVirtualIndex(i) || item_at(virtual_items_[i])->GetShouldSkip())) { ++i; } @@ -454,8 +474,7 @@ int Playlist::PreviousVirtualIndex(int i, bool ignore_repeat_track) const { return i; } - // If we're not bothered about whether a song is on the same album then - // return the previous virtual index, whatever it is. + // If we're not bothered about whether a song is on the same album then return the previous virtual index, whatever it is. if (!album_only) { --i; @@ -563,8 +582,7 @@ void Playlist::set_current_row(int i, bool is_stopping) { current_virtual_index_ = -1; } else if (is_shuffled_ && current_virtual_index_ == -1) { - // This is the first thing we're playing so we want to make sure the array - // is shuffled + // This is the first thing we're playing so we want to make sure the array is shuffled ReshuffleIndices(); // Bring the one we've been asked to play to the start of the list @@ -629,8 +647,7 @@ bool Playlist::dropMimeData(const QMimeData *data, Qt::DropAction action, int ro if (const SongMimeData *song_data = qobject_cast(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. + // 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() == Collection::kSongsTable) InsertSongItems(song_data->songs, row, play_now, enqueue_now); else @@ -672,8 +689,7 @@ bool Playlist::dropMimeData(const QMimeData *data, Qt::DropAction action, int ro for (int row : source_rows) items << source_playlist->item_at(row); if (items.count() > kUndoItemLimit) { - // Too big to keep in the undo stack. Also clear the stack because it - // might have been invalidated. + // Too big to keep in the undo stack. Also clear the stack because it might have been invalidated. InsertItemsWithoutUndo(items, row, false); undo_stack_->clear(); } @@ -725,8 +741,7 @@ void Playlist::MoveItemsWithoutUndo(const QList &source_rows, int pos) { pos = items_.count(); } - // Take the items out of the list first, keeping track of whether the - // insertion point changes + // Take the items out of the list first, keeping track of whether the insertion point changes int offset = 0; int start = pos; for (int source_row : source_rows) { @@ -749,7 +764,8 @@ void Playlist::MoveItemsWithoutUndo(const QList &source_rows, int pos) { if (dest_offset != -1) { // This index was moved changePersistentIndex(pidx, index(start + dest_offset, pidx.column(), QModelIndex())); - } else { + } + else { int d = 0; for (int source_row : source_rows) { if (pidx.row() > source_row) d--; @@ -763,11 +779,11 @@ void Playlist::MoveItemsWithoutUndo(const QList &source_rows, int pos) { layoutChanged(); Save(); - + } void Playlist::MoveItemsWithoutUndo(int start, const QList &dest_rows) { - + layoutAboutToBeChanged(); PlaylistItemList moved_items; @@ -833,8 +849,7 @@ void Playlist::InsertItems(const PlaylistItemList &itemsIn, int pos, bool play_n const int song_count = songs.length(); QSet vetoed; for (SongInsertVetoListener *listener : veto_listeners_) { - for (const Song &song : - listener->AboutToInsertSongs(GetAllSongs(), songs)) { + for (const Song &song : listener->AboutToInsertSongs(GetAllSongs(), songs)) { // avoid veto-ing a song multiple times vetoed.insert(song); } @@ -865,8 +880,7 @@ void Playlist::InsertItems(const PlaylistItemList &itemsIn, int pos, bool play_n const int start = pos == -1 ? items_.count() : pos; if (items.count() > kUndoItemLimit) { - // Too big to keep in the undo stack. Also clear the stack because it - // might have been invalidated. + // Too big to keep in the undo stack. Also clear the stack because it might have been invalidated. InsertItemsWithoutUndo(items, pos, enqueue); undo_stack_->clear(); } else { @@ -943,12 +957,10 @@ void Playlist::InsertSongsOrCollectionItems(const SongList &songs, int pos, bool void Playlist::UpdateItems(const SongList &songs) { qLog(Debug) << "Updating playlist with new tracks' info"; - // We first convert our songs list into a linked list (a 'real' list), - // because removals are faster with QLinkedList. + // We first convert our songs list into a linked list (a 'real' list), because removals are faster with QLinkedList. // Next, we walk through the list of playlist's items then the list of songs - // we want to update: if an item corresponds to the song (we rely on URL for - // this), we update the item with the new metadata, then we remove song from - // our list because we will not need to check it again. + // we want to update: if an item corresponds to the song (we rely on URL for this), we update the item with the new metadata, + // then we remove song from our list because we will not need to check it again. // And we also update undo actions. QLinkedList songs_list; for (const Song &song : songs) songs_list.append(song); @@ -994,8 +1006,7 @@ QMimeData *Playlist::mimeData(const QModelIndexList &indexes) const { if (indexes.isEmpty()) return nullptr; - // We only want one index per row, but we can't just take column 0 because - // the user might have hidden it. + // We only want one index per row, but we can't just take column 0 because the user might have hidden it. const int first_column = indexes.first().column(); QMimeData *data = new QMimeData; @@ -1164,8 +1175,7 @@ void Playlist::sort(int column, Qt::SortOrder order) { qStableSort(begin, new_items.end(), std::bind(&Playlist::CompareItems, Column_Album, order, _1, _2)); } else if (column == Column_Filename) { - // When sorting by full paths we also expect a hierarchical order. This - // returns a breath-first ordering of paths. + // When sorting by full paths we also expect a hierarchical order. This returns a breath-first ordering of paths. qStableSort(begin, new_items.end(), std::bind(&Playlist::CompareItems, Column_Filename, order, _1, _2)); qStableSort(begin, new_items.end(), std::bind(&Playlist::ComparePathDepths, order, _1, _2)); } @@ -1250,8 +1260,7 @@ void Playlist::ItemsLoaded(QFuture future) { PlaylistItemList items = future.result(); - // backend returns empty elements for collection items which it couldn't - // match (because they got deleted); we don't need those + // Backend returns empty elements for collection items which it couldn't match (because they got deleted); we don't need those QMutableListIterator it(items); while (it.hasNext()) { PlaylistItemPtr item = it.next(); @@ -1267,8 +1276,7 @@ void Playlist::ItemsLoaded(QFuture future) { PlaylistBackend::Playlist p = backend_->GetPlaylist(id_); - // the newly loaded list of items might be shorter than it was before so - // look out for a bad last_played index + // The newly loaded list of items might be shorter than it was before so look out for a bad last_played index last_played_item_index_ = p.last_played == -1 || p.last_played >= rowCount() ? QModelIndex() : index(p.last_played); emit RestoreFinished(); @@ -1276,7 +1284,7 @@ void Playlist::ItemsLoaded(QFuture future) { QSettings s; s.beginGroup(kSettingsGroup); - // should we gray out deleted songs asynchronously on startup? + // Should we gray out deleted songs asynchronously on startup? if (s.value("greyoutdeleted", false).toBool()) { QtConcurrent::run(this, &Playlist::InvalidateDeletedSongs); } @@ -1287,16 +1295,14 @@ static bool DescendingIntLessThan(int a, int b) { return a > b; } void Playlist::RemoveItemsWithoutUndo(const QList &indicesIn) { - // Sort the indices descending because removing elements 'backwards' - // is easier - indices don't 'move' in the process. + // Sort the indices descending because removing elements 'backwards' is easier - indices don't 'move' in the process. QList indices = indicesIn; qSort(indices.begin(), indices.end(), DescendingIntLessThan); for (int j = 0; j < indices.count(); j++) { int beginning = indices[j], end = indices[j]; - // Splits the indices into sequences. For example this: [1, 2, 4], - // will get split into [1, 2] and [4]. + // Splits the indices into sequences. For example this: [1, 2, 4], will get split into [1, 2] and [4]. while (j != indices.count() - 1 && indices[j] == indices[j + 1] + 1) { beginning--; j++; @@ -1315,8 +1321,7 @@ bool Playlist::removeRows(int row, int count, const QModelIndex &parent) { } if (count > kUndoItemLimit) { - // Too big to keep in the undo stack. Also clear the stack because it - // might have been invalidated. + // Too big to keep in the undo stack. Also clear the stack because it might have been invalidated. RemoveItemsWithoutUndo(row, count); undo_stack_->clear(); } @@ -1337,14 +1342,12 @@ bool Playlist::removeRows(QList &rows) { return false; } - // start from the end to be sure that indices won't 'move' during - // the removal process + // Start from the end to be sure that indices won't 'move' during the removal process qSort(rows.begin(), rows.end(), qGreater()); QList part; while (!rows.isEmpty()) { - // we're splitting the input list into sequences of consecutive - // numbers + // we're splitting the input list into sequences of consecutive numbers part.append(rows.takeFirst()); while (!rows.isEmpty() && rows.first() == part.last() - 1) { part.append(rows.takeFirst()); @@ -1492,11 +1495,11 @@ void Playlist::Clear() { const int count = items_.count(); if (count > kUndoItemLimit) { - // Too big to keep in the undo stack. Also clear the stack because it - // might have been invalidated. + // Too big to keep in the undo stack. Also clear the stack because it might have been invalidated. RemoveItemsWithoutUndo(0, count); undo_stack_->clear(); - } else { + } + else { undo_stack_->push(new PlaylistUndoCommands::RemoveItems(this, 0, count)); } @@ -1520,8 +1523,7 @@ void Playlist::RemoveItemsNotInQueue() { start++; } - // Figure out how many rows to remove - keep going until we find a row - // that is in the queue + // Figure out how many rows to remove - keep going until we find a row that is in the queue int count = 1; forever { if (start + count >= rowCount()) break; @@ -1608,8 +1610,7 @@ void Playlist::ReshuffleIndices() { return; } - // If the user is already playing a song, advance the begin iterator to - // only shuffle items that haven't been played yet. + // If the user is already playing a song, advance the begin iterator to only shuffle items that haven't been played yet. QList::iterator begin = virtual_items_.begin(); QList::iterator end = virtual_items_.end(); if (current_virtual_index_ != -1) @@ -1642,8 +1643,7 @@ void Playlist::ReshuffleIndices() { std::random_shuffle(shuffled_album_keys.begin(), shuffled_album_keys.end()); // If the user is currently playing a song, force its album to be first - // Or if the song was not playing but it was selected, force its album - // to be first. + // Or if the song was not playing but it was selected, force its album to be first. if (current_virtual_index_ != -1 || current_row() != -1) { const QString key = items_[current_row()]->Metadata().AlbumKey(); const int pos = shuffled_album_keys.indexOf(key); @@ -1741,8 +1741,7 @@ void Playlist::InformOfCurrentSongChange() { emit dataChanged(index(current_item_index_.row(), 0), index(current_item_index_.row(), ColumnCount - 1)); - // if the song is invalid, we won't play it - there's no point in - // informing anybody about the change + // if the song is invalid, we won't play it - there's no point in informing anybody about the change const Song metadata(current_item_metadata()); if (metadata.is_valid()) { emit CurrentSongChanged(metadata); @@ -1845,7 +1844,7 @@ void Playlist::RemoveUnavailableSongs() { PlaylistItemPtr item = items_[row]; const Song &song = item->Metadata(); - // check only local files + // Check only local files if (song.url().isLocalFile() && !QFile::exists(song.url().toLocalFile())) { rows_to_remove.append(row); } @@ -1862,12 +1861,12 @@ bool Playlist::ApplyValidityOnCurrentSong(const QUrl &url, bool valid) { if (current) { Song current_song = current->Metadata(); - // if validity has changed, reload the item + // If validity has changed, reload the item if(!current_song.is_cdda() && current_song.url() == url && current_song.is_valid() != QFile::exists(current_song.url().toLocalFile())) { ReloadItems(QList() << current_row()); } - // gray out the song if it's now broken; otherwise undo the gray color + // Gray out the song if it's now broken; otherwise undo the gray color if (valid) { current->RemoveForegroundColor(kInvalidSongPriority); } else { diff --git a/src/playlist/playlist.h b/src/playlist/playlist.h index f3768f61..deb7e0a0 100644 --- a/src/playlist/playlist.h +++ b/src/playlist/playlist.h @@ -23,13 +23,31 @@ #include "config.h" -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "core/song.h" +#include "core/tagreaderclient.h" #include "playlistitem.h" #include "playlistsequence.h" -#include "core/tagreaderclient.h" -#include "core/song.h" class CollectionBackend; class PlaylistBackend; @@ -37,33 +55,29 @@ class PlaylistFilter; class Queue; class TaskManager; -class QSortFilterProxyModel; -class QUndoStack; - namespace PlaylistUndoCommands { class InsertItems; -class RemoveItems; class MoveItems; class ReOrderItems; -class SortItems; +class RemoveItems; class ShuffleItems; +class SortItems; } typedef QMap ColumnAlignmentMap; Q_DECLARE_METATYPE(Qt::Alignment); Q_DECLARE_METATYPE(ColumnAlignmentMap); -// Objects that may prevent a song being added to the playlist. When there -// is something about to be inserted into it, Playlist notifies all of it's -// listeners about the fact and every one of them picks 'invalid' songs. +// Objects that may prevent a song being added to the playlist. +// When there is something about to be inserted into it, +// Playlist notifies all of it's listeners about the fact and every one of them picks 'invalid' songs. class SongInsertVetoListener : public QObject { Q_OBJECT public: - // Listener returns a list of 'invalid' songs. 'old_songs' are songs that are - // currently in the playlist and 'new_songs' are the songs about to be added if - // nobody exercises a veto. - virtual SongList AboutToInsertSongs(const SongList& old_songs, const SongList& new_songs) = 0; + // Listener returns a list of 'invalid' songs. + // 'old_songs' are songs that are currently in the playlist and 'new_songs' are the songs about to be added if nobody exercises a veto. + virtual SongList AboutToInsertSongs(const SongList &old_songs, const SongList &new_songs) = 0; }; class Playlist : public QAbstractListModel { @@ -75,10 +89,10 @@ class Playlist : public QAbstractListModel { friend class PlaylistUndoCommands::ReOrderItems; public: - Playlist(PlaylistBackend *backend, TaskManager *task_manager, CollectionBackend *collection, int id, const QString& special_type = QString(), bool favorite = false, QObject *parent = nullptr); + Playlist(PlaylistBackend *backend, TaskManager *task_manager, CollectionBackend *collection, int id, const QString &special_type = QString(), bool favorite = false, QObject *parent = nullptr); ~Playlist(); - void SkipTracks(const QModelIndexList& source_indexes); + void SkipTracks(const QModelIndexList &source_indexes); // Always add new columns to the end of this enum - the values are persisted enum Column { @@ -123,8 +137,7 @@ class Playlist : public QAbstractListModel { Path_Automatic = 0, // Automatically select path type Path_Absolute, // Always use absolute paths Path_Relative, // Always use relative paths - Path_Ask_User, // Only used in preferences: to ask user which of the - // previous values he wants to use. + Path_Ask_User, // Only used in preferences: to ask user which of the previous values he wants to use. }; static const char *kCddaMimeType; @@ -151,7 +164,7 @@ class Playlist : public QAbstractListModel { static QString abbreviated_column_name(Column column); static bool column_is_editable(Playlist::Column column); - static bool set_column_value(Song& song, Column column, const QVariant& value); + static bool set_column_value(Song &song, Column column, const QVariant &value); // Persistence void Save() const; @@ -162,7 +175,7 @@ class Playlist : public QAbstractListModel { Queue *queue() const { return queue_; } int id() const { return id_; } - const QString& ui_path() const { return ui_path_; } + const QString &ui_path() const { return ui_path_; } void set_ui_path(const QString &path) { ui_path_ = path; } bool is_favorite() const { return favorite_; } void set_favorite(bool favorite) { favorite_ = favorite; } @@ -207,14 +220,12 @@ class Playlist : public QAbstractListModel { void ReshuffleIndices(); // If this playlist contains the current item, this method will apply the "valid" flag on it. - // If the "valid" flag is false, the song will be greyed out. Otherwise the grey color will - // be undone. + // If the "valid" flag is false, the song will be greyed out. Otherwise the grey color will be undone. // If the song is a local file and it's valid but non existent or invalid but exists, the // song will be reloaded to even out the situation because obviously something has changed. // This returns true if this playlist had current item when the method was invoked. bool ApplyValidityOnCurrentSong(const QUrl &url, bool valid); - // Grays out and reloads all deleted songs in all playlists. Also, "ungreys" those songs - // which were once deleted but now got restored somehow. + // Grays out and reloads all deleted songs in all playlists. Also, "ungreys" those songs which were once deleted but now got restored somehow. void InvalidateDeletedSongs(); // Removes from the playlist all local files that don't exist anymore. void RemoveDeletedSongs(); @@ -223,8 +234,7 @@ class Playlist : public QAbstractListModel { void ReloadItems(const QList &rows); void InformOfCurrentSongChange(); - // Registers an object which will get notifications when new songs - // are about to be inserted into this playlist. + // Registers an object which will get notifications when new songs are about to be inserted into this playlist. void AddSongInsertVetoListener(SongInsertVetoListener *listener); // Unregisters a SongInsertVetoListener object. void RemoveSongInsertVetoListener(SongInsertVetoListener *listener); @@ -276,15 +286,13 @@ signals: void EditingFinished(const QModelIndex &index); void PlayRequested(const QModelIndex &index); - // Signals that the underlying list of items was changed, meaning that - // something was added to it, removed from it or the ordering changed. + // Signals that the underlying list of items was changed, meaning that something was added to it, removed from it or the ordering changed. void PlaylistChanged(); void DynamicModeChanged(bool dynamic); void Error(const QString &message); - // Signals that the queue has changed, meaning that the remaining queued - // items should update their position. + // Signals that the queue has changed, meaning that the remaining queued items should update their position. void QueueChanged(); private: @@ -296,8 +304,7 @@ private: template void InsertSongItems(const SongList &songs, int pos, bool play_now, bool enqueue); - // Modify the playlist without changing the undo stack. These are used by - // our friends in PlaylistUndoCommands + // Modify the playlist without changing the undo stack. These are used by our friends in PlaylistUndoCommands void InsertItemsWithoutUndo(const PlaylistItemList &items, int pos, bool enqueue = false); PlaylistItemList RemoveItemsWithoutUndo(int pos, int count); void MoveItemsWithoutUndo(const QList &source_rows, int pos); @@ -335,10 +342,9 @@ private: bool favorite_; PlaylistItemList items_; - QList virtual_items_; // Contains the indices into items_ in the order - // that they will be played. - // A map of collection ID to playlist item - for fast lookups when collection - // items change. + // Contains the indices into items_ in the order that they will be played. + QList virtual_items_; + // A map of collection ID to playlist item - for fast lookups when collection items change. QMultiMap collection_items_by_id_; QPersistentModelIndex current_item_index_; diff --git a/src/playlist/playlistbackend.cpp b/src/playlist/playlistbackend.cpp index 99378f35..20870c40 100644 --- a/src/playlist/playlistbackend.cpp +++ b/src/playlist/playlistbackend.cpp @@ -18,16 +18,23 @@ * */ -#include "config.h" - -#include "playlistbackend.h" - #include #include +#include +#include +#include +#include #include +#include #include -#include +#include +#include +#include +#include +#include +#include +#include #include #include @@ -38,7 +45,9 @@ #include "core/song.h" #include "collection/collectionbackend.h" #include "collection/sqlrow.h" -#include "playlist/songplaylistitem.h" +#include "playlistitem.h" +#include "songplaylistitem.h" +#include "playlistbackend.h" #include "playlistparsers/cueparser.h" using std::placeholders::_1; @@ -46,7 +55,7 @@ using std::shared_ptr; const int PlaylistBackend::kSongTableJoins = 2; -PlaylistBackend::PlaylistBackend(Application* app, QObject* parent) +PlaylistBackend::PlaylistBackend(Application *app, QObject *parent) : QObject(parent), app_(app), db_(app_->database()) {} PlaylistBackend::PlaylistList PlaylistBackend::GetAllPlaylists() { @@ -63,8 +72,6 @@ PlaylistBackend::PlaylistList PlaylistBackend::GetAllFavoritePlaylists() { PlaylistBackend::PlaylistList PlaylistBackend::GetPlaylists(GetPlaylistsFlags flags) { - //qLog(Debug) << __PRETTY_FUNCTION__; - QMutexLocker l(db_->Mutex()); QSqlDatabase db(db_->Connect()); @@ -157,12 +164,10 @@ QSqlQuery PlaylistBackend::GetPlaylistRows(int playlist) { QList PlaylistBackend::GetPlaylistItems(int playlist) { QSqlQuery q = GetPlaylistRows(playlist); - // Note that as this only accesses the query, not the db, we don't need the - // mutex. + // Note that as this only accesses the query, not the db, we don't need the mutex. if (db_->CheckErrors(q)) return QList(); - // it's probable that we'll have a few songs associated with the - // same CUE so we're caching results of parsing CUEs + // it's probable that we'll have a few songs associated with the same CUE so we're caching results of parsing CUEs std::shared_ptr state_ptr(new NewSongFromQueryState()); QList playlistitems; while (q.next()) { @@ -175,12 +180,10 @@ QList PlaylistBackend::GetPlaylistItems(int playlist) { QList PlaylistBackend::GetPlaylistSongs(int playlist) { QSqlQuery q = GetPlaylistRows(playlist); - // Note that as this only accesses the query, not the db, we don't need the - // mutex. + // Note that as this only accesses the query, not the db, we don't need the mutex. if (db_->CheckErrors(q)) return QList(); - // it's probable that we'll have a few songs associated with the - // same CUE so we're caching results of parsing CUEs + // it's probable that we'll have a few songs associated with the same CUE so we're caching results of parsing CUEs std::shared_ptr state_ptr(new NewSongFromQueryState()); QList songs; while (q.next()) { @@ -248,10 +251,8 @@ PlaylistItemPtr PlaylistBackend::RestoreCueData(PlaylistItemPtr item, std::share } for (const Song& from_list : song_list) { - if (from_list.url().toEncoded() == song.url().toEncoded() && - from_list.beginning_nanosec() == song.beginning_nanosec()) { - // we found a matching section; replace the input - // item with a new one containing CUE metadata + if (from_list.url().toEncoded() == song.url().toEncoded() && from_list.beginning_nanosec() == song.beginning_nanosec()) { + // we found a matching section; replace the input item with a new one containing CUE metadata return PlaylistItemPtr(new SongPlaylistItem(from_list)); } } @@ -268,7 +269,7 @@ void PlaylistBackend::SavePlaylistAsync(int playlist, const PlaylistItemList &it } -void PlaylistBackend::SavePlaylist(int playlist, const PlaylistItemList& items, int last_played) { +void PlaylistBackend::SavePlaylist(int playlist, const PlaylistItemList &items, int last_played) { QMutexLocker l(db_->Mutex()); QSqlDatabase db(db_->Connect()); @@ -308,7 +309,7 @@ void PlaylistBackend::SavePlaylist(int playlist, const PlaylistItemList& items, } -int PlaylistBackend::CreatePlaylist(const QString& name, const QString& special_type) { +int PlaylistBackend::CreatePlaylist(const QString &name, const QString &special_type) { QMutexLocker l(db_->Mutex()); QSqlDatabase db(db_->Connect()); diff --git a/src/playlist/playlistbackend.h b/src/playlist/playlistbackend.h index a439c59e..2e7b2e69 100644 --- a/src/playlist/playlistbackend.h +++ b/src/playlist/playlistbackend.h @@ -23,11 +23,20 @@ #include "config.h" +#include +#include + +#include +#include #include #include -#include -#include +#include +#include +#include +#include +#include "core/song.h" +#include "collection/sqlrow.h" #include "playlistitem.h" class Application; diff --git a/src/playlist/playlistcontainer.cpp b/src/playlist/playlistcontainer.cpp index ef1dcde8..4f3999f6 100644 --- a/src/playlist/playlistcontainer.cpp +++ b/src/playlist/playlistcontainer.cpp @@ -18,25 +18,43 @@ * */ -#include "config.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "core/iconloader.h" +#include "playlist.h" +#include "playlisttabbar.h" +#include "playlistview.h" #include "playlistcontainer.h" #include "playlistmanager.h" -#include "ui_playlistcontainer.h" -#include "core/logging.h" -#include "core/iconloader.h" #include "playlistparsers/playlistparser.h" - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include "ui_playlistcontainer.h" +#include "3rdparty/qocoa/qsearchfield.h" const char *PlaylistContainer::kSettingsGroup = "Playlist"; const int PlaylistContainer::kFilterDelayMs = 100; @@ -127,7 +145,7 @@ void PlaylistContainer::SetActions(QAction *new_playlist, QAction *load_playlist } void PlaylistContainer::SetManager(PlaylistManager *manager) { - + manager_ = manager; ui_->tab_bar->SetManager(manager); @@ -149,7 +167,7 @@ void PlaylistContainer::SetManager(PlaylistManager *manager) { void PlaylistContainer::SetViewModel(Playlist *playlist) { if (view()->selectionModel()) { - disconnect(view()->selectionModel(), SIGNAL(selectionChanged(QItemSelection,QItemSelection)), this, SLOT(SelectionChanged())); + disconnect(view()->selectionModel(), SIGNAL(selectionChanged(QItemSelection, QItemSelection)), this, SLOT(SelectionChanged())); } if (playlist_ && playlist_->proxy()) { disconnect(playlist_->proxy(), SIGNAL(modelReset()), this, SLOT(UpdateNoMatchesLabel())); @@ -172,7 +190,7 @@ void PlaylistContainer::SetViewModel(Playlist *playlist) { view()->selectionModel()->select(manager_->current_selection(), QItemSelectionModel::ClearAndSelect); playlist->IgnoreSorting(false); - connect(view()->selectionModel(), SIGNAL(selectionChanged(QItemSelection,QItemSelection)), this, SLOT(SelectionChanged())); + connect(view()->selectionModel(), SIGNAL(selectionChanged(QItemSelection, QItemSelection)), this, SLOT(SelectionChanged())); emit ViewSelectionModelChanged(); // Update filter @@ -180,11 +198,11 @@ void PlaylistContainer::SetViewModel(Playlist *playlist) { // Update the no matches label connect(playlist_->proxy(), SIGNAL(modelReset()), SLOT(UpdateNoMatchesLabel())); - connect(playlist_->proxy(), SIGNAL(rowsInserted(QModelIndex,int,int)), SLOT(UpdateNoMatchesLabel())); - connect(playlist_->proxy(), SIGNAL(rowsRemoved(QModelIndex,int,int)), SLOT(UpdateNoMatchesLabel())); + connect(playlist_->proxy(), SIGNAL(rowsInserted(QModelIndex, int, int)), SLOT(UpdateNoMatchesLabel())); + connect(playlist_->proxy(), SIGNAL(rowsRemoved(QModelIndex, int, int)), SLOT(UpdateNoMatchesLabel())); connect(playlist_, SIGNAL(modelReset()), SLOT(UpdateNoMatchesLabel())); - connect(playlist_, SIGNAL(rowsInserted(QModelIndex,int,int)), SLOT(UpdateNoMatchesLabel())); - connect(playlist_, SIGNAL(rowsRemoved(QModelIndex,int,int)), SLOT(UpdateNoMatchesLabel())); + connect(playlist_, SIGNAL(rowsInserted(QModelIndex, int, int)), SLOT(UpdateNoMatchesLabel())); + connect(playlist_, SIGNAL(rowsRemoved(QModelIndex, int, int)), SLOT(UpdateNoMatchesLabel())); UpdateNoMatchesLabel(); // Ensure that tab is current @@ -241,13 +259,11 @@ void PlaylistContainer::PlaylistAdded(int id, const QString &name, bool favorite } if (ui_->tab_bar->count() > 1) { - // Have to do this here because sizeHint() is only valid when there's a - // tab in the bar. + // Have to do this here because sizeHint() is only valid when there's a tab in the bar. tab_bar_animation_->setFrameRange(0, ui_->tab_bar->sizeHint().height()); if (!isVisible()) { - // Skip the animation since the window is hidden (eg. if we're still - // loading the UI). + // Skip the animation since the window is hidden (eg. if we're still loading the UI). tab_bar_visible_ = true; ui_->tab_bar->setMaximumHeight(tab_bar_animation_->endFrame()); } else { @@ -271,8 +287,6 @@ void PlaylistContainer::PlaylistRenamed(int id, const QString &new_name) { void PlaylistContainer::NewPlaylist() { manager_->New(tr("Playlist")); } void PlaylistContainer::LoadPlaylist() { - - //qLog(Debug) << __PRETTY_FUNCTION__; QString filename = settings_.value("last_load_playlist").toString(); filename = QFileDialog::getOpenFileName(this, tr("Load playlist"), filename, manager_->parser()->filters()); @@ -296,8 +310,7 @@ void PlaylistContainer::ClearPlaylist() { void PlaylistContainer::GoToNextPlaylistTab() { // Get the next tab' id - int id_next = ui_->tab_bar->id_of((ui_->tab_bar->currentIndex() + 1) % - ui_->tab_bar->count()); + int id_next = ui_->tab_bar->id_of((ui_->tab_bar->currentIndex() + 1) % ui_->tab_bar->count()); // Switch to next tab manager_->SetCurrentPlaylist(id_next); } @@ -330,8 +343,7 @@ void PlaylistContainer::SetTabBarHeight(int height) { void PlaylistContainer::MaybeUpdateFilter() { - // delaying the filter update on small playlists is undesirable - // and an empty filter applies very quickly, too + // delaying the filter update on small playlists is undesirable and an empty filter applies very quickly, too if (manager_->current()->rowCount() < kFilterDelayPlaylistSizeThreshold || ui_->filter->text().isEmpty()) { UpdateFilter(); } diff --git a/src/playlist/playlistcontainer.h b/src/playlist/playlistcontainer.h index 7f98d55c..bec5dc69 100644 --- a/src/playlist/playlistcontainer.h +++ b/src/playlist/playlistcontainer.h @@ -23,19 +23,28 @@ #include "config.h" +#include + +#include #include +#include +#include +#include +#include #include +#include +#include +#include +#include -class Ui_PlaylistContainer; +class QKeyEvent; +class QResizeEvent; -class LineEditInterface; class Playlist; class PlaylistManager; class PlaylistView; -class QTimeLine; -class QTimer; -class QLabel; +class Ui_PlaylistContainer; class PlaylistContainer : public QWidget { Q_OBJECT diff --git a/src/playlist/playlistdelegates.cpp b/src/playlist/playlistdelegates.cpp index fde2cf1e..4851a8b4 100644 --- a/src/playlist/playlistdelegates.cpp +++ b/src/playlist/playlistdelegates.cpp @@ -20,29 +20,55 @@ #include "config.h" +#include +#include +#include +#include +#include +#include +#include +#include #include #include -#include +#include +#include #include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include #include +#include +#include +#include +#include +#include +#include +#include #include -#include #include +#include #include -#include +#include +#include +#include +#include +#include -#include "playlistdelegates.h" - -#include "queue.h" +#include "core/closure.h" +#include "core/iconloader.h" #include "core/logging.h" #include "core/player.h" +#include "core/song.h" +#include "core/urlhandler.h" #include "core/utilities.h" -#include "core/iconloader.h" #include "collection/collectionbackend.h" -#include "widgets/trackslider.h" +#include "playlist/playlist.h" +#include "playlistdelegates.h" #ifdef Q_OS_DARWIN #include "core/mac_utilities.h" @@ -202,8 +228,7 @@ QStyleOptionViewItemV4 PlaylistDelegateBase::Adjusted(const QStyleOptionViewItem QStyleOptionViewItemV4 ret(option); if (index.data(Playlist::Role_IsCurrent).toBool()) { - // Move the text in a bit on the first column for the song that's currently - // playing + // Move the text in a bit on the first column for the song that's currently playing ret.rect.setLeft(ret.rect.left() + 20); } @@ -213,9 +238,7 @@ QStyleOptionViewItemV4 PlaylistDelegateBase::Adjusted(const QStyleOptionViewItem bool PlaylistDelegateBase::helpEvent(QHelpEvent *event, QAbstractItemView *view, const QStyleOptionViewItem &option, const QModelIndex &index) { - // This function is copied from QAbstractItemDelegate, and changed to show - // displayText() in the tooltip, rather than the index's naked - // Qt::ToolTipRole text. + // This function is copied from QAbstractItemDelegate, and changed to show displayText() in the tooltip, rather than the index's naked Qt::ToolTipRole text. Q_UNUSED(option); @@ -246,7 +269,8 @@ bool PlaylistDelegateBase::helpEvent(QHelpEvent *event, QAbstractItemView *view, is_elided = displayed_text.width() < real_text.width(); if (is_elided) { QToolTip::showText(he->globalPos(), text, view); - } else { // in case that another text was previously displayed + } + else { // in case that another text was previously displayed QToolTip::hideText(); } return true; diff --git a/src/playlist/playlistdelegates.h b/src/playlist/playlistdelegates.h index 34f68660..99d6aef4 100644 --- a/src/playlist/playlistdelegates.h +++ b/src/playlist/playlistdelegates.h @@ -23,16 +23,36 @@ #include "config.h" +#include + +#include +#include +#include #include +#include +#include +#include +#include #include +#include +#include +#include +#include +#include +#include #include +#include +#include #include +#include +#include +#include +#include #include #include "playlist.h" -#include "collection/collection.h" -#include "widgets/ratingwidget.h" +class CollectionBackend; class Player; class QueuedItemDelegate : public QStyledItemDelegate { @@ -142,8 +162,7 @@ class TagCompletionItemDelegate : public PlaylistDelegateBase { public: TagCompletionItemDelegate(QObject *parent, CollectionBackend *backend, Playlist::Column column) : PlaylistDelegateBase(parent), backend_(backend), column_(column) {}; - QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &option, - const QModelIndex &index) const; + QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const; private: CollectionBackend *backend_; diff --git a/src/playlist/playlistfilter.cpp b/src/playlist/playlistfilter.cpp index 3f5b7296..4d76b478 100644 --- a/src/playlist/playlistfilter.cpp +++ b/src/playlist/playlistfilter.cpp @@ -20,11 +20,18 @@ #include "config.h" +#include + +#include +#include +#include +#include +#include + +#include "playlist/playlist.h" #include "playlistfilter.h" #include "playlistfilterparser.h" -#include - PlaylistFilter::PlaylistFilter(QObject *parent) : QSortFilterProxyModel(parent), filter_tree_(new NopFilter), diff --git a/src/playlist/playlistfilter.h b/src/playlist/playlistfilter.h index 7428bea2..c4e5ad9c 100644 --- a/src/playlist/playlistfilter.h +++ b/src/playlist/playlistfilter.h @@ -23,13 +23,18 @@ #include "config.h" +#include + +#include +#include +#include +#include #include +#include #include #include "playlist.h" -#include - class FilterTree; class PlaylistFilter : public QSortFilterProxyModel { diff --git a/src/playlist/playlistfilterparser.cpp b/src/playlist/playlistfilterparser.cpp index 6d4a3e12..11f4a00c 100644 --- a/src/playlist/playlistfilterparser.cpp +++ b/src/playlist/playlistfilterparser.cpp @@ -20,12 +20,21 @@ #include "config.h" -#include "playlistfilterparser.h" -#include "playlist.h" -#include "core/logging.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include #include +#include "playlist.h" +#include "playlistfilterparser.h" + class SearchTermComparator { public: virtual ~SearchTermComparator() {} @@ -143,11 +152,9 @@ class LeComparator : public SearchTermComparator { int search_term_; }; -// The length field of the playlist (entries) contains a -// song's running time in nano seconds. However, We don't -// really care about nano seconds, just seconds. Thus, with -// this decorator we drop the last 9 digits, if that many -// are present. +// The length field of the playlist (entries) contains a song's running time in nano seconds. +// However, We don't really care about nano seconds, just seconds. +// Thus, with this decorator we drop the last 9 digits, if that many are present. class DropTailComparatorDecorator : public SearchTermComparator { public: explicit DropTailComparatorDecorator(SearchTermComparator *cmp) : cmp_(cmp) {} @@ -178,8 +185,7 @@ class FilterTerm : public FilterTree { public: explicit FilterTerm(SearchTermComparator *comparator, const QList &columns) : cmp_(comparator), columns_(columns) {} - virtual bool accept(int row, const QModelIndex &parent, - const QAbstractItemModel *const model) const { + virtual bool accept(int row, const QModelIndex &parent, const QAbstractItemModel *const model) const { for (int i : columns_) { QModelIndex idx(model->index(row, i, parent)); if (cmp_->Matches(idx.data().toString().toLower())) return true; @@ -399,8 +405,7 @@ FilterTree *FilterParser::parseSearchTerm() { *iter_ == '-') { break; } else if (buf_.isEmpty()) { - // we don't know whether there is a column part in this search term - // thus we assume the latter and just try and read a prefix + // we don't know whether there is a column part in this search term thus we assume the latter and just try and read a prefix if (prefix.isEmpty() && (*iter_ == '>' || *iter_ == '<' || *iter_ == '=' || *iter_ == '!')) { prefix += *iter_; } @@ -435,8 +440,7 @@ FilterTree *FilterParser::createSearchTermTreeNode( cmp = new NeComparator(search); } else if (!col.isEmpty() && columns_.contains(col) && numerical_columns_.contains(columns_[col])) { - // the length column contains the time in seconds (nano seconds, actually - - // the "nano" part is handled by the DropTailComparatorDecorator, though). + // the length column contains the time in seconds (nano seconds, actually - the "nano" part is handled by the DropTailComparatorDecorator, though). int search_value; if (columns_[col] == Playlist::Column_Length) { search_value = parseTime(search); diff --git a/src/playlist/playlistfilterparser.h b/src/playlist/playlistfilterparser.h index f7103d07..1fc0cecd 100644 --- a/src/playlist/playlistfilterparser.h +++ b/src/playlist/playlistfilterparser.h @@ -23,12 +23,14 @@ #include "config.h" +#include + #include -#include #include #include +#include -class QAbstractItemModel; +class QModelIndex; // structure for filter parse tree class FilterTree { @@ -80,9 +82,7 @@ class FilterParser { void advance(); FilterTree *parseOrGroup(); FilterTree *parseAndGroup(); - // check if iter is at the start of 'AND' - // if so, step over it and return true - // it not, return false and leave iter where it was + // check if iter is at the start of 'AND' if so, step over it and return true if not, return false and leave iter where it was bool checkAnd(); // check if iter is at the start of 'OR' bool checkOr(bool step_over = true); diff --git a/src/playlist/playlistheader.cpp b/src/playlist/playlistheader.cpp index 1311f929..ab0b230a 100644 --- a/src/playlist/playlistheader.cpp +++ b/src/playlist/playlistheader.cpp @@ -20,13 +20,23 @@ #include "config.h" -#include "playlistheader.h" -#include "playlistview.h" +#include -#include -#include +#include +#include +#include #include #include +#include +#include +#include +#include +#include +#include +#include + +#include "playlistheader.h" +#include "playlistview.h" PlaylistHeader::PlaylistHeader(Qt::Orientation orientation, PlaylistView *view, QWidget *parent) : StretchHeaderView(orientation, parent), diff --git a/src/playlist/playlistheader.h b/src/playlist/playlistheader.h index 09f2a3de..c7c98c5a 100644 --- a/src/playlist/playlistheader.h +++ b/src/playlist/playlistheader.h @@ -23,13 +23,21 @@ #include "config.h" +#include + +#include +#include +#include +#include +#include +#include +#include +#include + #include "widgets/stretchheaderview.h" class PlaylistView; -class QMenu; -class QSignalMapper; - class PlaylistHeader : public StretchHeaderView { Q_OBJECT diff --git a/src/playlist/playlistitem.cpp b/src/playlist/playlistitem.cpp index 1b41e319..7d9f1116 100644 --- a/src/playlist/playlistitem.cpp +++ b/src/playlist/playlistitem.cpp @@ -20,17 +20,22 @@ #include "config.h" -#include "playlistitem.h" -#include "songplaylistitem.h" -#include "core/logging.h" -#include "core/song.h" -#include "collection/collection.h" -#include "collection/collectionplaylistitem.h" +#include -#include #include +#include +#include +#include +#include #include +#include "core/logging.h" +#include "core/song.h" + +#include "collection/collection.h" +#include "collection/collectionplaylistitem.h" +#include "playlistitem.h" +#include "songplaylistitem.h" PlaylistItem::~PlaylistItem() { } diff --git a/src/playlist/playlistitem.h b/src/playlist/playlistitem.h index a9bd29f3..f71d73d0 100644 --- a/src/playlist/playlistitem.h +++ b/src/playlist/playlistitem.h @@ -24,16 +24,24 @@ #include "config.h" #include +#include #include -#include +#include #include -#include +#include +#include +#include +#include +#include #include +#include +#include +#include +#include #include "core/song.h" -class QAction; class SqlRow; class PlaylistItem : public std::enable_shared_from_this { @@ -87,11 +95,8 @@ class PlaylistItem : public std::enable_shared_from_this { QColor GetCurrentForegroundColor() const; bool HasCurrentForegroundColor() const; - // Convenience function to find out whether this item is from the local - // collection, as opposed to a device, a file on disk, or a stream. - // Remember that even if this returns true, the collection item might be - // invalid so you might want to check that its id is not equal to -1 - // before actually using it. + // Convenience function to find out whether this item is from the local collection, as opposed to a device, a file on disk, or a stream. + // Remember that even if this returns true, the collection item might be invalid so you might want to check that its id is not equal to -1 before actually using it. virtual bool IsLocalCollectionItem() const { return false; } void SetShouldSkip(bool val); bool GetShouldSkip() const; diff --git a/src/playlist/playlistitemmimedata.h b/src/playlist/playlistitemmimedata.h index 2103e338..26a546f9 100644 --- a/src/playlist/playlistitemmimedata.h +++ b/src/playlist/playlistitemmimedata.h @@ -23,8 +23,10 @@ #include "config.h" -#include "playlistitem.h" +#include + #include "core/mimedata.h" +#include "playlistitem.h" class PlaylistItemMimeData : public MimeData { Q_OBJECT diff --git a/src/playlist/playlistlistcontainer.cpp b/src/playlist/playlistlistcontainer.cpp index 6f0d26d1..de00a33c 100644 --- a/src/playlist/playlistlistcontainer.cpp +++ b/src/playlist/playlistlistcontainer.cpp @@ -20,23 +20,39 @@ #include "config.h" -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include #include -#include +#include #include -#include +#include +#include #include +#include +#include +#include +#include +#include +#include +#include +#include +#include "core/application.h" +#include "core/iconloader.h" +#include "core/player.h" #include "playlist.h" +#include "playlistbackend.h" +#include "playlistlistview.h" #include "playlistlistcontainer.h" #include "playlistlistmodel.h" #include "playlistmanager.h" #include "ui_playlistlistcontainer.h" -#include "core/application.h" -#include "core/logging.h" -#include "core/player.h" -#include "core/iconloader.h" class PlaylistListSortFilterModel : public QSortFilterProxyModel { public: @@ -50,8 +66,7 @@ public: if (ret < 0) return true; if (ret > 0) return false; - // Now use the source model row order to ensure we always get a - // deterministic sorting even when two items are named the same. + // Now use the source model row order to ensure we always get a deterministic sorting even when two items are named the same. return left.row() < right.row(); } }; @@ -152,7 +167,7 @@ void PlaylistListContainer::SetApplication(Application *app) { connect(manager, SIGNAL(CurrentChanged(Playlist*)), SLOT(CurrentChanged(Playlist*))); connect(manager, SIGNAL(ActiveChanged(Playlist*)), SLOT(ActiveChanged(Playlist*))); - connect(model_, SIGNAL(PlaylistRenamed(int,QString)), manager, SLOT(Rename(int,QString))); + connect(model_, SIGNAL(PlaylistRenamed(int, QString)), manager, SLOT(Rename(int, QString))); connect(player, SIGNAL(Paused()), SLOT(ActivePaused())); connect(player, SIGNAL(Playing()), SLOT(ActivePlaying())); @@ -187,8 +202,7 @@ void PlaylistListContainer::AddPlaylist(int id, const QString &name, bool favori } if (model_->PlaylistById(id)) { - // We know about this playlist already - it was probably one of the open - // ones that was loaded on startup. + // We know about this playlist already - it was probably one of the open ones that was loaded on startup. return; } diff --git a/src/playlist/playlistlistcontainer.h b/src/playlist/playlistlistcontainer.h index 890c0773..86efefde 100644 --- a/src/playlist/playlistlistcontainer.h +++ b/src/playlist/playlistlistcontainer.h @@ -23,14 +23,19 @@ #include "config.h" -#include "playlistbackend.h" +#include +#include #include +#include +#include +#include +#include +#include +#include +#include -class QMenu; -class QSortFilterProxyModel; -class QStandardItemModel; - +class QModelIndex; class Application; class Playlist; class PlaylistListModel; diff --git a/src/playlist/playlistlistmodel.cpp b/src/playlist/playlistlistmodel.cpp index fab85f10..b461ced6 100644 --- a/src/playlist/playlistlistmodel.cpp +++ b/src/playlist/playlistlistmodel.cpp @@ -20,10 +20,17 @@ #include "config.h" -#include "playlistlistmodel.h" -#include "core/logging.h" - +#include +#include #include +#include +#include +#include +#include +#include +#include + +#include "playlistlistmodel.h" PlaylistListModel::PlaylistListModel(QObject *parent) : QStandardItemModel(parent), dropping_rows_(false) { @@ -112,7 +119,7 @@ void PlaylistListModel::AddRowItem(QStandardItem *item, const QString &parent_pa } -void PlaylistListModel::RowsAboutToBeRemoved(const QModelIndex& parent, int start, int end) { +void PlaylistListModel::RowsAboutToBeRemoved(const QModelIndex &parent, int start, int end) { for (int i = start; i <= end; ++i) { const QModelIndex idx = index(i, 0, parent); diff --git a/src/playlist/playlistlistmodel.h b/src/playlist/playlistlistmodel.h index c1d12754..f9e699d9 100644 --- a/src/playlist/playlistlistmodel.h +++ b/src/playlist/playlistlistmodel.h @@ -23,7 +23,17 @@ #include "config.h" +#include + +#include #include +#include +#include +#include +#include +#include + +class QModelIndex; class PlaylistListModel : public QStandardItemModel { Q_OBJECT diff --git a/src/playlist/playlistlistview.cpp b/src/playlist/playlistlistview.cpp index c18cbb9a..ef16827a 100644 --- a/src/playlist/playlistlistview.cpp +++ b/src/playlist/playlistlistview.cpp @@ -20,9 +20,16 @@ #include "config.h" -#include "playlistlistview.h" +#include +#include +#include +#include #include +#include +#include + +#include "playlistlistview.h" PlaylistListView::PlaylistListView(QWidget *parent) : AutoExpandingTreeView(parent) {} diff --git a/src/playlist/playlistlistview.h b/src/playlist/playlistlistview.h index 8d7ac9fa..e75804e4 100644 --- a/src/playlist/playlistlistview.h +++ b/src/playlist/playlistlistview.h @@ -18,8 +18,16 @@ * */ +#ifndef PLAYLISTVIEW_H +#define PLAYLISTVIEW_H + #include "config.h" +#include +#include +#include +#include + #include "widgets/autoexpandingtreeview.h" class PlaylistListView : public AutoExpandingTreeView { @@ -31,5 +39,7 @@ class PlaylistListView : public AutoExpandingTreeView { protected: // QWidget - void paintEvent(QPaintEvent* event); + void paintEvent(QPaintEvent *event); }; + +#endif // PLAYLISTVIEW_H diff --git a/src/playlist/playlistmanager.cpp b/src/playlist/playlistmanager.cpp index 93aa9b84..cc537921 100644 --- a/src/playlist/playlistmanager.cpp +++ b/src/playlist/playlistmanager.cpp @@ -20,29 +20,45 @@ #include "config.h" +#include + +#include +#include +#include +#include +#include +#include #include #include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #include -#include "playlistmanager.h" - -#include "playlistbackend.h" -#include "playlistcontainer.h" -#include "playlistmanager.h" -#include "playlistsaveoptionsdialog.h" -#include "playlistview.h" #include "core/application.h" +#include "core/closure.h" #include "core/logging.h" #include "core/player.h" -#include "core/songloader.h" #include "core/utilities.h" #include "collection/collectionbackend.h" #include "collection/collectionplaylistitem.h" +#include "playlist.h" +#include "playlistbackend.h" +#include "playlistcontainer.h" +#include "playlistmanager.h" +#include "playlistitem.h" +#include "playlistview.h" +#include "playlistsaveoptionsdialog.h" #include "playlistparsers/playlistparser.h" +class ParserBase; + PlaylistManager::PlaylistManager(Application *app, QObject *parent) : PlaylistManagerInterface(app, parent), app_(app), @@ -176,9 +192,7 @@ void PlaylistManager::Save(int id, const QString &filename, Playlist::Path path_ parser_->Save(playlist(id)->GetAllSongs(), filename, path_type); } else { - // Playlist is not in the playlist manager: probably save action was - // triggered - // from the left side bar and the playlist isn't loaded. + // Playlist is not in the playlist manager: probably save action was triggered from the left side bar and the playlist isn't loaded. QFuture> future = QtConcurrent::run(playlist_backend_, &PlaylistBackend::GetPlaylistSongs, id); NewClosure(future, this, SLOT(ItemsLoadedForSavePlaylist(QFuture, QString, Playlist::Path)), future, filename, path_type); @@ -272,17 +286,14 @@ void PlaylistManager::Rename(int id, const QString &new_name) { void PlaylistManager::Favorite(int id, bool favorite) { if (playlists_.contains(id)) { - // If playlists_ contains this playlist, its means it's opened: star or - // unstar it. + // If playlists_ contains this playlist, its means it's opened: star or unstar it. playlist_backend_->FavoritePlaylist(id, favorite); playlists_[id].p->set_favorite(favorite); } else { Q_ASSERT(!favorite); - // Otherwise it means user wants to remove this playlist from the left - // panel, - // while it's not visible in the playlist tabbar either, because it has been - // closed: delete it. + // Otherwise it means user wants to remove this playlist from the left panel, + // while it's not visible in the playlist tabbar either, because it has been closed: delete it. playlist_backend_->RemovePlaylist(id); } emit PlaylistFavorited(id, favorite); @@ -359,9 +370,8 @@ void PlaylistManager::SetActivePlaylist(int id) { void PlaylistManager::SetActiveToCurrent() { // Check if we need to update the active playlist. - // By calling SetActiveToCurrent, the playlist manager emits the signal - // "ActiveChanged". This signal causes the network remote module to - // send all playlists to the clients, even no change happend. + // By calling SetActiveToCurrent, the playlist manager emits the signal "ActiveChanged". + // This signal causes the network remote module to send all playlists to the clients, even no change happend. if (current_id() != active_id()) { SetActivePlaylist(current_id()); } diff --git a/src/playlist/playlistmanager.h b/src/playlist/playlistmanager.h index a8c94073..72cad225 100644 --- a/src/playlist/playlistmanager.h +++ b/src/playlist/playlistmanager.h @@ -23,11 +23,16 @@ #include "config.h" -#include -#include -#include +#include + #include -#include +#include +#include +#include +#include +#include +#include +#include #include "core/song.h" #include "playlist.h" @@ -38,10 +43,6 @@ class PlaylistBackend; class PlaylistContainer; class PlaylistParser; class PlaylistSequence; -class TaskManager; - -class QModelIndex; -class QUrl; class PlaylistManagerInterface : public QObject { Q_OBJECT @@ -76,22 +77,22 @@ public: virtual PlaylistContainer *playlist_container() const = 0; public slots: - virtual void New(const QString& name, const SongList& songs = SongList(), const QString& special_type = QString()) = 0; - virtual void Load(const QString& filename) = 0; - virtual void Save(int id, const QString& filename, Playlist::Path path_type) = 0; - virtual void Rename(int id, const QString& new_name) = 0; + virtual void New(const QString &name, const SongList& songs = SongList(), const QString &special_type = QString()) = 0; + virtual void Load(const QString &filename) = 0; + virtual void Save(int id, const QString &filename, Playlist::Path path_type) = 0; + virtual void Rename(int id, const QString &new_name) = 0; virtual void Delete(int id) = 0; virtual bool Close(int id) = 0; virtual void Open(int id) = 0; virtual void ChangePlaylistOrder(const QList& ids) = 0; - virtual void SongChangeRequestProcessed(const QUrl& url, bool valid) = 0; + virtual void SongChangeRequestProcessed(const QUrl &url, bool valid) = 0; virtual void SetCurrentPlaylist(int id) = 0; virtual void SetActivePlaylist(int id) = 0; virtual void SetActiveToCurrent() = 0; - virtual void SelectionChanged(const QItemSelection& selection) = 0; + virtual void SelectionChanged(const QItemSelection &selection) = 0; // Convenience slots that defer to either current() or active() virtual void ClearCurrent() = 0; @@ -105,22 +106,21 @@ public slots: signals: void PlaylistManagerInitialized(); - void PlaylistAdded(int id, const QString& name, bool favorite); + void PlaylistAdded(int id, const QString &name, bool favorite); void PlaylistDeleted(int id); void PlaylistClosed(int id); - void PlaylistRenamed(int id, const QString& new_name); + void PlaylistRenamed(int id, const QString &new_name); void PlaylistFavorited(int id, bool favorite); void CurrentChanged(Playlist *new_playlist); void ActiveChanged(Playlist *new_playlist); - void Error(const QString& message); - void SummaryTextChanged(const QString& summary); + void Error(const QString &message); + void SummaryTextChanged(const QString &summary); // Forwarded from individual playlists void CurrentSongChanged(const Song& song); - // Signals that one of manager's playlists has changed (new items, new - // ordering etc.) - the argument shows which. + // Signals that one of manager's playlists has changed (new items, new ordering etc.) - the argument shows which. void PlaylistChanged(Playlist *playlist); void EditingFinished(const QModelIndex& index); void PlayRequested(const QModelIndex& index); @@ -168,12 +168,12 @@ class PlaylistManager : public PlaylistManagerInterface { PlaylistContainer *playlist_container() const { return playlist_container_; } public slots: - void New(const QString& name, const SongList& songs = SongList(), const QString& special_type = QString()); - void Load(const QString& filename); - void Save(int id, const QString& filename, Playlist::Path path_type); + void New(const QString &name, const SongList &songs = SongList(), const QString &special_type = QString()); + void Load(const QString &filename); + void Save(int id, const QString &filename, Playlist::Path path_type); // Display a file dialog to let user choose a file before saving the file - void SaveWithUI(int id, const QString& playlist_name); - void Rename(int id, const QString& new_name); + void SaveWithUI(int id, const QString &playlist_name); + void Rename(int id, const QString &new_name); void Favorite(int id, bool favorite); void Delete(int id); bool Close(int id); @@ -184,7 +184,7 @@ public slots: void SetActivePlaylist(int id); void SetActiveToCurrent(); - void SelectionChanged(const QItemSelection& selection); + void SelectionChanged(const QItemSelection &selection); // Makes a playlist current if it's open already, or opens it and makes it current if it is hidden. void SetCurrentOrOpen(int id); @@ -216,7 +216,7 @@ public slots: void ItemsLoadedForSavePlaylist(QFuture future, const QString& filename, Playlist::Path path_type); private: - Playlist *AddPlaylist(int id, const QString& name, const QString& special_type, const QString& ui_path, bool favorite); + Playlist *AddPlaylist(int id, const QString& name, const QString &special_type, const QString& ui_path, bool favorite); private: struct Data { diff --git a/src/playlist/playlistsaveoptionsdialog.cpp b/src/playlist/playlistsaveoptionsdialog.cpp index 967da87b..f359a66e 100644 --- a/src/playlist/playlistsaveoptionsdialog.cpp +++ b/src/playlist/playlistsaveoptionsdialog.cpp @@ -20,13 +20,17 @@ #include "config.h" -#include "playlistsaveoptionsdialog.h" - -#include "ui_playlistsaveoptionsdialog.h" -#include "playlistparsers/parserbase.h" - +#include +#include +#include +#include +#include #include +#include "playlist.h" +#include "playlistsaveoptionsdialog.h" +#include "ui_playlistsaveoptionsdialog.h" + const char *PlaylistSaveOptionsDialog::kSettingsGroup = "PlaylistSaveOptionsDialog"; PlaylistSaveOptionsDialog::PlaylistSaveOptionsDialog(QWidget *parent) : QDialog(parent), ui(new Ui::PlaylistSaveOptionsDialog) { diff --git a/src/playlist/playlistsaveoptionsdialog.h b/src/playlist/playlistsaveoptionsdialog.h index 8ec33011..730ea8fb 100644 --- a/src/playlist/playlistsaveoptionsdialog.h +++ b/src/playlist/playlistsaveoptionsdialog.h @@ -23,7 +23,10 @@ #include "config.h" +#include +#include #include +#include #include "playlist.h" diff --git a/src/playlist/playlistsequence.cpp b/src/playlist/playlistsequence.cpp index 300ba401..cb875f65 100644 --- a/src/playlist/playlistsequence.cpp +++ b/src/playlist/playlistsequence.cpp @@ -20,15 +20,21 @@ #include "config.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "core/iconloader.h" +#include "core/settingsprovider.h" #include "playlistsequence.h" #include "ui_playlistsequence.h" -#include "core/iconloader.h" - -#include -#include -#include -#include -#include const char *PlaylistSequence::kSettingsGroup = "PlaylistSequence"; @@ -40,8 +46,7 @@ PlaylistSequence::PlaylistSequence(QWidget *parent, SettingsProvider *settings) shuffle_menu_(new QMenu(this)), loading_(false), repeat_mode_(Repeat_Off), - shuffle_mode_(Shuffle_Off), - dynamic_(false) + shuffle_mode_(Shuffle_Off) { ui_->setupUi(this); @@ -189,7 +194,6 @@ void PlaylistSequence::SetShuffleMode(ShuffleMode mode) { case Shuffle_Albums: ui_->action_shuffle_albums->setChecked(true); break; } - if (mode != shuffle_mode_) { shuffle_mode_ = mode; emit ShuffleModeChanged(mode); @@ -199,23 +203,12 @@ void PlaylistSequence::SetShuffleMode(ShuffleMode mode) { } -void PlaylistSequence::SetUsingDynamicPlaylist(bool dynamic) { - - dynamic_ = dynamic; - const QString not_available(tr("Not available while using a dynamic playlist")); - - setEnabled(!dynamic); - ui_->shuffle->setToolTip(dynamic ? not_available : tr("Shuffle")); - ui_->repeat->setToolTip(dynamic ? not_available : tr("Repeat")); - -} - PlaylistSequence::ShuffleMode PlaylistSequence::shuffle_mode() const { - return dynamic_ ? Shuffle_Off : shuffle_mode_; + return shuffle_mode_; } PlaylistSequence::RepeatMode PlaylistSequence::repeat_mode() const { - return dynamic_ ? Repeat_Off : repeat_mode_; + return repeat_mode_; } //called from global shortcut diff --git a/src/playlist/playlistsequence.h b/src/playlist/playlistsequence.h index ac18a066..d09147dc 100644 --- a/src/playlist/playlistsequence.h +++ b/src/playlist/playlistsequence.h @@ -24,13 +24,17 @@ #include "config.h" #include +#include +#include #include +#include +#include +#include +#include +#include -#include "core/settingsprovider.h" - -class QMenu; - +class SettingsProvider; class Ui_PlaylistSequence; class PlaylistSequence : public QWidget { @@ -68,7 +72,6 @@ class PlaylistSequence : public QWidget { void SetShuffleMode(PlaylistSequence::ShuffleMode mode); void CycleShuffleMode(); void CycleRepeatMode(); - void SetUsingDynamicPlaylist(bool dynamic); signals: void RepeatModeChanged(PlaylistSequence::RepeatMode mode); @@ -94,7 +97,7 @@ class PlaylistSequence : public QWidget { bool loading_; RepeatMode repeat_mode_; ShuffleMode shuffle_mode_; - bool dynamic_; + }; #endif // PLAYLISTSEQUENCE_H diff --git a/src/playlist/playlisttabbar.cpp b/src/playlist/playlisttabbar.cpp index 8988ff67..aaf0252e 100644 --- a/src/playlist/playlisttabbar.cpp +++ b/src/playlist/playlisttabbar.cpp @@ -20,25 +20,39 @@ #include "config.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "core/iconloader.h" +#include "core/logging.h" +#include "core/mimedata.h" +#include "core/song.h" +#include "widgets/favoritewidget.h" +#include "widgets/renametablineedit.h" #include "playlist.h" #include "playlistmanager.h" #include "playlisttabbar.h" -#include "playlistview.h" -#include "songmimedata.h" -#include "core/logging.h" -#include "core/iconloader.h" -#include "widgets/renametablineedit.h" -#include "widgets/favoritewidget.h" - -#include -#include -#include -#include -#include -#include -#include -#include -#include const char *PlaylistTabBar::kSettingsGroup = "PlaylistTabBar"; @@ -91,8 +105,7 @@ void PlaylistTabBar::SetManager(PlaylistManager *manager) { void PlaylistTabBar::PlaylistManagerInitialized() { - // Signal that we are done loading and thus further changes should be - // committed to the db. + // Signal that we are done loading and thus further changes should be committed to the db. initialized_ = true; disconnect(manager_, SIGNAL(PlaylistManagerInitialized()), this, SLOT(PlaylistManagerInitialized())); @@ -100,7 +113,7 @@ void PlaylistTabBar::PlaylistManagerInitialized() { void PlaylistTabBar::contextMenuEvent(QContextMenuEvent *e) { - //we need to finish the renaming action before showing context menu + // We need to finish the renaming action before showing context menu if (rename_editor_->isVisible()) { //discard any change HideEditor(); @@ -128,10 +141,10 @@ void PlaylistTabBar::mouseReleaseEvent(QMouseEvent *e) { } void PlaylistTabBar::mouseDoubleClickEvent(QMouseEvent *e) { - + int index = tabAt(e->pos()); - // discard a double click with the middle button + // Discard a double click with the middle button if (e->button() != Qt::MidButton) { if (index == -1) { new_->activate(QAction::Trigger); @@ -172,10 +185,10 @@ void PlaylistTabBar::RenameInline() { void PlaylistTabBar::HideEditor() { - //editingFinished() will be called twice due to Qt bug #40, so we reuse the same instance, don't delete it + // editingFinished() will be called twice due to Qt bug #40, so we reuse the same instance, don't delete it rename_editor_->setVisible(false); - // hack to give back focus to playlist view + // Hack to give back focus to playlist view manager_->SetCurrentPlaylist(manager_->current()->id()); } @@ -232,10 +245,8 @@ void PlaylistTabBar::Close() { } } - // Close the playlist. If the playlist is not a favorite playlist, it will be - // deleted, as it will not be visible after being closed. Otherwise, the tab - // is closed but the playlist still exists and can be resurrected from the - // "Playlists" tab. + // Close the playlist. If the playlist is not a favorite playlist, it will be deleted, as it will not be visible after being closed. + // Otherwise, the tab is closed but the playlist still exists and can be resurrected from the "Playlists" tab. emit Close(playlist_id); // Select the nearest tab. @@ -305,8 +316,8 @@ void PlaylistTabBar::CurrentIndexChanged(int index) { if (!suppress_current_changed_) emit CurrentIdChanged(tabData(index).toInt()); } -void PlaylistTabBar::InsertTab(int id, int index, const QString &text, - bool favorite) { +void PlaylistTabBar::InsertTab(int id, int index, const QString &text, bool favorite) { + suppress_current_changed_ = true; insertTab(index, text); setTabData(index, id); @@ -319,8 +330,7 @@ void PlaylistTabBar::InsertTab(int id, int index, const QString &text, setTabButton(index, QTabBar::LeftSide, widget); suppress_current_changed_ = false; - // If we are still starting up, we don't need to do this, as the - // tab ordering after startup will be the same as was already in the db. + // If we are still starting up, we don't need to do this, as the tab ordering after startup will be the same as was already in the db. if (initialized_) { if (currentIndex() == index) emit CurrentIdChanged(id); @@ -330,11 +340,13 @@ void PlaylistTabBar::InsertTab(int id, int index, const QString &text, } void PlaylistTabBar::TabMoved() { + QList ids; for (int i = 0; i < count(); ++i) { ids << tabData(i).toInt(); } emit PlaylistOrderChanged(ids); + } void PlaylistTabBar::dragEnterEvent(QDragEnterEvent *e) { @@ -364,6 +376,7 @@ void PlaylistTabBar::dragLeaveEvent(QDragLeaveEvent*) { } void PlaylistTabBar::timerEvent(QTimerEvent *e) { + QTabBar::timerEvent(e); if (e->timerId() == drag_hover_timer_.timerId()) { diff --git a/src/playlist/playlisttabbar.h b/src/playlist/playlisttabbar.h index eac204d4..329ae742 100644 --- a/src/playlist/playlisttabbar.h +++ b/src/playlist/playlisttabbar.h @@ -23,15 +23,31 @@ #include "config.h" +#include + +#include +#include #include +#include +#include #include #include +#include +#include +#include + +class QEvent; +class QContextMenuEvent; +class QDragEnterEvent; +class QDragLeaveEvent; +class QDragMoveEvent; +class QDropEvent; +class QMouseEvent; +class QTimerEvent; class PlaylistManager; class RenameTabLineEdit; -class QMenu; - class PlaylistTabBar : public QTabBar { Q_OBJECT diff --git a/src/playlist/playlistundocommands.cpp b/src/playlist/playlistundocommands.cpp index 2adb72d4..148c6227 100644 --- a/src/playlist/playlistundocommands.cpp +++ b/src/playlist/playlistundocommands.cpp @@ -20,8 +20,16 @@ #include "config.h" -#include "playlistundocommands.h" +#include + +#include +#include +#include + +#include "core/song.h" #include "playlist.h" +#include "playlistitem.h" +#include "playlistundocommands.h" namespace PlaylistUndoCommands { @@ -66,8 +74,7 @@ RemoveItems::RemoveItems(Playlist *playlist, int pos, int count) : Base(playlist void RemoveItems::redo() { for (int i = 0; i < ranges_.count(); ++i) - ranges_[i].items_ = - playlist_->RemoveItemsWithoutUndo(ranges_[i].pos_, ranges_[i].count_); + ranges_[i].items_ = playlist_->RemoveItemsWithoutUndo(ranges_[i].pos_, ranges_[i].count_); } void RemoveItems::undo() { @@ -111,9 +118,9 @@ void ReOrderItems::undo() { playlist_->ReOrderWithoutUndo(old_items_); } void ReOrderItems::redo() { playlist_->ReOrderWithoutUndo(new_items_); } SortItems::SortItems(Playlist* playlist, int column, Qt::SortOrder order, const PlaylistItemList &new_items) - : ReOrderItems(playlist, new_items), - column_(column), - order_(order) + : ReOrderItems(playlist, new_items) + //column_(column), + //order_(order) { setText(tr("sort songs")); } diff --git a/src/playlist/playlistundocommands.h b/src/playlist/playlistundocommands.h index 1d6f43cc..18a62760 100644 --- a/src/playlist/playlistundocommands.h +++ b/src/playlist/playlistundocommands.h @@ -23,14 +23,18 @@ #include "config.h" -#include +#include + #include +#include +#include #include "playlistitem.h" class Playlist; namespace PlaylistUndoCommands { + enum Types { Type_RemoveItems = 0, }; @@ -52,9 +56,8 @@ namespace PlaylistUndoCommands { void undo(); void redo(); // When load is async, items have already been pushed, so we need to update them. - // This function try to find the equivalent item, and replace it with the - // new (completely loaded) one. - // return true if the was found (and updated), false otherwise + // This function try to find the equivalent item, and replace it with the new (completely loaded) one. + // Return true if the was found (and updated), false otherwise bool UpdateItem(const PlaylistItemPtr &updated_item); private: @@ -110,11 +113,11 @@ namespace PlaylistUndoCommands { class SortItems : public ReOrderItems { public: - SortItems(Playlist *playlist, int column, Qt::SortOrder order, const PlaylistItemList &new_items); + SortItems(Playlist *playlist, int column, Qt::SortOrder order, const PlaylistItemList &new_items); private: - int column_; - Qt::SortOrder order_; + //int column_; + //Qt::SortOrder order_; }; class ShuffleItems : public ReOrderItems { diff --git a/src/playlist/playlistview.cpp b/src/playlist/playlistview.cpp index 63dedfa8..bf6b04f4 100644 --- a/src/playlist/playlistview.cpp +++ b/src/playlist/playlistview.cpp @@ -22,33 +22,60 @@ #include -#include -#include -#include -#include -#include -#include -#include -#include #include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "core/application.h" +#include "core/player.h" +#include "core/qt_blurimage.h" +#include "core/song.h" #include "playlist.h" -#include "playlistview.h" #include "playlistdelegates.h" #include "playlistheader.h" -#include "core/application.h" -#include "core/logging.h" -#include "core/player.h" -#include "core/iconloader.h" -#include "core/qt_blurimage.h" +#include "playlistview.h" #include "covermanager/currentartloader.h" +#include "settings/appearancesettingspage.h" #include "settings/playbacksettingspage.h" #include "settings/playlistsettingspage.h" -#include "settings/appearancesettingspage.h" const int PlaylistView::kStateVersion = 6; const int PlaylistView::kGlowIntensitySteps = 24; @@ -72,7 +99,7 @@ void PlaylistProxyStyle::drawControl(ControlElement element, const QStyleOption const QString &text = header_option->text; const QFontMetrics &font_metrics = header_option->fontMetrics; - // spaces added to make transition less abrupt + // Spaces added to make transition less abrupt if (rect.width() < font_metrics.width(text + " ")) { const Playlist::Column column = static_cast(header_option->section); QStyleOptionHeader new_option(*header_option); @@ -132,8 +159,6 @@ PlaylistView::PlaylistView(QWidget *parent) drag_over_(false) { - //qLog(Debug) << __PRETTY_FUNCTION__; - setHeader(header_); header_->setSectionsMovable(true); setStyle(style_); @@ -248,8 +273,7 @@ void PlaylistView::setModel(QAbstractItemModel *m) { disconnect(model(), SIGNAL(dataChanged(QModelIndex, QModelIndex)), this, SLOT(InvalidateCachedCurrentPixmap())); //disconnect(model(), SIGNAL(layoutAboutToBeChanged()), this, SLOT(RatingHoverOut())); // When changing the model, always invalidate the current pixmap. - // If a remote client uses "stop after", without invaliding the stop - // mark would not appear. + // If a remote client uses "stop after", without invaliding the stop mark would not appear. InvalidateCachedCurrentPixmap(); } @@ -323,8 +347,6 @@ void PlaylistView::SaveGeometry() { void PlaylistView::ReloadBarPixmaps() { - //qLog(Debug) << __PRETTY_FUNCTION__; - currenttrack_bar_left_ = LoadBarPixmap(":/pictures/currenttrack_bar_left.png"); currenttrack_bar_mid_ = LoadBarPixmap(":/pictures/currenttrack_bar_mid.png"); currenttrack_bar_right_ = LoadBarPixmap(":/pictures/currenttrack_bar_right.png"); @@ -413,13 +435,11 @@ void PlaylistView::drawRow(QPainter *painter, const QStyleOptionViewItem &option opt.palette.setColor(QPalette::AlternateBase, Qt::transparent); opt.decorationSize = QSize(20, 20); - // Draw the actual row data on top. We cache this, because it's fairly - // expensive (1-2ms), and we do it many times per second. + // Draw the actual row data on top. We cache this, because it's fairly expensive (1-2ms), and we do it many times per second. const bool cache_dirty = cached_current_row_rect_ != opt.rect || cached_current_row_row_ != index.row() || cached_current_row_.isNull(); // We can't update the cache if we're not drawing the entire region, - // QTreeView clips its drawing to only the columns in the region, so it - // wouldn't update the whole pixmap properly. + // QTreeView clips its drawing to only the columns in the region, so it wouldn't update the whole pixmap properly. const bool whole_region = current_paint_region_.boundingRect().width() == viewport()->width(); if (!cache_dirty) { @@ -560,8 +580,7 @@ void PlaylistView::RemoveSelected(bool deleting_from_disk) { // Store the last selected row, which is the last in the list int last_row = selection.last().top(); - // Sort the selection so we remove the items at the *bottom* first, ensuring - // we don't have to mess around with changing row numbers + // Sort the selection so we remove the items at the *bottom* first, ensuring we don't have to mess around with changing row numbers qSort(selection.begin(), selection.end(), CompareSelectionRanges); for (const QItemSelectionRange &range : selection) { @@ -580,8 +599,7 @@ void PlaylistView::RemoveSelected(bool deleting_from_disk) { // Select the new current item, we want always the item after the last selected if (new_index.isValid()) { - // Workaround to update keyboard selected row, if it's not the first row - // (this also triggers selection) + // Workaround to update keyboard selected row, if it's not the first row (this also triggers selection) if (new_row != 0) keyPressEvent(new QKeyEvent(QEvent::KeyPress, Qt::Key_Down, Qt::NoModifier)); // Update visual selection with the entire row @@ -677,8 +695,6 @@ void PlaylistView::leaveEvent(QEvent *e) { } void PlaylistView::mousePressEvent(QMouseEvent *event) { - - //qLog(Debug) << __PRETTY_FUNCTION__; if (editTriggers() & QAbstractItemView::NoEditTriggers) { QTreeView::mousePressEvent(event); @@ -710,8 +726,7 @@ void PlaylistView::scrollContentsBy(int dx, int dy) { } void PlaylistView::InhibitAutoscrollTimeout() { - // For 30 seconds after the user clicks on or scrolls the playlist we promise - // not to automatically scroll the view to keep up with a track change. + // For 30 seconds after the user clicks on or scrolls the playlist we promise not to automatically scroll the view to keep up with a track change. inhibit_autoscroll_ = false; } @@ -766,11 +781,9 @@ void PlaylistView::paintEvent(QPaintEvent *event) { // Reimplemented to draw the background image. // Reimplemented also to draw the drop indicator - // When the user is dragging some stuff over the playlist paintEvent gets - // called for the entire viewport every time the user moves the mouse. - // The drawTree is kinda expensive, so we cache the result and draw from the - // cache while the user is dragging. The cached pixmap gets invalidated in - // dragLeaveEvent, dropEvent and scrollContentsBy. + // When the user is dragging some stuff over the playlist paintEvent gets called for the entire viewport every time the user moves the mouse. + // The drawTree is kinda expensive, so we cache the result and draw from the cache while the user is dragging. + // The cached pixmap gets invalidated in dragLeaveEvent, dropEvent and scrollContentsBy. // Draw background if (background_image_type_ == Custom || background_image_type_ == Album) { @@ -908,8 +921,6 @@ void PlaylistView::PlaylistDestroyed() { } void PlaylistView::ReloadSettings() { - - //qLog(Debug) << __PRETTY_FUNCTION__; QSettings s; @@ -979,10 +990,9 @@ void PlaylistView::ReloadSettings() { int opacity_level = s.value("opacity_level", kDefaultOpacityLevel).toInt(); s.endGroup(); // Check if background properties have changed. - // We change properties only if they have actually changed, to avoid to call - // set_background_image when it is not needed, as this will cause the fading - // animation to start again. This also avoid to do useless - // "force_background_redraw". + // We change properties only if they have actually changed, to avoid to call set_background_image when it is not needed, + // as this will cause the fading animation to start again. + // This also avoid to do useless "force_background_redraw". if (!background_initialized_ || background_image_filename != background_image_filename_ || background_type != background_image_type_ || blur_radius_ != blur_radius || opacity_level_ != opacity_level) { background_initialized_ = true; @@ -998,10 +1008,8 @@ void PlaylistView::ReloadSettings() { set_background_image(current_song_cover_art_); } else { - // User changed background image type to something that will not be - // painted through paintEvent: reset all background images. - // This avoid to use old (deprecated) images for fading when selecting - // Album or Custom background image type later. + // User changed background image type to something that will not be painted through paintEvent: reset all background images. + // This avoid to use old (deprecated) images for fading when selecting Album or Custom background image type later. //set_background_image(QImage(":/pictures/playlistbg.png")); set_background_image(QImage()); cached_scaled_background_image_ = QPixmap(); @@ -1064,8 +1072,7 @@ void PlaylistView::rowsInserted(const QModelIndex &parent, int start, int end) { QTreeView::rowsInserted(parent, start, end); if (at_end) { - // If the rows were inserted at the end of the playlist then let's scroll - // the view so the user can see. + // If the rows were inserted at the end of the playlist then let's scroll the view so the user can see. scrollTo(model()->index(start, 0, parent), QAbstractItemView::PositionAtTop); } @@ -1211,10 +1218,8 @@ void PlaylistView::focusInEvent(QFocusEvent *event) { if (event->reason() == Qt::TabFocusReason || event->reason() == Qt::BacktabFocusReason) { - // If there's a current item but no selection it probably means the list was - // filtered, and the selected item does not match the filter. If there's - // only 1 item in the view it is now impossible to select that item without - // using the mouse. + // If there's a current item but no selection it probably means the list was filtered, and the selected item does not match the filter. + // If there's only 1 item in the view it is now impossible to select that item without using the mouse. const QModelIndex ¤t = selectionModel()->currentIndex(); if (current.isValid() && selectionModel()->selectedIndexes().isEmpty()) { QItemSelection new_selection(current.sibling(current.row(), 0), current.sibling(current.row(), current.model()->columnCount(current.parent()) - 1)); diff --git a/src/playlist/playlistview.h b/src/playlist/playlistview.h index d30c5035..14916dcf 100644 --- a/src/playlist/playlistview.h +++ b/src/playlist/playlistview.h @@ -24,25 +24,56 @@ #include "config.h" #include +#include -#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #include #include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #include "playlist.h" -class QCommonStyle; +class QEvent; +class QShowEvent; +class QContextMenuEvent; +class QDragEnterEvent; +class QDragLeaveEvent; +class QDragMoveEvent; +class QDropEvent; +class QFocusEvent; +class QHideEvent; +class QKeyEvent; +class QMouseEvent; +class QPaintEvent; +class QTimerEvent; class Application; +class Song; class CollectionBackend; class PlaylistHeader; -class QTimeLine; - // This proxy style works around a bug/feature introduced in Qt 4.7's QGtkStyle -// that uses Gtk to paint row backgrounds, ignoring any custom brush or palette -// the caller set in the QStyleOption. That breaks our currently playing track -// animation, which relies on the background painted by Qt to be transparent. +// that uses Gtk to paint row backgrounds, ignoring any custom brush or palette the caller set in the QStyleOption. +// That breaks our currently playing track animation, which relies on the background painted by Qt to be transparent. // This proxy style uses QCommonStyle to paint the affected elements. // This class is used by the global search view as well. class PlaylistProxyStyle : public QProxyStyle { @@ -164,8 +195,7 @@ class PlaylistView : public QTreeView { background_image_type_ = bg; emit BackgroundPropertyChanged(); } - // Save image as the background_image_ after applying some modifications - // (opacity, ...). + // Save image as the background_image_ after applying some modifications (opacity, ...). // Should be used instead of modifying background_image_ directly void set_background_image(const QImage &image); @@ -190,9 +220,9 @@ class PlaylistView : public QTreeView { bool background_initialized_; BackgroundImageType background_image_type_; - // Stores the background image to be displayed. As we want this image to be - // particular (in terms of format, opacity), you should probably use - // set_background_image_type instead of modifying background_image_ directly + // Stores the background image to be displayed. + // As we want this image to be particular (in terms of format, opacity), + // you should probably use set_background_image_type instead of modifying background_image_ directly QImage background_image_; int blur_radius_; int opacity_level_; diff --git a/src/playlist/queue.cpp b/src/playlist/queue.cpp index bbaec44c..b08d6281 100644 --- a/src/playlist/queue.cpp +++ b/src/playlist/queue.cpp @@ -20,11 +20,24 @@ #include "config.h" -#include "queue.h" - +#include +#include +#include #include +#include +#include +#include +#include +#include +#include #include -#include +#include +#include +#include +#include + +#include "playlist.h" +#include "queue.h" const char *Queue::kRowsMimetype = "application/x-strawberry-queue-rows"; @@ -63,15 +76,15 @@ QModelIndex Queue::mapToSource(const QModelIndex &proxy_index) const { void Queue::setSourceModel(QAbstractItemModel *source_model) { if (sourceModel()) { - disconnect(sourceModel(), SIGNAL(dataChanged(QModelIndex,QModelIndex)), this, SLOT(SourceDataChanged(QModelIndex,QModelIndex))); - disconnect(sourceModel(), SIGNAL(rowsRemoved(QModelIndex,int,int)), this, SLOT(SourceLayoutChanged())); + disconnect(sourceModel(), SIGNAL(dataChanged(QModelIndex, QModelIndex)), this, SLOT(SourceDataChanged(QModelIndex, QModelIndex))); + disconnect(sourceModel(), SIGNAL(rowsRemoved(QModelIndex, int, int)), this, SLOT(SourceLayoutChanged())); disconnect(sourceModel(), SIGNAL(layoutChanged()), this, SLOT(SourceLayoutChanged())); } QAbstractProxyModel::setSourceModel(source_model); - connect(sourceModel(), SIGNAL(dataChanged(QModelIndex,QModelIndex)), this, SLOT(SourceDataChanged(QModelIndex,QModelIndex))); - connect(sourceModel(), SIGNAL(rowsRemoved(QModelIndex,int,int)), this, SLOT(SourceLayoutChanged())); + connect(sourceModel(), SIGNAL(dataChanged(QModelIndex, QModelIndex)), this, SLOT(SourceDataChanged(QModelIndex, QModelIndex))); + connect(sourceModel(), SIGNAL(rowsRemoved(QModelIndex, int, int)), this, SLOT(SourceLayoutChanged())); connect(sourceModel(), SIGNAL(layoutChanged()), this, SLOT(SourceLayoutChanged())); } @@ -94,7 +107,6 @@ void Queue::SourceLayoutChanged() { beginRemoveRows(QModelIndex(), i, i); source_indexes_.removeAt(i); endRemoveRows(); - --i; } } @@ -181,8 +193,7 @@ void Queue::Move(const QList &proxy_rows, int pos) { layoutAboutToBeChanged(); QList moved_items; - // Take the items out of the list first, keeping track of whether the - // insertion point changes + // Take the items out of the list first, keeping track of whether the insertion point changes int offset = 0; for (int row : proxy_rows) { moved_items << source_indexes_.takeAt(row - offset); @@ -343,15 +354,15 @@ QVariant Queue::headerData(int section, Qt::Orientation orientation, int role) c void Queue::Remove(QList &proxy_rows) { - // order the rows + // Order the rows qStableSort(proxy_rows); - // reflects immediately changes in the playlist + // Reflects immediately changes in the playlist layoutAboutToBeChanged(); int removed_rows = 0; for (int row : proxy_rows) { - // after the first row, the row number needs to be updated + // After the first row, the row number needs to be updated const int real_row = row - removed_rows; beginRemoveRows(QModelIndex(), real_row, real_row); source_indexes_.removeAt(real_row); diff --git a/src/playlist/queue.h b/src/playlist/queue.h index d07c9d38..79e54f80 100644 --- a/src/playlist/queue.h +++ b/src/playlist/queue.h @@ -23,9 +23,16 @@ #include "config.h" -#include "playlist.h" +#include +#include +#include #include +#include +#include +#include +#include +#include class Queue : public QAbstractProxyModel { Q_OBJECT diff --git a/src/playlist/queuemanager.cpp b/src/playlist/queuemanager.cpp index e3a50178..f38ed772 100644 --- a/src/playlist/queuemanager.cpp +++ b/src/playlist/queuemanager.cpp @@ -18,18 +18,26 @@ * */ -#include "config.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "core/iconloader.h" #include "playlist.h" #include "playlistdelegates.h" #include "playlistmanager.h" #include "queue.h" #include "queuemanager.h" #include "ui_queuemanager.h" -#include "core/iconloader.h" - -#include -#include QueueManager::QueueManager(QWidget *parent) : QDialog(parent), @@ -75,8 +83,8 @@ void QueueManager::SetPlaylistManager(PlaylistManager *manager) { void QueueManager::CurrentPlaylistChanged(Playlist *playlist) { if (current_playlist_) { - disconnect(current_playlist_->queue(), SIGNAL(rowsInserted(QModelIndex,int,int)), this, SLOT(UpdateButtonState())); - disconnect(current_playlist_->queue(), SIGNAL(rowsRemoved(QModelIndex,int,int)), this, SLOT(UpdateButtonState())); + disconnect(current_playlist_->queue(), SIGNAL(rowsInserted(QModelIndex, int, int)), this, SLOT(UpdateButtonState())); + disconnect(current_playlist_->queue(), SIGNAL(rowsRemoved(QModelIndex, int, int)), this, SLOT(UpdateButtonState())); disconnect(current_playlist_->queue(), SIGNAL(layoutChanged()), this, SLOT(UpdateButtonState())); disconnect(current_playlist_, SIGNAL(destroyed()), this, SLOT(PlaylistDestroyed())); } diff --git a/src/playlist/queuemanager.h b/src/playlist/queuemanager.h index e34ff3db..2b3a2325 100644 --- a/src/playlist/queuemanager.h +++ b/src/playlist/queuemanager.h @@ -23,14 +23,15 @@ #include "config.h" +#include +#include #include +#include class Playlist; class PlaylistManager; class Ui_QueueManager; -class QModelIndex; - class QueueManager : public QDialog { Q_OBJECT @@ -58,4 +59,3 @@ private: }; #endif // QUEUEMANAGER_H - diff --git a/src/playlist/songloaderinserter.cpp b/src/playlist/songloaderinserter.cpp index c0165819..da632f25 100644 --- a/src/playlist/songloaderinserter.cpp +++ b/src/playlist/songloaderinserter.cpp @@ -21,12 +21,16 @@ #include "config.h" #include +#include +#include +#include -#include "playlist.h" -#include "songloaderinserter.h" +#include "core/closure.h" #include "core/logging.h" #include "core/songloader.h" #include "core/taskmanager.h" +#include "playlist.h" +#include "songloaderinserter.h" SongLoaderInserter::SongLoaderInserter(TaskManager *task_manager, CollectionBackendInterface *collection, const Player *player) : task_manager_(task_manager), @@ -50,7 +54,7 @@ void SongLoaderInserter::Load(Playlist *destination, int row, bool play_now, boo connect(this, SIGNAL(PreloadFinished()), SLOT(InsertSongs())); connect(this, SIGNAL(EffectiveLoadFinished(const SongList&)), destination, SLOT(UpdateItems(const SongList&))); - for (const QUrl& url : urls) { + for (const QUrl &url : urls) { SongLoader *loader = new SongLoader(collection_, player_, this); SongLoader::Result ret = loader->Load(url); @@ -122,8 +126,7 @@ void SongLoaderInserter::AudioCDTagsLoaded(bool success) { } void SongLoaderInserter::InsertSongs() { - // Insert songs (that haven't been completely loaded) to allow user to see - // and play them while not loaded completely + // Insert songs (that haven't been completely loaded) to allow user to see and play them while not loaded completely if (destination_) { destination_->InsertSongsOrCollectionItems(songs_, row_, play_now_, enqueue_); } @@ -140,9 +143,8 @@ void SongLoaderInserter::AsyncLoad() { loader->LoadFilenamesBlocking(); task_manager_->SetTaskProgress(async_load_id, ++async_progress); if (i == 0) { - // Load everything from the first song. It'll start playing as soon as - // we emit PreloadFinished, so it needs to have the duration set to show - // properly in the UI. + // Load everything from the first song. + // It'll start playing as soon as we emit PreloadFinished, so it needs to have the duration set to show properly in the UI. loader->LoadMetadataBlocking(); } songs_ << loader->songs(); diff --git a/src/playlist/songloaderinserter.h b/src/playlist/songloaderinserter.h index ad2be028..fac81709 100644 --- a/src/playlist/songloaderinserter.h +++ b/src/playlist/songloaderinserter.h @@ -23,19 +23,20 @@ #include "config.h" -#include +#include + #include +#include +#include #include #include "core/song.h" -class CollectionBackendInterface; class Player; -class Playlist; class SongLoader; class TaskManager; - -class QModelIndex; +class CollectionBackendInterface; +class Playlist; class SongLoaderInserter : public QObject { Q_OBJECT diff --git a/src/playlist/songmimedata.h b/src/playlist/songmimedata.h index ff4841aa..a8b1b934 100644 --- a/src/playlist/songmimedata.h +++ b/src/playlist/songmimedata.h @@ -23,6 +23,7 @@ #include "config.h" +#include #include #include "core/mimedata.h" diff --git a/src/playlist/songplaylistitem.cpp b/src/playlist/songplaylistitem.cpp index 96d47bef..fafd48a5 100644 --- a/src/playlist/songplaylistitem.cpp +++ b/src/playlist/songplaylistitem.cpp @@ -20,15 +20,14 @@ #include "config.h" -#include "playlistbackend.h" -#include "songplaylistitem.h" +#include +#include +#include + #include "core/tagreaderclient.h" - #include "collection/sqlrow.h" - -#include -#include -#include +#include "playlistitem.h" +#include "songplaylistitem.h" SongPlaylistItem::SongPlaylistItem(const QString &type) : PlaylistItem(type) {} diff --git a/src/playlist/songplaylistitem.h b/src/playlist/songplaylistitem.h index f7250811..c6380051 100644 --- a/src/playlist/songplaylistitem.h +++ b/src/playlist/songplaylistitem.h @@ -23,17 +23,21 @@ #include "config.h" -#include "playlistitem.h" +#include +#include +#include + #include "core/song.h" +#include "collection/sqlrow.h" +#include "playlistitem.h" class SongPlaylistItem : public PlaylistItem { public: - SongPlaylistItem(const QString& type); - SongPlaylistItem(const Song& song); + SongPlaylistItem(const QString &type); + SongPlaylistItem(const Song &song); // Restores a stream- or file-related playlist item using query row. - // If it's a file related playlist item, this will restore it's CUE - // attributes (if any) but won't parse the CUE! + // If it's a file related playlist item, this will restore it's CUE attributes (if any) but won't parse the CUE! bool InitFromQuery(const SqlRow& query); void Reload(); diff --git a/src/playlistparsers/asxiniparser.cpp b/src/playlistparsers/asxiniparser.cpp index 145a76d8..9ec4993b 100644 --- a/src/playlistparsers/asxiniparser.cpp +++ b/src/playlistparsers/asxiniparser.cpp @@ -18,13 +18,17 @@ * */ -#include "config.h" +#include +#include +#include +#include +#include +#include #include "asxiniparser.h" -#include "core/logging.h" +#include "playlistparsers/parserbase.h" -#include -#include +class CollectionBackendInterface; AsxIniParser::AsxIniParser(CollectionBackendInterface *collection, QObject *parent) : ParserBase(collection, parent) {} diff --git a/src/playlistparsers/asxiniparser.h b/src/playlistparsers/asxiniparser.h index 29a3e3e1..71b58dc2 100644 --- a/src/playlistparsers/asxiniparser.h +++ b/src/playlistparsers/asxiniparser.h @@ -21,9 +21,20 @@ #ifndef ASXINIPARSER_H #define ASXINIPARSER_H -#include "config.h" +#include +#include +#include +#include +#include +#include +#include +#include "config.h" +#include "core/song.h" #include "parserbase.h" +#include "playlist/playlist.h" + +class CollectionBackendInterface; class AsxIniParser : public ParserBase { Q_OBJECT diff --git a/src/playlistparsers/asxparser.cpp b/src/playlistparsers/asxparser.cpp index 6fc405f9..86208a82 100644 --- a/src/playlistparsers/asxparser.cpp +++ b/src/playlistparsers/asxparser.cpp @@ -18,19 +18,23 @@ * */ -#include "config.h" - -#include "asxparser.h" -#include "core/utilities.h" - -#include -#include -#include +#include #include +#include +#include +#include +#include +#include #include #include #include -#include +#include + +#include "asxparser.h" +#include "core/utilities.h" +#include "playlistparsers/xmlparser.h" + +class CollectionBackendInterface; ASXParser::ASXParser(CollectionBackendInterface *collection, QObject *parent) : XMLParser(collection, parent) {} diff --git a/src/playlistparsers/asxparser.h b/src/playlistparsers/asxparser.h index e4211183..8f471862 100644 --- a/src/playlistparsers/asxparser.h +++ b/src/playlistparsers/asxparser.h @@ -21,10 +21,23 @@ #ifndef ASXPARSER_H #define ASXPARSER_H -#include "config.h" +#include +#include +#include +#include +#include +#include +#include +#include + +#include "config.h" +#include "core/song.h" +#include "playlist/playlist.h" #include "xmlparser.h" +class CollectionBackendInterface; + class ASXParser : public XMLParser { Q_OBJECT diff --git a/src/playlistparsers/cueparser.cpp b/src/playlistparsers/cueparser.cpp index 83ffdd20..21be709d 100644 --- a/src/playlistparsers/cueparser.cpp +++ b/src/playlistparsers/cueparser.cpp @@ -18,21 +18,27 @@ * */ -#include "config.h" - -#include "cueparser.h" -#include "core/logging.h" -#include "core/timeconstants.h" - -#include -#include +#include +#include +#include +#include #include -#include +#include +#include +#include +#include #include #include #include #include +#include "core/logging.h" +#include "core/timeconstants.h" +#include "cueparser.h" +#include "playlistparsers/parserbase.h" + +class CollectionBackendInterface; + const char *CueParser::kFileLineRegExp = "(\\S+)\\s+(?:\"([^\"]+)\"|(\\S+))\\s*(?:\"([^\"]+)\"|(\\S+))?"; const char *CueParser::kIndexRegExp = "(\\d{2,3}):(\\d{2}):(\\d{2})"; @@ -174,8 +180,7 @@ SongList CueParser::Load(QIODevice *device, const QString &playlist_path, const if (line_name == kTrack) { - // the beginning of another track's definition - we're saving the current one - // for later (if it's valid of course) + // the beginning of another track's definition - we're saving the current one for later (if it's valid of course) // please note that the same code is repeated just after this 'do-while' loop if(valid_file && !index.isEmpty() && (track_type.isEmpty() || track_type == kAudioTrackType)) { entries.append(CueEntry(file, index, title, artist, album_artist, album, composer, album_composer, genre, date, disc)); @@ -191,11 +196,10 @@ SongList CueParser::Load(QIODevice *device, const QString &playlist_path, const } else if (line_name == kIndex) { - // we need the index's position field + // We need the index's position field if (!line_additional.isEmpty()) { - // if there's none "01" index, we'll just take the first one - // also, we'll take the "01" index even if it's the last one + // If there's none "01" index, we'll just take the first one also, we'll take the "01" index even if it's the last one if (line_value == "01" || index.isEmpty()) { index = line_additional; @@ -210,17 +214,18 @@ SongList CueParser::Load(QIODevice *device, const QString &playlist_path, const } else if (line_name == kSongWriter) { composer = line_value; - // end of track's for the current file -> parse next one + // End of track's for the current file -> parse next one } else if (line_name == kFile) { break; } - // just ignore the rest of possible field types for now... - } while (!(line = text_stream.readLine()).isNull()); + // Just ignore the rest of possible field types for now... + } + while (!(line = text_stream.readLine()).isNull()); - // we didn't add the last song yet... + // We didn't add the last song yet... if(valid_file && !index.isEmpty() && (track_type.isEmpty() || track_type == kAudioTrackType)) { entries.append(CueEntry(file, index, title, artist, album_artist, album, composer, album_composer, genre, date, disc)); } @@ -228,28 +233,26 @@ SongList CueParser::Load(QIODevice *device, const QString &playlist_path, const QDateTime cue_mtime = QFileInfo(playlist_path).lastModified(); - // finalize parsing songs + // Finalize parsing songs for (int i = 0; i < entries.length(); i++) { CueEntry entry = entries.at(i); Song song = LoadSong(entry.file, IndexToMarker(entry.index), dir); - // cue song has mtime equal to qMax(media_file_mtime, cue_sheet_mtime) + // Cue song has mtime equal to qMax(media_file_mtime, cue_sheet_mtime) if (cue_mtime.isValid()) { song.set_mtime(qMax(cue_mtime.toTime_t(), song.mtime())); } song.set_cue_path(playlist_path); - // overwrite the stuff, we may have read from the file or collection, using - // the current .cue metadata + // Overwrite the stuff, we may have read from the file or collection, using the current .cue metadata - // set track number only in single-file mode + // Set track number only in single-file mode if (files == 1) { song.set_track(i + 1); } - // the last TRACK for every FILE gets it's 'end' marker from the media file's - // length + // The last TRACK for every FILE gets it's 'end' marker from the media file's length if(i + 1 < entries.size() && entries.at(i).file == entries.at(i + 1).file) { // incorrect indices? if (!UpdateSong(entry, entries.at(i + 1).index, &song)) { @@ -277,24 +280,23 @@ QStringList CueParser::SplitCueLine(const QString &line) const { return QStringList(); } - // let's remove the empty entries while we're at it + // Let's remove the empty entries while we're at it return line_regexp.capturedTexts().filter(QRegExp(".+")).mid(1, -1); } -// Updates the song with data from the .cue entry. This one mustn't be used for the -// last song in the .cue file. +// Updates the song with data from the .cue entry. This one mustn't be used for the last song in the .cue file. bool CueParser::UpdateSong(const CueEntry &entry, const QString &next_index, Song *song) const { qint64 beginning = IndexToMarker(entry.index); qint64 end = IndexToMarker(next_index); - // incorrect indices (we won't be able to calculate beginning or end) + // Incorrect indices (we won't be able to calculate beginning or end) if (beginning == -1 || end == -1) { return false; } - // believe the CUE: Init() forces validity + // Believe the CUE: Init() forces validity song->Init(entry.title, entry.PrettyArtist(), entry.album, beginning, end); song->set_albumartist(entry.album_artist); song->set_composer(entry.PrettyComposer()); @@ -306,18 +308,17 @@ bool CueParser::UpdateSong(const CueEntry &entry, const QString &next_index, Son } -// Updates the song with data from the .cue entry. This one must be used only for the -// last song in the .cue file. +// Updates the song with data from the .cue entry. This one must be used only for the last song in the .cue file. bool CueParser::UpdateLastSong(const CueEntry &entry, Song *song) const { qint64 beginning = IndexToMarker(entry.index); - // incorrect index (we won't be able to calculate beginning) + // Incorrect index (we won't be able to calculate beginning) if (beginning == -1) { return false; } - // believe the CUE and force validity (like UpdateSong() does) + // Believe the CUE and force validity (like UpdateSong() does) song->set_valid(true); song->set_title(entry.title); @@ -329,8 +330,7 @@ bool CueParser::UpdateLastSong(const CueEntry &entry, Song *song) const { song->set_composer(entry.PrettyComposer()); song->set_disc(entry.disc.toInt()); - // we don't do anything with the end here because it's already set to - // the end of the media file (if it exists) + // We don't do anything with the end here because it's already set to the end of the media file (if it exists) song->set_beginning_nanosec(beginning); return true; diff --git a/src/playlistparsers/cueparser.h b/src/playlistparsers/cueparser.h index 1c3f6d69..bef69dba 100644 --- a/src/playlistparsers/cueparser.h +++ b/src/playlistparsers/cueparser.h @@ -23,13 +23,24 @@ #include "config.h" +#include + +#include +#include +#include +#include +#include +#include +#include + +#include "core/song.h" #include "parserbase.h" +#include "playlist/playlist.h" -#include +class CollectionBackendInterface; -// This parser will try to detect the real encoding of a .cue file but there's -// a great chance it will fail so it's probably best to assume that the parser -// is UTF compatible only. +// This parser will try to detect the real encoding of a .cue file +// but there's a great chance it will fail so it's probably best to assume that the parser is UTF compatible only. class CueParser : public ParserBase { Q_OBJECT diff --git a/src/playlistparsers/m3uparser.cpp b/src/playlistparsers/m3uparser.cpp index 26dc9547..4043e85e 100644 --- a/src/playlistparsers/m3uparser.cpp +++ b/src/playlistparsers/m3uparser.cpp @@ -18,16 +18,26 @@ * */ -#include "config.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include -#include "m3uparser.h" #include "core/logging.h" #include "core/timeconstants.h" - +#include "m3uparser.h" #include "playlist/playlist.h" +#include "playlistparsers/parserbase.h" -#include -#include +class CollectionBackendInterface; M3UParser::M3UParser(CollectionBackendInterface *collection, QObject *parent) : ParserBase(collection, parent) {} diff --git a/src/playlistparsers/m3uparser.h b/src/playlistparsers/m3uparser.h index f1f6d545..2e7a365f 100644 --- a/src/playlistparsers/m3uparser.h +++ b/src/playlistparsers/m3uparser.h @@ -23,9 +23,21 @@ #include "config.h" -#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "core/song.h" #include "parserbase.h" +#include "playlist/playlist.h" + +class CollectionBackendInterface; class M3UParser : public ParserBase { Q_OBJECT diff --git a/src/playlistparsers/parserbase.cpp b/src/playlistparsers/parserbase.cpp index 32409925..637e3dce 100644 --- a/src/playlistparsers/parserbase.cpp +++ b/src/playlistparsers/parserbase.cpp @@ -18,17 +18,19 @@ * */ -#include "config.h" - -#include "parserbase.h" -#include "core/tagreaderclient.h" -#include "collection/collectionbackend.h" -#include "collection/collectionquery.h" -#include "collection/sqlrow.h" -#include "playlist/playlist.h" - +#include +#include +#include +#include +#include +#include #include +#include "collection/collectionbackend.h" +#include "core/tagreaderclient.h" +#include "parserbase.h" +#include "playlist/playlist.h" + ParserBase::ParserBase(CollectionBackendInterface *collection, QObject *parent) : QObject(parent), collection_(collection) {} @@ -76,8 +78,7 @@ void ParserBase::LoadSong(const QString &filename_or_url, qint64 beginning, cons collection_song = collection_->GetSongByUrl(url, beginning); } - // If it was found in the collection then use it, otherwise load metadata from - // disk. + // If it was found in the collection then use it, otherwise load metadata from disk. if (collection_song.is_valid()) { *song = collection_song; } diff --git a/src/playlistparsers/parserbase.h b/src/playlistparsers/parserbase.h index d50c7f42..626e8ebd 100644 --- a/src/playlistparsers/parserbase.h +++ b/src/playlistparsers/parserbase.h @@ -21,11 +21,18 @@ #ifndef PARSERBASE_H #define PARSERBASE_H -#include "config.h" +#include +#include #include +#include #include +#include +#include +#include +#include +#include "config.h" #include "core/song.h" #include "playlist/playlist.h" @@ -44,29 +51,23 @@ class ParserBase : public QObject { virtual bool TryMagic(const QByteArray &data) const = 0; // Loads all songs from playlist found at path 'playlist_path' in directory 'dir'. - // The 'device' argument is an opened and ready to read from represantation of - // this playlist. - // This method might not return all of the songs found in the playlist. Any playlist - // parser may decide to leave out some entries if it finds them incomplete or invalid. - // This means that the final resulting SongList should be considered valid (at least - // from the parser's point of view). + // The 'device' argument is an opened and ready to read from represantation of this playlist. + // This method might not return all of the songs found in the playlist. + // Any playlist parser may decide to leave out some entries if it finds them incomplete or invalid. + // This means that the final resulting SongList should be considered valid (at least from the parser's point of view). virtual SongList Load(QIODevice *device, const QString &playlist_path = "", const QDir &dir = QDir()) const = 0; virtual void Save(const SongList &songs, QIODevice *device, const QDir &dir = QDir(), Playlist::Path path_type = Playlist::Path_Automatic) const = 0; protected: - // Loads a song. If filename_or_url is a URL (with a scheme other than - // "file") then it is set on the song and the song marked as a stream. - // If it is a filename or a file:// URL then it is made absolute and canonical - // and set as a file:// url on the song. Also sets the song's metadata by - // searching in the Collection, or loading from the file as a fallback. + // Loads a song. If filename_or_url is a URL (with a scheme other than "file") then it is set on the song and the song marked as a stream. + // If it is a filename or a file:// URL then it is made absolute and canonical and set as a file:// url on the song. + // Also sets the song's metadata by searching in the Collection, or loading from the file as a fallback. // This function should always be used when loading a playlist. Song LoadSong(const QString &filename_or_url, qint64 beginning, const QDir &dir) const; void LoadSong(const QString &filename_or_url, qint64 beginning, const QDir &dir, Song *song) const; - // If the URL is a file:// URL then returns its path, absolute or relative to - // the directory depending on the path_type option. - // Otherwise returns the URL as is. - // This function should always be used when saving a playlist. + // If the URL is a file:// URL then returns its path, absolute or relative to the directory depending on the path_type option. + // Otherwise returns the URL as is. This function should always be used when saving a playlist. QString URLOrFilename(const QUrl &url, const QDir &dir, Playlist::Path path_type) const; private: diff --git a/src/playlistparsers/playlistparser.cpp b/src/playlistparsers/playlistparser.cpp index eb886193..b7104234 100644 --- a/src/playlistparsers/playlistparser.cpp +++ b/src/playlistparsers/playlistparser.cpp @@ -18,19 +18,28 @@ * */ -#include "config.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include -#include "asxparser.h" #include "asxiniparser.h" +#include "asxparser.h" +#include "core/logging.h" #include "cueparser.h" #include "m3uparser.h" #include "playlistparser.h" +#include "playlistparsers/parserbase.h" #include "plsparser.h" #include "wplparser.h" #include "xspfparser.h" -#include "core/logging.h" - -#include const int PlaylistParser::kMagicSize = 512; diff --git a/src/playlistparsers/playlistparser.h b/src/playlistparsers/playlistparser.h index dd706ee2..e07277d2 100644 --- a/src/playlistparsers/playlistparser.h +++ b/src/playlistparsers/playlistparser.h @@ -21,16 +21,20 @@ #ifndef PLAYLISTPARSER_H #define PLAYLISTPARSER_H -#include "config.h" - -#include #include +#include +#include +#include +#include +#include +#include +#include "config.h" #include "core/song.h" #include "playlist/playlist.h" -class ParserBase; class CollectionBackendInterface; +class ParserBase; class PlaylistParser : public QObject { Q_OBJECT diff --git a/src/playlistparsers/plsparser.cpp b/src/playlistparsers/plsparser.cpp index 59a9274f..64cfae62 100644 --- a/src/playlistparsers/plsparser.cpp +++ b/src/playlistparsers/plsparser.cpp @@ -18,14 +18,21 @@ * */ -#include "config.h" - -#include "plsparser.h" -#include "core/logging.h" -#include "core/timeconstants.h" - +#include +#include +#include +#include +#include +#include +#include +#include #include -#include + +#include "core/timeconstants.h" +#include "playlistparsers/parserbase.h" +#include "plsparser.h" + +class CollectionBackendInterface; PLSParser::PLSParser(CollectionBackendInterface *collection, QObject *parent) : ParserBase(collection, parent) {} diff --git a/src/playlistparsers/plsparser.h b/src/playlistparsers/plsparser.h index 51970ff9..9047d2e2 100644 --- a/src/playlistparsers/plsparser.h +++ b/src/playlistparsers/plsparser.h @@ -21,9 +21,21 @@ #ifndef PLSPARSER_H #define PLSPARSER_H -#include "config.h" +#include +#include +#include +#include +#include +#include +#include + +#include "config.h" +#include "core/song.h" #include "parserbase.h" +#include "playlist/playlist.h" + +class CollectionBackendInterface; class PLSParser : public ParserBase { Q_OBJECT diff --git a/src/playlistparsers/wplparser.cpp b/src/playlistparsers/wplparser.cpp index 1a58bdb7..da10dcde 100644 --- a/src/playlistparsers/wplparser.cpp +++ b/src/playlistparsers/wplparser.cpp @@ -18,13 +18,20 @@ * */ -#include "config.h" - -#include "wplparser.h" -#include "core/utilities.h" -#include "version.h" - +#include +#include +#include +#include +#include #include +#include + +#include "core/utilities.h" +#include "playlistparsers/xmlparser.h" +#include "version.h" +#include "wplparser.h" + +class CollectionBackendInterface; WplParser::WplParser(CollectionBackendInterface *collection, QObject *parent) : XMLParser(collection, parent) {} diff --git a/src/playlistparsers/wplparser.h b/src/playlistparsers/wplparser.h index 02daf832..198a0b0d 100644 --- a/src/playlistparsers/wplparser.h +++ b/src/playlistparsers/wplparser.h @@ -21,10 +21,24 @@ #ifndef WPLPARSER_H #define WPLPARSER_H -#include "config.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "config.h" +#include "core/song.h" +#include "playlist/playlist.h" #include "xmlparser.h" +class CollectionBackendInterface; + + class WplParser : public XMLParser { public: WplParser(CollectionBackendInterface *collection, QObject *parent = nullptr); diff --git a/src/playlistparsers/xmlparser.cpp b/src/playlistparsers/xmlparser.cpp index 5c0348d6..d350778c 100644 --- a/src/playlistparsers/xmlparser.cpp +++ b/src/playlistparsers/xmlparser.cpp @@ -18,16 +18,13 @@ * */ -#include "config.h" - +#include "playlistparsers/parserbase.h" #include "xmlparser.h" -#include -#include -#include -#include -#include -#include +#include + +class CollectionBackendInterface; XMLParser::XMLParser(CollectionBackendInterface *collection, QObject *parent) : ParserBase(collection, parent) {} + diff --git a/src/playlistparsers/xmlparser.h b/src/playlistparsers/xmlparser.h index ffe38fad..75428db7 100644 --- a/src/playlistparsers/xmlparser.h +++ b/src/playlistparsers/xmlparser.h @@ -23,13 +23,14 @@ #include "config.h" -#include "parserbase.h" - -#include +#include +#include +#include #include -class QDomDocument; -class QDomNode; +#include "parserbase.h" + +class CollectionBackendInterface; class XMLParser : public ParserBase { protected: diff --git a/src/playlistparsers/xspfparser.cpp b/src/playlistparsers/xspfparser.cpp index 971b2cbd..a1764c06 100644 --- a/src/playlistparsers/xspfparser.cpp +++ b/src/playlistparsers/xspfparser.cpp @@ -18,20 +18,26 @@ * */ -#include "config.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include -#include "xspfparser.h" #include "core/timeconstants.h" #include "core/utilities.h" - #include "playlist/playlist.h" +#include "playlistparsers/xmlparser.h" +#include "xspfparser.h" -#include -#include -#include -#include -#include -#include +class CollectionBackendInterface; XSPFParser::XSPFParser(CollectionBackendInterface *collection, QObject *parent) : XMLParser(collection, parent) {} @@ -175,12 +181,12 @@ void XSPFParser::Save(const SongList &songs, QIODevice *device, const QDir &dir, } if (!art_filename.isEmpty() && !(art_filename == "(embedded)")) { - // Make this filename relative to the directory we're saving the - // playlist. + // Make this filename relative to the directory we're saving the playlist. QUrl url = QUrl(art_filename); url.setScheme("file"); // Need to explicitly set this. art_filename = URLOrFilename(url, dir, path_type).toUtf8(); - } else { + } + else { // Just use whatever URL was in the Song. art_filename = art; } diff --git a/src/playlistparsers/xspfparser.h b/src/playlistparsers/xspfparser.h index 487653b2..0c0e06ae 100644 --- a/src/playlistparsers/xspfparser.h +++ b/src/playlistparsers/xspfparser.h @@ -23,12 +23,21 @@ #include "config.h" -#include "xmlparser.h" +#include +#include +#include +#include +#include +#include +#include #include -class QDomDocument; -class QDomNode; +#include "core/song.h" +#include "playlist/playlist.h" +#include "xmlparser.h" + +class CollectionBackendInterface; class XSPFParser : public XMLParser { Q_OBJECT diff --git a/src/settings/appearancesettingspage.cpp b/src/settings/appearancesettingspage.cpp index 2e59f57b..78ad3f03 100644 --- a/src/settings/appearancesettingspage.cpp +++ b/src/settings/appearancesettingspage.cpp @@ -18,26 +18,29 @@ * */ -#include "config.h" - #include +#include +#include +#include +#include +#include #include #include -#include +#include +#include +#include +#include +#include #include #include "appearancesettingspage.h" -#include "ui_appearancesettingspage.h" - -#include "settingsdialog.h" - -#include "core/application.h" -#include "core/mainwindow.h" #include "core/appearance.h" -#include "core/logging.h" #include "core/iconloader.h" #include "playlist/playlistview.h" #include "covermanager/albumcoverchoicecontroller.h" +#include "settingspage.h" +#include "settingsdialog.h" +#include "ui_appearancesettingspage.h" const char *AppearanceSettingsPage::kSettingsGroup = "Appearance"; @@ -223,8 +226,6 @@ void AppearanceSettingsPage::UpdateColorSelectorColor(QWidget *color_selector, c void AppearanceSettingsPage::SelectBackgroundImage() { - //qLog(Debug) << __PRETTY_FUNCTION__; - QString selected_filename = QFileDialog::getOpenFileName(this, tr("Select background image"), playlist_view_background_image_filename_, tr(AlbumCoverChoiceController::kLoadImageFileFilter) + ";;" + tr(AlbumCoverChoiceController::kAllFilesFilter)); if (selected_filename.isEmpty()) return; playlist_view_background_image_filename_ = selected_filename; diff --git a/src/settings/appearancesettingspage.h b/src/settings/appearancesettingspage.h index 0fc4784b..c4d1e2c0 100644 --- a/src/settings/appearancesettingspage.h +++ b/src/settings/appearancesettingspage.h @@ -23,12 +23,17 @@ #include "config.h" -#include "settingspage.h" +#include + +#include +#include +#include +#include #include "playlist/playlistview.h" +#include "settingspage.h" -class QWidget; - +class SettingsDialog; class Ui_AppearanceSettingsPage; class AppearanceSettingsPage : public SettingsPage { diff --git a/src/settings/backendsettingspage.cpp b/src/settings/backendsettingspage.cpp index c0f66779..a2d31e8c 100644 --- a/src/settings/backendsettingspage.cpp +++ b/src/settings/backendsettingspage.cpp @@ -19,30 +19,41 @@ #include "config.h" -#include "backendsettingspage.h" -#include "ui_backendsettingspage.h" - +#include +#include #include #include -#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "backendsettingspage.h" -#include "settingsdialog.h" #include "core/application.h" -#include "core/player.h" -#include "core/logging.h" -#include "core/utilities.h" #include "core/iconloader.h" -#include "engine/enginetype.h" +#include "core/player.h" +#include "engine/engine_fwd.h" #include "engine/enginebase.h" +#include "engine/enginedevice.h" +#include "engine/enginetype.h" +#include "engine/devicefinder.h" #ifdef HAVE_GSTREAMER -#include "engine/gstengine.h" +# include "engine/gstengine.h" #endif #ifdef HAVE_XINE -#include "engine/xineengine.h" +# include "engine/xineengine.h" #endif -#include "engine/devicefinder.h" - +#include "widgets/lineedit.h" +#include "widgets/stickyslider.h" #include "dialogs/errordialog.h" +#include "settings/settingspage.h" +#include "settingsdialog.h" +#include "ui_backendsettingspage.h" const char *BackendSettingsPage::kSettingsGroup = "Backend"; const char *BackendSettingsPage::EngineText_Xine = "Xine"; @@ -491,12 +502,14 @@ void BackendSettingsPage::DeviceSelectionChanged(int index) { return; } +#if !defined(Q_OS_WIN32) QVariant device = ui_->combobox_device->itemData(index).value(); if (device.type() == QVariant::String) { ui_->lineedit_device->setEnabled(true); ui_->lineedit_device->setText(device.toString()); return; } +#endif ui_->lineedit_device->setEnabled(false); ui_->lineedit_device->setText(""); @@ -513,7 +526,7 @@ void BackendSettingsPage::DeviceStringChanged() { return; } } - + // Assume this is a custom alsa device string if (ui_->combobox_device->currentText() != "Custom") { diff --git a/src/settings/backendsettingspage.h b/src/settings/backendsettingspage.h index 82f2b8ad..a00d5363 100644 --- a/src/settings/backendsettingspage.h +++ b/src/settings/backendsettingspage.h @@ -22,18 +22,18 @@ #include "config.h" +#include + +#include +#include #include #include -#include "backendsettingspage.h" - +#include "engine/enginetype.h" +#include "dialogs/errordialog.h" #include "settingspage.h" -#include "engine/engine_fwd.h" -#include "engine/enginetype.h" - -#include "dialogs/errordialog.h" - +class SettingsDialog; class Ui_BackendSettingsPage; class BackendSettingsPage : public SettingsPage { diff --git a/src/settings/behavioursettingspage.cpp b/src/settings/behavioursettingspage.cpp index a81c2b20..ee61f6ef 100644 --- a/src/settings/behavioursettingspage.cpp +++ b/src/settings/behavioursettingspage.cpp @@ -20,14 +20,20 @@ #include "config.h" -#include - -#include "behavioursettingspage.h" +#include +#include +#include +#include +#include #include "core/iconloader.h" #include "core/mainwindow.h" +#include "settings/settingspage.h" +#include "behavioursettingspage.h" #include "ui_behavioursettingspage.h" +class SettingsDialog; + const char *BehaviourSettingsPage::kSettingsGroup = "Behaviour"; BehaviourSettingsPage::BehaviourSettingsPage(SettingsDialog *dialog) : SettingsPage(dialog), ui_(new Ui_BehaviourSettingsPage) { diff --git a/src/settings/behavioursettingspage.h b/src/settings/behavioursettingspage.h index 9cd1032f..79953b7c 100644 --- a/src/settings/behavioursettingspage.h +++ b/src/settings/behavioursettingspage.h @@ -23,10 +23,14 @@ #include "config.h" +#include + +#include +#include + #include "settingspage.h" -#include - +class SettingsDialog; class Ui_BehaviourSettingsPage; class BehaviourSettingsPage : public SettingsPage { diff --git a/src/settings/collectionsettingspage.cpp b/src/settings/collectionsettingspage.cpp index 5e1549c7..35022771 100644 --- a/src/settings/collectionsettingspage.cpp +++ b/src/settings/collectionsettingspage.cpp @@ -20,25 +20,26 @@ #include "config.h" -#include -#include -#include -#include #include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include -#include "collectionsettingspage.h" -#include "ui_collectionsettingspage.h" - -#include "settings/settingsdialog.h" -#include "core/application.h" #include "core/iconloader.h" -#include "playlist/playlistdelegates.h" - -#include "collection/collectionbackend.h" #include "collection/collectiondirectorymodel.h" -#include "collection/collectionmodel.h" -#include "collection/collectionview.h" -#include "collection/collectionwatcher.h" +#include "collectionsettingspage.h" +#include "playlist/playlistdelegates.h" +#include "settings/settingsdialog.h" +#include "settings/settingspage.h" +#include "ui_collectionsettingspage.h" const char *CollectionSettingsPage::kSettingsGroup = "Collection"; diff --git a/src/settings/collectionsettingspage.h b/src/settings/collectionsettingspage.h index a5fa7221..e9eceddd 100644 --- a/src/settings/collectionsettingspage.h +++ b/src/settings/collectionsettingspage.h @@ -23,13 +23,17 @@ #include "config.h" +#include +#include +#include + #include "settingspage.h" -class Ui_CollectionSettingsPage; -class CollectionDirectoryModel; - class QModelIndex; +class SettingsDialog; +class Ui_CollectionSettingsPage; + class CollectionSettingsPage : public SettingsPage { Q_OBJECT diff --git a/src/settings/networkproxysettingspage.cpp b/src/settings/networkproxysettingspage.cpp index f27686c3..55d021e1 100644 --- a/src/settings/networkproxysettingspage.cpp +++ b/src/settings/networkproxysettingspage.cpp @@ -20,13 +20,24 @@ #include "config.h" -#include "networkproxysettingspage.h" -#include "ui_networkproxysettingspage.h" +#include + +#include +#include +#include +#include +#include +#include +#include +#include #include "core/iconloader.h" #include "core/networkproxyfactory.h" +#include "networkproxysettingspage.h" +#include "settings/settingspage.h" +#include "ui_networkproxysettingspage.h" -#include +class SettingsDialog; const char *NetworkProxySettingsPage::kSettingsGroup = "NetworkProxy"; diff --git a/src/settings/networkproxysettingspage.h b/src/settings/networkproxysettingspage.h index 75579ef9..8055b2e9 100644 --- a/src/settings/networkproxysettingspage.h +++ b/src/settings/networkproxysettingspage.h @@ -23,8 +23,12 @@ #include "config.h" +#include +#include + #include "settingspage.h" +class SettingsDialog; class Ui_NetworkProxySettingsPage; class NetworkProxySettingsPage : public SettingsPage { diff --git a/src/settings/notificationssettingspage.cpp b/src/settings/notificationssettingspage.cpp index 77fe8784..02ce8f6e 100644 --- a/src/settings/notificationssettingspage.cpp +++ b/src/settings/notificationssettingspage.cpp @@ -20,17 +20,40 @@ #include "config.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "core/iconloader.h" +#include "widgets/osd.h" +#include "widgets/osdpretty.h" +#include "settingspage.h" +#include "settingsdialog.h" #include "notificationssettingspage.h" #include "ui_notificationssettingspage.h" -#include "settingsdialog.h" -#include "core/iconloader.h" -#include "widgets/osdpretty.h" - -#include -#include -#include -#include +class QHideEvent; +class QShowEvent; const char *NotificationsSettingsPage::kSettingsGroup = "Notifications"; @@ -45,7 +68,7 @@ NotificationsSettingsPage::NotificationsSettingsPage(SettingsDialog* dialog) ui_->notifications_bg_preset->setItemData(1, QColor(OSDPretty::kPresetOrange), Qt::DecorationRole); // Create and populate the helper menus - QMenu* menu = new QMenu(this); + QMenu *menu = new QMenu(this); menu->addAction(ui_->action_artist); menu->addAction(ui_->action_album); menu->addAction(ui_->action_title); diff --git a/src/settings/notificationssettingspage.h b/src/settings/notificationssettingspage.h index 8f046d0a..618473a4 100644 --- a/src/settings/notificationssettingspage.h +++ b/src/settings/notificationssettingspage.h @@ -23,8 +23,19 @@ #include "config.h" +#include +#include +#include +#include +#include + #include "settingspage.h" +class QHideEvent; +class QShowEvent; + +class OSDPretty; +class SettingsDialog; class Ui_NotificationsSettingsPage; class NotificationsSettingsPage : public SettingsPage { diff --git a/src/settings/playbacksettingspage.cpp b/src/settings/playbacksettingspage.cpp index 6c599a0c..fcce1d2b 100644 --- a/src/settings/playbacksettingspage.cpp +++ b/src/settings/playbacksettingspage.cpp @@ -20,12 +20,21 @@ #include "config.h" +#include + +#include +#include +#include +#include +#include +#include + +#include "core/iconloader.h" +#include "settingspage.h" #include "playbacksettingspage.h" #include "ui_playbacksettingspage.h" -#include "core/iconloader.h" -#include "settingsdialog.h" -#include "playlist/playlist.h" +class SettingsDialog; const char *PlaybackSettingsPage::kSettingsGroup = "Playback"; diff --git a/src/settings/playbacksettingspage.h b/src/settings/playbacksettingspage.h index d869bd11..3ce9d2ad 100644 --- a/src/settings/playbacksettingspage.h +++ b/src/settings/playbacksettingspage.h @@ -23,8 +23,12 @@ #include "config.h" +#include +#include + #include "settingspage.h" +class SettingsDialog; class Ui_PlaybackSettingsPage; class PlaybackSettingsPage : public SettingsPage { diff --git a/src/settings/playlistsettingspage.cpp b/src/settings/playlistsettingspage.cpp index cbc60e8e..c32f6f6b 100644 --- a/src/settings/playlistsettingspage.cpp +++ b/src/settings/playlistsettingspage.cpp @@ -20,16 +20,22 @@ #include "config.h" -#include +#include -#include "playlistsettingspage.h" +#include +#include +#include +#include +#include -#include "core/mainwindow.h" #include "core/iconloader.h" -#include "ui_playlistsettingspage.h" +#include "core/mainwindow.h" #include "playlist/playlist.h" -#include "playlist/playlisttabbar.h" -#include "settings/playlistsettingspage.h" +#include "settingspage.h" +#include "playlistsettingspage.h" +#include "ui_playlistsettingspage.h" + +class SettingsDialog; const char *PlaylistSettingsPage::kSettingsGroup = "Playlist"; diff --git a/src/settings/playlistsettingspage.h b/src/settings/playlistsettingspage.h index e39f846c..5ef780b9 100644 --- a/src/settings/playlistsettingspage.h +++ b/src/settings/playlistsettingspage.h @@ -23,10 +23,12 @@ #include "config.h" +#include +#include + #include "settingspage.h" -#include - +class SettingsDialog; class Ui_PlaylistSettingsPage; class PlaylistSettingsPage : public SettingsPage { diff --git a/src/settings/settingsdialog.cpp b/src/settings/settingsdialog.cpp index dcb78e64..c0b97426 100644 --- a/src/settings/settingsdialog.cpp +++ b/src/settings/settingsdialog.cpp @@ -20,40 +20,48 @@ #include "config.h" -#include +#include +#include +#include +#include +#include #include +#include +#include +#include +#include #include +#include +#include +#include +#include +#include +#include +#include #include #include +#include +#include + +#include "core/application.h" +#include "widgets/groupediconview.h" +#include "collection/collectionmodel.h" #include "settingsdialog.h" - +#include "settingspage.h" +#include "appearancesettingspage.h" +#include "backendsettingspage.h" #include "behavioursettingspage.h" #include "collectionsettingspage.h" -#include "backendsettingspage.h" +#include "networkproxysettingspage.h" +#include "notificationssettingspage.h" #include "playbacksettingspage.h" #include "playlistsettingspage.h" #include "shortcutssettingspage.h" #include "transcodersettingspage.h" -#include "appearancesettingspage.h" -#include "networkproxysettingspage.h" -#include "notificationssettingspage.h" - -#include "core/application.h" -#include "core/mainwindow.h" -#include "core/player.h" -#include "core/logging.h" -#include "core/networkproxyfactory.h" -#include "core/player.h" -#include "core/iconloader.h" -#include "engine/enginebase.h" -#include "engine/gstengine.h" -#include "playlist/playlistview.h" -#include "widgets/groupediconview.h" -#include "widgets/osdpretty.h" - #include "ui_settingsdialog.h" +class QShowEvent; SettingsItemDelegate::SettingsItemDelegate(QObject *parent) : QStyledItemDelegate(parent) @@ -154,7 +162,7 @@ void SettingsDialog::AddPage(Page id, SettingsPage *page, QTreeWidgetItem *paren if (!parent) parent = ui_->list->invisibleRootItem(); // Connect page's signals to the settings dialog's signals - connect(page, SIGNAL(NotificationPreview(OSD::Behaviour,QString,QString)), SIGNAL(NotificationPreview(OSD::Behaviour,QString,QString))); + connect(page, SIGNAL(NotificationPreview(OSD::Behaviour, QString, QString)), SIGNAL(NotificationPreview(OSD::Behaviour, QString, QString))); // Create the list item QTreeWidgetItem *item = new QTreeWidgetItem; diff --git a/src/settings/settingsdialog.h b/src/settings/settingsdialog.h index 15cebbde..a9cebe36 100644 --- a/src/settings/settingsdialog.h +++ b/src/settings/settingsdialog.h @@ -23,25 +23,32 @@ #include "config.h" +#include +#include +#include #include +#include +#include +#include +#include +#include #include +#include +#include +#include #include "widgets/osd.h" -class QAbstractButton; -class QScrollArea; -class QTreeWidgetItem; +class QModelIndex; +class QShowEvent; -class Application; -class Player; class Appearance; -class GlobalShortcuts; +class Application; class CollectionDirectoryModel; +class GlobalShortcuts; class SettingsPage; -class Ui_MainWindow; -class Ui_SettingsDialog; -class GstEngine; +class Ui_SettingsDialog; class SettingsItemDelegate : public QStyledItemDelegate { @@ -81,11 +88,8 @@ public: bool is_loading_settings() const { return loading_settings_; } Application *app() const { return app_; } - //Player *player() const { return player_; } CollectionDirectoryModel *collection_directory_model() const { return model_; } GlobalShortcuts *global_shortcuts_manager() const { return manager_; } - //const EngineBase *engine() const { return engine_; } - //const GstEngine *gst_engine() const { return gst_engine_; } Appearance *appearance() const { return appearance_; } void OpenAtPage(Page page); @@ -118,15 +122,11 @@ private: private: Application *app_; - //Player *player_; CollectionDirectoryModel *model_; GlobalShortcuts *manager_; - //const EngineBase *engine_; Appearance *appearance_; - //const GstEngine *gst_engine_; Ui_SettingsDialog *ui_; - //Ui_MainWindow *mui_; bool loading_settings_; QMap pages_; diff --git a/src/settings/settingspage.cpp b/src/settings/settingspage.cpp index a2507484..0a3ae118 100644 --- a/src/settings/settingspage.cpp +++ b/src/settings/settingspage.cpp @@ -18,7 +18,7 @@ * */ -#include "config.h" +#include #include "settingsdialog.h" #include "settingspage.h" diff --git a/src/settings/settingspage.h b/src/settings/settingspage.h index 0bf377b8..99a48a12 100644 --- a/src/settings/settingspage.h +++ b/src/settings/settingspage.h @@ -23,7 +23,11 @@ #include "config.h" +#include + +#include #include +#include #include "widgets/osd.h" @@ -33,7 +37,7 @@ class SettingsPage : public QWidget { Q_OBJECT public: - SettingsPage(SettingsDialog* dialog); + SettingsPage(SettingsDialog *dialog); // Return false to grey out the page's item in the list. virtual bool IsEnabled() const { return true; } diff --git a/src/settings/shortcutssettingspage.cpp b/src/settings/shortcutssettingspage.cpp index 84ffc929..bb0ce309 100644 --- a/src/settings/shortcutssettingspage.cpp +++ b/src/settings/shortcutssettingspage.cpp @@ -20,24 +20,31 @@ #include "config.h" -#include +#include +#include +#include +#include +#include +#include #include #include -#include -#include +#include +#include #include -#include +#include +#include +#include +#include +#include +#include "core/iconloader.h" +#include "globalshortcuts/globalshortcutgrabber.h" +#include "globalshortcuts/globalshortcuts.h" +#include "settingspage.h" +#include "settingsdialog.h" #include "shortcutssettingspage.h" #include "ui_shortcutssettingspage.h" -#include "globalshortcuts/globalshortcuts.h" -#include "globalshortcuts/globalshortcutgrabber.h" -#include "core/logging.h" -#include "core/utilities.h" -#include "core/iconloader.h" -#include "settings/settingsdialog.h" - const char *GlobalShortcutsSettingsPage::kSettingsGroup = "GlobalShortcuts"; GlobalShortcutsSettingsPage::GlobalShortcutsSettingsPage(SettingsDialog *dialog) diff --git a/src/settings/shortcutssettingspage.h b/src/settings/shortcutssettingspage.h index df386aad..0c3a807a 100644 --- a/src/settings/shortcutssettingspage.h +++ b/src/settings/shortcutssettingspage.h @@ -24,17 +24,21 @@ #include "config.h" #include +#include -#include +#include #include +#include +#include +#include +#include #include "globalshortcuts/globalshortcuts.h" -#include "settings/settingspage.h" +#include "settingspage.h" -class QTreeWidgetItem; - -class Ui_GlobalShortcutsSettingsPage; class GlobalShortcutGrabber; +class SettingsDialog; +class Ui_GlobalShortcutsSettingsPage; class GlobalShortcutsSettingsPage : public SettingsPage { Q_OBJECT diff --git a/src/settings/transcodersettingspage.cpp b/src/settings/transcodersettingspage.cpp index 89c456ca..54fef02b 100644 --- a/src/settings/transcodersettingspage.cpp +++ b/src/settings/transcodersettingspage.cpp @@ -20,10 +20,19 @@ #include "config.h" +#include "core/iconloader.h" +#include "settingspage.h" +#include "transcoder/transcoderoptionsaac.h" +#include "transcoder/transcoderoptionsflac.h" +#include "transcoder/transcoderoptionsmp3.h" +#include "transcoder/transcoderoptionsopus.h" +#include "transcoder/transcoderoptionsspeex.h" +#include "transcoder/transcoderoptionsvorbis.h" +#include "transcoder/transcoderoptionswma.h" #include "transcodersettingspage.h" #include "ui_transcodersettingspage.h" -#include "core/iconloader.h" +class SettingsDialog; TranscoderSettingsPage::TranscoderSettingsPage(SettingsDialog* dialog) : SettingsPage(dialog), ui_(new Ui_TranscoderSettingsPage) { diff --git a/src/settings/transcodersettingspage.h b/src/settings/transcodersettingspage.h index 1f13fec3..599bb07b 100644 --- a/src/settings/transcodersettingspage.h +++ b/src/settings/transcodersettingspage.h @@ -23,8 +23,12 @@ #include "config.h" +#include +#include + #include "settingspage.h" +class SettingsDialog; class Ui_TranscoderSettingsPage; class TranscoderSettingsPage : public SettingsPage { diff --git a/src/transcoder/transcodedialog.cpp b/src/transcoder/transcodedialog.cpp index 287a21f4..b2577b5a 100644 --- a/src/transcoder/transcodedialog.cpp +++ b/src/transcoder/transcodedialog.cpp @@ -20,20 +20,42 @@ #include "config.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "core/iconloader.h" +#include "core/mainwindow.h" +#include "widgets/fileview.h" #include "transcodedialog.h" #include "transcoder.h" #include "transcoderoptionsdialog.h" #include "ui_transcodedialog.h" #include "ui_transcodelogdialog.h" -#include "core/iconloader.h" -#include "core/mainwindow.h" -#include "widgets/fileview.h" - -#include -#include -#include -#include -#include // winspool.h defines this :( #ifdef AddJob @@ -226,8 +248,6 @@ void TranscodeDialog::AllJobsComplete() { void TranscodeDialog::Add() { - //qLog(Debug) << __PRETTY_FUNCTION__; - QStringList filenames = QFileDialog::getOpenFileNames( this, tr("Add files to transcode"), last_add_dir_, QString("%1 (%2);;%3").arg(tr("Music"), FileView::kFileFilter, tr(MainWindow::kAllFilesFilterSpec))); diff --git a/src/transcoder/transcodedialog.h b/src/transcoder/transcodedialog.h index a835ecec..2f536fa8 100644 --- a/src/transcoder/transcodedialog.h +++ b/src/transcoder/transcodedialog.h @@ -23,14 +23,20 @@ #include "config.h" -#include +#include + +#include +#include #include -#include +#include +#include +#include +#include +#include class Transcoder; class Ui_TranscodeDialog; class Ui_TranscodeLogDialog; - struct TranscoderPreset; class TranscodeDialog : public QDialog { diff --git a/src/transcoder/transcoder.cpp b/src/transcoder/transcoder.cpp index 5eb8ccbe..c75ccae9 100644 --- a/src/transcoder/transcoder.cpp +++ b/src/transcoder/transcoder.cpp @@ -20,20 +20,31 @@ #include "config.h" -#include "transcoder.h" - +#include +#include +#include #include +#include +#include +#include #include +#include #include #include +#include +#include +#include +#include +#include +#include #include -#include #include #include "core/logging.h" #include "core/signalchecker.h" #include "core/utilities.h" +#include "transcoder.h" using std::shared_ptr; @@ -88,8 +99,7 @@ GstElement *Transcoder::CreateElementForMimeType(const QString &element_type, co return CreateElement("ffmux_mp4", bin); } - // Keep track of all the suitable elements we find and figure out which - // is the best at the end. + // Keep track of all the suitable elements we find and figure out which is the best at the end. QList suitable_elements_; // The caps we're trying to find @@ -141,9 +151,7 @@ GstElement *Transcoder::CreateElementForMimeType(const QString &element_type, co LogLine(QString("Using '%1' (rank %2)").arg(best.name_).arg(best.rank_)); if (best.name_ == "lamemp3enc") { - // Special case: we need to add xingmux and id3v2mux to the pipeline when - // using lamemp3enc because it doesn't write the VBR or ID3v2 headers - // itself. + // Special case: we need to add xingmux and id3v2mux to the pipeline when using lamemp3enc because it doesn't write the VBR or ID3v2 headers itself. LogLine("Adding xingmux and id3v2mux to the pipeline"); @@ -278,8 +286,7 @@ void Transcoder::AddJob(const QString &input, const TranscoderPreset &preset, co job.input = input; job.preset = preset; - // Use the supplied filename if there was one, otherwise take the file - // extension off the input filename and append the correct one. + // Use the supplied filename if there was one, otherwise take the file extension off the input filename and append the correct one. if (!output.isEmpty()) job.output = output; else @@ -400,8 +407,7 @@ bool Transcoder::StartJob(const Job &job) { emit LogLine(tr("Starting %1").arg(QDir::toNativeSeparators(job.input))); // Create the pipeline. - // This should be a scoped_ptr, but scoped_ptr doesn't support custom - // destructors. + // This should be a scoped_ptr, but scoped_ptr doesn't support custom destructors. state->pipeline_ = gst_pipeline_new("pipeline"); if (!state->pipeline_) return false; @@ -445,9 +451,8 @@ bool Transcoder::StartJob(const Job &job) { // Start the pipeline gst_element_set_state(state->pipeline_, GST_STATE_PLAYING); - // GStreamer now transcodes in another thread, so we can return now and do - // something else. Keep the JobState object around. It'll post an event - // to our event loop when it finishes. + // GStreamer now transcodes in another thread, so we can return now and do something else. + // Keep the JobState object around. It'll post an event to our event loop when it finishes. current_jobs_ << state; return true; @@ -475,16 +480,14 @@ bool Transcoder::event(QEvent *e) { ++it; } if (it == current_jobs_.end()) { - // Couldn't find it, maybe GStreamer gave us an event after we'd destroyed - // the pipeline? + // Couldn't find it, maybe GStreamer gave us an event after we'd destroyed the pipeline? return true; } QString input = (*it)->job_.input; QString output = (*it)->job_.output; - // Remove event handlers from the gstreamer pipeline so they don't get - // called after the pipeline is shutting down + // Remove event handlers from the gstreamer pipeline so they don't get called after the pipeline is shutting down gst_bus_set_sync_handler(gst_pipeline_get_bus(GST_PIPELINE(finished_event->state_->pipeline_)), nullptr, nullptr, nullptr); // Remove it from the list - this will also destroy the GStreamer pipeline @@ -513,8 +516,7 @@ void Transcoder::Cancel() { while (it != current_jobs_.end()) { shared_ptr state(*it); - // Remove event handlers from the gstreamer pipeline so they don't get - // called after the pipeline is shutting down + // Remove event handlers from the gstreamer pipeline so they don't get called after the pipeline is shutting down gst_bus_set_sync_handler(gst_pipeline_get_bus(GST_PIPELINE(state->pipeline_)), nullptr, nullptr, nullptr); // Stop the pipeline diff --git a/src/transcoder/transcoder.h b/src/transcoder/transcoder.h index 72e71b65..f1347658 100644 --- a/src/transcoder/transcoder.h +++ b/src/transcoder/transcoder.h @@ -24,13 +24,19 @@ #include "config.h" #include - +#include +#include +#include #include #include -#include -#include +#include +#include #include +#include +#include +#include +#include #include "core/song.h" @@ -85,8 +91,7 @@ signals: TranscoderPreset preset; }; - // State held by a job and shared across gstreamer callbacks - lives in the - // job's thread. + // State held by a job and shared across gstreamer callbacks - lives in the job's thread. struct JobState { JobState(const Job &job, Transcoder *parent) : job_(job), @@ -104,8 +109,7 @@ signals: GstElement *convert_element_; }; - // Event passed from a GStreamer callback to the Transcoder when a job - // finishes. + // Event passed from a GStreamer callback to the Transcoder when a job finishes. struct JobFinishedEvent : public QEvent { JobFinishedEvent(JobState *state, bool success); diff --git a/src/transcoder/transcoderoptionsaac.cpp b/src/transcoder/transcoderoptionsaac.cpp index 7ffc64b9..dad4d922 100644 --- a/src/transcoder/transcoderoptionsaac.cpp +++ b/src/transcoder/transcoderoptionsaac.cpp @@ -20,11 +20,20 @@ #include "config.h" +#include + +#include +#include +#include +#include +#include +#include +#include + +#include "transcoderoptionsinterface.h" #include "transcoderoptionsaac.h" #include "ui_transcoderoptionsaac.h" -#include - const char *TranscoderOptionsAAC::kSettingsGroup = "Transcoder/faac"; TranscoderOptionsAAC::TranscoderOptionsAAC(QWidget* parent) : TranscoderOptionsInterface(parent), ui_(new Ui_TranscoderOptionsAAC) { diff --git a/src/transcoder/transcoderoptionsaac.h b/src/transcoder/transcoderoptionsaac.h index bf55fa08..25003829 100644 --- a/src/transcoder/transcoderoptionsaac.h +++ b/src/transcoder/transcoderoptionsaac.h @@ -23,6 +23,8 @@ #include "config.h" +#include + #include "transcoderoptionsinterface.h" class Ui_TranscoderOptionsAAC; diff --git a/src/transcoder/transcoderoptionsdialog.cpp b/src/transcoder/transcoderoptionsdialog.cpp index e60ac649..48ff2764 100644 --- a/src/transcoder/transcoderoptionsdialog.cpp +++ b/src/transcoder/transcoderoptionsdialog.cpp @@ -20,13 +20,21 @@ #include "config.h" +#include +#include +#include +#include +#include +#include + +#include "transcoderoptionsinterface.h" #include "transcoderoptionsaac.h" #include "transcoderoptionsdialog.h" #include "transcoderoptionsflac.h" #include "transcoderoptionsmp3.h" +#include "transcoderoptionsopus.h" #include "transcoderoptionsspeex.h" #include "transcoderoptionsvorbis.h" -#include "transcoderoptionsopus.h" #include "transcoderoptionswma.h" #include "ui_transcoderoptionsdialog.h" diff --git a/src/transcoder/transcoderoptionsdialog.h b/src/transcoder/transcoderoptionsdialog.h index 0205dd45..9b170bda 100644 --- a/src/transcoder/transcoderoptionsdialog.h +++ b/src/transcoder/transcoderoptionsdialog.h @@ -23,11 +23,18 @@ #include "config.h" -#include +#include + +#include +#include +#include +#include -#include "transcoderoptionsinterface.h" #include "core/song.h" +class QShowEvent; + +class TranscoderOptionsInterface; class Ui_TranscoderOptionsDialog; class TranscoderOptionsDialog : public QDialog { diff --git a/src/transcoder/transcoderoptionsflac.cpp b/src/transcoder/transcoderoptionsflac.cpp index 2dc06011..5ac172bd 100644 --- a/src/transcoder/transcoderoptionsflac.cpp +++ b/src/transcoder/transcoderoptionsflac.cpp @@ -20,11 +20,17 @@ #include "config.h" +#include +#include +#include +#include +#include +#include + +#include "transcoderoptionsinterface.h" #include "transcoderoptionsflac.h" #include "ui_transcoderoptionsflac.h" -#include - const char *TranscoderOptionsFlac::kSettingsGroup = "Transcoder/flacenc"; TranscoderOptionsFlac::TranscoderOptionsFlac(QWidget *parent) diff --git a/src/transcoder/transcoderoptionsflac.h b/src/transcoder/transcoderoptionsflac.h index 4ee9e200..07a1a2c6 100644 --- a/src/transcoder/transcoderoptionsflac.h +++ b/src/transcoder/transcoderoptionsflac.h @@ -23,6 +23,8 @@ #include "config.h" +#include + #include "transcoderoptionsinterface.h" class Ui_TranscoderOptionsFlac; diff --git a/src/transcoder/transcoderoptionsinterface.h b/src/transcoder/transcoderoptionsinterface.h index 21492612..9648ac2a 100644 --- a/src/transcoder/transcoderoptionsinterface.h +++ b/src/transcoder/transcoderoptionsinterface.h @@ -24,6 +24,7 @@ #include "config.h" #include +#include class TranscoderOptionsInterface : public QWidget { public: diff --git a/src/transcoder/transcoderoptionsmp3.cpp b/src/transcoder/transcoderoptionsmp3.cpp index 56aaef44..a132e6be 100644 --- a/src/transcoder/transcoderoptionsmp3.cpp +++ b/src/transcoder/transcoderoptionsmp3.cpp @@ -20,12 +20,23 @@ #include "config.h" +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "transcoderoptionsinterface.h" #include "transcoderoptionsmp3.h" #include "ui_transcoderoptionsmp3.h" -#include - -const char* TranscoderOptionsMP3::kSettingsGroup = "Transcoder/lamemp3enc"; +const char *TranscoderOptionsMP3::kSettingsGroup = "Transcoder/lamemp3enc"; TranscoderOptionsMP3::TranscoderOptionsMP3(QWidget *parent) : TranscoderOptionsInterface(parent), ui_(new Ui_TranscoderOptionsMP3) { diff --git a/src/transcoder/transcoderoptionsmp3.h b/src/transcoder/transcoderoptionsmp3.h index 240bcaf3..6572d737 100644 --- a/src/transcoder/transcoderoptionsmp3.h +++ b/src/transcoder/transcoderoptionsmp3.h @@ -23,6 +23,10 @@ #include "config.h" +#include +#include +#include + #include "transcoderoptionsinterface.h" class Ui_TranscoderOptionsMP3; diff --git a/src/transcoder/transcoderoptionsopus.cpp b/src/transcoder/transcoderoptionsopus.cpp index 860aa934..e906a3d0 100644 --- a/src/transcoder/transcoderoptionsopus.cpp +++ b/src/transcoder/transcoderoptionsopus.cpp @@ -20,13 +20,18 @@ #include "config.h" +#include +#include +#include +#include +#include +#include + +#include "transcoderoptionsinterface.h" #include "transcoderoptionsopus.h" #include "ui_transcoderoptionsopus.h" -#include - -// TODO: Add more options than only bitrate as soon as gst doesn't crash -// anymore while using the cbr parmameter (like cbr=false) +// TODO: Add more options than only bitrate as soon as gst doesn't crash anymore while using the cbr parmameter (like cbr=false) const char* TranscoderOptionsOpus::kSettingsGroup = "Transcoder/opusenc"; diff --git a/src/transcoder/transcoderoptionsopus.h b/src/transcoder/transcoderoptionsopus.h index 07e352e0..95856a06 100644 --- a/src/transcoder/transcoderoptionsopus.h +++ b/src/transcoder/transcoderoptionsopus.h @@ -23,6 +23,8 @@ #include "config.h" +#include + #include "transcoderoptionsinterface.h" class Ui_TranscoderOptionsOpus; diff --git a/src/transcoder/transcoderoptionsspeex.cpp b/src/transcoder/transcoderoptionsspeex.cpp index 5ade71be..4979c1a1 100644 --- a/src/transcoder/transcoderoptionsspeex.cpp +++ b/src/transcoder/transcoderoptionsspeex.cpp @@ -20,11 +20,22 @@ #include "config.h" +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "transcoderoptionsinterface.h" #include "transcoderoptionsspeex.h" #include "ui_transcoderoptionsspeex.h" -#include - const char *TranscoderOptionsSpeex::kSettingsGroup = "Transcoder/speexenc"; TranscoderOptionsSpeex::TranscoderOptionsSpeex(QWidget *parent) diff --git a/src/transcoder/transcoderoptionsspeex.h b/src/transcoder/transcoderoptionsspeex.h index d4611eb4..fb2857bc 100644 --- a/src/transcoder/transcoderoptionsspeex.h +++ b/src/transcoder/transcoderoptionsspeex.h @@ -23,6 +23,8 @@ #include "config.h" +#include + #include "transcoderoptionsinterface.h" class Ui_TranscoderOptionsSpeex; diff --git a/src/transcoder/transcoderoptionsvorbis.cpp b/src/transcoder/transcoderoptionsvorbis.cpp index 542b3750..543d8885 100644 --- a/src/transcoder/transcoderoptionsvorbis.cpp +++ b/src/transcoder/transcoderoptionsvorbis.cpp @@ -20,14 +20,23 @@ #include "config.h" +#include + +#include +#include +#include +#include +#include +#include +#include + +#include "transcoderoptionsinterface.h" #include "transcoderoptionsvorbis.h" #include "ui_transcoderoptionsvorbis.h" -#include +const char *TranscoderOptionsVorbis::kSettingsGroup = "Transcoder/vorbisenc"; -const char* TranscoderOptionsVorbis::kSettingsGroup = "Transcoder/vorbisenc"; - -TranscoderOptionsVorbis::TranscoderOptionsVorbis(QWidget* parent) +TranscoderOptionsVorbis::TranscoderOptionsVorbis(QWidget *parent) : TranscoderOptionsInterface(parent), ui_(new Ui_TranscoderOptionsVorbis) { ui_->setupUi(this); } diff --git a/src/transcoder/transcoderoptionsvorbis.h b/src/transcoder/transcoderoptionsvorbis.h index 5df6b801..fdef7c68 100644 --- a/src/transcoder/transcoderoptionsvorbis.h +++ b/src/transcoder/transcoderoptionsvorbis.h @@ -23,6 +23,8 @@ #include "config.h" +#include + #include "transcoderoptionsinterface.h" class Ui_TranscoderOptionsVorbis; diff --git a/src/transcoder/transcoderoptionswma.cpp b/src/transcoder/transcoderoptionswma.cpp index ca6d8857..88d44ac1 100644 --- a/src/transcoder/transcoderoptionswma.cpp +++ b/src/transcoder/transcoderoptionswma.cpp @@ -20,11 +20,17 @@ #include "config.h" +#include +#include +#include +#include +#include +#include + +#include "transcoder/transcoderoptionsinterface.h" #include "transcoderoptionswma.h" #include "ui_transcoderoptionswma.h" -#include - const char *TranscoderOptionsWma::kSettingsGroup = "Transcoder/ffenc_wmav2"; TranscoderOptionsWma::TranscoderOptionsWma(QWidget *parent) diff --git a/src/transcoder/transcoderoptionswma.h b/src/transcoder/transcoderoptionswma.h index 0203b0b8..820a5350 100644 --- a/src/transcoder/transcoderoptionswma.h +++ b/src/transcoder/transcoderoptionswma.h @@ -23,6 +23,8 @@ #include "config.h" +#include + #include "transcoderoptionsinterface.h" class Ui_TranscoderOptionsWma; diff --git a/src/widgets/autoexpandingtreeview.cpp b/src/widgets/autoexpandingtreeview.cpp index 61be6782..50c4f1fa 100644 --- a/src/widgets/autoexpandingtreeview.cpp +++ b/src/widgets/autoexpandingtreeview.cpp @@ -20,8 +20,12 @@ #include "config.h" -#include -#include +#include +#include +#include +#include +#include +#include #include "autoexpandingtreeview.h" #include "core/mimedata.h" @@ -129,8 +133,7 @@ void AutoExpandingTreeView::mouseDoubleClickEvent(QMouseEvent *event) { QTreeView::mouseDoubleClickEvent(event); // If the p_state was the "AnimatingState", then the base class's - // "mouseDoubleClickEvent" method just did nothing, hence the - // "doubleClicked" signal is not emitted. So let's do it ourselves. + // "mouseDoubleClickEvent" method just did nothing, hence the "doubleClicked" signal is not emitted. So let's do it ourselves. if (index.isValid() && p_state == AnimatingState) { emit doubleClicked(index); } diff --git a/src/widgets/autoexpandingtreeview.h b/src/widgets/autoexpandingtreeview.h index f2b3013c..e5427400 100644 --- a/src/widgets/autoexpandingtreeview.h +++ b/src/widgets/autoexpandingtreeview.h @@ -23,7 +23,16 @@ #include "config.h" +#include + +#include +#include +#include +#include #include +#include + +class QModelIndex; class AutoExpandingTreeView : public QTreeView { Q_OBJECT diff --git a/src/widgets/busyindicator.cpp b/src/widgets/busyindicator.cpp index 09586e0d..63de6e18 100644 --- a/src/widgets/busyindicator.cpp +++ b/src/widgets/busyindicator.cpp @@ -20,13 +20,21 @@ #include "config.h" -#include -#include +#include -#include "core/logging.h" +#include +#include +#include +#include +#include +#include +#include #include "busyindicator.h" +class QHideEvent; +class QShowEvent; + BusyIndicator::BusyIndicator(const QString &text, QWidget* parent) : QWidget(parent) { Init(text); @@ -39,8 +47,6 @@ BusyIndicator::BusyIndicator(QWidget* parent) void BusyIndicator::Init(const QString &text) { - //qLog(Debug) << __PRETTY_FUNCTION__; - movie_ = new QMovie(":pictures/spinner.gif"), label_ = new QLabel; diff --git a/src/widgets/busyindicator.h b/src/widgets/busyindicator.h index bdc39350..8ccbea48 100644 --- a/src/widgets/busyindicator.h +++ b/src/widgets/busyindicator.h @@ -23,9 +23,14 @@ #include "config.h" +#include +#include +#include #include +#include -class QMovie; +class QShowEvent; +class QHideEvent; class BusyIndicator : public QWidget { Q_OBJECT diff --git a/src/widgets/clickablelabel.cpp b/src/widgets/clickablelabel.cpp index 33c53ce8..5446a622 100644 --- a/src/widgets/clickablelabel.cpp +++ b/src/widgets/clickablelabel.cpp @@ -19,6 +19,9 @@ #include "clickablelabel.h" +#include +#include + ClickableLabel::ClickableLabel(QWidget *parent) : QLabel(parent) { diff --git a/src/widgets/clickablelabel.h b/src/widgets/clickablelabel.h index 85ad70ba..306a8230 100644 --- a/src/widgets/clickablelabel.h +++ b/src/widgets/clickablelabel.h @@ -20,7 +20,13 @@ #include "config.h" +#include +#include +#include #include +#include + +class QMouseEvent; class ClickableLabel : public QLabel { Q_OBJECT @@ -32,7 +38,7 @@ signals: void Clicked(); protected: - void mousePressEvent(QMouseEvent* event); + void mousePressEvent(QMouseEvent *event); }; #endif // CLICKABLELABEL_H diff --git a/src/widgets/didyoumean.cpp b/src/widgets/didyoumean.cpp index 2229baf6..a9df18b5 100644 --- a/src/widgets/didyoumean.cpp +++ b/src/widgets/didyoumean.cpp @@ -20,15 +20,23 @@ #include "config.h" -#include -#include +#include +#include +#include +#include +#include +#include +#include #include +#include +#include +#include +#include #include +#include #include "didyoumean.h" -#include "core/logging.h" - const int DidYouMean::kPadding = 3; DidYouMean::DidYouMean(QWidget *buddy, QWidget *parent) @@ -68,7 +76,7 @@ DidYouMean::DidYouMean(QWidget *buddy, QWidget *parent) } bool DidYouMean::eventFilter(QObject *object, QEvent *event) { - + if (object != buddy_) { return QObject::eventFilter(object, event); } @@ -122,8 +130,7 @@ void DidYouMean::UpdateGeometry() { const int height = text_height + kPadding * 2; move(buddy_->mapToGlobal(buddy_->rect().bottomLeft())); - // Resize to len(text to display) + total number of padding added + - // size(close button), so the "Did you mean" widget is always fully displayed + // Resize to len(text to display) + total number of padding added + size(close button), so the "Did you mean" widget is always fully displayed resize(QSize(did_you_mean_size_ + QFontMetrics(correction_font_).width(correction_ + " ") + press_enter_size_ + kPadding * 6 + close_->width(), height)); diff --git a/src/widgets/didyoumean.h b/src/widgets/didyoumean.h index 2ce8ccb0..0c4b8b97 100644 --- a/src/widgets/didyoumean.h +++ b/src/widgets/didyoumean.h @@ -23,9 +23,19 @@ #include "config.h" -#include +#include -class QToolButton; +#include +#include +#include +#include +#include +#include + +class QEvent; +class QMouseEvent; +class QPaintEvent; +class QShowEvent; class DidYouMean : public QWidget { Q_OBJECT diff --git a/src/widgets/elidedlabel.cpp b/src/widgets/elidedlabel.cpp index db82de58..4619d18f 100644 --- a/src/widgets/elidedlabel.cpp +++ b/src/widgets/elidedlabel.cpp @@ -20,8 +20,16 @@ #include "config.h" +#include +#include +#include +#include +#include + #include "elidedlabel.h" +class QResizeEvent; + ElidedLabel::ElidedLabel(QWidget *parent) : QLabel(parent) {} void ElidedLabel::SetText(const QString& text) { diff --git a/src/widgets/elidedlabel.h b/src/widgets/elidedlabel.h index 1a439e0b..2e2b074e 100644 --- a/src/widgets/elidedlabel.h +++ b/src/widgets/elidedlabel.h @@ -23,7 +23,13 @@ #include "config.h" +#include +#include +#include #include +#include + +class QResizeEvent; class ElidedLabel : public QLabel { Q_OBJECT diff --git a/src/widgets/fancytabwidget.cpp b/src/widgets/fancytabwidget.cpp index 74eef05a..842586a5 100644 --- a/src/widgets/fancytabwidget.cpp +++ b/src/widgets/fancytabwidget.cpp @@ -27,27 +27,54 @@ ** **************************************************************************/ +#include "config.h" + #include "fancytabwidget.h" -#include "stylehelper.h" -#include "core/logging.h" -#include - -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #include #include -#include +#include +#include +#include +#include #include -#include -#include +#include #include -#include -#include +#include +#include +#include +#include +#include +#include + +#include "core/logging.h" +#include "stylehelper.h" using namespace Core; using namespace Internal; @@ -146,7 +173,8 @@ void FancyTabProxyStyle::drawControl(ControlElement element, const QStyleOption* animation->setEndValue(40); animation->start(); } - } else { + } + else { if (animation->state() != QAbstractAnimation::Running && fader != 0) { animation->stop(); animation->setDuration(160); @@ -239,8 +267,7 @@ void FancyTab::setFader(float value) } FancyTabBar::FancyTabBar(QWidget *parent) - : QWidget(parent) -{ + : QWidget(parent) { setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Expanding); setStyle(new QCommonStyle); setMinimumWidth(qMax(2 * m_rounding, 40)); @@ -250,7 +277,7 @@ FancyTabBar::FancyTabBar(QWidget *parent) m_triggerTimer.setSingleShot(true); QVBoxLayout* layout = new QVBoxLayout; - layout->addSpacerItem(new QSpacerItem(0, 0, QSizePolicy::Fixed, QSizePolicy::Expanding)); + layout->addSpacerItem(new QSpacerItem(0, 0, QSizePolicy::Fixed, QSizePolicy::Expanding)); layout->setSpacing(0); layout->setContentsMargins(0, 0, 0, 0); setLayout(layout); @@ -276,8 +303,7 @@ QSize FancyTab::sizeHint() const { return ret; } -QSize FancyTabBar::tabSizeHint(bool minimum) const -{ +QSize FancyTabBar::tabSizeHint(bool minimum) const { QFont boldFont(font()); boldFont.setPointSizeF(Utils::StyleHelper::sidebarFontSize()); boldFont.setBold(true); @@ -355,9 +381,7 @@ void FancyTabBar::setTabToolTip(int index, const QString& toolTip) { m_tabs[index]->setToolTip(toolTip); } -// This keeps the sidebar responsive since -// we get a repaint before loading the -// mode itself +// This keeps the sidebar responsive since we get a repaint before loading the mode itself void FancyTabBar::emitCurrentIndex() { emit currentChanged(m_currentIndex); @@ -427,7 +451,7 @@ void FancyTabBar::paintTab(QPainter *painter, int tabIndex) const painter->drawLine(rect.bottomLeft() + QPoint(0,-1), rect.bottomRight()-QPoint(0,1)); } - QString tabText(painter->fontMetrics().elidedText(this->tabText(tabIndex), Qt::ElideRight, width())); + QString tabText(painter->fontMetrics().elidedText(this->tabText(tabIndex), Qt::ElideRight, width())); QRect tabTextRect(tabRect(tabIndex)); QRect tabIconRect(tabTextRect); tabIconRect.adjust(+4, +4, -4, -4); @@ -675,8 +699,7 @@ void FancyTabWidget::contextMenuEvent(QContextMenuEvent* e) { menu_->popup(e->globalPos()); } -void FancyTabWidget::AddMenuItem(QSignalMapper* mapper, QActionGroup* group, - const QString& text, Mode mode) { +void FancyTabWidget::AddMenuItem(QSignalMapper* mapper, QActionGroup* group, const QString& text, Mode mode) { QAction* action = group->addAction(text); action->setCheckable(true); mapper->setMapping(action, mode); diff --git a/src/widgets/fancytabwidget.h b/src/widgets/fancytabwidget.h index 70d72be5..44c456c4 100644 --- a/src/widgets/fancytabwidget.h +++ b/src/widgets/fancytabwidget.h @@ -30,22 +30,40 @@ #ifndef FANCYTABWIDGET_H #define FANCYTABWIDGET_H -#include +#include "config.h" +#include +#include + +#include +#include #include -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #include #include -#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include -class QActionGroup; -class QMenu; -class QPainter; -class QSignalMapper; -class QStackedLayout; -class QStatusBar; -class QVBoxLayout; +class QEvent; +class QMouseEvent; +class QPaintEvent; +class QContextMenuEvent; namespace Core { namespace Internal { @@ -54,14 +72,13 @@ class FancyTabProxyStyle : public QProxyStyle { Q_OBJECT public: - void drawControl(ControlElement element, const QStyleOption* option, - QPainter* painter, const QWidget* widget) const; - void polish(QWidget* widget); - void polish(QApplication* app); - void polish(QPalette& palette); + void drawControl(ControlElement element, const QStyleOption *option, QPainter *painter, const QWidget *widget) const; + void polish(QWidget *widget); + void polish(QApplication *app); + void polish(QPalette &palette); protected: - bool eventFilter(QObject* o, QEvent* e); + bool eventFilter(QObject *o, QEvent *e); }; class FancyTab : public QWidget { @@ -88,7 +105,7 @@ protected: private: QPropertyAnimation animator; - QWidget *tabbar; + QWidget *tabbar; float m_fader; }; @@ -97,32 +114,32 @@ class FancyTabBar : public QWidget Q_OBJECT public: - FancyTabBar(QWidget* parent = nullptr); + FancyTabBar(QWidget *parent = nullptr); ~FancyTabBar(); - void paintEvent(QPaintEvent *event); - void paintTab(QPainter *painter, int tabIndex) const; - void mousePressEvent(QMouseEvent *); - bool validIndex(int index) const { return index >= 0 && index < m_tabs.count(); } + void paintEvent(QPaintEvent *event); + void paintTab(QPainter *painter, int tabIndex) const; + void mousePressEvent(QMouseEvent *); + bool validIndex(int index) const { return index >= 0 && index < m_tabs.count(); } QSize sizeHint() const; QSize minimumSizeHint() const; - void addTab(const QIcon &icon, const QString &label); + void addTab(const QIcon &icon, const QString &label); void addSpacer(int size = 40); void removeTab(int index) { - FancyTab *tab = m_tabs.takeAt(index); + FancyTab *tab = m_tabs.takeAt(index); delete tab; } void setCurrentIndex(int index); int currentIndex() const { return m_currentIndex; } - void setTabToolTip(int index, const QString& toolTip); + void setTabToolTip(int index, const QString &toolTip); QString tabToolTip(int index) const; - QIcon tabIcon(int index) const {return m_tabs.at(index)->icon; } + QIcon tabIcon(int index) const {return m_tabs.at(index)->icon; } QString tabText(int index) const { return m_tabs.at(index)->text; } - int count() const {return m_tabs.count(); } + int count() const {return m_tabs.count(); } QRect tabRect(int index) const; signals: @@ -145,7 +162,7 @@ class FancyTabWidget : public QWidget { Q_OBJECT public: - FancyTabWidget(QWidget* parent = nullptr); + FancyTabWidget(QWidget *parent = nullptr); // Values are persisted - only add to the end enum Mode { @@ -159,7 +176,7 @@ class FancyTabWidget : public QWidget { }; struct Item { - Item(const QIcon& icon, const QString& label) + Item(const QIcon &icon, const QString &label) : type_(Type_Tab), tab_label_(label), tab_icon_(icon), spacer_size_(0) {} Item(int size) : type_(Type_Spacer), spacer_size_(size) {} @@ -176,16 +193,16 @@ class FancyTabWidget : public QWidget { void AddTab(QWidget *tab, const QIcon &icon, const QString &label); void AddSpacer(int size = 40); - void SetBackgroundPixmap(const QPixmap& pixmap); + void SetBackgroundPixmap(const QPixmap &pixmap); - void AddBottomWidget(QWidget* widget); + void AddBottomWidget(QWidget *widget); int current_index() const; Mode mode() const { return mode_; } public slots: void SetCurrentIndex(int index); - void SetCurrentWidget(QWidget* widget); + void SetCurrentWidget(QWidget *widget); void SetMode(Mode mode); void SetMode(int mode) { SetMode(Mode(mode)); } @@ -195,29 +212,28 @@ signals: protected: void paintEvent(QPaintEvent *event); - void contextMenuEvent(QContextMenuEvent* e); + void contextMenuEvent(QContextMenuEvent *e); private slots: void ShowWidget(int index); private: void MakeTabBar(QTabBar::Shape shape, bool text, bool icons, bool fancy); - void AddMenuItem(QSignalMapper* mapper, QActionGroup* group, - const QString& text, Mode mode); + void AddMenuItem(QSignalMapper *mapper, QActionGroup *group, const QString &text, Mode mode); Mode mode_; QList items_; - QWidget* tab_bar_; - QStackedLayout* stack_; + QWidget *tab_bar_; + QStackedLayout *stack_; QPixmap background_pixmap_; - QWidget* side_widget_; - QVBoxLayout* side_layout_; - QVBoxLayout* top_layout_; + QWidget *side_widget_; + QVBoxLayout *side_layout_; + QVBoxLayout *top_layout_; bool use_background_; - QMenu* menu_; + QMenu *menu_; std::unique_ptr proxy_style_; }; diff --git a/src/widgets/favoritewidget.cpp b/src/widgets/favoritewidget.cpp index a535d7b5..cea954f5 100644 --- a/src/widgets/favoritewidget.cpp +++ b/src/widgets/favoritewidget.cpp @@ -20,15 +20,15 @@ #include "config.h" -#include "favoritewidget.h" +#include -#include -#include +#include #include #include #include +#include -#include "core/logging.h" +#include "favoritewidget.h" const int FavoriteWidget::kStarSize = 15; diff --git a/src/widgets/favoritewidget.h b/src/widgets/favoritewidget.h index f0599200..b70997c3 100644 --- a/src/widgets/favoritewidget.h +++ b/src/widgets/favoritewidget.h @@ -20,10 +20,18 @@ #include "config.h" -#include +#include + +#include +#include +#include +#include +#include +#include +#include -class QPaintEvent; class QMouseEvent; +class QPaintEvent; class FavoriteWidget : public QWidget { Q_OBJECT @@ -31,8 +39,7 @@ class FavoriteWidget : public QWidget { public: FavoriteWidget(int tab_id, bool favorite = false, QWidget *parent = nullptr); - // Change the value if different from the current one and then update display - // and emit FavoriteStateChanged signal + // Change the value if different from the current one and then update display and emit FavoriteStateChanged signal void SetFavorite(bool favorite); QSize sizeHint() const; diff --git a/src/widgets/fileview.cpp b/src/widgets/fileview.cpp index 3efed83d..de84c4db 100644 --- a/src/widgets/fileview.cpp +++ b/src/widgets/fileview.cpp @@ -20,21 +20,31 @@ #include "config.h" -#include +#include + +#include +#include +#include +#include #include +#include +#include +#include #include #include +#include +#include +#include -#include "fileview.h" - -#include "ui_fileview.h" #include "core/deletefiles.h" #include "core/filesystemmusicstorage.h" -#include "core/mimedata.h" #include "core/iconloader.h" -#include "core/mainwindow.h" // for filter information +#include "core/mimedata.h" +#include "fileview.h" +#include "fileviewlist.h" +#include "ui_fileview.h" #ifdef HAVE_GSTREAMER -#include "dialogs/organiseerrordialog.h" +# include "dialogs/organiseerrordialog.h" #endif const char *FileView::kFileFilter = @@ -105,8 +115,7 @@ void FileView::FileUp() { QDir dir(model_->rootDirectory()); dir.cdUp(); - // Is this the same as going back? If so just go back, so we can keep the - // view scroll position. + // Is this the same as going back? If so just go back, so we can keep the view scroll position. if (undo_stack_->canUndo()) { const UndoCommand *last_dir = static_cast(undo_stack_->command(undo_stack_->index()-1)); if (last_dir->undo_path() == dir.path()) { diff --git a/src/widgets/fileview.h b/src/widgets/fileview.h index 29a54502..0584a536 100644 --- a/src/widgets/fileview.h +++ b/src/widgets/fileview.h @@ -25,21 +25,29 @@ #include +#include #include -#include +#include +#include +#include +#include +#include #include -#include +#include +#include +#include +#include #include "core/song.h" -class FilesystemMusicStorage; +class QModelIndex; +class QKeyEvent; +class QShowEvent; + class MusicStorage; class TaskManager; class Ui_FileView; -class QFileSystemModel; -class QUndoStack; - class FileView : public QWidget { Q_OBJECT diff --git a/src/widgets/fileviewlist.cpp b/src/widgets/fileviewlist.cpp index 27ade84d..f0e3b7cc 100644 --- a/src/widgets/fileviewlist.cpp +++ b/src/widgets/fileviewlist.cpp @@ -20,24 +20,26 @@ #include "config.h" -#include +#include + +#include +#include +#include #include #include -#include - -#include "fileviewlist.h" +#include +#include +#include "core/iconloader.h" #include "core/mimedata.h" #include "core/utilities.h" -#include "core/logging.h" -#include "core/iconloader.h" +#include "fileviewlist.h" FileViewList::FileViewList(QWidget *parent) : QListView(parent), menu_(new QMenu(this)) { - //qLog(Debug) << __PRETTY_FUNCTION__; menu_->addAction(IconLoader::Load("media-play"), tr("Append to current playlist"), this, SLOT(AddToPlaylistSlot())); menu_->addAction(IconLoader::Load("media-play"), tr("Replace current playlist"), this, SLOT(LoadSlot())); menu_->addAction(IconLoader::Load("document-new"), tr("Open in new playlist"), this, SLOT(OpenInNewPlaylistSlot())); diff --git a/src/widgets/fileviewlist.h b/src/widgets/fileviewlist.h index b3b8f08e..46386bb4 100644 --- a/src/widgets/fileviewlist.h +++ b/src/widgets/fileviewlist.h @@ -23,8 +23,20 @@ #include "config.h" +#include +#include +#include #include +#include #include +#include +#include +#include +#include +#include + +class QMouseEvent; +class QContextMenuEvent; class MimeData; @@ -32,7 +44,7 @@ class FileViewList : public QListView { Q_OBJECT public: - FileViewList(QWidget* parent = nullptr); + FileViewList(QWidget *parent = nullptr); void mousePressEvent(QMouseEvent *e); diff --git a/src/widgets/forcescrollperpixel.cpp b/src/widgets/forcescrollperpixel.cpp index 7f42b6c1..baf95c93 100644 --- a/src/widgets/forcescrollperpixel.cpp +++ b/src/widgets/forcescrollperpixel.cpp @@ -20,12 +20,12 @@ #include "config.h" -#include "forcescrollperpixel.h" - +#include #include -#include #include +#include +#include "forcescrollperpixel.h" ForceScrollPerPixel::ForceScrollPerPixel(QAbstractItemView *item_view, QObject *parent) : QObject(parent), item_view_(item_view) { @@ -33,9 +33,7 @@ ForceScrollPerPixel::ForceScrollPerPixel(QAbstractItemView *item_view, QObject * } bool ForceScrollPerPixel::eventFilter(QObject *object, QEvent *event) { - if (object == item_view_ && - event->type() != QEvent::Destroy && - event->type() != QEvent::WinIdChange) { + if (object == item_view_ && event->type() != QEvent::Destroy && event->type() != QEvent::WinIdChange) { //event->type() != QEvent::AccessibilityPrepare) item_view_->setVerticalScrollMode(QAbstractItemView::ScrollPerPixel); item_view_->verticalScrollBar()->setSingleStep(20); diff --git a/src/widgets/forcescrollperpixel.h b/src/widgets/forcescrollperpixel.h index 4329e34f..e2c278e8 100644 --- a/src/widgets/forcescrollperpixel.h +++ b/src/widgets/forcescrollperpixel.h @@ -23,9 +23,12 @@ #include "config.h" +#include #include +#include +#include -class QAbstractItemView; +class QEvent; // Some KDE styles override the ScrollMode property of QAbstractItemViews. // This helper class forces the mode back to ScrollPerPixel. diff --git a/src/widgets/freespacebar.cpp b/src/widgets/freespacebar.cpp index 2f959a91..df5bfdb9 100644 --- a/src/widgets/freespacebar.cpp +++ b/src/widgets/freespacebar.cpp @@ -20,11 +20,32 @@ #include "config.h" -#include -#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include -#include "freespacebar.h" #include "core/utilities.h" +#include "freespacebar.h" + +class QPaintEvent; const int FreeSpaceBar::kBarHeight = 20; const int FreeSpaceBar::kBarBorderRadius = 8; diff --git a/src/widgets/freespacebar.h b/src/widgets/freespacebar.h index b845e0e1..50254864 100644 --- a/src/widgets/freespacebar.h +++ b/src/widgets/freespacebar.h @@ -23,7 +23,17 @@ #include "config.h" +#include +#include #include +#include +#include +#include +#include +#include +#include + +class QPaintEvent; class FreeSpaceBar : public QWidget { Q_OBJECT diff --git a/src/widgets/groupediconview.cpp b/src/widgets/groupediconview.cpp index b92b4f6d..2bfda43f 100644 --- a/src/widgets/groupediconview.cpp +++ b/src/widgets/groupediconview.cpp @@ -18,16 +18,40 @@ * */ -#include "config.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #include -#include +#include +#include +#include +#include +#include #include -#include -#include +#include +#include +#include +#include +#include -#include "groupediconview.h" #include "core/multisortfilterproxy.h" +#include "groupediconview.h" + +class QModelIndex; +class QResizeEvent; const int GroupedIconView::kBarThickness = 2; const int GroupedIconView::kBarMarginTop = 3; @@ -94,8 +118,7 @@ void GroupedIconView::DrawHeader(QPainter *painter, const QRect &rect, const QFo const QPoint end(rect.right(), start.y()); painter->setRenderHint(QPainter::Antialiasing, true); - painter->setPen(QPen(palette.color(QPalette::Disabled, QPalette::Text), - kBarThickness, Qt::SolidLine, Qt::RoundCap)); + painter->setPen(QPen(palette.color(QPalette::Disabled, QPalette::Text), kBarThickness, Qt::SolidLine, Qt::RoundCap)); painter->setOpacity(0.5); painter->drawLine(start, end); @@ -208,8 +231,7 @@ QModelIndex GroupedIconView::indexAt(const QPoint &p) const { } void GroupedIconView::paintEvent(QPaintEvent *e) { - // This code was adapted from QListView::paintEvent(), changed to use the - // visualRect() of items, and to draw headers. + // This code was adapted from QListView::paintEvent(), changed to use the visualRect() of items, and to draw headers. QStyleOptionViewItemV4 option(viewOptions()); if (isWrapping()) diff --git a/src/widgets/groupediconview.h b/src/widgets/groupediconview.h index bcea9155..79334e65 100644 --- a/src/widgets/groupediconview.h +++ b/src/widgets/groupediconview.h @@ -23,11 +23,27 @@ #include "config.h" +#include +#include #include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +class QModelIndex; +class QPaintEvent; +class QResizeEvent; class MultiSortFilterProxy; - class GroupedIconView : public QListView { Q_OBJECT diff --git a/src/widgets/lineedit.cpp b/src/widgets/lineedit.cpp index 2a08e1d8..fca9654e 100644 --- a/src/widgets/lineedit.cpp +++ b/src/widgets/lineedit.cpp @@ -20,15 +20,31 @@ #include "config.h" +#include +#include +#include +#include +#include #include -#include +#include +#include +#include +#include #include #include #include -#include +#include +#include +#include +#include +#include +#include "core/iconloader.h" #include "lineedit.h" +class QPaintEvent; +class QResizeEvent; + ExtendedEditor::ExtendedEditor(QWidget *widget, int extra_right_padding, bool draw_hint) : LineEditInterface(widget), has_clear_button_(true), @@ -88,8 +104,7 @@ void ExtendedEditor::UpdateButtonGeometry() { const int left = frame_width + 1 + (has_clear_button() ? clear_button_->sizeHint().width() : 0); const int right = frame_width + 1 + (has_reset_button() ? reset_button_->sizeHint().width() : 0); - widget_->setStyleSheet( - QString("QLineEdit { padding-left: %1px; padding-right: %2px; }").arg(left).arg(right)); + widget_->setStyleSheet(QString("QLineEdit { padding-left: %1px; padding-right: %2px; }").arg(left).arg(right)); QSize msz = widget_->minimumSizeHint(); widget_->setMinimumSize(msz.width() + (clear_button_->sizeHint().width() + frame_width + 1) * 2 + extra_right_padding_, qMax(msz.height(), clear_button_->sizeHint().height() + frame_width * 2 + 2)); @@ -153,9 +168,7 @@ void LineEdit::text_changed(const QString& text) { set_rtl(false); } else { - // For some reason Qt will detect any text with LTR at the end as LTR, so - // instead - // compare only the first character + // For some reason Qt will detect any text with LTR at the end as LTR, so instead compare only the first character set_rtl(QString(text.at(0)).isRightToLeft()); } Resize(); diff --git a/src/widgets/lineedit.h b/src/widgets/lineedit.h index b2a51580..2fdfa991 100644 --- a/src/widgets/lineedit.h +++ b/src/widgets/lineedit.h @@ -23,13 +23,21 @@ #include "config.h" +#include + +#include +#include +#include +#include #include #include #include +#include +#include +#include -#include "core/iconloader.h" - -class QToolButton; +class QPaintEvent; +class QResizeEvent; class LineEditInterface { public: diff --git a/src/widgets/linetextedit.cpp b/src/widgets/linetextedit.cpp index a19295de..3d073b87 100644 --- a/src/widgets/linetextedit.cpp +++ b/src/widgets/linetextedit.cpp @@ -20,7 +20,16 @@ #include "config.h" -#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include #include "linetextedit.h" @@ -51,7 +60,8 @@ QSize LineTextEdit::minimumSizeHint() const { void LineTextEdit::keyPressEvent(QKeyEvent *e) { if (e->key() == Qt::Key_Enter || e->key() == Qt::Key_Return) { e->ignore(); - } else { + } + else { QTextEdit::keyPressEvent(e); } } diff --git a/src/widgets/linetextedit.h b/src/widgets/linetextedit.h index cf5827ad..b047ce27 100644 --- a/src/widgets/linetextedit.h +++ b/src/widgets/linetextedit.h @@ -23,7 +23,14 @@ #include "config.h" +#include +#include +#include +#include #include +#include + +class QKeyEvent; class LineTextEdit : public QTextEdit { Q_OBJECT diff --git a/src/widgets/multiloadingindicator.cpp b/src/widgets/multiloadingindicator.cpp index b37ebb8d..0357b866 100644 --- a/src/widgets/multiloadingindicator.cpp +++ b/src/widgets/multiloadingindicator.cpp @@ -20,12 +20,24 @@ #include "config.h" -#include "multiloadingindicator.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + #include "core/taskmanager.h" +#include "multiloadingindicator.h" #include "widgets/busyindicator.h" -#include -#include +class QPaintEvent; const int MultiLoadingIndicator::kVerticalPadding = 4; const int MultiLoadingIndicator::kHorizontalPadding = 6; diff --git a/src/widgets/multiloadingindicator.h b/src/widgets/multiloadingindicator.h index 217a4fb5..21e3865e 100644 --- a/src/widgets/multiloadingindicator.h +++ b/src/widgets/multiloadingindicator.h @@ -23,7 +23,13 @@ #include "config.h" +#include #include +#include +#include +#include + +class QPaintEvent; class BusyIndicator; class TaskManager; diff --git a/src/widgets/osd.cpp b/src/widgets/osd.cpp index d2fd7acb..5713a94e 100644 --- a/src/widgets/osd.cpp +++ b/src/widgets/osd.cpp @@ -20,17 +20,26 @@ #include "config.h" +#include #include -#include +#include +#include +#include +#include +#include +#include #include +#ifdef HAVE_DBUS +# include +#endif #include "osd.h" +#include "osdpretty.h" #include "core/application.h" #include "core/logging.h" #include "core/systemtrayicon.h" #include "covermanager/currentartloader.h" -#include "osdpretty.h" #ifdef HAVE_DBUS # include "dbus/notification.h" @@ -54,12 +63,13 @@ OSD::OSD(SystemTrayIcon *tray_icon, Application *app, QObject *parent) preview_mode_(false), force_show_next_(false), ignore_next_stopped_(false), - pretty_popup_(new OSDPretty(OSDPretty::Mode_Popup)) -{ - connect(app_->current_art_loader(), SIGNAL(ThumbnailLoaded(Song,QString,QImage)), SLOT(AlbumArtLoaded(Song,QString,QImage))); + pretty_popup_(new OSDPretty(OSDPretty::Mode_Popup)) { + + connect(app_->current_art_loader(), SIGNAL(ThumbnailLoaded(Song, QString, QImage)), SLOT(AlbumArtLoaded(Song, QString, QImage))); ReloadSettings(); Init(); + } OSD::~OSD() { @@ -179,9 +189,7 @@ void OSD::Stopped() { } void OSD::StopAfterToggle(bool stop) { - ShowMessage( - QCoreApplication::applicationName(), - tr("Stop playing after track: %1").arg(stop ? tr("On") : tr("Off"))); + ShowMessage(QCoreApplication::applicationName(), tr("Stop playing after track: %1").arg(stop ? tr("On") : tr("Off"))); } void OSD::PlaylistFinished() { diff --git a/src/widgets/osd.h b/src/widgets/osd.h index bd5820be..941d3256 100644 --- a/src/widgets/osd.h +++ b/src/widgets/osd.h @@ -24,25 +24,30 @@ #include "config.h" #include +#include +#include +#include +#include #include #include -#include +#ifdef HAVE_DBUS +# include +# include +#endif -#include "engine/engine_fwd.h" #include "core/song.h" +#include "engine/engine_fwd.h" #include "playlist/playlistsequence.h" class Application; -class OrgFreedesktopNotificationsInterface; class OSDPretty; +class OrgFreedesktopNotificationsInterface; class SystemTrayIcon; class QDBusPendingCallWatcher; #ifdef HAVE_DBUS -#include - QDBusArgument& operator<< (QDBusArgument &arg, const QImage &image); const QDBusArgument &operator>> (const QDBusArgument &arg, QImage &image); #endif diff --git a/src/widgets/osd_mac.mm b/src/widgets/osd_mac.mm index 717a0baf..d31c8734 100644 --- a/src/widgets/osd_mac.mm +++ b/src/widgets/osd_mac.mm @@ -57,8 +57,7 @@ bool OSD::SupportsNativeNotifications() { bool OSD::SupportsTrayPopups() { return false; } -void OSD::ShowMessageNative(const QString& summary, const QString& message, - const QString& icon, const QImage& image) { +void OSD::ShowMessageNative(const QString& summary, const QString& message, const QString& icon, const QImage& image) { Q_UNUSED(icon); if (NotificationCenterSupported()) { scoped_nsobject mac_message( diff --git a/src/widgets/osd_win.cpp b/src/widgets/osd_win.cpp index 50c81cd5..7a6a5b4f 100644 --- a/src/widgets/osd_win.cpp +++ b/src/widgets/osd_win.cpp @@ -23,6 +23,8 @@ #include "osd.h" #include "core/logging.h" +#include +#include #include void OSD::Init() { diff --git a/src/widgets/osd_x11.cpp b/src/widgets/osd_x11.cpp index 9b6b5e81..9577e790 100644 --- a/src/widgets/osd_x11.cpp +++ b/src/widgets/osd_x11.cpp @@ -20,19 +20,35 @@ #include "config.h" -#include "osd.h" - +#include #include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#ifdef HAVE_DBUS +# include +# include +# include +# include +# include +# include +#endif +#include #include -#include "config.h" #include "core/logging.h" +#include "osd.h" #ifdef HAVE_DBUS -#include "dbus/notification.h" -#include -#include +# include "dbus/notification.h" QDBusArgument& operator<<(QDBusArgument& arg, const QImage& image) { @@ -123,8 +139,7 @@ void OSD::ShowMessageNative(const QString& summary, const QString& message, cons int id = 0; if (last_notification_time_.secsTo(QDateTime::currentDateTime()) * 1000 < timeout_msec_) { // Reuse the existing popup if it's still open. The reason we don't always - // reuse the popup is because the notification daemon on KDE4 won't re-show - // the bubble if it's already gone to the tray. See issue #118 + // reuse the popup is because the notification daemon on KDE4 won't re-show the bubble if it's already gone to the tray. See issue #118 id = notification_id_; } diff --git a/src/widgets/osdpretty.cpp b/src/widgets/osdpretty.cpp index 2861003c..f70ba5be 100644 --- a/src/widgets/osdpretty.cpp +++ b/src/widgets/osdpretty.cpp @@ -20,29 +20,45 @@ #include "config.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#ifdef Q_WS_X11 +# include +#endif + #include "osdpretty.h" #include "ui_osdpretty.h" -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include - -#ifdef Q_WS_X11 -# include -#endif - #ifdef Q_OS_WIN32 -# include "qtwin.h" -# include +# include "qtwin.h" +# include #endif const char *OSDPretty::kSettingsGroup = "OSDPretty"; @@ -324,8 +340,7 @@ void OSDPretty::Reposition() { layout()->activate(); resize(sizeHint()); - // Work out where to place the OSD. -1 for x or y means "on the right or - // bottom edge". + // Work out where to place the OSD. -1 for x or y means "on the right or bottom edge". QRect geometry(desktop->availableGeometry(popup_display_)); int x = popup_pos_.x() < 0 ? geometry.right() - width() : geometry.left() + popup_pos_.x(); @@ -342,8 +357,7 @@ void OSDPretty::Reposition() { p.drawRoundedRect(BoxBorder().adjusted(-1, -1, 0, 0), kBorderRadius, kBorderRadius); p.end(); - // If there's no compositing window manager running then we have to set an - // XShape mask. + // If there's no compositing window manager running then we have to set an XShape mask. if (IsTransparencyAvailable()) clearMask(); else { diff --git a/src/widgets/osdpretty.h b/src/widgets/osdpretty.h index 1bfbd396..b6310c61 100644 --- a/src/widgets/osdpretty.h +++ b/src/widgets/osdpretty.h @@ -23,12 +23,29 @@ #include "config.h" +#include + +#include +#include #include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +class QEvent; +class QMouseEvent; +class QPaintEvent; +class QShowEvent; class Ui_OSDPretty; -class QTimeLine; - class OSDPretty : public QWidget { Q_OBJECT @@ -77,9 +94,8 @@ class OSDPretty : public QWidget { QFont font() const { return font_; } bool disable_duration() const { return disable_duration_; } - // When the user has been moving the popup, use these to get its current - // position and screen. Note that these return invalid values if the popup - // is hidden. + // When the user has been moving the popup, use these to get its current position and screen. + // Note that these return invalid values if the popup is hidden. int current_display() const; QPoint current_pos() const; diff --git a/src/widgets/playingwidget.cpp b/src/widgets/playingwidget.cpp index 636ca68e..e0931094 100644 --- a/src/widgets/playingwidget.cpp +++ b/src/widgets/playingwidget.cpp @@ -21,26 +21,33 @@ #include "config.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include #include #include #include -#include -#include +#include +#include #include #include #include -#include - -#include "playingwidget.h" +#include +#include +#include +#include #include "core/application.h" -#include "core/logging.h" -#include "core/iconloader.h" -#include "collection/collectionbackend.h" -#include "covermanager/albumcoverloader.h" -#include "covermanager/coverproviders.h" -#include "covermanager/currentartloader.h" #include "covermanager/albumcoverchoicecontroller.h" +#include "covermanager/albumcoverloader.h" +#include "covermanager/currentartloader.h" +#include "playingwidget.h" const char *PlayingWidget::kSettingsGroup = "PlayingWidget"; diff --git a/src/widgets/playingwidget.h b/src/widgets/playingwidget.h index 1e4b7b66..2246c9aa 100644 --- a/src/widgets/playingwidget.h +++ b/src/widgets/playingwidget.h @@ -24,23 +24,38 @@ #include "config.h" #include +#include +#include +#include #include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #include "core/song.h" #include "covermanager/albumcoverloaderoptions.h" +class QContextMenuEvent; +class QDragEnterEvent; +class QDropEvent; +class QMouseEvent; +class QPaintEvent; +class QPainter; +class QResizeEvent; + class AlbumCoverChoiceController; class Application; -class QAction; -class QActionGroup; -class QMenu; -class QMovie; -class QSignalMapper; -class QTextDocument; -class QTimeLine; - class PlayingWidget : public QWidget { Q_OBJECT diff --git a/src/widgets/prettyimage.cpp b/src/widgets/prettyimage.cpp index 1fcd8882..2a4334fc 100644 --- a/src/widgets/prettyimage.cpp +++ b/src/widgets/prettyimage.cpp @@ -20,27 +20,49 @@ #include "config.h" -#include "prettyimage.h" +#include +#include +#include #include -#include -#include +#include #include #include +#include +#include +#include +#include +#include +#include +#include +#include #include +#include +#include +#include +#include +#include +#include #include #include -#include -#include -#include #include +#include +#include +#include +#include #include -#include +#include +#include +#include +#include +#include +#include #include "core/closure.h" +#include "core/iconloader.h" #include "core/logging.h" #include "core/network.h" -#include "core/iconloader.h" +#include "prettyimage.h" const int PrettyImage::kTotalHeight = 200; const int PrettyImage::kReflectionHeight = 40; @@ -50,7 +72,7 @@ const int PrettyImage::kMaxImageWidth = 300; const char *PrettyImage::kSettingsGroup = "PrettyImageView"; -PrettyImage::PrettyImage(const QUrl& url, QNetworkAccessManager* network, QWidget* parent) +PrettyImage::PrettyImage(const QUrl &url, QNetworkAccessManager* network, QWidget* parent) : QWidget(parent), network_(network), state_(State_WaitingForLazyLoad), @@ -96,7 +118,8 @@ void PrettyImage::ImageFetched(RedirectFollower* follower) { if (image.isNull()) { qLog(Debug) << "Image failed to load" << reply->request().url() << reply->error(); deleteLater(); - } else { + } + else { state_ = State_CreatingThumbnail; image_ = image; diff --git a/src/widgets/prettyimage.h b/src/widgets/prettyimage.h index 82e17de8..68477c2a 100644 --- a/src/widgets/prettyimage.h +++ b/src/widgets/prettyimage.h @@ -23,19 +23,30 @@ #include "config.h" -#include -#include +#include #include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +class QContextMenuEvent; +class QPaintEvent; -class QMenu; -class QNetworkAccessManager; class RedirectFollower; class PrettyImage : public QWidget { Q_OBJECT public: - PrettyImage(const QUrl& url, QNetworkAccessManager* network, QWidget* parent = nullptr); + PrettyImage(const QUrl &url, QNetworkAccessManager *network, QWidget *parent = nullptr); static const int kTotalHeight; static const int kReflectionHeight; @@ -43,7 +54,7 @@ public: static const int kMaxImageWidth; - static const char* kSettingsGroup; + static const char *kSettingsGroup; QSize sizeHint() const; QSize image_size() const; @@ -61,7 +72,7 @@ protected: void paintEvent(QPaintEvent*); private slots: - void ImageFetched(RedirectFollower* reply); + void ImageFetched(RedirectFollower *reply); void ImageScaled(QFuture future); private: @@ -72,17 +83,17 @@ private: State_Finished, }; - void DrawThumbnail(QPainter* p, const QRect& rect); + void DrawThumbnail(QPainter *p, const QRect &rect); private: - QNetworkAccessManager* network_; + QNetworkAccessManager *network_; State state_; QUrl url_; QImage image_; QPixmap thumbnail_; - QMenu* menu_; + QMenu *menu_; QString last_save_dir_; }; diff --git a/src/widgets/prettyimageview.cpp b/src/widgets/prettyimageview.cpp index bff91799..e3f34c94 100644 --- a/src/widgets/prettyimageview.cpp +++ b/src/widgets/prettyimageview.cpp @@ -20,16 +20,28 @@ #include "config.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + #include "prettyimage.h" #include "prettyimageview.h" -#include -#include -#include -#include -#include -#include - PrettyImageView::PrettyImageView(QNetworkAccessManager* network, QWidget* parent) : QScrollArea(parent), network_(network), diff --git a/src/widgets/prettyimageview.h b/src/widgets/prettyimageview.h index 8123814c..ef339cff 100644 --- a/src/widgets/prettyimageview.h +++ b/src/widgets/prettyimageview.h @@ -23,32 +23,38 @@ #include "config.h" -#include -#include -#include +#include -class QHBoxLayout; -class QMenu; -class QNetworkAccessManager; -class QNetworkReply; -class QPropertyAnimation; -class QTimeLine; +#include +#include +#include +#include +#include +#include +#include +#include +#include + +class QEvent; +class QMouseEvent; +class QResizeEvent; +class QWheelEvent; class PrettyImageView : public QScrollArea { Q_OBJECT public: - PrettyImageView(QNetworkAccessManager* network, QWidget* parent = nullptr); + PrettyImageView(QNetworkAccessManager *network, QWidget *parent = nullptr); - static const char* kSettingsGroup; + static const char *kSettingsGroup; public slots: void AddImage(const QUrl& url); protected: void mouseReleaseEvent(QMouseEvent*); - void resizeEvent(QResizeEvent* e); - void wheelEvent(QWheelEvent* e); + void resizeEvent(QResizeEvent *e); + void wheelEvent(QWheelEvent *e); private slots: void ScrollBarReleased(); @@ -59,13 +65,13 @@ private slots: private: bool eventFilter(QObject*, QEvent*); - QNetworkAccessManager* network_; + QNetworkAccessManager *network_; - QWidget* container_; - QHBoxLayout* layout_; + QWidget *container_; + QHBoxLayout *layout_; int current_index_; - QPropertyAnimation* scroll_animation_; + QPropertyAnimation *scroll_animation_; bool recursion_filter_; }; diff --git a/src/widgets/progressitemdelegate.cpp b/src/widgets/progressitemdelegate.cpp index e3bd2f6f..5e2803bb 100644 --- a/src/widgets/progressitemdelegate.cpp +++ b/src/widgets/progressitemdelegate.cpp @@ -20,9 +20,21 @@ #include "config.h" -#include "progressitemdelegate.h" +#include +#include +#include +#include #include +#include +#include +#include +#include +#include +#include +#include + +#include "progressitemdelegate.h" ProgressItemDelegate::ProgressItemDelegate(QObject *parent) : QStyledItemDelegate(parent) @@ -30,6 +42,7 @@ ProgressItemDelegate::ProgressItemDelegate(QObject *parent) } void ProgressItemDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const { + bool ok = false; int progress = index.data().toInt(&ok); @@ -43,8 +56,10 @@ void ProgressItemDelegate::paint(QPainter *painter, const QStyleOptionViewItem & opt.textVisible = true; QApplication::style()->drawControl(QStyle::CE_ProgressBar, &opt, painter); - } else { + } + else { QStyledItemDelegate::paint(painter, option, index); } + } diff --git a/src/widgets/progressitemdelegate.h b/src/widgets/progressitemdelegate.h index c2ce6037..ea13cde1 100644 --- a/src/widgets/progressitemdelegate.h +++ b/src/widgets/progressitemdelegate.h @@ -23,7 +23,14 @@ #include "config.h" +#include +#include +#include +#include #include +#include + +class QModelIndex; class ProgressItemDelegate : public QStyledItemDelegate { Q_OBJECT diff --git a/src/widgets/ratingwidget.cpp b/src/widgets/ratingwidget.cpp index ebfc9020..c390e09e 100644 --- a/src/widgets/ratingwidget.cpp +++ b/src/widgets/ratingwidget.cpp @@ -20,12 +20,23 @@ #include "config.h" -#include "ratingwidget.h" +#include -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #include -#include +#include + +#include "ratingwidget.h" const int RatingPainter::kStarCount; const int RatingPainter::kStarSize; @@ -61,7 +72,8 @@ RatingPainter::RatingPainter() { const QRect source_right(kStarSize/2, 0, kStarSize/2, kStarSize); p.drawPixmap(target_left, on, source_left); p.drawPixmap(target_right, off, source_right); - } else { + } + else { // Totally full p.drawPixmap(rect, on); } @@ -109,8 +121,7 @@ RatingWidget::RatingWidget(QWidget* parent) QSize RatingWidget::sizeHint() const { const int frame_width = 1 + style()->pixelMetric(QStyle::PM_DefaultFrameWidth); - return QSize(RatingPainter::kStarSize * (RatingPainter::kStarCount+2) + frame_width*2, - RatingPainter::kStarSize + frame_width*2); + return QSize(RatingPainter::kStarSize * (RatingPainter::kStarCount+2) + frame_width*2, RatingPainter::kStarSize + frame_width*2); } void RatingWidget::set_rating(float rating) { diff --git a/src/widgets/ratingwidget.h b/src/widgets/ratingwidget.h index 03d0df8b..86277826 100644 --- a/src/widgets/ratingwidget.h +++ b/src/widgets/ratingwidget.h @@ -21,8 +21,21 @@ #ifndef RATINGWIDGET_H #define RATINGWIDGET_H -#include +#include "config.h" + +#include +#include +#include #include +#include +#include +#include +#include +#include + +class QEvent; +class QMouseEvent; +class QPaintEvent; class RatingPainter { public: @@ -33,7 +46,7 @@ public: static QRect Contents(const QRect& rect); static double RatingForPos(const QPoint& pos, const QRect& rect); - void Paint(QPainter* painter, const QRect& rect, float rating) const; + void Paint(QPainter *painter, const QRect& rect, float rating) const; private: QPixmap stars_[kStarCount*2+1]; @@ -44,7 +57,7 @@ class RatingWidget : public QWidget { Q_PROPERTY(float rating READ rating WRITE set_rating); public: - RatingWidget(QWidget* parent = nullptr); + RatingWidget(QWidget *parent = nullptr); QSize sizeHint() const; @@ -56,8 +69,8 @@ signals: protected: void paintEvent(QPaintEvent*); - void mousePressEvent(QMouseEvent* e); - void mouseMoveEvent(QMouseEvent* e); + void mousePressEvent(QMouseEvent *e); + void mouseMoveEvent(QMouseEvent *e); void leaveEvent(QEvent*); private: diff --git a/src/widgets/renametablineedit.cpp b/src/widgets/renametablineedit.cpp index 012eaca8..7004afd4 100644 --- a/src/widgets/renametablineedit.cpp +++ b/src/widgets/renametablineedit.cpp @@ -18,9 +18,13 @@ * */ -#include "renametablineedit.h" +#include "config.h" -#include +#include +#include +#include + +#include "renametablineedit.h" RenameTabLineEdit::RenameTabLineEdit(QWidget *parent) : QLineEdit(parent) diff --git a/src/widgets/renametablineedit.h b/src/widgets/renametablineedit.h index e197905c..d0405704 100644 --- a/src/widgets/renametablineedit.h +++ b/src/widgets/renametablineedit.h @@ -21,7 +21,16 @@ #ifndef RENAMETABLINEEDIT_H #define RENAMETABLINEEDIT_H +#include "config.h" + +#include +#include +#include #include +#include + +class QFocusEvent; +class QKeyEvent; class RenameTabLineEdit : public QLineEdit { Q_OBJECT diff --git a/src/widgets/sliderwidget.cpp b/src/widgets/sliderwidget.cpp index 324a7cda..4db58f4d 100644 --- a/src/widgets/sliderwidget.cpp +++ b/src/widgets/sliderwidget.cpp @@ -17,20 +17,36 @@ * * ***************************************************************************/ +#include "config.h" + #include "sliderwidget.h" #include -#include -#include +#include +#include +#include +#include #include #include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include +#include Amarok::Slider::Slider(Qt::Orientation orientation, QWidget* parent, uint max) : QSlider(orientation, parent), diff --git a/src/widgets/sliderwidget.h b/src/widgets/sliderwidget.h index 185c6cf7..a2042eef 100644 --- a/src/widgets/sliderwidget.h +++ b/src/widgets/sliderwidget.h @@ -17,15 +17,30 @@ * * ***************************************************************************/ -#ifndef AMAROKSLIDER_H -#define AMAROKSLIDER_H +#ifndef SLIDERWIDGET_H +#define SLIDERWIDGET_H -#include -#include +#include "config.h" + +#include + +#include +#include +#include #include +#include +#include +#include +#include +#include +#include +#include -class QPalette; -class QTimer; +class QEvent; +class QMouseEvent; +class QPaintEvent; +class QWheelEvent; +class QContextMenuEvent; namespace Amarok { class Slider : public QSlider { @@ -36,14 +51,12 @@ class Slider : public QSlider { virtual void setValue(int); - // WARNING non-virtual - and thus only really intended for internal use - // this is a major flaw in the class presently, however it suits our - // current needs fine + // WARNING non-virtual - and thus only really intended for internal use this is a major flaw in the class presently, + // however it suits our current needs fine int value() const { return adjustValue(QSlider::value()); } signals: - // we emit this when the user has specifically changed the slider - // so connect to it if valueChanged() is too generic + // we emit this when the user has specifically changed the slider so connect to it if valueChanged() is too generic // Qt also emits valueChanged( int ) void sliderReleased(int); @@ -79,8 +92,7 @@ class PrettySlider : public Slider { Pretty } SliderMode; - PrettySlider(Qt::Orientation orientation, SliderMode mode, QWidget* parent, - uint max = 0); + PrettySlider(Qt::Orientation orientation, SliderMode mode, QWidget* parent, uint max = 0); protected: virtual void slideEvent(QMouseEvent*); @@ -138,4 +150,4 @@ class VolumeSlider : public Slider { }; } -#endif +#endif // SLIDERWIDGET_H diff --git a/src/widgets/statusview.cpp b/src/widgets/statusview.cpp index 418e8bce..99522c6e 100644 --- a/src/widgets/statusview.cpp +++ b/src/widgets/statusview.cpp @@ -19,42 +19,48 @@ #include "config.h" -#include - -#include "statusview.h" - +#include #include -#include +#include +#include #include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include #include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #include +#include -#include "core/utilities.h" -#include "core/logging.h" -#include "core/song.h" #include "core/application.h" +#include "core/logging.h" #include "core/player.h" -#include "core/mainwindow.h" - -#include "collection/collection.h" +#include "core/song.h" +#include "core/utilities.h" +#include "engine/engine_fwd.h" +#include "engine/enginebase.h" +#include "engine/enginetype.h" #include "collection/collectionbackend.h" +#include "collection/collectionquery.h" #include "collection/collectionview.h" #include "collection/collectionviewcontainer.h" - -#include "covermanager/albumcoverloader.h" -#include "covermanager/coverproviders.h" -#include "covermanager/currentartloader.h" #include "covermanager/albumcoverchoicecontroller.h" - -#include "engine/enginetype.h" -#include "engine/enginebase.h" +#include "covermanager/albumcoverloader.h" +#include "covermanager/currentartloader.h" +#include "statusview.h" const char *StatusView::kSettingsGroup = "StatusView"; @@ -284,13 +290,12 @@ void StatusView::SwitchWidgets(WidgetState state) { } -void StatusView::UpdateSong(const Song &song) { +void StatusView::UpdateSong() { //qLog(Debug) << __PRETTY_FUNCTION__; SwitchWidgets(Playing); - const Song *song_ = &song; const QueryOptions opt; CollectionBackend::AlbumList albumlist; Engine::EngineType enginetype = app_->player()->engine()->type(); @@ -301,15 +306,15 @@ void StatusView::UpdateSong(const Song &song) { QString html; QString html_albums; - html += QString("%1 - %2
%3").arg(song_->PrettyTitle().toHtmlEscaped(), song_->artist().toHtmlEscaped(), song_->album().toHtmlEscaped()); + html += QString("%1 - %2
%3").arg(metadata_.PrettyTitle().toHtmlEscaped(), metadata_.artist().toHtmlEscaped(), metadata_.album().toHtmlEscaped()); label_playing_top_->setText(html); html = ""; - html += QString("Filetype: %1
\n").arg(song_->TextForFiletype()); - html += QString("Length: %1
\n").arg(Utilities::PrettyTimeNanosec(song.length_nanosec())); - html += QString("Bitrate: %1 kbps
\n").arg(song_->bitrate()); - html += QString("Samplerate: %1 hz / %2 bit
\n").arg(song_->samplerate()).arg(song_->bitdepth()); + html += QString("Filetype: %1
\n").arg(metadata_.TextForFiletype()); + html += QString("Length: %1
\n").arg(Utilities::PrettyTimeNanosec(metadata_.length_nanosec())); + html += QString("Bitrate: %1 kbps
\n").arg(metadata_.bitrate()); + html += QString("Samplerate: %1 hz / %2 bit
\n").arg(metadata_.samplerate()).arg(metadata_.bitdepth()); if (enginetype != Engine::EngineType::None) { html += QString("
"); @@ -318,9 +323,9 @@ void StatusView::UpdateSong(const Song &song) { html += QString("
"); - html_albums += QString("Albums by %1:").arg( song_->artist().toHtmlEscaped() ); + html_albums += QString("Albums by %1:").arg( metadata_.artist().toHtmlEscaped() ); - albumlist = app_->collection_backend()->GetAlbumsByArtist(song_->artist(), opt); + albumlist = app_->collection_backend()->GetAlbumsByArtist(metadata_.artist(), opt); html_albums += QString("
    "); int i=0; @@ -379,9 +384,8 @@ void StatusView::SongChanged(const Song &song) { stopped_ = false; metadata_ = song; - const Song *song_ = &song; - UpdateSong(*song_); + UpdateSong(); update(); diff --git a/src/widgets/statusview.h b/src/widgets/statusview.h index c74ea192..8f47169f 100644 --- a/src/widgets/statusview.h +++ b/src/widgets/statusview.h @@ -22,31 +22,38 @@ #include "config.h" -#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #include "core/song.h" -#include "core/database.h" -#include "core/application.h" - -#include "collection/collectionbackend.h" -#include "collection/collectionview.h" -#include "collection/collectionviewcontainer.h" - #include "covermanager/albumcoverloaderoptions.h" -class QVBoxLayout; -class QHBoxLayout; -class QScrollArea; -class QWidget; -class QTimeLine; -class QLabel; -class QImage; -class QPixmap; -class QPainter; +class QEvent; +class QContextMenuEvent; +class QDragEnterEvent; +class QDropEvent; +class QMouseEvent; class Application; class CollectionView; -class CollectionBackend; +class CollectionViewContainer; +class AlbumCoverChoiceController; class StatusView : public QWidget { Q_OBJECT @@ -54,7 +61,7 @@ class StatusView : public QWidget { public: StatusView(CollectionViewContainer *collectionviewcontainer, QWidget *parent = nullptr); ~StatusView(); - + static const char* kSettingsGroup; static const int kPadding; static const int kGradientHead; @@ -62,9 +69,9 @@ public: static const int kMaxCoverSize; static const int kBottomOffset; static const int kTopBorder; - + void SetApplication(Application *app); - + public slots: void SongChanged(const Song &song); void SongFinished(); @@ -100,8 +107,6 @@ private: QPixmap *pixmap_album_; QPainter *painter_album_; - Song song_; - CollectionView *collectionview_; AlbumCoverLoaderOptions cover_loader_options_; @@ -150,10 +155,9 @@ private: Stopped }; WidgetState widgetstate_; - QMenu* menu_; + QMenu *menu_; protected: - bool eventFilter(QObject *, QEvent *); void handlePaintEvent(QObject *object, QEvent *event); void paintEvent_album(QEvent *event); @@ -161,7 +165,7 @@ protected: void mouseReleaseEvent(QMouseEvent *); void dragEnterEvent(QDragEnterEvent *e); void dropEvent(QDropEvent *e); - void UpdateSong(const Song &song); + void UpdateSong(); void NoSong(); void SwitchWidgets(WidgetState state); diff --git a/src/widgets/stickyslider.cpp b/src/widgets/stickyslider.cpp index 27688ad1..c711012b 100644 --- a/src/widgets/stickyslider.cpp +++ b/src/widgets/stickyslider.cpp @@ -20,8 +20,13 @@ #include "config.h" +#include +#include + #include "stickyslider.h" +class QMouseEvent; + StickySlider::StickySlider(QWidget *parent) : QSlider(parent), sticky_center_(-1), diff --git a/src/widgets/stickyslider.h b/src/widgets/stickyslider.h index 0ce0f836..0b7c6944 100644 --- a/src/widgets/stickyslider.h +++ b/src/widgets/stickyslider.h @@ -23,8 +23,12 @@ #include "config.h" +#include +#include #include +class QMouseEvent; + class StickySlider : public QSlider { Q_OBJECT Q_PROPERTY(int sticky_center READ sticky_center WRITE set_sticky_center); diff --git a/src/widgets/stretchheaderview.cpp b/src/widgets/stretchheaderview.cpp index 8f5414d4..aa08cbed 100644 --- a/src/widgets/stretchheaderview.cpp +++ b/src/widgets/stretchheaderview.cpp @@ -20,15 +20,22 @@ #include "config.h" -#include "stretchheaderview.h" -#include "core/logging.h" - -#include - #include -#include #include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "stretchheaderview.h" + const int StretchHeaderView::kMinimumColumnWidth = 10; const int StretchHeaderView::kMagicNumber = 0x502c950f; @@ -239,7 +246,7 @@ void StretchHeaderView::SetColumnWidth(int logical, ColumnWidthType width) { bool StretchHeaderView::RestoreState(const QByteArray& data) { QDataStream s(data); - s.setVersion(QDataStream::Qt_4_6); + s.setVersion(QDataStream::Qt_5_6); int magic_number = 0; s >> magic_number; @@ -264,8 +271,7 @@ bool StretchHeaderView::RestoreState(const QByteArray& data) { const int persisted_column_count = qMin(qMin(visual_indices.count(), pixel_widths.count()), column_widths_.count()); - // Set column visible state, visual indices and, if we're not in stretch mode, - // pixel widths. + // Set column visible state, visual indices and, if we're not in stretch mode, pixel widths. for (int i = 0; i < count() && i < persisted_column_count; ++i) { setSectionHidden(i, pixel_widths[i] <= kMinimumColumnWidth); moveSection(visualIndex(visual_indices[i]), i); @@ -281,8 +287,7 @@ bool StretchHeaderView::RestoreState(const QByteArray& data) { } if (stretch_enabled_) { - // In stretch mode, we've already set the proportional column widths so apply - // them now. + // In stretch mode, we've already set the proportional column widths so apply them now. UpdateWidths(); } @@ -305,7 +310,7 @@ QByteArray StretchHeaderView::SaveState() const { visual_indices << logicalIndex(i); } - s.setVersion(QDataStream::Qt_4_6); + s.setVersion(QDataStream::Qt_5_6); s << kMagicNumber; s << stretch_enabled_; diff --git a/src/widgets/stretchheaderview.h b/src/widgets/stretchheaderview.h index bdc1068d..8dc8a58a 100644 --- a/src/widgets/stretchheaderview.h +++ b/src/widgets/stretchheaderview.h @@ -23,7 +23,20 @@ #include "config.h" +#include + +#include +#include +#include +#include #include +#include +#include +#include +#include + +class QMouseEvent; +class QResizeEvent; class StretchHeaderView : public QHeaderView { Q_OBJECT @@ -38,14 +51,12 @@ class StretchHeaderView : public QHeaderView { void setModel(QAbstractItemModel* model); - // Serialises the proportional and actual column widths. Use these instead - // of QHeaderView::restoreState and QHeaderView::saveState to persist the - // proportional values directly and avoid floating point errors over time. + // Serialises the proportional and actual column widths. + // Use these instead of QHeaderView::restoreState and QHeaderView::saveState to persist the proportional values directly and avoid floating point errors over time. bool RestoreState(const QByteArray& data); QByteArray SaveState() const; - // Hides a section and resizes all other sections to fill the gap. Does - // nothing if you try to hide the last section. + // Hides a section and resizes all other sections to fill the gap. Does nothing if you try to hide the last section. void HideSection(int logical); // Shows a section and resizes all other sections to make room. @@ -79,8 +90,7 @@ protected: // Scales column_widths_ values so the total is 1.0. void NormaliseWidths(const QList& sections = QList()); - // Resizes the actual columns to make them match the proportional values - // in column_widths_. + // Resizes the actual columns to make them match the proportional values in column_widths_. void UpdateWidths(const QList& sections = QList()); private slots: diff --git a/src/widgets/stylehelper.cpp b/src/widgets/stylehelper.cpp index 00b3198a..c8937ba7 100644 --- a/src/widgets/stylehelper.cpp +++ b/src/widgets/stylehelper.cpp @@ -27,28 +27,36 @@ ** **************************************************************************/ +#include "config.h" + #include "stylehelper.h" -#include -#include +#include #include -#include -#include -#include +#include +#include +#include +#include +#include #include -#include +#include +#include +#include +#include +#include +#include + +#include "core/qt_blurimage.h" // Clamps float color values within (0, 255) -static int clamp(float x) -{ +static int clamp(float x) { const int val = x > 255 ? 255 : static_cast(x); return val < 0 ? 0 : val; } namespace Utils { -qreal StyleHelper::sidebarFontSize() -{ +qreal StyleHelper::sidebarFontSize() { #if defined(Q_WS_MAC) return 10; #else @@ -56,8 +64,7 @@ qreal StyleHelper::sidebarFontSize() #endif } -QColor StyleHelper::panelTextColor(bool lightColored) -{ +QColor StyleHelper::panelTextColor(bool lightColored) { if (!lightColored) return Qt::white; else @@ -68,57 +75,41 @@ QColor StyleHelper::panelTextColor(bool lightColored) QColor StyleHelper::m_baseColor; QColor StyleHelper::m_requestedBaseColor; -QColor StyleHelper::baseColor(bool lightColored) -{ +QColor StyleHelper::baseColor(bool lightColored) { if (!lightColored) return m_baseColor; else return m_baseColor.lighter(230); } -QColor StyleHelper::highlightColor(bool lightColored) -{ +QColor StyleHelper::highlightColor(bool lightColored) { QColor result = baseColor(lightColored); if (!lightColored) - result.setHsv(result.hue(), - clamp(result.saturation()), - clamp(result.value() * 1.16)); + result.setHsv(result.hue(), clamp(result.saturation()), clamp(result.value() * 1.16)); else - result.setHsv(result.hue(), - clamp(result.saturation()), - clamp(result.value() * 1.06)); + result.setHsv(result.hue(), clamp(result.saturation()), clamp(result.value() * 1.06)); return result; } QColor StyleHelper::shadowColor(bool lightColored) { QColor result = baseColor(lightColored); - result.setHsv(result.hue(), - clamp(result.saturation() * 1.1), - clamp(result.value() * 0.70)); + result.setHsv(result.hue(), clamp(result.saturation() * 1.1), clamp(result.value() * 0.70)); return result; } -QColor StyleHelper::borderColor(bool lightColored) -{ +QColor StyleHelper::borderColor(bool lightColored) { QColor result = baseColor(lightColored); - result.setHsv(result.hue(), - result.saturation(), - result.value() / 2); + result.setHsv(result.hue(), result.saturation(), result.value() / 2); return result; } -// We try to ensure that the actual color used are within -// reasonalbe bounds while generating the actual baseColor -// from the users request. -void StyleHelper::setBaseColor(const QColor &newcolor) -{ +// We try to ensure that the actual color used are within reasonalbe bounds while generating the actual baseColor from the users request. +void StyleHelper::setBaseColor(const QColor &newcolor) { m_requestedBaseColor = newcolor; QColor color; - color.setHsv(newcolor.hue(), - newcolor.saturation() * 0.7, - 64 + newcolor.value() / 3); + color.setHsv(newcolor.hue(), newcolor.saturation() * 0.7, 64 + newcolor.value() / 3); if (color.isValid() && color != m_baseColor) { m_baseColor = color; @@ -128,8 +119,7 @@ void StyleHelper::setBaseColor(const QColor &newcolor) } } -static void verticalGradientHelper(QPainter *p, const QRect &spanRect, const QRect &rect, bool lightColored) -{ +static void verticalGradientHelper(QPainter *p, const QRect &spanRect, const QRect &rect, bool lightColored) { QColor highlight = StyleHelper::highlightColor(lightColored); QColor shadow = StyleHelper::shadowColor(lightColored); QLinearGradient grad(spanRect.topRight(), spanRect.topLeft()); @@ -139,20 +129,17 @@ static void verticalGradientHelper(QPainter *p, const QRect &spanRect, const QRe QColor light(255, 255, 255, 80); p->setPen(light); - p->drawLine(rect.topRight() - QPoint(1, 0), rect.bottomRight() - QPoint(1, 0)); + p->drawLine(rect.topRight() - QPoint(1, 0), rect.bottomRight() - QPoint(1, 0)); QColor dark(0, 0, 0, 90); p->setPen(dark); p->drawLine(rect.topLeft(), rect.bottomLeft()); } -void StyleHelper::verticalGradient(QPainter *painter, const QRect &spanRect, const QRect &clipRect, bool lightColored) -{ +void StyleHelper::verticalGradient(QPainter *painter, const QRect &spanRect, const QRect &clipRect, bool lightColored) { if (StyleHelper::usePixmapCache()) { QString key; QColor keyColor = baseColor(lightColored); - key.sprintf("mh_vertical %d %d %d %d %d", - spanRect.width(), spanRect.height(), clipRect.width(), - clipRect.height(), keyColor.rgb());; + key.sprintf("mh_vertical %d %d %d %d %d", spanRect.width(), spanRect.height(), clipRect.width(), clipRect.height(), keyColor.rgb()); QPixmap pixmap; if (!QPixmapCache::find(key, pixmap)) { @@ -165,17 +152,16 @@ void StyleHelper::verticalGradient(QPainter *painter, const QRect &spanRect, con } painter->drawPixmap(clipRect.topLeft(), pixmap); - } else { + } + else { verticalGradientHelper(painter, spanRect, clipRect, lightColored); } } // Draws a cached pixmap with shadow -void StyleHelper::drawIconWithShadow(const QIcon &icon, const QRect &rect, - QPainter *p, QIcon::Mode iconMode, int radius, const QColor &color, const QPoint &offset) -{ +void StyleHelper::drawIconWithShadow(const QIcon &icon, const QRect &rect, QPainter *p, QIcon::Mode iconMode, int radius, const QColor &color, const QPoint &offset) { QPixmap cache; - QString pixmapName = QString("icon %0 %1 %2").arg(icon.cacheKey()).arg(iconMode).arg(rect.height()); + QString pixmapName = QString("icon %0 %1 %2").arg(icon.cacheKey()).arg(iconMode).arg(rect.height()); if (!QPixmapCache::find(pixmapName, cache)) { QPixmap px = icon.pixmap(rect.size()); @@ -198,7 +184,7 @@ void StyleHelper::drawIconWithShadow(const QIcon &icon, const QRect &rect, } // Draw shadow - QImage tmp(px.size() + QSize(radius * 2, radius * 2 + 1), QImage::Format_ARGB32_Premultiplied); + QImage tmp(px.size() + QSize(radius * 2, radius * 2 + 1), QImage::Format_ARGB32_Premultiplied); tmp.fill(Qt::transparent); QPainter tmpPainter(&tmp); @@ -227,7 +213,7 @@ void StyleHelper::drawIconWithShadow(const QIcon &icon, const QRect &rect, tmpPainter.end(); // draw the blurred drop shadow... - cachePainter.drawImage(QRect(0, 0, cache.rect().width(), cache.rect().height()), tmp); + cachePainter.drawImage(QRect(0, 0, cache.rect().width(), cache.rect().height()), tmp); // Draw the actual pixmap... cachePainter.drawPixmap(QPoint(radius, radius) + offset, px); diff --git a/src/widgets/stylehelper.h b/src/widgets/stylehelper.h index c6142227..d3616b2d 100644 --- a/src/widgets/stylehelper.h +++ b/src/widgets/stylehelper.h @@ -30,16 +30,14 @@ #ifndef STYLEHELPER_H #define STYLEHELPER_H +#include + +#include +#include +#include #include -#include - -#include "core/qt_blurimage.h" - -QT_BEGIN_NAMESPACE -class QPalette; -class QPainter; -class QRect; -QT_END_NAMESPACE +#include +#include // Helper class holding all custom color values @@ -70,9 +68,7 @@ public: static void verticalGradient(QPainter *painter, const QRect &spanRect, const QRect &clipRect, bool lightColored = false); static bool usePixmapCache() { return true; } - static void drawIconWithShadow(const QIcon &icon, const QRect &rect, QPainter *p, QIcon::Mode iconMode, - int radius = 3, const QColor &color = QColor(0, 0, 0, 130), - const QPoint &offset = QPoint(1, -2)); + static void drawIconWithShadow(const QIcon &icon, const QRect &rect, QPainter *p, QIcon::Mode iconMode, int radius = 3, const QColor &color = QColor(0, 0, 0, 130), const QPoint &offset = QPoint(1, -2)); private: static QColor m_baseColor; diff --git a/src/widgets/trackslider.cpp b/src/widgets/trackslider.cpp index 85e9822f..b307b73c 100644 --- a/src/widgets/trackslider.cpp +++ b/src/widgets/trackslider.cpp @@ -18,14 +18,22 @@ * */ -#include "config.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include -#include "trackslider.h" -#include "ui_trackslider.h" #include "core/timeconstants.h" #include "core/utilities.h" - -#include +#include "trackslider.h" +#include "ui_trackslider.h" +#include "clickablelabel.h" +#include "tracksliderslider.h" const char* TrackSlider::kSettingsGroup = "MainWindow"; @@ -59,8 +67,7 @@ void TrackSlider::SetApplication(Application* app) { } void TrackSlider::UpdateLabelWidth() { - // We set the label's minimum size so it won't resize itself when the user - // is dragging the slider. + // We set the label's minimum size so it won't resize itself when the user is dragging the slider. UpdateLabelWidth(ui_->elapsed, "0:00:00"); UpdateLabelWidth(ui_->remaining, "-0:00:00"); } @@ -103,12 +110,12 @@ void TrackSlider::SetValue(int elapsed, int total) { void TrackSlider::UpdateTimes(int elapsed) { ui_->elapsed->setText(Utilities::PrettyTime(elapsed)); - //update normally if showing remaining time + // Update normally if showing remaining time if (show_remaining_time_) { ui_->remaining->setText("-" + Utilities::PrettyTime((ui_->slider->maximum() / kMsecPerSec) - elapsed)); } else { - // check if slider maximum value is changed before updating + // Check if slider maximum value is changed before updating if (slider_maximum_value_ != ui_->slider->maximum()) { slider_maximum_value_ = ui_->slider->maximum(); ui_->remaining->setText(Utilities::PrettyTime((ui_->slider->maximum() / kMsecPerSec))); @@ -165,12 +172,12 @@ void TrackSlider::ToggleTimeDisplay() { show_remaining_time_ = !show_remaining_time_; if (!show_remaining_time_) { - //we set the value to -1 because the label must be updated + // We set the value to -1 because the label must be updated slider_maximum_value_ = -1; } UpdateTimes(ui_->slider->value() / kMsecPerSec); - // save this setting + // Save this setting QSettings s; s.beginGroup(kSettingsGroup); s.setValue("show_remaining_time", show_remaining_time_); diff --git a/src/widgets/trackslider.h b/src/widgets/trackslider.h index d434e1ac..785d4ab7 100644 --- a/src/widgets/trackslider.h +++ b/src/widgets/trackslider.h @@ -23,9 +23,15 @@ #include "config.h" -#include +#include -class QLabel; +#include +#include +#include +#include +#include + +class QEvent; class Application; class Ui_TrackSlider; diff --git a/src/widgets/tracksliderpopup.cpp b/src/widgets/tracksliderpopup.cpp index 0a8031ba..c142ba07 100644 --- a/src/widgets/tracksliderpopup.cpp +++ b/src/widgets/tracksliderpopup.cpp @@ -20,17 +20,28 @@ #include "config.h" -#include "tracksliderpopup.h" +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #include "core/qt_blurimage.h" +#include "tracksliderpopup.h" -#include -#include -#include -#include -#include -#include -#include +class QPaintEvent; const int TrackSliderPopup::kTextMargin = 4; const int TrackSliderPopup::kPointLength = 16; diff --git a/src/widgets/tracksliderpopup.h b/src/widgets/tracksliderpopup.h index a882d185..ba62057d 100644 --- a/src/widgets/tracksliderpopup.h +++ b/src/widgets/tracksliderpopup.h @@ -23,7 +23,18 @@ #include "config.h" +#include +#include #include +#include +#include +#include +#include +#include +#include + +class QMouseEvent; +class QPaintEvent; class TrackSliderPopup : public QWidget { Q_OBJECT diff --git a/src/widgets/tracksliderslider.cpp b/src/widgets/tracksliderslider.cpp index 48f8ed4e..3d9982ef 100644 --- a/src/widgets/tracksliderslider.cpp +++ b/src/widgets/tracksliderslider.cpp @@ -20,16 +20,20 @@ #include "config.h" -#include "tracksliderpopup.h" -#include "tracksliderslider.h" +#include + +#include +#include +#include +#include +#include +#include +#include + #include "core/timeconstants.h" #include "core/utilities.h" - -#include -#include -#include -#include -#include +#include "tracksliderpopup.h" +#include "tracksliderslider.h" TrackSliderSlider::TrackSliderSlider(QWidget* parent) : QSlider(parent), @@ -42,9 +46,8 @@ TrackSliderSlider::TrackSliderSlider(QWidget* parent) } void TrackSliderSlider::mousePressEvent(QMouseEvent* e) { - // QSlider asks QStyle which mouse button should do what (absolute move or - // page step). We force our own behaviour here because it makes more sense - // for a music player IMO. + // QSlider asks QStyle which mouse button should do what (absolute move or page step). + // We force our own behaviour here because it makes more sense for a music player IMO. Qt::MouseButton new_button = e->button(); if (e->button() == Qt::LeftButton) { diff --git a/src/widgets/tracksliderslider.h b/src/widgets/tracksliderslider.h index 729a776e..dd2117c9 100644 --- a/src/widgets/tracksliderslider.h +++ b/src/widgets/tracksliderslider.h @@ -23,8 +23,16 @@ #include "config.h" +#include +#include +#include #include +#include +class QEvent; +class QKeyEvent; +class QMouseEvent; +class QWheelEvent; class TrackSliderPopup; // It's the slider inside the TrackSliderSlider diff --git a/src/widgets/widgetfadehelper.cpp b/src/widgets/widgetfadehelper.cpp index 07787b0d..e29b380c 100644 --- a/src/widgets/widgetfadehelper.cpp +++ b/src/widgets/widgetfadehelper.cpp @@ -20,14 +20,24 @@ #include "config.h" -#include "widgetfadehelper.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #include "core/qt_blurimage.h" - -#include -#include -#include -#include +#include "widgetfadehelper.h" const int WidgetFadeHelper::kLoadingPadding = 9; const int WidgetFadeHelper::kLoadingBorderRadius = 10; @@ -126,8 +136,7 @@ void WidgetFadeHelper::CaptureParent() { void WidgetFadeHelper::StartFade() { if (blur_timeline_->state() == QTimeLine::Running) { - // Blur timeline is still running, so we need render the current state - // into a new pixmap. + // Blur timeline is still running, so we need render the current state into a new pixmap. QPixmap pixmap(original_pixmap_); QPainter painter(&pixmap); painter.setOpacity(blur_timeline_->currentValue()); diff --git a/src/widgets/widgetfadehelper.h b/src/widgets/widgetfadehelper.h index 0ca3dd7d..0325c08f 100644 --- a/src/widgets/widgetfadehelper.h +++ b/src/widgets/widgetfadehelper.h @@ -23,9 +23,18 @@ #include "config.h" -#include +#include -class QTimeLine; +#include +#include +#include +#include +#include +#include +#include + +class QEvent; +class QPaintEvent; class WidgetFadeHelper : public QWidget { Q_OBJECT