Skip to content
Permalink
Browse files

Moving duplicate file-related functions to QtSFileUtils (#888)

* Updating verifyPathExists functions to use the new static function in QtSFileUtils.
  • Loading branch information...
joeykleingers committed Mar 5, 2019
1 parent 5b7d839 commit 1c56b92d1290d9eb3462f92955382fe55639bc21
@@ -44,6 +44,7 @@
#include "SIMPLib/Utilities/FilePathGenerator.h"

#include "SVWidgetsLib/QtSupport/QtSFileCompleter.h"
#include "SVWidgetsLib/QtSupport/QtSFileUtils.h"

#include "OrientationAnalysis/FilterParameters/ConvertHexGridToSquareGridFilterParameter.h"
#include "OrientationAnalysis/OrientationAnalysisFilters/ConvertHexGridToSquareGrid.h"
@@ -245,30 +246,12 @@ void ConvertHexGridToSquareGridWidget::resolutionChanged(const QString& string)
emit parametersChanged();
}

// -----------------------------------------------------------------------------
//
// -----------------------------------------------------------------------------
bool ConvertHexGridToSquareGridWidget::verifyPathExists(QString outFilePath, QLineEdit* lineEdit)
{
// std::cout << "outFilePath: " << outFilePath << std::endl;
QFileInfo fileinfo(outFilePath);
if(!fileinfo.exists())
{
lineEdit->setStyleSheet("border: 1px solid red;");
}
else
{
lineEdit->setStyleSheet("");
}
return fileinfo.exists();
}

