Implement a custom FileSystemModel class derived from QFileSystemModel in order to avoid "+" button in front of folders without sub-dirs.
This commit is contained in:
parent
571df62e39
commit
4936d58092
@ -350,6 +350,10 @@
|
||||
RelativePath=".\src\Model_FileList.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\src\Model_FileSystem.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\src\Model_MetaInfo.cpp"
|
||||
>
|
||||
@ -435,7 +439,7 @@
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"
|
||||
Description="MOC "$(SolutionDir)tmp\MOC_$(SafeInputName).cpp""
|
||||
CommandLine=""$(QTDIR)\bin\moc.exe" -o "$(SolutionDir)tmp\MOC_$(SafeInputName).cpp" "$(InputPath)""
|
||||
CommandLine=""$(QTDIR)\bin\moc.exe" -o "$(SolutionDir)tmp\MOC_$(SafeInputName).cpp" "$(InputPath)"
"
|
||||
Outputs=""$(SolutionDir)tmp\MOC_$(SafeInputName).cpp""
|
||||
/>
|
||||
</FileConfiguration>
|
||||
@ -445,7 +449,7 @@
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"
|
||||
Description="MOC "$(SolutionDir)tmp\MOC_$(SafeInputName).cpp""
|
||||
CommandLine=""$(QTDIR)\bin\moc.exe" -o "$(SolutionDir)tmp\MOC_$(SafeInputName).cpp" "$(InputPath)""
|
||||
CommandLine=""$(QTDIR)\bin\moc.exe" -o "$(SolutionDir)tmp\MOC_$(SafeInputName).cpp" "$(InputPath)"
"
|
||||
Outputs=""$(SolutionDir)tmp\MOC_$(SafeInputName).cpp""
|
||||
/>
|
||||
</FileConfiguration>
|
||||
@ -455,7 +459,7 @@
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"
|
||||
Description="MOC "$(SolutionDir)tmp\MOC_$(SafeInputName).cpp""
|
||||
CommandLine=""$(QTDIR)\bin\moc.exe" -o "$(SolutionDir)tmp\MOC_$(SafeInputName).cpp" "$(InputPath)""
|
||||
CommandLine=""$(QTDIR)\bin\moc.exe" -o "$(SolutionDir)tmp\MOC_$(SafeInputName).cpp" "$(InputPath)"
"
|
||||
Outputs=""$(SolutionDir)tmp\MOC_$(SafeInputName).cpp""
|
||||
/>
|
||||
</FileConfiguration>
|
||||
@ -748,6 +752,10 @@
|
||||
/>
|
||||
</FileConfiguration>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\src\Model_FileSystem.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\src\Model_MetaInfo.h"
|
||||
>
|
||||
@ -1215,7 +1223,7 @@
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"
|
||||
Description="UIC "$(SolutionDir)tmp\UIC_$(SafeInputName).h""
|
||||
CommandLine=""$(QTDIR)\bin\uic.exe" -o "$(SolutionDir)tmp\UIC_$(SafeInputName).h" "$(InputPath)""
|
||||
CommandLine=""$(QTDIR)\bin\uic.exe" -o "$(SolutionDir)tmp\UIC_$(SafeInputName).h" "$(InputPath)"
"
|
||||
Outputs=""$(SolutionDir)tmp\UIC_$(SafeInputName).h""
|
||||
/>
|
||||
</FileConfiguration>
|
||||
@ -1225,7 +1233,7 @@
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"
|
||||
Description="UIC "$(SolutionDir)tmp\UIC_$(SafeInputName).h""
|
||||
CommandLine=""$(QTDIR)\bin\uic.exe" -o "$(SolutionDir)tmp\UIC_$(SafeInputName).h" "$(InputPath)""
|
||||
CommandLine=""$(QTDIR)\bin\uic.exe" -o "$(SolutionDir)tmp\UIC_$(SafeInputName).h" "$(InputPath)"
"
|
||||
Outputs=""$(SolutionDir)tmp\UIC_$(SafeInputName).h""
|
||||
/>
|
||||
</FileConfiguration>
|
||||
@ -1235,7 +1243,7 @@
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"
|
||||
Description="UIC "$(SolutionDir)tmp\UIC_$(SafeInputName).h""
|
||||
CommandLine=""$(QTDIR)\bin\uic.exe" -o "$(SolutionDir)tmp\UIC_$(SafeInputName).h" "$(InputPath)""
|
||||
CommandLine=""$(QTDIR)\bin\uic.exe" -o "$(SolutionDir)tmp\UIC_$(SafeInputName).h" "$(InputPath)"
"
|
||||
Outputs=""$(SolutionDir)tmp\UIC_$(SafeInputName).h""
|
||||
/>
|
||||
</FileConfiguration>
|
||||
|
@ -361,7 +361,7 @@
|
||||
<item>
|
||||
<widget class="QCheckBox" name="saveToSourceFolderCheckBox">
|
||||
<property name="text">
|
||||
<string>Save output files to the same location where the input file is loacated</string>
|
||||
<string>Save output files to the same location where the input file is located</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
@ -1348,6 +1348,8 @@
|
||||
<include location="../res/Images.qrc"/>
|
||||
<include location="../res/Icons.qrc"/>
|
||||
<include location="../res/Images.qrc"/>
|
||||
<include location="../res/Icons.qrc"/>
|
||||
<include location="../res/Images.qrc"/>
|
||||
</resources>
|
||||
<connections>
|
||||
<connection>
|
||||
|
@ -182,7 +182,7 @@
|
||||
<item>
|
||||
<widget class="QLabel" name="label_headerStatus">
|
||||
<property name="text">
|
||||
<string><b>Encoding Files</b><br>Your files are being encoded, please be pateint...</string>
|
||||
<string><b>Encoding Files</b><br>Your files are being encoded, please be patient...</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
@ -434,6 +434,8 @@
|
||||
<include location="../res/Images.qrc"/>
|
||||
<include location="../res/Icons.qrc"/>
|
||||
<include location="../res/Images.qrc"/>
|
||||
<include location="../res/Icons.qrc"/>
|
||||
<include location="../res/Images.qrc"/>
|
||||
</resources>
|
||||
<connections>
|
||||
<connection>
|
||||
|
@ -25,7 +25,7 @@
|
||||
#define VER_LAMEXP_MAJOR 4
|
||||
#define VER_LAMEXP_MINOR_HI 0
|
||||
#define VER_LAMEXP_MINOR_LO 0
|
||||
#define VER_LAMEXP_BUILD 74
|
||||
#define VER_LAMEXP_BUILD 76
|
||||
#define VER_LAMEXP_SUFFIX TechPreview
|
||||
|
||||
/*
|
||||
|
@ -32,6 +32,7 @@
|
||||
#include "Model_MetaInfo.h"
|
||||
#include "Model_Settings.h"
|
||||
#include "Model_FileList.h"
|
||||
#include "Model_FileSystem.h"
|
||||
#include "Encoder_MP3.h"
|
||||
|
||||
//Qt includes
|
||||
@ -129,8 +130,7 @@ MainWindow::MainWindow(FileListModel *fileListModel, AudioFileModel *metaInfo, S
|
||||
connect(m_fileListModel, SIGNAL(modelReset()), this, SLOT(sourceModelChanged()));
|
||||
|
||||
//Setup "Output" tab
|
||||
m_fileSystemModel = new QFileSystemModel();
|
||||
m_fileSystemModel->setFilter(QDir::Dirs | QDir::NoDotAndDotDot);
|
||||
m_fileSystemModel = new QFileSystemModelEx();
|
||||
m_fileSystemModel->setRootPath(m_fileSystemModel->rootPath());
|
||||
m_fileSystemModel->installEventFilter(this);
|
||||
outputFolderView->setModel(m_fileSystemModel);
|
||||
@ -396,10 +396,10 @@ void MainWindow::resizeEvent(QResizeEvent *event)
|
||||
|
||||
bool MainWindow::eventFilter(QObject *obj, QEvent *event)
|
||||
{
|
||||
if(obj == m_fileSystemModel)
|
||||
if(obj == m_fileSystemModel && QApplication::overrideCursor() == NULL)
|
||||
{
|
||||
QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
|
||||
QTimer::singleShot(0, this, SLOT(restoreCursor()));
|
||||
QTimer::singleShot(250, this, SLOT(restoreCursor()));
|
||||
}
|
||||
|
||||
return false;
|
||||
@ -763,7 +763,7 @@ void MainWindow::makeFolderButtonClicked(void)
|
||||
{
|
||||
ABORT_IF_BUSY;
|
||||
|
||||
QDir basePath(m_fileSystemModel->filePath(outputFolderView->currentIndex()));
|
||||
QDir basePath(m_fileSystemModel->fileInfo(outputFolderView->currentIndex()).absoluteFilePath());
|
||||
|
||||
bool bApplied = true;
|
||||
QString folderName = QInputDialog::getText(this, "New Folder", "Enter the name of the new folder:", QLineEdit::Normal, "New folder", &bApplied, Qt::WindowStaysOnTopHint).simplified();
|
||||
@ -798,7 +798,7 @@ void MainWindow::makeFolderButtonClicked(void)
|
||||
}
|
||||
else
|
||||
{
|
||||
QMessageBox::warning(this, "Failed to create folder", QString("The folder '%1' could not be created!").arg(newFolder));
|
||||
QMessageBox::warning(this, "Failed to create folder", QString("The new folder could not be created:<br><nobr>%1</nobr><br><br>Drive is read-only or insufficient access rights!").arg(basePath.absoluteFilePath(newFolder)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -23,10 +23,8 @@
|
||||
|
||||
#include "../tmp/UIC_MainWindow.h"
|
||||
|
||||
//#include "Model_FileList.h"
|
||||
|
||||
//Class declarations
|
||||
class QFileSystemModel;
|
||||
class QFileSystemModelEx;
|
||||
class WorkingBanner;
|
||||
class MessageHandlerThread;
|
||||
class AudioFileModel;
|
||||
@ -96,7 +94,7 @@ private:
|
||||
bool m_accepted;
|
||||
bool m_firstTimeShown;
|
||||
FileListModel *m_fileListModel;
|
||||
QFileSystemModel *m_fileSystemModel;
|
||||
QFileSystemModelEx *m_fileSystemModel;
|
||||
QActionGroup *m_tabActionGroup;
|
||||
QActionGroup *m_styleActionGroup;
|
||||
QButtonGroup *m_encoderButtonGroup;
|
||||
|
47
src/Model_FileSystem.cpp
Normal file
47
src/Model_FileSystem.cpp
Normal file
@ -0,0 +1,47 @@
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// LameXP - Audio Encoder Front-End
|
||||
// Copyright (C) 2004-2010 LoRd_MuldeR <MuldeR2@GMX.de>
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation; either version 2 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License along
|
||||
// with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
//
|
||||
// http://www.gnu.org/licenses/gpl-2.0.txt
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "Model_FileSystem.h"
|
||||
|
||||
#include <QApplication>
|
||||
|
||||
QFileSystemModelEx::QFileSystemModelEx()
|
||||
:
|
||||
QFileSystemModel()
|
||||
{
|
||||
this->setFilter(QDir::Dirs | QDir::NoDotAndDotDot);
|
||||
}
|
||||
|
||||
bool QFileSystemModelEx::hasChildren(const QModelIndex &parent) const
|
||||
{
|
||||
bool result = QFileSystemModel::hasChildren(parent);
|
||||
|
||||
if(parent.isValid() && result)
|
||||
{
|
||||
QFileInfo fileInfo = QFileSystemModel::fileInfo(parent);
|
||||
if(fileInfo.isDir())
|
||||
{
|
||||
result = (QDir(fileInfo.absoluteFilePath()).entryInfoList(QDir::Dirs | QDir::NoDotAndDotDot).count() > 0);
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
31
src/Model_FileSystem.h
Normal file
31
src/Model_FileSystem.h
Normal file
@ -0,0 +1,31 @@
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// LameXP - Audio Encoder Front-End
|
||||
// Copyright (C) 2004-2010 LoRd_MuldeR <MuldeR2@GMX.de>
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation; either version 2 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License along
|
||||
// with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
//
|
||||
// http://www.gnu.org/licenses/gpl-2.0.txt
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <QFileSystemModel>
|
||||
|
||||
class QFileSystemModelEx : public QFileSystemModel
|
||||
{
|
||||
public:
|
||||
QFileSystemModelEx();
|
||||
virtual bool hasChildren(const QModelIndex &parent = QModelIndex()) const;
|
||||
};
|
Loading…
Reference in New Issue
Block a user