From 47f0f1629cb785638b5d4d02c2d41bfea83ba6a6 Mon Sep 17 00:00:00 2001 From: lordmulder Date: Wed, 28 Mar 2012 02:21:34 +0200 Subject: [PATCH] Some tweaks to the initialization of the QFileSystem model. --- src/Config.h | 2 +- src/Dialog_MainWindow.cpp | 27 ++++++++++++++++++++------- src/Dialog_MainWindow.h | 1 + src/Model_FileSystem.cpp | 3 +-- 4 files changed, 23 insertions(+), 10 deletions(-) diff --git a/src/Config.h b/src/Config.h index 9c916188..0282e094 100644 --- a/src/Config.h +++ b/src/Config.h @@ -30,7 +30,7 @@ #define VER_LAMEXP_MINOR_LO 4 #define VER_LAMEXP_TYPE Beta #define VER_LAMEXP_PATCH 9 -#define VER_LAMEXP_BUILD 925 +#define VER_LAMEXP_BUILD 927 /////////////////////////////////////////////////////////////////////////////// // Tool versions (minimum expected versions!) diff --git a/src/Dialog_MainWindow.cpp b/src/Dialog_MainWindow.cpp index d561a14b..389eb8f8 100644 --- a/src/Dialog_MainWindow.cpp +++ b/src/Dialog_MainWindow.cpp @@ -1435,6 +1435,10 @@ void MainWindow::tabPageChanged(int idx) { QTimer::singleShot(0, this, SLOT(initOutputFolderModel())); } + else + { + QTimer::singleShot(0, this, SLOT(centerOutputFolderModel())); + } } if(initialWidth < this->width()) @@ -2616,7 +2620,7 @@ void MainWindow::outputFolderEditFinished(void) QFileInfo info(text); if(info.exists() && info.isDir()) { - QModelIndex index = m_fileSystemModel->index(info.canonicalFilePath()); + QModelIndex index = m_fileSystemModel->index(QFileInfo(info.canonicalFilePath()).absoluteFilePath()); if(index.isValid()) { ok = true; @@ -2626,7 +2630,7 @@ void MainWindow::outputFolderEditFinished(void) } else if(info.exists() && info.isFile()) { - QModelIndex index = m_fileSystemModel->index(info.canonicalPath()); + QModelIndex index = m_fileSystemModel->index(QFileInfo(info.canonicalFilePath()).absoluteFilePath()); if(index.isValid()) { ok = true; @@ -2650,14 +2654,23 @@ void MainWindow::outputFolderEditFinished(void) */ void MainWindow::initOutputFolderModel(void) { - QModelIndex previousIndex = outputFolderView->currentIndex(); - m_fileSystemModel->setRootPath(m_fileSystemModel->rootPath()); - QApplication::processEvents(); - outputFolderView->reset(); - outputFolderView->setCurrentIndex(previousIndex); + //QModelIndex previousIndex = outputFolderView->currentIndex(); + //outputFolderView->reset(); + //QApplication::processEvents(QEventLoop::ExcludeUserInputEvents); + //outputFolderView->setCurrentIndex(previousIndex); + //QTimer::singleShot(125, this, SLOT(centerOutputFolderModel())); + + m_fileSystemModel->setRootPath(""); + QTimer::singleShot(333, this, SLOT(centerOutputFolderModel())); m_OutputFolderViewInitialized = true; } +void MainWindow::centerOutputFolderModel(void) +{ + outputFolderView->scrollTo(outputFolderView->currentIndex(), QAbstractItemView::PositionAtCenter); + outputFolderView->setFocus(); +} + // ========================================================= // Metadata tab slots // ========================================================= diff --git a/src/Dialog_MainWindow.h b/src/Dialog_MainWindow.h index 485a1a6a..c2d63bc4 100644 --- a/src/Dialog_MainWindow.h +++ b/src/Dialog_MainWindow.h @@ -62,6 +62,7 @@ private slots: void bitrateManagementMaxChanged(int value); void bitrateManagementMinChanged(int value); void browseCustomTempFolderButtonClicked(void); + void centerOutputFolderModel(void); void channelModeChanged(int value); void checkForBetaUpdatesActionTriggered(bool checked); void checkUpdatesActionActivated(void); diff --git a/src/Model_FileSystem.cpp b/src/Model_FileSystem.cpp index f25e768e..0bbaaac7 100644 --- a/src/Model_FileSystem.cpp +++ b/src/Model_FileSystem.cpp @@ -154,8 +154,7 @@ bool QFileSystemModelEx::hasChildren(const QModelIndex &parent) const { if(parent.isValid()) { - QDir dir = QDir(QFileSystemModel::filePath(parent)); - return dir.exists() && (dir.entryList(QDir::Dirs | QDir::NoDotAndDotDot).count() > 0); + return (QDir(QFileSystemModel::filePath(parent)).entryList(QDir::Dirs | QDir::NoDotAndDotDot).count() > 0); } return true; -- 2.11.0