Beispiel #1
0
void MQLEdit::fileExit()
{
  if(askSaveIfModified())
  {
    close();
  }
}
Beispiel #2
0
void MQLEdit::fileOpen()
{
  if(askSaveIfModified())
  {
    QString fileName = QFileDialog::getOpenFileName(this);
    if(!fileName.isEmpty())
    {
      QFile file(fileName);
      if(file.open(QIODevice::ReadOnly))
      {
        QTextStream stream(&file);
        _text->setText(stream.readAll());
        _text->document()->setModified(false);
        _fileName = fileName;
        _mqlGrade = -1;
        _mqlGroup = QString::null;
        _mqlName  = QString::null;
        _mqlNotes = QString::null;
        _mqlSchema= QString::null;
        setWindowTitle(getTitleString(MQLFile));
        setDestType(MQLFile);
      }
    }
  }
}
Beispiel #3
0
void MQLEdit::fileNew()
{
    if(askSaveIfModified()) {
	// now that we have that out of the way we are free to go ahead and do our stuff
	_text->clear();
	_text->document()->setModified(false);
	_fileName = QString::null;
    }
}
Beispiel #4
0
void MQLEdit::fileOpen()
{
    if(askSaveIfModified()) {
	QString fileName = QFileDialog::getOpenFileName(this);
	if(!fileName.isEmpty()) {
	    QFile file(fileName);
	    if(file.open(QIODevice::ReadOnly)) {
		QTextStream stream(&file);
		_text->setText(stream.readAll());
		_text->document()->setModified(false);
		_fileName = fileName;
	    }
	}
    }
}
Beispiel #5
0
void MQLEdit::fileDatabaseOpen(const int id)
{
  if (askSaveIfModified())
  {
    XSqlQuery getq;
    getq.prepare("SELECT metasql.*, nspname"
                 "  FROM metasql"
                 "  JOIN pg_class ON (metasql.tableoid=pg_class.oid)"
                 "  JOIN pg_namespace ON (relnamespace=pg_namespace.oid)"
                 " WHERE (metasql_id=:id);");
    getq.bindValue(":id", id);
    getq.exec();
    if (getq.first())
    {
      _text->setText(getq.value("metasql_query").toString());
      _text->document()->setModified(false);
      _fileName = QString::null;
      _mqlGrade = getq.value("metasql_grade").toInt();
      _mqlGroup = getq.value("metasql_group").toString();
      _mqlName  = getq.value("metasql_name").toString();
      _mqlNotes = getq.value("metasql_notes").toString();
      _mqlSchema= getq.value("nspname").toString();

      setWindowTitle(getTitleString(MQLDatabase));
      setDestType(MQLDatabase);
    }
    else if (getq.lastError().type() != QSqlError::NoError)
    {
      QMessageBox::warning(this, tr("Database Error"),
                            tr("<p>Trying to read the MetaSQL statement, "
                               "the database server returned an error: %1")
                              .arg(getq.lastError().text()));
      return;
    }
    else
    {
      QMessageBox::warning(this, tr("Not Found"),
                            tr("<p>Could not find the MetaSQL statement "
                               "with id %1.").arg(id));
      return;
    }
  }
}
Beispiel #6
0
void MQLEdit::fileNew()
{
  if(askSaveIfModified())
    clear();
}
Beispiel #7
0
void MQLEdit::fileExit()
{
    if(askSaveIfModified()) {
	QApplication::exit();
    }
}