From 6a9b5c654aaf326cb078a701eb38b2d10786bf7c Mon Sep 17 00:00:00 2001 From: Arno Date: Sun, 21 Nov 2010 09:22:22 +0100 Subject: Solved update problem during mount Keep FSWidget updated when mounting a dvd. It's an ugly hack involving changing the current directory several times, but it works... --- filesystemwidget.cpp | 27 ++++++++++++++++++++++----- 1 file changed, 22 insertions(+), 5 deletions(-) (limited to 'filesystemwidget.cpp') diff --git a/filesystemwidget.cpp b/filesystemwidget.cpp index 037c5f5..769bb50 100644 --- a/filesystemwidget.cpp +++ b/filesystemwidget.cpp @@ -429,7 +429,6 @@ void FilesystemWidget::dvdMount(){ QSettings s; QString mountDir = s.value("paths/dvdmount").toString(); if(isMounted()){ - goBack(); int retval = QProcess::execute("umount", QStringList() << mountDir); if(retval){ QString message = QString(tr("Could not unmount %1: %2")).arg(mountDir).arg(strerror(retval)); @@ -438,14 +437,32 @@ void FilesystemWidget::dvdMount(){ } emit mounted(false); }else{ - int retval = QProcess::execute("mount", QStringList() << mountDir); - if(retval){ + int retval = -1; + int ctr = 0; + while(retval){ + retval = QProcess::execute("mount", QStringList() << mountDir); + ++ctr; + if(ctr > 4){ + break; + } + } + QModelIndex mIdx = mDirProxy->mapFromSource(mModel->index(mountDir)); + mDirView->selectionModel()->setCurrentIndex(mIdx, QItemSelectionModel::ClearAndSelect); + if(!isMounted()){ QString message = QString(tr("Could not mount %1: %2")).arg(mountDir).arg(strerror(retval)); QMessageBox::critical(this, tr("Error"), message); + emit mounted(isMounted()); return; } - QModelIndex mountIdx = mModel->index(mountDir); - emit mounted(true); + //ugly hack to update QFileSytemModel + QString tDirPath = mLastDir.isEmpty() ? QDir::homePath() : mLastDir; + QModelIndex tIdx = mDirProxy->mapFromSource(mModel->index(tDirPath)); + mDirView->selectionModel()->setCurrentIndex(tIdx, QItemSelectionModel::ClearAndSelect); + mDirView->selectionModel()->setCurrentIndex(mIdx, QItemSelectionModel::ClearAndSelect); + mDirView->selectionModel()->setCurrentIndex(tIdx, QItemSelectionModel::ClearAndSelect); + mDirView->selectionModel()->setCurrentIndex(mIdx, QItemSelectionModel::ClearAndSelect); + mDirView->expand(mIdx); + emit mounted(isMounted()); } } -- cgit v1.2.3-70-g09d2