// -----------------------------------------------------------------------------
//
// -----------------------------------------------------------------------------
void ConvertHexGridToSquareGridWidget::checkIOFiles()
{
if(this->verifyPathExists(m_InputDir->text(), this->m_InputDir))
if(QtSFileUtils::VerifyPathExists(m_InputDir->text(), this->m_InputDir))
{
findMaxSliceAndPrefix();
}
@@ -296,7 +279,7 @@ void ConvertHexGridToSquareGridWidget::on_m_InputDirBtn_clicked()
// -----------------------------------------------------------------------------
void ConvertHexGridToSquareGridWidget::on_m_InputDir_textChanged(const QString& text)
{
if(verifyPathExists(m_InputDir->text(), m_InputDir))
if(QtSFileUtils::VerifyPathExists(m_InputDir->text(), m_InputDir))
{
findMaxSliceAndPrefix();
QDir dir(m_InputDir->text());
@@ -343,7 +326,7 @@ void ConvertHexGridToSquareGridWidget::on_m_OutputDirBtn_clicked()
// -----------------------------------------------------------------------------
void ConvertHexGridToSquareGridWidget::on_m_OutputDir_textChanged(const QString& text)
{
// if (verifyPathExists(text, m_OutputFile) == true )
// if (QtSFileUtils::VerifyPathExists(text, m_OutputFile) == true )
//{
// QFileInfo fi(text);
// setOpenDialogLastFilePath(fi.path());
@@ -139,14 +139,6 @@ class ConvertHexGridToSquareGridWidget : public FilterParameterWidget, private U
*/
void validateInputFile();

/**
* @brief verifyPathExists
* @param outFilePath
* @param lineEdit
* @return
*/
bool verifyPathExists(QString outFilePath, QLineEdit* lineEdit);

/**
* @brief setWidgetListEnabled
*/
@@ -331,7 +331,7 @@ void EbsdMontageImportWidget::inputDir_textChanged(const QString& text)

m_Ui->inputDir->setToolTip("Absolute File Path: " + inputPath);

if(verifyPathExists(inputPath, m_Ui->inputDir))
if(QtSFileUtils::VerifyPathExists(inputPath, m_Ui->inputDir))
{
m_ShowFileAction->setEnabled(true);
QDir dir(inputPath);
@@ -351,7 +351,7 @@ void EbsdToH5EbsdWidget::on_m_OutputFile_textChanged(const QString& text)
// -----------------------------------------------------------------------------
void EbsdToH5EbsdWidget::checkIOFiles()
{
if(this->verifyPathExists(m_LineEdit->text(), this->m_LineEdit))
if(QtSFileUtils::VerifyPathExists(m_LineEdit->text(), this->m_LineEdit))
{
findEbsdMaxSliceAndPrefix();
}
@@ -410,7 +410,7 @@ void EbsdToH5EbsdWidget::on_m_LineEdit_textChanged(const QString& text)
inputAbsPathLabel->hide();
}

if(verifyPathExists(inputPath, m_LineEdit))
if(QtSFileUtils::VerifyPathExists(inputPath, m_LineEdit))
{
m_ShowFileAction->setEnabled(true);
m_RefFrameOptionsBtn->setEnabled(true);
@@ -903,7 +903,7 @@ void EbsdToH5EbsdWidget::setInputDirectory(const QString &val)
// -----------------------------------------------------------------------------
void EbsdToH5EbsdWidget::showFileInFileSystem()
{
verifyPathExists(m_LineEdit->text(), m_LineEdit); // This basically sets an internal variable of the superclass.
QtSFileUtils::VerifyPathExists(m_LineEdit->text(), m_LineEdit); // This basically sets an internal variable of the superclass.
FilterParameterWidget::showFileInFileSystem();
#if 0
QFileInfo fi(m_CurrentlyValidPath);
@@ -335,7 +335,7 @@ void ReadH5EbsdWidget::on_m_LineEdit_textChanged(const QString& text)
absPathLabel->hide();
}

if(verifyPathExists(inputPath, m_LineEdit))
if(QtSFileUtils::VerifyPathExists(inputPath, m_LineEdit))
{
m_ShowFileAction->setEnabled(true);
}
@@ -591,7 +591,7 @@ void ReadH5EbsdWidget::updateFileInfoWidgets()
SIMPLDataPathValidator* validator = SIMPLDataPathValidator::Instance();
QString inputPath = validator->convertToAbsolutePath(m_LineEdit->text());

if(verifyPathExists(inputPath, m_LineEdit))
if(QtSFileUtils::VerifyPathExists(inputPath, m_LineEdit))
{
QFileInfo fi(inputPath);
if(fi.exists() && fi.isFile())
@@ -61,6 +61,7 @@
#include "SIMPLib/StatsData/StatsData.h"

#include "SVWidgetsLib/QtSupport/QtSFileCompleter.h"
#include "SVWidgetsLib/QtSupport/QtSFileUtils.h"

#include "SyntheticBuilding/SyntheticBuildingFilters/InitializeSyntheticVolume.h"

@@ -180,7 +181,7 @@ void InitializeSyntheticVolumeWidget::on_m_InputFile_textChanged(const QString&
{
return;
}
if(!verifyPathExists(m_InputFile->text(), m_InputFile))
if(!QtSFileUtils::VerifyPathExists(m_InputFile->text(), m_InputFile))
{
return;
}
@@ -550,24 +551,6 @@ void InitializeSyntheticVolumeWidget::estimateNumFeaturesSetup()
m_EstimatedGrains->setText(QString::number(est_nFeatures));
}

// -----------------------------------------------------------------------------
//
// -----------------------------------------------------------------------------
bool InitializeSyntheticVolumeWidget::verifyPathExists(QString outFilePath, QLineEdit* lineEdit)
{
// std::cout << "outFilePath: " << outFilePath << std::endl;
QFileInfo fileinfo(outFilePath);
if(!fileinfo.exists())
{
lineEdit->setStyleSheet("border: 1px solid red;");
}
else
{
lineEdit->setStyleSheet("");
}
return fileinfo.exists();
}

// -----------------------------------------------------------------------------
//
// -----------------------------------------------------------------------------
@@ -733,22 +716,4 @@ QFilterWidget* InitializeSyntheticVolumeWidget::createDeepCopy()
void InitializeSyntheticVolumeWidget::setShapeTypes(DataArray<unsigned int>::Pointer array)
{}

// -----------------------------------------------------------------------------
//
// -----------------------------------------------------------------------------
bool InitializeSyntheticVolumeWidget::verifyPathExists(QString outFilePath, QLineEdit* lineEdit)
{
// qDebug() << "outFilePath: " << outFilePath() << "\n";
QFileInfo fileinfo(outFilePath);
if (false == fileinfo.exists() )
{
lineEdit->setStyleSheet("border: 1px solid red;");
}
else
{
lineEdit->setStyleSheet("");
}
return fileinfo.exists();
}

#endif
@@ -105,14 +105,6 @@ class InitializeSyntheticVolumeWidget : public FilterParameterWidget, private Ui
*/
void setWidgetListEnabled(bool v);

/**
* @brief verifyPathExists
* @param outFilePath
* @param lineEdit
* @return
*/
bool verifyPathExists(QString outFilePath, QLineEdit* lineEdit);

/**
* @brief estimate_numFeatures
* @param xpoints
@@ -629,23 +629,6 @@ bool StatsGeneratorWidget::verifyOutputPathParentExists(QString outFilePath, QLi
return parent.exists();
}

// -----------------------------------------------------------------------------
//
// -----------------------------------------------------------------------------
bool StatsGeneratorWidget::verifyPathExists(const QString& outFilePath, QLineEdit* lineEdit)
{
QFileInfo fileinfo(outFilePath);
if(!fileinfo.exists())
{
lineEdit->setStyleSheet("border: 1px solid red;");
}
else
{
lineEdit->setStyleSheet("");
}
return fileinfo.exists();
}

// -----------------------------------------------------------------------------
//
// -----------------------------------------------------------------------------
@@ -104,13 +104,6 @@ protected slots:
*/
void setupGui();

/**
* @brief Verifies that a path exists on the file system.
* @param outFilePath The file path to check
* @param lineEdit The QLineEdit object to modify visuals of (Usually by placing a red line around the QLineEdit widget)
*/
bool verifyPathExists(const QString& outFilePath, QLineEdit* lineEdit);

/**
* @brief Verifies that a parent path exists on the file system.
* @param outFilePath The parent file path to check

0 comments on commit 1c56b92

Please sign in to comment.
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.