17#include "moc_qgsmeshdatasetgrouptreewidget.cpp" 
   36  connect( mAddDatasetButton, &QToolButton::clicked, 
this, &QgsMeshDatasetGroupTreeWidget::addDataset );
 
   37  connect( mRemoveDatasetButton, &QToolButton::clicked, 
this, &QgsMeshDatasetGroupTreeWidget::removeDataset );
 
   38  connect( mCollapseButton, &QToolButton::clicked, mDatasetGroupTreeView, &QTreeView::collapseAll );
 
   39  connect( mExpandButton, &QToolButton::clicked, mDatasetGroupTreeView, &QTreeView::expandAll );
 
   42  connect( mResetDefaultButton, &QToolButton::clicked, 
this, [
this] {
 
   43    this->mDatasetGroupTreeView->resetDefault( this->mMeshLayer );
 
   46  connect( mDatasetGroupTreeView->selectionModel(), &QItemSelectionModel::currentChanged, 
this, [
this]() {
 
   47    const QModelIndex index = mDatasetGroupTreeView->currentIndex();
 
   48    const QgsMeshDatasetGroupTreeItem *meshGroupItem = mDatasetGroupTreeView->datasetGroupTreeRootItem()->childFromDatasetGroupIndex( index.row() );
 
   51      if ( mMeshLayer->dataProvider()->dataSourceUri().contains( meshGroupItem->description() ) )
 
   53        mRemoveDatasetButton->setEnabled( false );
 
   57        mRemoveDatasetButton->setEnabled( true );
 
 
   67  mMeshLayer = meshLayer;
 
   68  mDatasetGroupTreeView->syncToLayer( meshLayer );
 
 
   77void QgsMeshDatasetGroupTreeWidget::removeDataset()
 
   79  const QModelIndex index = mDatasetGroupTreeView->currentIndex();
 
   81  const QString datasetGroupName = meshGroupItem->
defaultName();
 
   84    QMessageBox::warning( 
this, tr( 
"Remove mesh datasets" ), tr( 
"Dataset Group removed from mesh." ) );
 
   89    QMessageBox::warning( 
this, tr( 
"Remove mesh datasets" ), tr( 
"Could not remove mesh dataset group." ) );
 
   92  mDatasetGroupTreeView->resetDefault( mMeshLayer );
 
   95void QgsMeshDatasetGroupTreeWidget::addDataset()
 
  101  const QString openFileDir = settings.
value( QStringLiteral( 
"lastMeshDatasetDir" ), QDir::homePath(), 
QgsSettings::App ).toString();
 
  102  const QString openFileString = QFileDialog::getOpenFileName( 
nullptr, tr( 
"Load mesh datasets" ), openFileDir, 
QgsProviderRegistry::instance()->fileMeshDatasetFilters() );
 
  104  if ( openFileString.isEmpty() )
 
  111    QMessageBox::warning( 
this, tr( 
"Load mesh datasets" ), tr( 
"Could not add dataset from path that is already added to the mesh." ) );
 
  115  const QFileInfo openFileInfo( openFileString );
 
  117  const QFile datasetFile( openFileString );
 
  121    QMessageBox::information( 
this, tr( 
"Load mesh datasets" ), tr( 
"Datasets successfully added to the mesh layer" ) );
 
  126    QMessageBox::warning( 
this, tr( 
"Load mesh datasets" ), tr( 
"Could not read mesh dataset." ) );
 
Tree item for display of the mesh dataset groups.
 
QString defaultName() const
 
QgsMeshDatasetGroupTreeItem * child(int row) const
Returns a child.
 
Represents a mesh layer supporting display of data on structured or unstructured meshes.
 
bool addDatasets(const QString &path, const QDateTime &defaultReferenceTime=QDateTime())
Adds datasets to the mesh from file with path.
 
void setDatasetGroupTreeRootItem(QgsMeshDatasetGroupTreeItem *rootItem)
Sets the root items of the dataset group tree item.
 
QgsMeshDataProvider * dataProvider() override
Returns the layer's data provider, it may be nullptr.
 
bool datasetsPathUnique(const QString &path)
Checks whether that datasets path is already added to this mesh layer.
 
bool removeDatasets(const QString &name)
Removes datasets from the mesh with given name.
 
QgsDateTimeRange temporalRange() const
Returns the project's temporal range, which indicates the earliest and latest datetime ranges associa...
 
static QgsProject * instance()
Returns the QgsProject singleton instance.
 
const QgsProjectTimeSettings * timeSettings() const
Returns the project's time settings, which contains the project's temporal range and other time based...
 
static QgsProviderRegistry * instance(const QString &pluginPath=QString())
Means of accessing canonical single instance.
 
This class is a composition of two QSettings instances:
 
QVariant value(const QString &key, const QVariant &defaultValue=QVariant(), Section section=NoSection) const
Returns the value for setting key.
 
void setValue(const QString &key, const QVariant &value, QgsSettings::Section section=QgsSettings::NoSection)
Sets the value of setting key to value.
 
T begin() const
Returns the beginning of the range.