MigraineMainWindow::MigraineMainWindow( QWidget * parent, Qt::WFlags f )
	: QMainWindow(parent, f)
{
    QCoreApplication::setApplicationName("Migraine");
    QCoreApplication::setOrganizationDomain("migraine.com");
    QCoreApplication::setOrganizationName("MIGRAINE");
	
    setupUi(this);
	
    connDialog = new ConnectionDialog(this);
//    connDialog = new SettingsDialog(this);

    _settings = new QSettings(CONFIG_FILE_PATH, QSettings::IniFormat, this);

    analyst = new DBAnalyst(this);
    analyst->setCreateTables(true);
    migrator = new DBMigrator(this->analyst, this);
    progressWidget = new MigrationProgressWidget(this);
    readSettings();
    setupObjectConnections();
    refreshConnections();

    previewMigrationButton->addAction(actionPre_view_Migration);
    resetMigrationButton->addAction(actionReset_Migration);
    migrateButton->addAction(actionMigrate);
}
void QgsGeoPackageRootItem::newConnection()
{
  if ( QgsOgrDataCollectionItem::createConnection( QStringLiteral( "GeoPackage" ),  QStringLiteral( "GeoPackage Database (*.gpkg)" ),  QStringLiteral( "GPKG" ) ) )
  {
    refreshConnections();
  }
}
Exemple #3
0
void QgsXyzTileRootItem::newConnection()
{
  QgsXyzConnectionDialog dlg;
  if ( !dlg.exec() )
    return;

  QgsXyzConnectionUtils::addConnection( dlg.connection() );
  refreshConnections();
}
Exemple #4
0
void QgsWMSRootItem::newConnection()
{
  QgsNewHttpConnection nc( nullptr );

  if ( nc.exec() )
  {
    refreshConnections();
  }
}
Exemple #5
0
void QgsAmsRootItem::newConnection()
{
  QgsNewHttpConnection nc( 0, QgsNewHttpConnection::ConnectionOther, QStringLiteral( "qgis/connections-arcgismapserver/" ) );
  nc.setWindowTitle( tr( "Create a New ArcGIS Map Server Connection" ) );

  if ( nc.exec() )
  {
    refreshConnections();
  }
}
Exemple #6
0
void VPiano::initialization()
{
    initMidi();
    refreshConnections();
    readSettings();
    initToolBars();
    applyPreferences();
    applyConnections();
    applyInitialSettings();
}
Exemple #7
0
void VPiano::slotConnections()
{
    refreshConnections();
    dlgMidiSetup.setCurrentInput(m_currentIn);
    dlgMidiSetup.setCurrentOutput(m_currentOut);
    releaseKb();
    if (dlgMidiSetup.exec() == QDialog::Accepted) {
        applyConnections();
    }
    grabKb();
}
void QgsGeoPackageRootItem::createDatabase()
{
  QgsNewGeoPackageLayerDialog dialog( nullptr );
  dialog.setCrs( QgsProject::instance()->defaultCrsForNewLayers() );
  if ( dialog.exec() == QDialog::Accepted )
  {
    if ( QgsOgrDataCollectionItem::storeConnection( dialog.databasePath(), QStringLiteral( "GPKG" ) ) )
    {
      refreshConnections();
    }
  }
}
void QgsGeoPackageCollectionItem::addTable()
{
  QgsNewGeoPackageLayerDialog dialog( nullptr );
  dialog.setDatabasePath( mPath );
  dialog.setCrs( QgsProject::instance()->defaultCrsForNewLayers() );
  dialog.setOverwriteBehavior( QgsNewGeoPackageLayerDialog::AddNewLayer );
  dialog.lockDatabasePath();
  if ( dialog.exec() == QDialog::Accepted )
  {
    refreshConnections();
  }
}
Exemple #10
0
void VPiano::initialization()
{
    if (m_initialized = initMidi()) {
        refreshConnections();
        readSettings();
        initToolBars();
        applyPreferences();
        applyConnections();
        applyInitialSettings();
        initExtraControllers();
    }
}
Exemple #11
0
void QgsXyzTileRootItem::loadXyzTilesServers()
{
  QString fileName = QFileDialog::getOpenFileName( nullptr, tr( "Load Connections" ), QDir::homePath(),
                     tr( "XML files (*.xml *.XML)" ) );
  if ( fileName.isEmpty() )
  {
    return;
  }

  QgsManageConnectionsDialog dlg( nullptr, QgsManageConnectionsDialog::Import, QgsManageConnectionsDialog::XyzTiles, fileName );
  dlg.exec();
  refreshConnections();
}
void MigraineMainWindow::setupObjectConnections()
{
    connect( dbSrcConnCombo, SIGNAL(activated(const QString &)), this, SLOT(srcConnectionSelected(const QString&)) );
    connect( dbTgtConnCombo, SIGNAL(activated(const QString &)), this, SLOT(tgtConnectionSelected(const QString&)) );
    connect( actionConnections, SIGNAL(activated()), connDialog, SLOT(show()) );

    connect( connDialog, SIGNAL(accepted()), this, SLOT(refreshConnections()) );
    connect( connDialog, SIGNAL(settingsWritten()), this, SLOT(readSettings()) );

    connect( analyst, SIGNAL(exactMatchFound(const QString&)), this, SLOT(exactMatch(const QString&)) );
    connect( analyst, SIGNAL(nameMatchFound(const QString&)), this, SLOT(matchByName(const QString&)) );
    connect( analyst, SIGNAL(noMatchFound(const QString&)), this, SLOT(noMatch(const QString&)) );
    connect( analyst, SIGNAL(setMatchError(const QString&)), logTextEdit, SLOT(append(const QString&)));
    connect( analyst, SIGNAL(analysisDone(bool)), actionPre_view_Migration, SLOT(setEnabled(bool)) );

    connect( actionMigrate, SIGNAL(activated()), this, SLOT(startMigration()) );

    connect( nameMatchListView, SIGNAL(pressed(const QModelIndex &)), this, SLOT(nameMatchSelected(const QModelIndex &)) );
    connect( tgtColumnsTableWidget, SIGNAL(itemSelectionChanged()), this, SLOT(tgtColumnSelected()) );
    connect( addMapColumnButton, SIGNAL(clicked()), this, SLOT(addMapColumn()) );

    connect( createTablesCheckbox, SIGNAL(toggled(bool)), analyst, SLOT(setCreateTables(bool)) );

    connect( migrator, SIGNAL(migrationError(const QString &)), this, SLOT(showErrorMessage(const QString&)));
    connect( migrator, SIGNAL(insertProgress(const int&, const int&)), progressWidget, SLOT(setInsertProgress(const int&, const int &)) );
    connect( migrator, SIGNAL(tablesToCopy(const int&)), progressWidget, SLOT(setCopyProgressTotal(const int&)) );
    connect( migrator, SIGNAL(tablesToMigrate(const int&)), progressWidget, SLOT(setMigrateProgressTotal(const int&)) );
    connect( migrator, SIGNAL(tablesToCreate(const int&)), progressWidget, SLOT(setCreateProgressTotal(const int&)) );
    connect( migrator, SIGNAL(migrationDone()), progressWidget, SLOT(close()) );
    connect( migrator, SIGNAL(migrationDone(const int&, const int&, const int&)), this, SLOT(showMigrationStats(const int&, const int&, const int&)) );
    connect( migrator, SIGNAL(tableCopyStarted(const QString&, const int&)), this, SLOT(updateCopyTablesProgress(const QString&, const int&)) );
    connect( migrator, SIGNAL(tableMigrationStarted(const QString&, const int&)), this, SLOT(updateMigrateTablesProgress(const QString&, const int&)) );
    connect( migrator, SIGNAL(tableCreationStarted(const QString&, const int&)), this, SLOT(updateCreateTablesProgress(const QString&, const int&)) );

    connect( actionOutput, SIGNAL(changed()), this, SLOT(writeSettings()) );
}
bool QgsGeoPackageCollectionItem::handleDrop( const QMimeData *data, Qt::DropAction )
{

  if ( !QgsMimeDataUtils::isUriList( data ) )
    return false;

  QString uri;

  QStringList importResults;
  bool hasError = false;

  // Main task
  std::unique_ptr< QgsConcurrentFileWriterImportTask > mainTask( new QgsConcurrentFileWriterImportTask( tr( "GeoPackage import" ) ) );
  QgsTaskList importTasks;

  const auto lst = QgsMimeDataUtils::decodeUriList( data );
  for ( const QgsMimeDataUtils::Uri &dropUri : lst )
  {
    // Check that we are not copying over self
    if ( dropUri.uri.startsWith( mPath ) )
    {
      importResults.append( tr( "You cannot import layer %1 over itself!" ).arg( dropUri.name ) );
      hasError = true;

    }
    else
    {
      QgsMapLayer *srcLayer = nullptr;
      bool owner;
      bool isVector = false;
      QString error;
      // Common checks for raster and vector
      // aspatial is treated like vector
      if ( dropUri.layerType == QStringLiteral( "vector" ) )
      {
        // open the source layer
        srcLayer = dropUri.vectorLayer( owner, error );
        isVector = true;
      }
      else if ( dropUri.layerType == QStringLiteral( "mesh" ) )
      {
        // unsupported
        hasError = true;
        continue;
      }
      else
      {
        srcLayer = dropUri.rasterLayer( owner, error );
      }
      if ( !srcLayer )
      {
        importResults.append( tr( "%1: %2" ).arg( dropUri.name, error ) );
        hasError = true;
        continue;
      }

      if ( srcLayer->isValid() )
      {
        uri = mPath;
        QgsDebugMsgLevel( "URI " + uri, 3 );

        // check if the destination layer already exists
        bool exists = false;
        const auto c( children() );
        for ( const QgsDataItem *child : c )
        {
          if ( child->name() == dropUri.name )
          {
            exists = true;
          }
        }

        if ( exists && !isVector )
        {
          QMessageBox::warning( nullptr, tr( "Cannot Overwrite Layer" ),
                                tr( "Destination layer <b>%1</b> already exists. Overwriting with raster layers is not currently supported." ).arg( dropUri.name ) );
        }
        else if ( ! exists || QMessageBox::question( nullptr, tr( "Overwrite Layer" ),
                  tr( "Destination layer <b>%1</b> already exists. Do you want to overwrite it?" ).arg( dropUri.name ), QMessageBox::Yes |  QMessageBox::No ) == QMessageBox::Yes )
        {
          if ( isVector ) // Import vectors and aspatial
          {
            QgsVectorLayer *vectorSrcLayer = qobject_cast < QgsVectorLayer * >( srcLayer );
            QVariantMap options;
            options.insert( QStringLiteral( "driverName" ), QStringLiteral( "GPKG" ) );
            options.insert( QStringLiteral( "update" ), true );
            options.insert( QStringLiteral( "overwrite" ), true );
            options.insert( QStringLiteral( "layerName" ), dropUri.name );
            options.insert( QStringLiteral( "forceSinglePartGeometryType" ), true );
            QgsVectorLayerExporterTask *exportTask = new QgsVectorLayerExporterTask( vectorSrcLayer, uri, QStringLiteral( "ogr" ), vectorSrcLayer->crs(), options, owner );
            mainTask->addSubTask( exportTask, importTasks );
            importTasks << exportTask;
            // when export is successful:
            connect( exportTask, &QgsVectorLayerExporterTask::exportComplete, this, [ = ]()
            {
              // this is gross - TODO - find a way to get access to messageBar from data items
              QMessageBox::information( nullptr, tr( "Import to GeoPackage database" ), tr( "Import was successful." ) );
              refreshConnections();
            } );

            // when an error occurs:
            connect( exportTask, &QgsVectorLayerExporterTask::errorOccurred, this, [ = ]( int error, const QString & errorMessage )
            {
              if ( error != QgsVectorLayerExporter::ErrUserCanceled )
              {
                QgsMessageOutput *output = QgsMessageOutput::createMessageOutput();
                output->setTitle( tr( "Import to GeoPackage database" ) );
                output->setMessage( tr( "Failed to import some vector layers!\n\n" ) + errorMessage, QgsMessageOutput::MessageText );
                output->showMessage();
              }
            } );

          }
          else  // Import raster
          {
            QgsGeoPackageRasterWriterTask  *exportTask = new QgsGeoPackageRasterWriterTask( dropUri, mPath );
            mainTask->addSubTask( exportTask, importTasks );
            importTasks << exportTask;
            // when export is successful:
            connect( exportTask, &QgsGeoPackageRasterWriterTask::writeComplete, this, [ = ]()
            {
              // this is gross - TODO - find a way to get access to messageBar from data items
              QMessageBox::information( nullptr, tr( "Import to GeoPackage database" ), tr( "Import was successful." ) );
              refreshConnections();
            } );

            // when an error occurs:
            connect( exportTask, &QgsGeoPackageRasterWriterTask::errorOccurred, this, [ = ]( QgsGeoPackageRasterWriter::WriterError error, const QString & errorMessage )
            {
              if ( error != QgsGeoPackageRasterWriter::WriterError::ErrUserCanceled )
              {
                QgsMessageOutput *output = QgsMessageOutput::createMessageOutput();
                output->setTitle( tr( "Import to GeoPackage database" ) );
                output->setMessage( tr( "Failed to import some raster layers!\n\n" ) + errorMessage, QgsMessageOutput::MessageText );
                output->showMessage();
              }
              // Always try to delete the imported raster, in case the gpkg has been left
              // in an inconsistent status. Ignore delete errors.
              QString deleteErr;
              deleteGeoPackageRasterLayer( QStringLiteral( "GPKG:%1:%2" ).arg( mPath, dropUri.name ), deleteErr );
            } );

          }
        } // do not overwrite
      }
      else
      {
        importResults.append( tr( "%1: Not a valid layer!" ).arg( dropUri.name ) );
        hasError = true;
      }
    } // check for self copy
  } // for each

  if ( hasError )
  {
    QgsMessageOutput *output = QgsMessageOutput::createMessageOutput();
    output->setTitle( tr( "Import to GeoPackage database" ) );
    output->setMessage( tr( "Failed to import some layers!\n\n" ) + importResults.join( QStringLiteral( "\n" ) ), QgsMessageOutput::MessageText );
    output->showMessage();
  }
  if ( ! importTasks.isEmpty() )
  {
    QgsApplication::taskManager()->addTask( mainTask.release() );
  }
  return true;
}
Exemple #14
0
void P2PConnectionsWindow::onRefreshTimer(wxTimerEvent &e)
{
	refreshConnections();

	e.Skip();
}