2018-01-10 06:55:48 -06:00
|
|
|
/////////////////////////////////////////////////////////////////////////////////
|
|
|
|
//
|
|
|
|
// Copyright (C) 2017- Statoil ASA
|
2019-09-06 03:40:57 -05:00
|
|
|
//
|
2018-01-10 06:55:48 -06:00
|
|
|
// ResInsight 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 3 of the License, or
|
|
|
|
// (at your option) any later version.
|
2019-09-06 03:40:57 -05:00
|
|
|
//
|
2018-01-10 06:55:48 -06:00
|
|
|
// ResInsight 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.
|
2019-09-06 03:40:57 -05:00
|
|
|
//
|
|
|
|
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
2018-01-10 06:55:48 -06:00
|
|
|
// for more details.
|
|
|
|
//
|
|
|
|
/////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "Rim3dOverlayInfoConfig.h"
|
|
|
|
|
|
|
|
#include "cafPdmPointer.h"
|
|
|
|
|
|
|
|
#include <QDialog>
|
|
|
|
|
|
|
|
class QLabel;
|
|
|
|
class QLineEdit;
|
2018-01-16 06:37:57 -06:00
|
|
|
class QTextEdit;
|
2018-01-10 06:55:48 -06:00
|
|
|
class QDialogButtonBox;
|
|
|
|
class QPushButton;
|
|
|
|
class QMainWindow;
|
2018-01-24 03:43:31 -06:00
|
|
|
class QListWidget;
|
2019-08-19 04:09:59 -05:00
|
|
|
class QGroupBox;
|
2020-11-10 11:34:17 -06:00
|
|
|
class QComboBox;
|
2020-11-11 04:45:08 -06:00
|
|
|
class QCheckBox;
|
2019-08-19 04:09:59 -05:00
|
|
|
|
2019-08-16 07:10:45 -05:00
|
|
|
class RicRecursiveFileSearchDialogResult;
|
2018-01-10 06:55:48 -06:00
|
|
|
|
|
|
|
//==================================================================================================
|
2019-09-06 03:40:57 -05:00
|
|
|
///
|
2018-01-10 06:55:48 -06:00
|
|
|
//==================================================================================================
|
2019-08-16 07:10:45 -05:00
|
|
|
class RicRecursiveFileSearchDialog : public QDialog
|
2018-01-10 06:55:48 -06:00
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
enum Status
|
|
|
|
{
|
|
|
|
SEARCHING_FOR_DIRS,
|
|
|
|
SEARCHING_FOR_FILES,
|
|
|
|
NO_FILES_FOUND
|
|
|
|
};
|
2018-01-24 03:43:31 -06:00
|
|
|
|
2018-01-10 06:55:48 -06:00
|
|
|
public:
|
2019-09-06 03:40:57 -05:00
|
|
|
static RicRecursiveFileSearchDialogResult runRecursiveSearchDialog( QWidget* parent = nullptr,
|
|
|
|
const QString& caption = QString(),
|
|
|
|
const QString& dir = QString(),
|
|
|
|
const QString& pathFilter = QString(),
|
|
|
|
const QString& fileNameFilter = QString(),
|
|
|
|
const QStringList& fileExtensions = QStringList() );
|
2018-01-10 06:55:48 -06:00
|
|
|
|
|
|
|
private:
|
2019-09-06 03:40:57 -05:00
|
|
|
RicRecursiveFileSearchDialog( QWidget* parent );
|
2019-08-19 04:44:19 -05:00
|
|
|
~RicRecursiveFileSearchDialog() override;
|
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
QString cleanTextFromPathFilterField() const;
|
|
|
|
QString rootDirWithEndSeparator() const;
|
|
|
|
QString pathFilterWithoutStartSeparator() const;
|
|
|
|
QString fileNameFilter() const;
|
2019-08-19 04:44:19 -05:00
|
|
|
|
2018-01-24 03:43:31 -06:00
|
|
|
QStringList fileExtensions() const;
|
2018-04-30 07:57:43 -05:00
|
|
|
QString extensionFromFileNameFilter() const;
|
2021-09-21 15:27:36 -05:00
|
|
|
bool groupByIteration() const;
|
2018-04-30 07:57:43 -05:00
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
void setOkButtonEnabled( bool enabled );
|
|
|
|
void warningIfInvalidCharacters();
|
|
|
|
void updateEffectiveFilter();
|
|
|
|
void updateStatus( Status status, const QString& extraText = "" );
|
2018-01-24 03:43:31 -06:00
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
void updateFileListWidget();
|
|
|
|
void clearFileList();
|
2021-09-21 15:27:36 -05:00
|
|
|
void addToFileListWidget( const QStringList& fileNames );
|
2018-01-16 06:37:57 -06:00
|
|
|
|
2019-08-19 04:44:19 -05:00
|
|
|
// File search methods
|
2018-04-24 10:49:47 -05:00
|
|
|
|
2020-11-11 04:45:08 -06:00
|
|
|
QStringList findMatchingFiles();
|
|
|
|
void buildDirectoryListRecursiveSimple( const QString& currentDir,
|
|
|
|
const QString& currentPathFilter,
|
|
|
|
QStringList* accumulatedDirs );
|
|
|
|
QStringList findFilesInDirs( const QStringList& dirs );
|
|
|
|
QStringList createFileNameFilterList();
|
|
|
|
static QString replaceWithRealizationStar( const QString& text );
|
2018-01-10 06:55:48 -06:00
|
|
|
|
2021-09-09 04:19:22 -05:00
|
|
|
static void populateComboBoxHistoryFromRegistry( QComboBox* comboBox, const QString& registryKey );
|
|
|
|
|
2018-01-10 06:55:48 -06:00
|
|
|
private slots:
|
2021-09-09 04:19:22 -05:00
|
|
|
void slotPathFilterChanged( const QString& text );
|
|
|
|
void slotFileFilterChanged( const QString& text );
|
2019-08-19 04:44:19 -05:00
|
|
|
void slotBrowseButtonClicked();
|
2020-11-11 04:45:08 -06:00
|
|
|
void slotUseRealizationStarClicked();
|
2019-08-19 04:44:19 -05:00
|
|
|
void slotFindOrCancelButtonClicked();
|
2019-09-06 03:40:57 -05:00
|
|
|
|
|
|
|
void slotFileListCustomMenuRequested( const QPoint& point );
|
2019-08-19 04:44:19 -05:00
|
|
|
void slotCopyFileItemText();
|
2018-01-24 05:35:47 -06:00
|
|
|
void slotToggleFileListItems();
|
|
|
|
void slotTurnOffFileListItems();
|
|
|
|
void slotTurnOnFileListItems();
|
2019-08-16 03:07:39 -05:00
|
|
|
|
2018-01-10 06:55:48 -06:00
|
|
|
void slotDialogOkClicked();
|
|
|
|
void slotDialogCancelClicked();
|
|
|
|
|
|
|
|
private:
|
2019-09-06 03:40:57 -05:00
|
|
|
QLabel* m_pathFilterLabel;
|
2020-11-10 11:34:17 -06:00
|
|
|
QComboBox* m_pathFilterField;
|
2019-09-06 03:40:57 -05:00
|
|
|
QPushButton* m_browseButton;
|
2020-11-11 04:45:08 -06:00
|
|
|
QCheckBox* m_useRealizationStarCheckBox;
|
2021-09-21 15:27:36 -05:00
|
|
|
QCheckBox* m_groupByIterationCheckBox;
|
2018-01-10 06:55:48 -06:00
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
QLabel* m_fileFilterLabel;
|
2021-09-09 04:19:22 -05:00
|
|
|
QComboBox* m_fileFilterField;
|
2018-01-10 06:55:48 -06:00
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
QLabel* m_effectiveFilterLabel;
|
|
|
|
QLabel* m_effectiveFilterContentLabel;
|
|
|
|
QPushButton* m_findOrCancelButton;
|
2018-01-16 06:37:57 -06:00
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
QGroupBox* m_outputGroup;
|
|
|
|
QLabel* m_searchRootLabel;
|
|
|
|
QLabel* m_searchRootContentLabel;
|
|
|
|
QListWidget* m_fileListWidget;
|
2018-01-16 06:37:57 -06:00
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
QDialogButtonBox* m_buttons;
|
2018-01-10 06:55:48 -06:00
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
QStringList m_foundFiles;
|
|
|
|
QStringList m_fileExtensions;
|
2018-01-16 06:37:57 -06:00
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
bool m_isCancelPressed;
|
2019-08-19 04:44:19 -05:00
|
|
|
|
|
|
|
// Obsolete. Here for reference if this search mode is needed later
|
2019-09-06 03:40:57 -05:00
|
|
|
QStringList buildDirectoryListRecursive( const QString& currentDir, int level = 0 );
|
|
|
|
bool pathFilterMatch( const QString& pathFilter, const QString& relPath );
|
2018-01-10 06:55:48 -06:00
|
|
|
};
|
|
|
|
|
|
|
|
//==================================================================================================
|
2019-09-06 03:40:57 -05:00
|
|
|
///
|
2018-01-10 06:55:48 -06:00
|
|
|
//==================================================================================================
|
2019-08-16 07:10:45 -05:00
|
|
|
class RicRecursiveFileSearchDialogResult
|
2018-01-10 06:55:48 -06:00
|
|
|
{
|
|
|
|
public:
|
2019-09-06 03:40:57 -05:00
|
|
|
RicRecursiveFileSearchDialogResult( bool ok,
|
|
|
|
const QStringList& files,
|
|
|
|
const QString& rootDir,
|
|
|
|
const QString& pathFilter,
|
2021-09-21 15:27:36 -05:00
|
|
|
const QString& fileNameFilter,
|
|
|
|
bool groupByIteration )
|
2019-09-06 03:40:57 -05:00
|
|
|
: ok( ok )
|
|
|
|
, files( files )
|
|
|
|
, rootDir( rootDir )
|
|
|
|
, pathFilter( pathFilter )
|
|
|
|
, fileNameFilter( fileNameFilter )
|
2021-09-21 15:27:36 -05:00
|
|
|
, groupByIteration( groupByIteration )
|
2019-09-06 03:40:57 -05:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
bool ok;
|
|
|
|
QStringList files;
|
|
|
|
QString rootDir;
|
|
|
|
QString pathFilter;
|
|
|
|
QString fileNameFilter;
|
2021-09-21 15:27:36 -05:00
|
|
|
bool groupByIteration;
|
2020-11-10 11:34:17 -06:00
|
|
|
};
|