Skip to content

Commit

Permalink
library/serato/seratofeature: Switch to new TreeItem initialization
Browse files Browse the repository at this point in the history
  • Loading branch information
Holzhaus committed Feb 15, 2020
1 parent 0c5c24e commit 627d112
Showing 1 changed file with 8 additions and 9 deletions.
17 changes: 8 additions & 9 deletions src/library/serato/seratofeature.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -662,12 +662,10 @@ QString parseDatabase(mixxx::DbConnectionPoolPtr dbConnectionPool, TreeItem* dat
}

// This function is executed in a separate thread other than the main thread
QList<TreeItem*> findSeratoDatabases(SeratoFeature* seratoFeature) {
QList<TreeItem*> findSeratoDatabases() {
QThread* thisThread = QThread::currentThread();
thisThread->setPriority(QThread::LowPriority);

QList<TreeItem*> foundDatabases;

// Build a list of directories that could contain the _Serato_ directory
QFileInfoList databaseLocations;
foreach (const QString& musicDir, QStandardPaths::standardLocations(QStandardPaths::MusicLocation)) {
Expand Down Expand Up @@ -712,6 +710,7 @@ QList<TreeItem*> findSeratoDatabases(SeratoFeature* seratoFeature) {
volumesDir.entryInfoList(QDir::AllDirs | QDir::NoDotAndDotDot));
#endif

QList<TreeItem*> foundDatabases;
foreach (QFileInfo databaseLocation, databaseLocations) {
QDir databaseDir = QDir(databaseLocation.filePath());
if (!databaseDir.cd(kDatabaseDirectory)) {
Expand All @@ -722,19 +721,19 @@ QList<TreeItem*> findSeratoDatabases(SeratoFeature* seratoFeature) {
continue;
}

TreeItem* foundDatabase = new TreeItem(seratoFeature);

QString displayPath = databaseLocation.filePath();
if (displayPath.endsWith("/")) {
displayPath.chop(1);
}

foundDatabase->setLabel(displayPath);

QList<QVariant> data;
data << QVariant(databaseDir.filePath(kDatabaseFilename))
<< QVariant(false);
foundDatabase->setData(data);

TreeItem* foundDatabase = new TreeItem(
std::move(displayPath),
QVariant(data));

foundDatabases << foundDatabase;
}
Expand Down Expand Up @@ -908,7 +907,7 @@ SeratoFeature::SeratoFeature(
&SeratoFeature::onTracksFound);

// initialize the model
m_childModel.setRootItem(std::make_unique<TreeItem>(this));
m_childModel.setRootItem(TreeItem::newRoot(this));
}

SeratoFeature::~SeratoFeature() {
Expand Down Expand Up @@ -999,7 +998,7 @@ void SeratoFeature::activate() {
qDebug() << "SeratoFeature::activate()";

// Let a worker thread do the parsing
m_databasesFuture = QtConcurrent::run(findSeratoDatabases, this);
m_databasesFuture = QtConcurrent::run(findSeratoDatabases);
m_databasesFutureWatcher.setFuture(m_databasesFuture);
m_title = tr("(loading) Serato");
//calls a slot in the sidebar model such that 'Serato (isLoading)' is displayed.
Expand Down

0 comments on commit 627d112

Please sign in to comment.