Пример #1
0
void MysqlConnection::doGetCreateScript(const QString& table)
{
	QSqlQuery q("SHOW CREATE TABLE " + table, m_db);
	// This query returns two columns: table name, create
	if(!q.next()) {
		qWarning() << "Couldn't show table (" << table << ") creation script: " << q.lastError().text();
		emit newScript(q.lastError().text());
	}

	emit newScript(q.value(1).toString());
}
Пример #2
0
void PythonEditor::initialize() throw (tgt::Exception) {
    VoreenVEPlugin::initialize();

    if (PythonModule::getInstance()) {
        PythonModule::getInstance()->addOutputListener(this);
        newScript();
    }
    else
        LWARNING("Python module class not instantiated");

    updateGuiState();
}
Пример #3
0
// 																		<<<<<<<<<<-------------- TODO: Check this out...dose some intresting things
static void
skip_percent_comment(void)
{

#ifndef TTYEDEN
    Script     *script;
    extern Script *st_script, *dd_script;
    extern int  run(short, void *, char *);
    extern void dd_lex(int), st_lex(int);
#ifdef WANT_SASAMI
    extern Script *sa_script;
    extern void sa_input(char);
#endif /* WANT_SASAMI */
#ifdef DISTRIB
    extern void lsd_lex(int);
#endif /* DISTRIB */
#endif /* not TTYEDEN */

    /* skip_percent_comment is called when we are starting a new line
       and nextc=='%' [Ash] */

    char       *s;
    int         start = yyleng;

    safe_input();		/* read in the initial '%' */

    for (;;) {

	s = yytext + start;

	/* safe_input until we have an end-of-line or EOF */
	if ((nextc != '\n') && (nextc != '\r') && (nextc != 0)) {
	  safe_input();
	  continue;
	} else {
	  /* now we've found the end of the line, terminate it correctly */
	  end_text1();
	}

	if ((nextc == '\n') || (nextc == '\r')) {
	  if (notationSwitch(s)) {
	    char execstr[100];
	    int c;
	    
	    changeNotation(NEWOTHER);

	    /* Notation now changed to a non-default one.  Slurp in
	       the rest of the text until (just before) the next
	       change of notation and parse it.  [Ash] */
	    for (nextc = peek();
		 (nextc != '\0') && (nextc != EOF);
		 nextc = peek()) {
	      
	      if (Inp_Dev->newline && nextc == '%') {
		/* Trying to fix sqleddi "prepare to eat and then eat"
		   bug [Ash, 23rd October 2002] */
		/*
		  strcpy(execstr, "notationChar('\\\n');");
		  run(STRING_DEV, execstr, 0);
		*/
		
		nextc = '\n';
		return;
	      } else if (Inp_Dev->newline && nextc == '#') {
		c = keyin();
		if (nextc == '#') {
		  /* "##" comment input: ignore to end of line */
		  do {c = keyin();} while (!Inp_Dev->newline);
		  
		} else {
		  /* input line starts with #, but second character is
		     not #.  Pass the first # to the Eden parser, and
		     parse the second character the next time round
		     the loop. */
		  strcpy(execstr, "notationChar('#');");
		  run(STRING_DEV, execstr, 0);
		}
	      } else {
		/* Something in the sqleddi model causes C's idea
                   about the status of the current notation to get
                   confused.  As this piece of code is executing, we
                   must be in a NEWOTHER notation, so set it
                   explicitly.  [Ash, 24th October 2002] */
#ifdef TTYEDEN
		changeNotation(NEWOTHER);
#endif
		c = keyin();
		/* fprintf(stderr, "KEYIN %d\n", c); */
		
		if (c == '\'')
		  strcpy(execstr, "notationChar('\\\'');");
		else if (c == '\\')
		  strcpy(execstr, "notationChar('\\\\');");
		else
		  sprintf(execstr, "notationChar('%c');", c);
		
		run(STRING_DEV, execstr, 0);
	      }
	      
	    } /* end for */
	    
#ifdef TTYEDEN
	    /* ttyeden does not currently keep track of the current
	       notation properly.  It should still be %eddi after an
	       included file has changed to that notation and not back
	       again, but this would require some work on the lexer.
	       At least we can ensure that the prompt is correct here.
	       [Ash] */
	    /*
	      if ((nextc == EOF) || (nextc == '\0')) {
	      fprintf(stderr, "EOF FUDGE\n");
	      notationSwitch("%eden");
	      currentNotation = EDEN;
	      }
	    */

	    currentNotation = EDEN;
	    /* peek() does not seem to manage to successfully push
	       back the EOF character in TTYEDEN and so keyin() would
	       cause another character to be read.  Stop immediately
	       instead.  [Ash] */
	    return;
#else
	    keyin();	/* read the null character */
	    /* treat end-of-file as end-of-line */
	    /* the code feeding the parser with \n below is a
	       reinterpretation of something Chris Brown put in, but
	       it doesn't seem to be required any more */
	    /*
	     * strcpy(execstr, "notationChar('\\n');");
	     * run(STRING_DEV, execstr, 0);
	     */
	    setprompt();
#endif
	    
	  } /* end if notationSwitch(s) */


#ifndef TTYEDEN
	  /* DoNaLD -------------------------------------------- */
	  /* %donald0 is an alternative alias for %donald, so that we
	     can replace %donald with a new translator but still
	     access this builtin as %donald0 */
	  else if ((strncmp(s, "%donald0", 8) == 0) ||
		   (strncmp(s, "%donald", 7) == 0)) {
	    changeNotation(DONALD);
	    dd_script = script = newScript();
	    for (nextc = peek(); nextc != '\0'; nextc = peek()) {
	      if (Inp_Dev->newline && (nextc == '%' || nextc == '>'
				       || nextc == '<')) {
		if (nextc == '>' || nextc == '<') {
		  input();
		  getAgentName();
		}
		else {
		  nextc = '\n';
		  if (script->text[0] != '\0') {
		    appAgentName--;
		    /* printf("from donald 1"); */
		    pushEntryStack(DONALD);
		    run(STRING_DEV, script->text, 0);
		    popEntryStack();
		    appAgentName++;
		  }
		  deleteScript(script);
		  return;
		} /* end if (nextc == '>' || nextc == '<') */
	      } /* end if (Inp_Dev->newline...) */
	      else {
		dd_lex(keyin());
		if (script->ready) {
		  if (script->text[0] != '\0') {
		    appAgentName--;
		    /* printf("from donald 2"); */
		    pushEntryStack(DONALD);
		    run(STRING_DEV, script->text, 0);
		    dd_script = script;
		    popEntryStack();
		    /* printf("from donald 3"); */
		    appAgentName++;
		  }
		  resetScript(script);
		} /* end if (script->ready) */
	      } /* end if (Inp_Dev->newline...) (two versions) */
	    } /* end for (nextc = peek()...) */


	    keyin();	/* read the null character */
	    dd_lex('\n');	/* treat end-of-file as end-of-line */

	    if (script->text[0] != '\0') {
	      appAgentName--;
	      pushEntryStack(DONALD);
	      run(STRING_DEV, script->text, 0);
	      popEntryStack();
	      /* printf("from donald 4"); */
	      appAgentName++;
	    }
	    deleteScript(script);
	  } /* end if (strncmp(s, "%donald", 7) == 0) */


	  /* SCOUT -------------------------------------------- */
	  else if (strncmp(s, "%scout", 6) == 0) {	/* is SCOUT */
	    scoutScreenInitOpen();
	    changeNotation(SCOUT);
	    st_script = script = newScript();
	    for (nextc = peek(); nextc != '\0'; nextc = peek()) {
	      if (Inp_Dev->newline && (nextc == '%' || nextc == '>'
				       || nextc == '<')) {
		if (nextc == '>' || nextc == '<') {
		  input();
		  getAgentName();
		} else {
		  nextc = '\n';
		  if (script->text[0] != '\0') {
		    appAgentName--;
		    /* printf("from scout 1"); */
		    pushEntryStack(SCOUT);
		    run(STRING_DEV, script->text, 0);
		    popEntryStack();
		    appAgentName++;
		  }
		  deleteScript(script);
		  return;
		}
	      } /* end if (Inp_Dev->newline...) */
	      else {
		st_lex(keyin());
		if (script->ready) {
		  if (script->text[0] != '\0') {
		    appAgentName--;
		    /* printf("from scout 2 %s\n", script->text); */
		    pushEntryStack(SCOUT);
		    run(STRING_DEV, script->text, 0);
		    st_script = script;
		    popEntryStack();
		    appAgentName++;
		  }
		  resetScript(script);
		}
	      }
	    } /* end for (nextc = peek();... */

	    keyin();	/* read the null character */
	    st_lex('\n');	/* treat end-of-file as end-of-line */
	    if (script->text[0] != '\0') {
	      appAgentName--;
	      pushEntryStack(SCOUT);
	      run(STRING_DEV, script->text, 0);
	      popEntryStack();
	      appAgentName++;
	    }
	    deleteScript(script);
	  } /* end if (strncmp(s, "%scout", 6)... */

#ifdef WANT_SASAMI

	  /* Sasami -------------------------------------------- */

	  else if (strncmp(s, "%sasami", 7) == 0) {
	    changeNotation(SASAMI);
	    sa_script = script = newScript();
	    for (nextc = peek(); nextc != '\0'; nextc = peek())	{
	      if (Inp_Dev->newline && (nextc == '%' || nextc == '>' ||
				       nextc == '<')) {
		/* This is a %, > or < statement and shouldn't be
                   passed to Sasami */
		if (nextc == '>' || nextc == '<') {
		  input();
		  getAgentName();
		} else {
		  nextc = '\n';
		  if (script->text[0] != '\0') {
		    appAgentName--;
		    /* printf("from sasami 1"); */
		    pushEntryStack(SASAMI);
		    run(STRING_DEV, script->text, 0);
		    popEntryStack();
		    appAgentName++;
		  }
		  deleteScript(script);
		  return;
		}
	      } else {
		/* This must be something worth sending to Sasami */
		sa_input(keyin());
		/* Now run the EDEN script that Sasami's produced (if
                   there is one) */
		if (script->ready) {
		  if (script->text[0] != '\0') {
		    appAgentName--;
		    /* printf("from sasami 2"); */
		    pushEntryStack(SASAMI);
		    run(STRING_DEV, script->text, 0);
		    sa_script = script;
		    popEntryStack();
		    /* printf("from sasami 3"); */
		    appAgentName++;
		  }
		  resetScript(script);
		}
	      }
	    }

	    /* OK - finished with the input, so send an EOL to make
	       sure that the parser runs the last input line, and
	       exit. */

	    keyin();	/* read the null character */

	    sa_input('\n');	/* treat end-of-file as end-of-line */

	    if (script->text[0] != '\0') {
	      appAgentName--;
	      pushEntryStack(SASAMI);
	      run(STRING_DEV, script->text, 0);
	      popEntryStack();
	      /* printf("from sasami 4"); */
	      appAgentName++;
	    }
	    deleteScript(script);
	  } /* end if (strncmp(s, "%sasami", 7) == 0) */
#endif /* WANT_SASAMI */

#ifdef DISTRIB
	  /* LSD -------------------------------------------- */
	  else if (strncmp(s, "%lsd", 4) == 0) {
	    changeNotation(LSD);
	    for (nextc = peek(); nextc != '\0'; nextc = peek()) {
	      if (Inp_Dev->newline && (nextc == '%' || nextc == '>'
				       || nextc == '<')) {
		if (nextc == '>' || nextc == '<') {
		  input();
		  getAgentName();
		} else {
		  nextc = '\n';
		  return;
		}
	      } else {
		lsd_lex(keyin());
	      }
	    }
	    keyin();	/* read the null character */
	    lsd_lex('\n');	/* treat end-of-file as end-of-line */
	  } /* end if (strncmp(s, "%lsd", 4)... */
#endif /* DISTRIB */

	  /* This push and pop facility ("%+eden") appears be used
             only in Donald [Ash] */

	  /* Push entry -------------------------------------------- */
	  else if (s[1] == '+') {
	    /*  appAgentName=0; */
	    if ((strncmp(s + 2, "donald0", 7) == 0) ||
		(strncmp(s + 2, "donald", 6) == 0)) {	/* is DoNaLD */
	      pushEntryStack(DONALD);
	    } else if (strncmp(s + 2, "scout", 5) == 0) {	/* is SCOUT */
	      pushEntryStack(SCOUT);
	    } else if (strncmp(s + 2, "eden", 4) == 0) {	/* is EDEN */
	      pushEntryStack(EDEN);
#ifdef WANT_SASAMI
	    } else if (strncmp(s + 2, "sasami", 6) == 0) {	/* is Sasami */
	      pushEntryStack(SASAMI);
#endif /* WANT_SASAMI */
	    }
	  } /* end if (s[1] == '+') */


	  /* Pop entry -------------------------------------------- */
	  else if (s[1] == '-') {
	    if ((strncmp(s + 2, "donald0", 7) == 0)
		|| strncmp(s + 2, "donald", 6) == 0
		|| strncmp(s + 2, "scout", 5) == 0	/* is SCOUT */
#ifdef WANT_SASAMI
		|| strncmp(s + 2, "sasami", 6) == 0	/* is Sasami */
#endif
		|| strncmp(s + 2, "eden", 4) == 0) {	/* is EDEN */
	      popEntryStack();
	      /*  appAgentName=1; */
	    }
	  } /* end if (s[1] == '-') */

#endif /* not TTYEDEN */

	  /* Eden -------------------------------------------- */
	  else {
	    changeNotation(EDEN);
	  }

	  return;

	} else if (nextc == 0) {
	  /* EOF */
#ifdef TTYEDEN
	  /* Dummy if start to make the else's below work... [Ash] */
	  if (0) {}
#else
	  if ((strncmp(s, "%donald0", 8) == 0) ||
	      (strncmp(s, "%donald", 7) == 0)) {	/* is DoNaLD */
	    changeNotation(DONALD);
	  }
	  else if (strncmp(s, "%scout", 6) == 0) {	/* is SCOUT */
	    changeNotation(SCOUT);
	  }
#ifdef WANT_SASAMI
	  else if (strncmp(s, "%sasami", 7) == 0) {	/* is Sasami */
	    changeNotation(SASAMI);
	  }
#endif /* WANT_SASAMI */
#endif /* not TTYEDEN */
          else if (notationSwitch(s)) {
	    changeNotation(NEWOTHER);
	  } else {		/* is EDEN */
	    changeNotation(EDEN);
	  }
	  return;
	} /* end if nextc==0 */
    } /* end for ;; */
} /* end skip_percent_comment */
void ScriptWindow::initActions()
{
	actionNew = new QAction(QPixmap(new_xpm), tr("&New"), this);
	actionNew->setShortcut( tr("Ctrl+N") );
	connect(actionNew, SIGNAL(activated()), this, SLOT(newScript()));
	file->addAction(actionNew);

	actionOpen = new QAction(QPixmap(fileopen_xpm), tr("&Open..."), this);
	actionOpen->setShortcut( tr("Ctrl+O") );
	connect(actionOpen, SIGNAL(activated()), this, SLOT(open()));
	file->addAction(actionOpen);

	actionSave = new QAction(QPixmap(filesave_xpm), tr("&Save"), this);
	actionSave->setShortcut( tr("Ctrl+S") );
	connect(actionSave, SIGNAL(activated()), this, SLOT(save()));
	file->addAction(actionSave);

	actionSaveAs = new QAction(tr("Save &As..."), this);
	connect(actionSaveAs, SIGNAL(activated()), this, SLOT(saveAs()));
	file->addAction(actionSaveAs);

	actionPrint = new QAction(QPixmap(fileprint_xpm), tr("&Print"), this);
	actionPrint->setShortcut( tr("Ctrl+P") );
	connect(actionPrint, SIGNAL(activated()), te, SLOT(print()));
	file->addAction(actionPrint);

	actionUndo = new QAction(QPixmap(undo_xpm), tr("&Undo"), this);
	actionUndo->setShortcut( tr("Ctrl+Z") );
	connect(actionUndo, SIGNAL(activated()), te, SLOT(undo()));
	edit->addAction(actionUndo);
	actionUndo->setEnabled(false);

	actionRedo = new QAction(QPixmap(redo_xpm), tr("&Redo"), this);
	actionRedo->setShortcut( tr("Ctrl+Y") );
	connect(actionRedo, SIGNAL(activated()), te, SLOT(redo()));
	edit->addAction(actionRedo);
	actionRedo->setEnabled(false);
	edit->insertSeparator();

	actionCut = new QAction(QPixmap(cut_xpm), tr("&Cut"), this);
	actionCut->setShortcut( tr("Ctrl+x") );
	connect(actionCut, SIGNAL(activated()), te, SLOT(cut()));
	edit->addAction(actionCut);
	actionCut->setEnabled(false);

	actionCopy = new QAction(QPixmap(copy_xpm), tr("&Copy"), this);
	actionCopy->setShortcut( tr("Ctrl+C") );
	connect(actionCopy, SIGNAL(activated()), te, SLOT(copy()));
	edit->addAction(actionCopy);
	actionCopy->setEnabled(false);

	actionPaste = new QAction(QPixmap(paste_xpm), tr("&Paste"), this);
	actionPaste->setShortcut( tr("Ctrl+V") );
	connect(actionPaste, SIGNAL(activated()), te, SLOT(paste()));
	edit->addAction(actionPaste);

	edit->insertSeparator();

	actionShowLineNumbers = new QAction(tr("Show &Line Numbers"), this);
	actionShowLineNumbers->setCheckable(true);
	actionShowLineNumbers->setChecked(d_app->d_note_line_numbers);
	connect(actionShowLineNumbers, SIGNAL(toggled(bool)), d_line_number, SLOT(setVisible(bool)));
	edit->addAction(actionShowLineNumbers);

	actionExecute = new QAction(tr("E&xecute"), this);
	actionExecute->setShortcut( tr("CTRL+J") );
	connect(actionExecute, SIGNAL(activated()), te, SLOT(execute()));
	run->addAction(actionExecute);

	actionExecuteAll = new QAction(tr("Execute &All"), this);
	actionExecuteAll->setShortcut( tr("CTRL+SHIFT+J") );
	connect(actionExecuteAll, SIGNAL(activated()), te, SLOT(executeAll()));
	run->addAction(actionExecuteAll);

	actionEval = new QAction(tr("&Evaluate Expression"), this);
	actionEval->setShortcut( tr("CTRL+Return") );
	connect(actionEval, SIGNAL(activated()), te, SLOT(evaluate()));
	run->addAction(actionEval);

	actionAlwaysOnTop = new QAction(tr("Always on &Top"), this);
	actionAlwaysOnTop->setCheckable(true);
	if (d_app)
		actionAlwaysOnTop->setChecked (d_app->d_script_win_on_top);
	windowMenu->addAction(actionAlwaysOnTop);
	connect(actionAlwaysOnTop, SIGNAL(toggled(bool)), this, SLOT(setAlwaysOnTop(bool)));

	actionHide = new QAction(tr("&Hide"), this);
	connect(actionHide, SIGNAL(activated()), this, SLOT(close()));
	windowMenu->addAction(actionHide);

	connect(te, SIGNAL(copyAvailable(bool)), actionCut, SLOT(setEnabled(bool)));
	connect(te, SIGNAL(copyAvailable(bool)), actionCopy, SLOT(setEnabled(bool)));
	connect(te, SIGNAL(undoAvailable(bool)), actionUndo, SLOT(setEnabled(bool)));
	connect(te, SIGNAL(redoAvailable(bool)), actionRedo, SLOT(setEnabled(bool)));
}
Пример #5
0
void PythonEditor::createWidgets() {
    runBt_ = new QToolButton();
    runBt_->setIcon(QIcon(":/modules/python/python.png"));
    runBt_->setIconSize(QSize(24, 24));
    runBt_->setShortcut(QKeySequence("Ctrl+R"));
    runBt_->setToolTip("Run Script (Ctrl+R)");
    newBt_ = new QToolButton();
    newBt_->setIcon(QIcon(":/modules/python/python_2.png"));
    newBt_->setIconSize(QSize(24, 24));
    newBt_->setToolTip("New Script");
    openBt_ = new QToolButton();
    openBt_->setIcon(QIcon(":/qt/icons/open.png"));
    openBt_->setIconSize(QSize(24, 24));
    openBt_->setToolTip("Load Script");
    saveBt_ = new QToolButton();
    saveBt_->setIcon(QIcon(":/qt/icons/save.png"));
    saveBt_->setIconSize(QSize(24, 24));
    saveBt_->setToolTip("Save Script");
    saveAsBt_ = new QToolButton();
    saveAsBt_->setIcon(QIcon(":/qt/icons/saveas.png"));
    saveAsBt_->setIconSize(QSize(24, 24));
    saveAsBt_->setToolTip("Save Script As");

    increaseFontSizeBt_ = new QToolButton();
    increaseFontSizeBt_->setIcon(QIcon(":/qt/icons/viewmag+.png"));
    increaseFontSizeBt_->setIconSize(QSize(24, 24));
    increaseFontSizeBt_->setToolTip("Increase Font Size");
    decreaseFontSizeBt_ = new QToolButton();
    decreaseFontSizeBt_->setIcon(QIcon(":/qt/icons/viewmag_.png"));
    decreaseFontSizeBt_->setIconSize(QSize(24, 24));
    decreaseFontSizeBt_->setToolTip("Decrease Font Size");

    QHBoxLayout* hbox = new QHBoxLayout();
    hbox->setContentsMargins(0,0,0,0);
    hbox->addWidget(runBt_);
    QFrame* sep = new QFrame();
    sep->setFrameShape(QFrame::VLine);
    hbox->addWidget(sep);
    hbox->addWidget(newBt_);
    hbox->addWidget(openBt_);
    hbox->addWidget(saveBt_);
    hbox->addWidget(saveAsBt_);
    hbox->addStretch();
    hbox->addWidget(increaseFontSizeBt_);
    hbox->addWidget(decreaseFontSizeBt_);
    QWidget* toolButtonBar = new QWidget();
    toolButtonBar->setLayout(hbox);

    QFont font;
    font.setFamily("Courier");
    font.setFixedPitch(true);
    font.setPointSize(fontSize_);

    codeEdit_ = new CodeEdit();
    codeEdit_->setFont(font);
    highlighter_ = new PythonHighlighter(codeEdit_->document());

    compilerLogWidget_ = new QTextEdit();
    compilerLogWidget_->setFont(font);
    compilerLogWidget_->setReadOnly(true);
    compilerLogWidget_->setFixedHeight(150);
    QVBoxLayout* vbox = new QVBoxLayout();
    vbox->addWidget(toolButtonBar);
    vbox->addWidget(codeEdit_);
    vbox->addWidget(compilerLogWidget_);
    setLayout(vbox);

    connect(runBt_, SIGNAL(clicked()), this, SLOT(runScript()));
    connect(newBt_, SIGNAL(clicked()), this, SLOT(newScript()));
    connect(openBt_, SIGNAL(clicked()), this, SLOT(openScript()));
    connect(saveBt_, SIGNAL(clicked()), this, SLOT(saveScript()));
    connect(saveAsBt_, SIGNAL(clicked()), this, SLOT(saveScriptAs()));
    connect(increaseFontSizeBt_, SIGNAL(clicked()), this, SLOT(increaseFontSize()));
    connect(decreaseFontSizeBt_, SIGNAL(clicked()), this, SLOT(decreaseFontSize()));
    connect(codeEdit_, SIGNAL(textChanged()), this, SIGNAL(modified()));

    setMinimumSize(300, 400);
}