void MainWindow::topMenuTreatment(QAction *action) {
    if (action && action->text()=="Export to XML") {
        exportToXml();
    }
    if (action && action->text()=="Import XML") {
        importXml();
    }
}
//--------------------------------------------------------------------------------------------------
/// 
//--------------------------------------------------------------------------------------------------
bool RegGrid2DExportXml::exportToXmlFile(const RegGrid2D& regGrid, uint precision, const String& filename)
{
    ref<XmlDocument> doc = XmlDocument::create();
    CVF_ASSERT(doc.notNull());

    XmlElement* root = doc->createRootElement("Root");
    if (!root)
    {
        return false;
    }

    exportToXml(regGrid, precision, root);
    
    return doc->saveFile(filename);
}
Exemplo n.º 3
0
bool Deck::exportDeck(QVariant param)
{
    /// first of all, open the deck!
    if(!openDeck())
        return false;

    QString fileName = param.toString();
    QFileInfo fi(fileName);
    QString suffix = fi.suffix().toLower();
    QString baseName = fi.baseName().toLower();

    if(suffix == dana_suffix) {
        return exportToDana(fileName);
    } else if(suffix == xml_suffix) {
        return exportToXml(fileName);
    } else if(suffix == txt_suffix) {
        return exportToTxt(fileName);
    } 

    /// Unknown file name!
    return false;
}
Exemplo n.º 4
0
bool Deck::exportToDana(QString fileName)
{
    QFileInfo fi(fileName);
    QString baseName = fi.baseName().toLower();
    
    QString tempFolder = utils::combinePaths(tempPath(), baseName);
    QString deckFile = utils::combinePaths(tempFolder, "deck.xml"); 
        
    utils::removeDirectory(tempFolder);
    utils::createDirectory(tempFolder);
    
    if(!exportToXml(deckFile))
        return false;

    utils::copyDirectory(tempFolder, getDeckPath());

    Compressor c;
    if(!c.compressFolder(tempFolder, fileName)) {
        return false;
    }

    return true;  
}
Exemplo n.º 5
0
QgsBookmarks::QgsBookmarks( QWidget *parent )
    : QgsDockWidget( parent )
    , mQgisModel( nullptr )
    , mProjectModel( nullptr )
{
  setupUi( this );
  restorePosition();

  bookmarksDockContents->layout()->setMargin( 0 );
  bookmarksDockContents->layout()->setContentsMargins( 0, 0, 0, 0 );
  static_cast< QGridLayout* >( bookmarksDockContents->layout() )->setVerticalSpacing( 0 );

  QToolButton* btnImpExp = new QToolButton;
  btnImpExp->setAutoRaise( true );
  btnImpExp->setToolTip( tr( "Import/Export Bookmarks" ) );
  btnImpExp->setIcon( QgsApplication::getThemeIcon( QStringLiteral( "/mActionSharing.svg" ) ) );
  btnImpExp->setPopupMode( QToolButton::InstantPopup );

  QMenu *share = new QMenu( this );
  QAction *btnExport = share->addAction( tr( "&Export" ) );
  QAction *btnImport = share->addAction( tr( "&Import" ) );
  btnExport->setIcon( QgsApplication::getThemeIcon( QStringLiteral( "/mActionSharingExport.svg" ) ) );
  btnImport->setIcon( QgsApplication::getThemeIcon( QStringLiteral( "/mActionSharingImport.svg" ) ) );
  connect( btnExport, SIGNAL( triggered() ), this, SLOT( exportToXml() ) );
  connect( btnImport, SIGNAL( triggered() ), this, SLOT( importFromXml() ) );
  btnImpExp->setMenu( share );

  connect( actionAdd, SIGNAL( triggered() ), this, SLOT( addClicked() ) );
  connect( actionDelete, SIGNAL( triggered() ), this, SLOT( deleteClicked() ) );
  connect( actionZoomTo, SIGNAL( triggered() ), this, SLOT( zoomToBookmark() ) );

  mBookmarkToolbar->addWidget( btnImpExp );

  // open the database
  QSqlDatabase db = QSqlDatabase::addDatabase( QStringLiteral( "QSQLITE" ), QStringLiteral( "bookmarks" ) );
  db.setDatabaseName( QgsApplication::qgisUserDbFilePath() );
  if ( !db.open() )
  {
    QMessageBox::warning( this, tr( "Error" ),
                          tr( "Unable to open bookmarks database.\nDatabase: %1\nDriver: %2\nDatabase: %3" )
                          .arg( QgsApplication::qgisUserDbFilePath(),
                                db.lastError().driverText(),
                                db.lastError().databaseText() )
                        );
    deleteLater();
    return;
  }

  mQgisModel = new QSqlTableModel( this, db );
  mQgisModel->setTable( QStringLiteral( "tbl_bookmarks" ) );
  mQgisModel->setSort( 0, Qt::AscendingOrder );
  mQgisModel->select();
  mQgisModel->setEditStrategy( QSqlTableModel::OnFieldChange );

  // set better headers then column names from table
  mQgisModel->setHeaderData( 0, Qt::Horizontal, tr( "ID" ) );
  mQgisModel->setHeaderData( 1, Qt::Horizontal, tr( "Name" ) );
  mQgisModel->setHeaderData( 2, Qt::Horizontal, tr( "Project" ) );
  mQgisModel->setHeaderData( 3, Qt::Horizontal, tr( "xMin" ) );
  mQgisModel->setHeaderData( 4, Qt::Horizontal, tr( "yMin" ) );
  mQgisModel->setHeaderData( 5, Qt::Horizontal, tr( "xMax" ) );
  mQgisModel->setHeaderData( 6, Qt::Horizontal, tr( "yMax" ) );
  mQgisModel->setHeaderData( 7, Qt::Horizontal, tr( "SRID" ) );

  mProjectModel = new QgsProjectBookmarksTableModel();
  mModel.reset( new QgsMergedBookmarksTableModel( *mQgisModel, *mProjectModel, lstBookmarks ) );

  lstBookmarks->setModel( mModel.data() );

  QSettings settings;
  lstBookmarks->header()->restoreState( settings.value( QStringLiteral( "/Windows/Bookmarks/headerstate" ) ).toByteArray() );

#ifndef QGISDEBUG
  lstBookmarks->setColumnHidden( 0, true );
#endif
}