Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions include/Song.h
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,10 @@ class EXPORT Song : public TrackContainer

void processNextBuffer();

inline int getLoadingTrackCount() const
{
return m_nLoadingTrack;
}
inline int getMilliseconds() const
{
return m_elapsedMilliSeconds;
Expand Down Expand Up @@ -339,6 +343,7 @@ private slots:

ControllerVector m_controllers;

int m_nLoadingTrack;

QString m_fileName;
QString m_oldFileName;
Expand Down
21 changes: 21 additions & 0 deletions src/core/Song.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1054,6 +1054,27 @@ void Song::loadProject( const QString & fileName )
}

node = dataFile.content().firstChild();

QDomNodeList tclist=dataFile.content().elementsByTagName("trackcontainer");
m_nLoadingTrack=0;
for( int i=0,n=tclist.count(); i<n; ++i )
{
QDomNode nd=tclist.at(i).firstChild();
while(!nd.isNull())
{
if( nd.isElement() && nd.nodeName() == "track" )
{
++m_nLoadingTrack;
if( nd.toElement().attribute("type").toInt() == Track::BBTrack )
{
n += nd.toElement().elementsByTagName("bbtrack").at(0)
.toElement().firstChildElement().childNodes().count();
}
nd=nd.nextSibling();
}
}
}

while( !node.isNull() )
{
if( node.isElement() )
Expand Down
18 changes: 9 additions & 9 deletions src/core/TrackContainer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,25 +86,18 @@ void TrackContainer::loadSettings( const QDomElement & _this )

static QProgressDialog * pd = NULL;
bool was_null = ( pd == NULL );
int start_val = 0;
if( !journalRestore && gui != nullptr )
{
if( pd == NULL )
{
pd = new QProgressDialog( tr( "Loading project..." ),
tr( "Cancel" ), 0,
_this.childNodes().count(),
Engine::getSong()->getLoadingTrackCount(),
gui->mainWindow() );
pd->setWindowModality( Qt::ApplicationModal );
pd->setWindowTitle( tr( "Please wait..." ) );
pd->show();
}
else
{
start_val = pd->value();
pd->setMaximum( pd->maximum() +
_this.childNodes().count() );
}
}

QDomNode node = _this.firstChild();
Expand All @@ -124,14 +117,21 @@ void TrackContainer::loadSettings( const QDomElement & _this )
if( node.isElement() &&
!node.toElement().attribute( "metadata" ).toInt() )
{
QString trackName = node.toElement().hasAttribute( "name" ) ?
node.toElement().attribute( "name" ) :
node.firstChild().toElement().attribute( "name" );
if( pd != NULL )
{
pd->setLabelText( tr("Loading Track %1 (%2/Total %3)").arg( trackName ).
arg( pd->value() + 1 ).arg( Engine::getSong()->getLoadingTrackCount() ) );
}
Track::create( node.toElement(), this );
}
node = node.nextSibling();
}

if( pd != NULL )
{
pd->setValue( start_val + _this.childNodes().count() );
if( was_null )
{
delete pd;
Expand Down