1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-03-19 07:19:42 +01:00

Update the tree on mac after /Volumes is shown to avoid a race condition

This commit is contained in:
Leo Franchi 2011-11-25 14:30:49 -05:00
parent ed306b00f0
commit f9b18a9c26
2 changed files with 25 additions and 1 deletions

View File

@ -20,6 +20,7 @@
#include "checkdirtree.h"
#include "utils/logger.h"
#include "tomahawksettings.h"
#include <QProcess>
@ -57,7 +58,9 @@ CheckDirModel::getFileInfoResult()
if ( res == "1" )
{
// Remove the hidden flag for the /Volumnes folder so all mount points are visible in the default (Q)FileSystemModel
QProcess::startDetached( QString( "SetFile -a v %1" ).arg( s_macVolumePath ) );
QProcess* p = new QProcess( this );
connect( p, SIGNAL( finished( int, QProcess::ExitStatus ) ), this, SLOT( volumeShowFinished() ) );
p->start( QString( "SetFile -a v %1" ).arg( s_macVolumePath ) );
m_shownVolumes = true;
}
@ -65,6 +68,12 @@ CheckDirModel::getFileInfoResult()
#endif
}
void
CheckDirModel::volumeShowFinished()
{
reset();
}
Qt::ItemFlags
CheckDirModel::flags( const QModelIndex& index ) const
{
@ -150,6 +159,8 @@ CheckDirTree::CheckDirTree( QWidget* parent )
SLOT( updateNode( QModelIndex ) ) );
connect( &m_dirModel, SIGNAL( dataChangedByUser( const QModelIndex& ) ),
SIGNAL( changed() ) );
connect( &m_dirModel, SIGNAL( modelReset() ),
SLOT( modelReset() ) );
connect( this, SIGNAL( collapsed( QModelIndex ) ),
SLOT( onCollapse( QModelIndex ) ) );
@ -301,6 +312,16 @@ CheckDirTree::updateNode( const QModelIndex& idx )
}
void
CheckDirTree::modelReset()
{
foreach ( const QString& dir, TomahawkSettings::instance()->scannerPaths() )
{
checkPath( dir, Qt::Checked );
}
}
void
CheckDirTree::fillDown( const QModelIndex& parent )
{

View File

@ -1,6 +1,7 @@
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
*
* Copyright 2010-2011, Christian Muehlhaeuser <muesli@tomahawk-player.org>
* Copyright 2011, Leo Franchi <lfranchi@kde.org>
*
* Tomahawk is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -44,6 +45,7 @@ signals:
private slots:
void getFileInfoResult();
void volumeShowFinished();
private:
QHash<QPersistentModelIndex, Qt::CheckState> m_checkTable;
@ -73,6 +75,7 @@ private slots:
void onExpand( const QModelIndex& idx );
void updateNode( const QModelIndex& idx );
void modelReset();
private:
CheckDirModel m_dirModel;
QSet<qint64> m_expandedSet;