mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
#6963 Import Dialog : Add recently used folders and search terms in registry
This commit is contained in:
parent
7f3df954ad
commit
e9656cc167
@ -20,6 +20,7 @@
|
|||||||
|
|
||||||
#include "RiaFilePathTools.h"
|
#include "RiaFilePathTools.h"
|
||||||
#include "RiaGuiApplication.h"
|
#include "RiaGuiApplication.h"
|
||||||
|
#include "RiaStringListSerializer.h"
|
||||||
|
|
||||||
#include "RiuFileDialogTools.h"
|
#include "RiuFileDialogTools.h"
|
||||||
#include "RiuTools.h"
|
#include "RiuTools.h"
|
||||||
@ -27,6 +28,7 @@
|
|||||||
#include <QAbstractItemView>
|
#include <QAbstractItemView>
|
||||||
#include <QAction>
|
#include <QAction>
|
||||||
#include <QClipboard>
|
#include <QClipboard>
|
||||||
|
#include <QComboBox>
|
||||||
#include <QDialogButtonBox>
|
#include <QDialogButtonBox>
|
||||||
#include <QDir>
|
#include <QDir>
|
||||||
#include <QGroupBox>
|
#include <QGroupBox>
|
||||||
@ -41,6 +43,7 @@
|
|||||||
#include <QToolTip>
|
#include <QToolTip>
|
||||||
#include <QVBoxLayout>
|
#include <QVBoxLayout>
|
||||||
|
|
||||||
|
#include <algorithm>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#define RECURSIVE_FILESEARCH_DEFAULT_DIALOG_HEIGHT 350
|
#define RECURSIVE_FILESEARCH_DEFAULT_DIALOG_HEIGHT 350
|
||||||
@ -70,7 +73,25 @@ RicRecursiveFileSearchDialogResult RicRecursiveFileSearchDialog::runRecursiveSea
|
|||||||
QString pathFilterText = dir;
|
QString pathFilterText = dir;
|
||||||
RiaFilePathTools::appendSeparatorIfNo( pathFilterText );
|
RiaFilePathTools::appendSeparatorIfNo( pathFilterText );
|
||||||
pathFilterText += pathFilter;
|
pathFilterText += pathFilter;
|
||||||
dialog.m_pathFilterField->setText( QDir::toNativeSeparators( pathFilterText ) );
|
|
||||||
|
const QString completeRegistryKey = QString( "RicRecursiveFileSearchDialog %1" ).arg( caption ).replace( " ", "_" );
|
||||||
|
const int maxItemsInRegistry = 10;
|
||||||
|
|
||||||
|
{
|
||||||
|
RiaStringListSerializer stringListSerializer( completeRegistryKey );
|
||||||
|
QStringList files = stringListSerializer.textStrings();
|
||||||
|
|
||||||
|
int numRecentFiles = std::min( files.size(), maxItemsInRegistry );
|
||||||
|
for ( int i = 0; i < numRecentFiles; i++ )
|
||||||
|
{
|
||||||
|
dialog.m_pathFilterField->addItem( files[i] );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
dialog.m_pathFilterField->addItem( QDir::toNativeSeparators( pathFilterText ) );
|
||||||
|
dialog.m_pathFilterField->setCurrentText( QDir::toNativeSeparators( pathFilterText ) );
|
||||||
|
|
||||||
|
dialog.m_pathFilterField->setEditable( true );
|
||||||
dialog.m_fileFilterField->setText( fileNameFilter );
|
dialog.m_fileFilterField->setText( fileNameFilter );
|
||||||
dialog.m_fileExtensions = trimLeftStrings( fileExtensions, "." );
|
dialog.m_fileExtensions = trimLeftStrings( fileExtensions, "." );
|
||||||
|
|
||||||
@ -81,6 +102,12 @@ RicRecursiveFileSearchDialogResult RicRecursiveFileSearchDialog::runRecursiveSea
|
|||||||
dialog.resize( 800, 150 );
|
dialog.resize( 800, 150 );
|
||||||
dialog.exec();
|
dialog.exec();
|
||||||
|
|
||||||
|
if ( dialog.result() == QDialog::Accepted )
|
||||||
|
{
|
||||||
|
RiaStringListSerializer stringListSerializer( completeRegistryKey );
|
||||||
|
stringListSerializer.addString( dialog.m_pathFilterField->currentText(), maxItemsInRegistry );
|
||||||
|
}
|
||||||
|
|
||||||
return RicRecursiveFileSearchDialogResult( dialog.result() == QDialog::Accepted,
|
return RicRecursiveFileSearchDialogResult( dialog.result() == QDialog::Accepted,
|
||||||
dialog.m_foundFiles,
|
dialog.m_foundFiles,
|
||||||
dialog.rootDirWithEndSeparator(),
|
dialog.rootDirWithEndSeparator(),
|
||||||
@ -97,7 +124,7 @@ RicRecursiveFileSearchDialog::RicRecursiveFileSearchDialog( QWidget* parent )
|
|||||||
// Create widgets
|
// Create widgets
|
||||||
m_browseButton = new QPushButton();
|
m_browseButton = new QPushButton();
|
||||||
m_pathFilterLabel = new QLabel();
|
m_pathFilterLabel = new QLabel();
|
||||||
m_pathFilterField = new QLineEdit();
|
m_pathFilterField = new QComboBox();
|
||||||
m_fileFilterLabel = new QLabel();
|
m_fileFilterLabel = new QLabel();
|
||||||
m_fileFilterField = new QLineEdit();
|
m_fileFilterField = new QLineEdit();
|
||||||
m_effectiveFilterLabel = new QLabel();
|
m_effectiveFilterLabel = new QLabel();
|
||||||
@ -110,7 +137,15 @@ RicRecursiveFileSearchDialog::RicRecursiveFileSearchDialog( QWidget* parent )
|
|||||||
m_buttons = new QDialogButtonBox( QDialogButtonBox::Ok | QDialogButtonBox::Cancel );
|
m_buttons = new QDialogButtonBox( QDialogButtonBox::Ok | QDialogButtonBox::Cancel );
|
||||||
|
|
||||||
// Connect to signals
|
// Connect to signals
|
||||||
connect( m_pathFilterField, SIGNAL( textChanged( const QString& ) ), this, SLOT( slotFilterChanged( const QString& ) ) );
|
connect( m_pathFilterField,
|
||||||
|
SIGNAL( currentTextChanged( const QString& ) ),
|
||||||
|
this,
|
||||||
|
SLOT( slotFilterChanged( const QString& ) ) );
|
||||||
|
connect( m_pathFilterField,
|
||||||
|
SIGNAL( editTextChanged( const QString& ) ),
|
||||||
|
this,
|
||||||
|
SLOT( slotFilterChanged( const QString& ) ) );
|
||||||
|
|
||||||
connect( m_fileFilterField, SIGNAL( textChanged( const QString& ) ), this, SLOT( slotFilterChanged( const QString& ) ) );
|
connect( m_fileFilterField, SIGNAL( textChanged( const QString& ) ), this, SLOT( slotFilterChanged( const QString& ) ) );
|
||||||
|
|
||||||
connect( m_fileListWidget,
|
connect( m_fileListWidget,
|
||||||
@ -221,7 +256,7 @@ RicRecursiveFileSearchDialog::~RicRecursiveFileSearchDialog()
|
|||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
QString RicRecursiveFileSearchDialog::cleanTextFromPathFilterField() const
|
QString RicRecursiveFileSearchDialog::cleanTextFromPathFilterField() const
|
||||||
{
|
{
|
||||||
QString pathFilterText = m_pathFilterField->text().trimmed();
|
QString pathFilterText = m_pathFilterField->currentText().trimmed();
|
||||||
pathFilterText = RiaFilePathTools::toInternalSeparator( pathFilterText );
|
pathFilterText = RiaFilePathTools::toInternalSeparator( pathFilterText );
|
||||||
pathFilterText = RiaFilePathTools::removeDuplicatePathSeparators( pathFilterText );
|
pathFilterText = RiaFilePathTools::removeDuplicatePathSeparators( pathFilterText );
|
||||||
pathFilterText.replace( QString( "**" ), QString( "*" ) );
|
pathFilterText.replace( QString( "**" ), QString( "*" ) );
|
||||||
@ -715,7 +750,11 @@ void RicRecursiveFileSearchDialog::slotBrowseButtonClicked()
|
|||||||
QString folder = RiuFileDialogTools::getExistingDirectory( this, "Select folder", rootDirWithEndSeparator() );
|
QString folder = RiuFileDialogTools::getExistingDirectory( this, "Select folder", rootDirWithEndSeparator() );
|
||||||
RiaFilePathTools::appendSeparatorIfNo( folder );
|
RiaFilePathTools::appendSeparatorIfNo( folder );
|
||||||
folder += "*";
|
folder += "*";
|
||||||
if ( !folder.isEmpty() ) m_pathFilterField->setText( QDir::toNativeSeparators( folder ) );
|
if ( !folder.isEmpty() )
|
||||||
|
{
|
||||||
|
m_pathFilterField->addItem( QDir::toNativeSeparators( folder ) );
|
||||||
|
m_pathFilterField->setCurrentText( QDir::toNativeSeparators( folder ) );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
@ -32,6 +32,7 @@ class QPushButton;
|
|||||||
class QMainWindow;
|
class QMainWindow;
|
||||||
class QListWidget;
|
class QListWidget;
|
||||||
class QGroupBox;
|
class QGroupBox;
|
||||||
|
class QComboBox;
|
||||||
|
|
||||||
class RicRecursiveFileSearchDialogResult;
|
class RicRecursiveFileSearchDialogResult;
|
||||||
|
|
||||||
@ -102,7 +103,7 @@ private slots:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
QLabel* m_pathFilterLabel;
|
QLabel* m_pathFilterLabel;
|
||||||
QLineEdit* m_pathFilterField;
|
QComboBox* m_pathFilterField;
|
||||||
QPushButton* m_browseButton;
|
QPushButton* m_browseButton;
|
||||||
|
|
||||||
QLabel* m_fileFilterLabel;
|
QLabel* m_fileFilterLabel;
|
||||||
@ -153,4 +154,4 @@ public:
|
|||||||
QString rootDir;
|
QString rootDir;
|
||||||
QString pathFilter;
|
QString pathFilter;
|
||||||
QString fileNameFilter;
|
QString fileNameFilter;
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user