OSDN Git Service

Some tweaks to the initialization of the QFileSystem model.
authorlordmulder <mulder2@gmx.de>
Wed, 28 Mar 2012 00:21:34 +0000 (02:21 +0200)
committerlordmulder <mulder2@gmx.de>
Wed, 28 Mar 2012 00:21:34 +0000 (02:21 +0200)
src/Config.h
src/Dialog_MainWindow.cpp
src/Dialog_MainWindow.h
src/Model_FileSystem.cpp

index 9c91618..0282e09 100644 (file)
@@ -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!)
index d561a14..389eb8f 100644 (file)
@@ -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
 // =========================================================
index 485a1a6..c2d63bc 100644 (file)
@@ -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);
index f25e768..0bbaaac 100644 (file)
@@ -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;