mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
Added a multi case import dialog
p4#: 20758
This commit is contained in:
@@ -40,6 +40,7 @@
|
||||
|
||||
#include "cafPdmUiPropertyView.h"
|
||||
#include "RimUiTreeView.h"
|
||||
#include "RiuMultiCaseImportDialog.h"
|
||||
|
||||
|
||||
|
||||
@@ -1255,45 +1256,6 @@ void RIMainWindow::hideAllDockWindows()
|
||||
}
|
||||
|
||||
|
||||
void appendEGRIDFilesRecursively(const QString& folderName, QStringList& gridFileNames)
|
||||
{
|
||||
{
|
||||
QDir baseDir(folderName);
|
||||
baseDir.setFilter(QDir::Files);
|
||||
|
||||
QStringList nameFilters;
|
||||
nameFilters << "*.egrid" << ".EGRID";
|
||||
baseDir.setNameFilters(nameFilters);
|
||||
|
||||
QStringList fileNames = baseDir.entryList();
|
||||
|
||||
for (int i = 0; i < fileNames.size(); ++i)
|
||||
{
|
||||
QString fileName = fileNames[i];
|
||||
|
||||
QString absoluteFolderName = baseDir.absoluteFilePath(fileName);
|
||||
|
||||
gridFileNames.append(absoluteFolderName);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
{
|
||||
QDir baseDir(folderName);
|
||||
baseDir.setFilter(QDir::Dirs | QDir::NoDotAndDotDot);
|
||||
|
||||
QStringList subFolders = baseDir.entryList();
|
||||
|
||||
for (int i = 0; i < subFolders.size(); ++i)
|
||||
{
|
||||
QString folderName = subFolders[i];
|
||||
|
||||
QString absoluteFolderName = baseDir.absoluteFilePath(folderName);
|
||||
appendEGRIDFilesRecursively(absoluteFolderName, gridFileNames);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -1301,16 +1263,11 @@ void RIMainWindow::slotOpenMultipleCases()
|
||||
{
|
||||
RIApplication* app = RIApplication::instance();
|
||||
|
||||
|
||||
QStringList folderNames;
|
||||
QStringList gridFileNames;
|
||||
|
||||
for (int i = 0; i < folderNames.size(); i++)
|
||||
RiuMultiCaseImportDialog dialog;
|
||||
int action = dialog.exec();
|
||||
if (action == QDialog::Accepted)
|
||||
{
|
||||
QString fileName = folderNames[i];
|
||||
|
||||
appendEGRIDFilesRecursively(fileName, gridFileNames);
|
||||
QStringList gridFileNames = dialog.eclipseCaseFileNames();
|
||||
app->addEclipseCases(gridFileNames);
|
||||
}
|
||||
|
||||
app->addEclipseCases(gridFileNames);
|
||||
}
|
||||
|
||||
202
ApplicationCode/UserInterface/RiuMultiCaseImportDialog.cpp
Normal file
202
ApplicationCode/UserInterface/RiuMultiCaseImportDialog.cpp
Normal file
@@ -0,0 +1,202 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2011-2012 Statoil ASA, Ceetron AS
|
||||
//
|
||||
// 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.
|
||||
//
|
||||
// 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.
|
||||
//
|
||||
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
||||
// for more details.
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "RiuMultiCaseImportDialog.h"
|
||||
#include "ui_RiuMultiCaseImportDialog.h"
|
||||
#include <QFileSystemModel>
|
||||
#include <QFileDialog>
|
||||
#include <QStringListModel>
|
||||
#include <QFileIconProvider>
|
||||
|
||||
class FileListModel: public QStringListModel
|
||||
{
|
||||
public:
|
||||
FileListModel(QObject *parent = 0) : m_isItemsEditable(false), QStringListModel(parent)
|
||||
{
|
||||
}
|
||||
|
||||
virtual Qt::ItemFlags flags (const QModelIndex& index) const
|
||||
{
|
||||
if (m_isItemsEditable)
|
||||
return Qt::ItemIsSelectable | Qt::ItemIsEnabled | Qt::ItemIsEditable;
|
||||
else
|
||||
return Qt::ItemIsSelectable | Qt::ItemIsEnabled;
|
||||
}
|
||||
|
||||
virtual QVariant data ( const QModelIndex & index, int role ) const
|
||||
{
|
||||
if (role == Qt::DecorationRole)
|
||||
{
|
||||
QFileInfo fileInfo(stringList()[index.row()]);
|
||||
QFileIconProvider iconProv;
|
||||
return QVariant(iconProv.icon(fileInfo));
|
||||
}
|
||||
else
|
||||
{
|
||||
return QStringListModel::data(index, role);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void setItemsEditable(bool isEditable)
|
||||
{
|
||||
m_isItemsEditable = isEditable;
|
||||
}
|
||||
|
||||
private:
|
||||
bool m_isItemsEditable;
|
||||
};
|
||||
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RiuMultiCaseImportDialog::RiuMultiCaseImportDialog(QWidget *parent /*= 0*/)
|
||||
: QDialog(parent)
|
||||
{
|
||||
ui = new Ui::RiuMultiCaseImportDialog;
|
||||
ui->setupUi(this);
|
||||
|
||||
m_searchFolders = new FileListModel(this);
|
||||
ui->m_searchFolderList->setModel(m_searchFolders);
|
||||
|
||||
m_eclipseGridFiles = new FileListModel(this);
|
||||
ui->m_eclipseCasesList->setModel(m_eclipseGridFiles);
|
||||
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RiuMultiCaseImportDialog::~RiuMultiCaseImportDialog()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiuMultiCaseImportDialog::on_m_addSearchFolderButton_clicked()
|
||||
{
|
||||
QString selectedFolder = QFileDialog::getExistingDirectory(this, "Select an Eclipse case search folder" );
|
||||
QStringList folderNames = m_searchFolders->stringList();
|
||||
if (!folderNames.contains(selectedFolder))
|
||||
{
|
||||
folderNames.push_back(selectedFolder);
|
||||
m_searchFolders->setStringList(folderNames);
|
||||
updateGridFileList();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiuMultiCaseImportDialog::on_m_removeSearchFolderButton_clicked()
|
||||
{
|
||||
QModelIndexList selection = ui->m_searchFolderList->selectionModel()->selectedIndexes();
|
||||
for (int i = 0; i < selection.size(); ++i)
|
||||
{
|
||||
ui->m_searchFolderList->model()->removeRow(selection[i].row(), selection[i].parent());
|
||||
}
|
||||
|
||||
if (selection.size())
|
||||
{
|
||||
updateGridFileList();
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiuMultiCaseImportDialog::updateGridFileList()
|
||||
{
|
||||
|
||||
QStringList folderNames = m_searchFolders->stringList();
|
||||
QStringList gridFileNames;
|
||||
|
||||
for (int i = 0; i < folderNames.size(); i++)
|
||||
{
|
||||
QString folderName = folderNames[i];
|
||||
|
||||
appendEGRIDFilesRecursively(folderName, gridFileNames);
|
||||
}
|
||||
|
||||
m_eclipseGridFiles->setStringList(gridFileNames);
|
||||
}
|
||||
|
||||
|
||||
void RiuMultiCaseImportDialog::appendEGRIDFilesRecursively(const QString& folderName, QStringList& gridFileNames)
|
||||
{
|
||||
{
|
||||
QDir baseDir(folderName);
|
||||
baseDir.setFilter(QDir::Files);
|
||||
|
||||
QStringList nameFilters;
|
||||
nameFilters << "*.egrid" << ".EGRID";
|
||||
baseDir.setNameFilters(nameFilters);
|
||||
|
||||
QStringList fileNames = baseDir.entryList();
|
||||
|
||||
for (int i = 0; i < fileNames.size(); ++i)
|
||||
{
|
||||
QString fileName = fileNames[i];
|
||||
|
||||
QString absoluteFolderName = baseDir.absoluteFilePath(fileName);
|
||||
|
||||
gridFileNames.append(absoluteFolderName);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
{
|
||||
QDir baseDir(folderName);
|
||||
baseDir.setFilter(QDir::Dirs | QDir::NoDotAndDotDot);
|
||||
|
||||
QStringList subFolders = baseDir.entryList();
|
||||
|
||||
for (int i = 0; i < subFolders.size(); ++i)
|
||||
{
|
||||
QString folderName = subFolders[i];
|
||||
|
||||
QString absoluteFolderName = baseDir.absoluteFilePath(folderName);
|
||||
appendEGRIDFilesRecursively(absoluteFolderName, gridFileNames);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QStringList RiuMultiCaseImportDialog::eclipseCaseFileNames() const
|
||||
{
|
||||
return m_eclipseGridFiles->stringList();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiuMultiCaseImportDialog::on_m_removeEclipseCaseButton_clicked()
|
||||
{
|
||||
QModelIndexList selection = ui->m_eclipseCasesList->selectionModel()->selectedIndexes();
|
||||
for (int i = 0; i < selection.size(); ++i)
|
||||
{
|
||||
ui->m_eclipseCasesList->model()->removeRow(selection[i].row(), selection[i].parent());
|
||||
}
|
||||
}
|
||||
56
ApplicationCode/UserInterface/RiuMultiCaseImportDialog.h
Normal file
56
ApplicationCode/UserInterface/RiuMultiCaseImportDialog.h
Normal file
@@ -0,0 +1,56 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2011-2012 Statoil ASA, Ceetron AS
|
||||
//
|
||||
// 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.
|
||||
//
|
||||
// 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.
|
||||
//
|
||||
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
||||
// for more details.
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <QDialog>
|
||||
|
||||
namespace Ui {
|
||||
class RiuMultiCaseImportDialog;
|
||||
};
|
||||
|
||||
class FileListModel;
|
||||
|
||||
//==================================================================================================
|
||||
//
|
||||
//
|
||||
//
|
||||
//==================================================================================================
|
||||
|
||||
class RiuMultiCaseImportDialog: public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
RiuMultiCaseImportDialog(QWidget *parent = 0);
|
||||
virtual ~RiuMultiCaseImportDialog();
|
||||
|
||||
QStringList eclipseCaseFileNames() const;
|
||||
|
||||
protected slots:
|
||||
void on_m_addSearchFolderButton_clicked();
|
||||
void on_m_removeSearchFolderButton_clicked();
|
||||
void on_m_removeEclipseCaseButton_clicked();
|
||||
private:
|
||||
void updateGridFileList();
|
||||
static void appendEGRIDFilesRecursively(const QString& folderName, QStringList& gridFileNames);
|
||||
Ui::RiuMultiCaseImportDialog* ui;
|
||||
|
||||
FileListModel *m_searchFolders;
|
||||
FileListModel *m_eclipseGridFiles;
|
||||
};
|
||||
186
ApplicationCode/UserInterface/RiuMultiCaseImportDialog.ui
Normal file
186
ApplicationCode/UserInterface/RiuMultiCaseImportDialog.ui
Normal file
@@ -0,0 +1,186 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>RiuMultiCaseImportDialog</class>
|
||||
<widget class="QDialog" name="RiuMultiCaseImportDialog">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>755</width>
|
||||
<height>736</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Import multiple cases</string>
|
||||
</property>
|
||||
<property name="modal">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="QSplitter" name="splitter">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<widget class="QWidget" name="">
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="1" column="0" colspan="3">
|
||||
<widget class="QListView" name="m_searchFolderList">
|
||||
<property name="selectionMode">
|
||||
<enum>QAbstractItemView::ExtendedSelection</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="QPushButton" name="m_removeSearchFolderButton">
|
||||
<property name="text">
|
||||
<string>Remove</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="2">
|
||||
<widget class="QPushButton" name="m_addSearchFolderButton">
|
||||
<property name="text">
|
||||
<string>Add</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<spacer name="horizontalSpacer_4">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="0" column="0" colspan="3">
|
||||
<widget class="QLabel" name="m_searchFolderLabel">
|
||||
<property name="text">
|
||||
<string>Search Folders</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0" colspan="3">
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>222</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QWidget" name="">
|
||||
<layout class="QGridLayout" name="gridLayout_2" columnstretch="0,0">
|
||||
<item row="1" column="0" colspan="2">
|
||||
<widget class="QListView" name="m_eclipseCasesList">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="selectionMode">
|
||||
<enum>QAbstractItemView::ExtendedSelection</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0" colspan="2">
|
||||
<widget class="QLabel" name="m_eclipseCaseListLabel">
|
||||
<property name="text">
|
||||
<string>Selected Eclipse Cases</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="QPushButton" name="m_removeEclipseCaseButton">
|
||||
<property name="text">
|
||||
<string>Remove</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<spacer name="horizontalSpacer_3">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeType">
|
||||
<enum>QSizePolicy::Minimum</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>400</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="Line" name="line">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QDialogButtonBox" name="m_dialogButtons">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="standardButtons">
|
||||
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections>
|
||||
<connection>
|
||||
<sender>m_dialogButtons</sender>
|
||||
<signal>accepted()</signal>
|
||||
<receiver>RiuMultiCaseImportDialog</receiver>
|
||||
<slot>accept()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>248</x>
|
||||
<y>254</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>157</x>
|
||||
<y>274</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>m_dialogButtons</sender>
|
||||
<signal>rejected()</signal>
|
||||
<receiver>RiuMultiCaseImportDialog</receiver>
|
||||
<slot>reject()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>316</x>
|
||||
<y>260</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>286</x>
|
||||
<y>274</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
</connections>
|
||||
</ui>
|
||||
Reference in New Issue
Block a user