summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--filesystemwidget.cpp27
1 files changed, 22 insertions, 5 deletions
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());
}
}