コード例 #1
0
bool CFileNode::data(QString gate_name, const CConstDataPointer &data)
{
    // No input gates.
    Q_UNUSED(gate_name);

    if(data->getType() == "message") {
        auto pmsg = data.staticCast<const CMessageData>();
        QString msg = pmsg->getMessage();
        if(msg == "start") {

            // Create and read the file.
            QSharedPointer<CFileData> file_data =
                    QSharedPointer<CFileData>(
                        static_cast<CFileData *>(createData("file")));

            QVariant filename = getConfig().getParameter("input_file")->value;
            QVariant binary = getConfig().getParameter("binary")->value;

            if(!file_data.isNull() &&
                    file_data->readFile(filename.toString(),
                                        binary.toBool())) {
                commit("out", file_data);
            }
            else {
                commitError("out", "Could not read file.");
            }
            return true;
        }
    }

    return false;
}
コード例 #2
0
ファイル: qgsguivectorlayertools.cpp プロジェクト: Ariki/QGIS
bool QgsGuiVectorLayerTools::saveEdits( QgsVectorLayer* layer ) const
{
  bool res = true;

  if ( layer->isModified() )
  {
    if ( !layer->commitChanges() )
    {
      commitError( layer );
      // Leave the in-memory editing state alone,
      // to give the user a chance to enter different values
      // and try the commit again later
      res = false;
    }
    layer->startEditing();
  }
  else //layer not modified
  {
    res = true;
  }
  return res;
}
コード例 #3
0
bool CMawiLabelsNode::data(QString gate_name, const CConstDataPointer &data)
{
    Q_UNUSED(gate_name);

    // Process input files.
    if(data->getType() == "file") {
        // The file to read.
        auto p_file = data.staticCast<const CFileData>();
        // The table to output the anomalies.
        QSharedPointer<CTableData> table_data = createTable();
        // Place the anomaly labels of the XML file into a table.
        if(parseMawiXml(p_file->getBytes(), table_data)) {
            // Pass the table of anomalies forward.
            commit("out", table_data);
        }
        else {
            commitError("out", "MAWI labels could not be parsed correctly.");
        }

        return true;
    }

    return false;
}
コード例 #4
0
ファイル: qgsguivectorlayertools.cpp プロジェクト: Ariki/QGIS
bool QgsGuiVectorLayerTools::stopEditing( QgsVectorLayer* layer, bool allowCancel ) const
{
  bool res = true;

  if ( layer->isModified() )
  {
    QMessageBox::StandardButtons buttons = QMessageBox::Save | QMessageBox::Discard;
    if ( allowCancel )
      buttons |= QMessageBox::Cancel;

    switch ( QMessageBox::information( 0,
                                       tr( "Stop editing" ),
                                       tr( "Do you want to save the changes to layer %1?" ).arg( layer->name() ),
                                       buttons ) )
    {
      case QMessageBox::Cancel:
        res = false;
        break;

      case QMessageBox::Save:
        if ( !layer->commitChanges() )
        {
          commitError( layer );
          // Leave the in-memory editing state alone,
          // to give the user a chance to enter different values
          // and try the commit again later
          res = false;
        }

        layer->triggerRepaint();
        break;

      case QMessageBox::Discard:
        QgisApp::instance()->mapCanvas()->freeze( true );
        if ( !layer->rollBack() )
        {
          QgisApp::instance()->messageBar()->pushMessage( tr( "Error" ),
              tr( "Problems during roll back" ),
              QgsMessageBar::CRITICAL );
          res = false;
        }
        QgisApp::instance()->mapCanvas()->freeze( false );

        layer->triggerRepaint();
        break;

      default:
        break;
    }
  }
  else //layer not modified
  {
    QgisApp::instance()->mapCanvas()->freeze( true );
    layer->rollBack();
    QgisApp::instance()->mapCanvas()->freeze( false );
    res = true;
    layer->triggerRepaint();
  }

  return res;
}