//! [11] void MainWindow::changeModel() { delete completer; completer = new QCompleter(this); completer->setMaxVisibleItems(maxVisibleSpinBox->value()); switch (modelCombo->currentIndex()) { default: case 0: { // Unsorted QFileSystemModel QFileSystemModel *fsModel = new QFileSystemModel(completer); fsModel->setRootPath(""); completer->setModel(fsModel); contentsLabel->setText(tr("Enter file path")); } break; //! [11] //! [12] case 1: { // FileSystemModel that shows full paths FileSystemModel *fsModel = new FileSystemModel(completer); completer->setModel(fsModel); fsModel->setRootPath(""); contentsLabel->setText(tr("Enter file path")); } break; //! [12] //! [13] case 2: { // Country List completer->setModel(modelFromFile(":/resources/countries.txt")); QTreeView *treeView = new QTreeView; completer->setPopup(treeView); treeView->setRootIsDecorated(false); treeView->header()->hide(); treeView->header()->setStretchLastSection(false); treeView->header()->setResizeMode(0, QHeaderView::Stretch); treeView->header()->setResizeMode(1, QHeaderView::ResizeToContents); contentsLabel->setText(tr("Enter name of your country")); } break; //! [13] //! [14] case 3: { // Word list completer->setModel(modelFromFile(":/resources/wordlist.txt")); completer->setModelSorting(QCompleter::CaseInsensitivelySortedModel); contentsLabel->setText(tr("Enter a word")); } break; } changeMode(modeCombo->currentIndex()); changeCase(caseCombo->currentIndex()); completer->setWrapAround(wrapCheckBox->isChecked()); lineEdit->setCompleter(completer); connect(wrapCheckBox, SIGNAL(clicked(bool)), completer, SLOT(setWrapAround(bool))); }
void MainWindow::setupEditor() { QFont font; font.setFamily("Courier"); font.setFixedPitch(true); font.setPointSize(10); statusLabel = new QLabel; statusLabel->setTextFormat(Qt::RichText); statusBar()->addWidget(statusLabel); completingTextEdit = new TextEditor; completer = new QCompleter(this); completer->setModel(modelFromFile(":resources/wordlist.txt")); completer->setModelSorting(QCompleter::CaseInsensitivelySortedModel); completer->setCaseSensitivity(Qt::CaseInsensitive); completer->setWrapAround(false); completingTextEdit->setLineWrapMode(QTextEdit::NoWrap); completingTextEdit->setCompleter(completer); completingTextEdit->setContextMenuPolicy(Qt::ActionsContextMenu); setCentralWidget(completingTextEdit); completingTextEdit->setFont(font); completingTextEdit->setPalette(Qt::white); highlighter = new Highlighter(completingTextEdit->document()); QFile file("mainwindow.h"); if (file.open(QFile::ReadOnly | QFile::Text)) completingTextEdit->setPlainText(file.readAll()); }
//! [0] MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), completer(0) { createMenu(); completingTextEdit = new TextEdit; completer = new QCompleter(this); completer->setModel(modelFromFile(":/resources/wordlist.txt")); completer->setModelSorting(QCompleter::CaseInsensitivelySortedModel); completer->setCaseSensitivity(Qt::CaseInsensitive); completer->setWrapAround(false); completingTextEdit->setCompleter(completer); setCentralWidget(completingTextEdit); resize(500, 300); setWindowTitle(tr("Completer")); }
void Ventana_Principal::AnalisisJSLT() { Pestana *actual = (Pestana*)ui->tabWidget->currentWidget(); if(actual != NULL){ QFile file("temp2.txt"); //SE CREA UN ARCHIVO TEMPORAL PARA COMPILARLO if ( file.open( file.WriteOnly ) ) { //BUFFER PARA EL TEXTO QUE SE DESEA COMPILAR QTextStream stream1( &file ); stream1 << actual->enviar_texto(); } //INICIO DE AUTOCOMPLETADO completer->setModel(modelFromFile("/home/jerduar/COMPI2/palabras.txt")); completer->setModelSorting(QCompleter::CaseInsensitivelySortedModel); completer->setCaseSensitivity(Qt::CaseInsensitive); completer->setWrapAround(false); actual->setCompleter(completer); const char* x = "temp2.txt"; FILE* input = fopen(x, "r" ); this->errores->ven()->clear(); SetVentana(this->errores->ven()); SetVentanita(this->errores->ven()); jjsetFila(); jjsetColumna(); setEdit_jslt(actual->textedit()); jjrestart(input);//SE PASA LA CADENA DE ENTRADA A FLEX jjparse();//SE INICIA LA COMPILACION ArbolAST *nuevo; nuevo = setArbol(); if(nuevo != NULL){ //nuevo->Dibujar(); }else{ //QMessageBox::information(this,"ÁRBOL","El árbol es nulo"); } } }
//! [0] MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), completer(0), lineEdit(0) { createMenu(); completer = new TreeModelCompleter(this); completer->setModel(modelFromFile(":/resources/treemodel.txt")); completer->setSeparator(QLatin1String(".")); QObject::connect(completer, SIGNAL(highlighted(QModelIndex)), this, SLOT(highlight(QModelIndex))); QWidget *centralWidget = new QWidget; QLabel *modelLabel = new QLabel; modelLabel->setText(tr("Tree Model<br>(Double click items to edit)")); QLabel *modeLabel = new QLabel; modeLabel->setText(tr("Completion Mode")); modeCombo = new QComboBox; modeCombo->addItem(tr("Inline")); modeCombo->addItem(tr("Filtered Popup")); modeCombo->addItem(tr("Unfiltered Popup")); modeCombo->setCurrentIndex(1); QLabel *caseLabel = new QLabel; caseLabel->setText(tr("Case Sensitivity")); caseCombo = new QComboBox; caseCombo->addItem(tr("Case Insensitive")); caseCombo->addItem(tr("Case Sensitive")); caseCombo->setCurrentIndex(0); //! [0] //! [1] QLabel *separatorLabel = new QLabel; separatorLabel->setText(tr("Tree Separator")); QLineEdit *separatorLineEdit = new QLineEdit; separatorLineEdit->setText(completer->separator()); connect(separatorLineEdit, SIGNAL(textChanged(QString)), completer, SLOT(setSeparator(QString))); QCheckBox *wrapCheckBox = new QCheckBox; wrapCheckBox->setText(tr("Wrap around completions")); wrapCheckBox->setChecked(completer->wrapAround()); connect(wrapCheckBox, SIGNAL(clicked(bool)), completer, SLOT(setWrapAround(bool))); contentsLabel = new QLabel; contentsLabel->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed); connect(separatorLineEdit, SIGNAL(textChanged(QString)), this, SLOT(updateContentsLabel(QString))); treeView = new QTreeView; treeView->setModel(completer->model()); treeView->header()->hide(); treeView->expandAll(); //! [1] //! [2] connect(modeCombo, SIGNAL(activated(int)), this, SLOT(changeMode(int))); connect(caseCombo, SIGNAL(activated(int)), this, SLOT(changeCase(int))); lineEdit = new QLineEdit; lineEdit->setCompleter(completer); //! [2] //! [3] QGridLayout *layout = new QGridLayout; layout->addWidget(modelLabel, 0, 0); layout->addWidget(treeView, 0, 1); layout->addWidget(modeLabel, 1, 0); layout->addWidget(modeCombo, 1, 1); layout->addWidget(caseLabel, 2, 0); layout->addWidget(caseCombo, 2, 1); layout->addWidget(separatorLabel, 3, 0); layout->addWidget(separatorLineEdit, 3, 1); layout->addWidget(wrapCheckBox, 4, 0); layout->addWidget(contentsLabel, 5, 0, 1, 2); layout->addWidget(lineEdit, 6, 0, 1, 2); centralWidget->setLayout(layout); setCentralWidget(centralWidget); changeCase(caseCombo->currentIndex()); changeMode(modeCombo->currentIndex()); setWindowTitle(tr("Tree Model Completer")); lineEdit->setFocus(); }
QFEHelpEditorWidget::QFEHelpEditorWidget(QWidget* parent) : QWidget(parent), ui(new Ui::QFEHelpEditorWidget) { modified=false; newScript=true; ui->setupUi(this); ui->edtScript->getEditor()->setWordWrapMode(QTextOption::WrapAtWordBoundaryOrAnywhere); ui->edtScript->getEditor()->setLineWrapMode(QTextEdit::WidgetWidth); connect(ui->edtScript->getEditor()->document(), SIGNAL(contentsChanged()), this, SLOT(documentWasModified())); highlighter=new QFHTMLHighlighter("", ui->edtScript->getEditor()->document()); highlighter->setUseSpecial2("$(", ")$"); highlighter->setUseSpecial1("$$", "$$"); completer = new QCompleter(ui->edtScript->getEditor()); completermodel=modelFromFile(ProgramOptions::getInstance()->getAssetsDirectory()+"/qtscript/completer.txt"); completer->setModel(completermodel); completer->setModelSorting(QCompleter::CaseInsensitivelySortedModel); completer->setCaseSensitivity(Qt::CaseInsensitive); completer->setWrapAround(false); ui->edtScript->getEditor()->setCompleter(completer); recentHelpFiles=new QRecentFilesMenu(this); recentHelpFiles->setUseSystemFileIcons(false); recentHelpFiles->setAlwaysEnabled(true); connect(recentHelpFiles, SIGNAL(openRecentFile(QString)), this, SLOT(openScriptNoAsk(QString))); ui->btnOpen->setMenu(recentHelpFiles); connect(ui->edtScript->getEditor(), SIGNAL(cursorPositionChanged()), this, SLOT(edtScript_cursorPositionChanged())); actLoadAutosave=new QFActionWithNoMenuRole(tr("load last autosaved file ..."), this); connect(actLoadAutosave, SIGNAL(triggered()), this, SLOT(reloadLastAutosave())); cutAct = new QFActionWithNoMenuRole(QIcon(":/qfe_helpeditor/script_cut.png"), tr("Cu&t"), this); cutAct->setShortcut(tr("Ctrl+X")); cutAct->setToolTip(tr("Cut the current selection's contents to the " "clipboard")); connect(cutAct, SIGNAL(triggered()), ui->edtScript->getEditor(), SLOT(cut())); copyAct = new QFActionWithNoMenuRole(QIcon(":/qfe_helpeditor/script_copy.png"), tr("&Copy"), this); copyAct->setShortcut(tr("Ctrl+C")); copyAct->setToolTip(tr("Copy the current selection's contents to the " "clipboard")); connect(copyAct, SIGNAL(triggered()), ui->edtScript->getEditor(), SLOT(copy())); pasteAct = new QFActionWithNoMenuRole(QIcon(":/qfe_helpeditor/script_paste.png"), tr("&Paste"), this); pasteAct->setShortcut(tr("Ctrl+V")); pasteAct->setToolTip(tr("Paste the clipboard's contents into the current " "selection")); connect(pasteAct, SIGNAL(triggered()), ui->edtScript->getEditor(), SLOT(paste())); undoAct = new QFActionWithNoMenuRole(QIcon(":/qfe_helpeditor/script_undo.png"), tr("&Undo"), this); undoAct->setShortcut(tr("Ctrl+Z")); undoAct->setToolTip(tr("Undo the last change ")); connect(undoAct, SIGNAL(triggered()), ui->edtScript->getEditor(), SLOT(undo())); redoAct = new QFActionWithNoMenuRole(QIcon(":/qfe_helpeditor/script_redo.png"), tr("&Redo"), this); redoAct->setShortcut(tr("Ctrl+Shift+Z")); redoAct->setToolTip(tr("Redo the last undone change ")); connect(redoAct, SIGNAL(triggered()), ui->edtScript->getEditor(), SLOT(redo())); findAct = new QFActionWithNoMenuRole(QIcon(":/qfe_helpeditor/script_find.png"), tr("&Find ..."), this); findAct->setShortcut(tr("Ctrl+F")); findAct->setToolTip(tr("Find a string in sequence ")); connect(findAct, SIGNAL(triggered()), this, SLOT(findFirst())); findNextAct = new QFActionWithNoMenuRole(QIcon(":/qfe_helpeditor/script_find_next.png"), tr("Find &next"), this); findNextAct->setShortcut(tr("F3")); findNextAct->setToolTip(tr("Find the next occurence ")); connect(findNextAct, SIGNAL(triggered()), this, SLOT(findNext())); findNextAct->setEnabled(false); replaceAct = new QFActionWithNoMenuRole(QIcon(":/qfe_helpeditor/script_find_replace.png"), tr("Find && &replace ..."), this); replaceAct->setShortcut(tr("Ctrl+R")); replaceAct->setToolTip(tr("Find a string in sequence and replace it with another string ")); connect(replaceAct, SIGNAL(triggered()), this, SLOT(replaceFirst())); commentAct = new QFActionWithNoMenuRole(tr("&Comment text"), this); commentAct->setShortcut(tr("Ctrl+B")); commentAct->setToolTip(tr("add (single line) comment at the beginning of each line ")); connect(commentAct, SIGNAL(triggered()), ui->edtScript->getEditor(), SLOT(comment())); unCommentAct = new QFActionWithNoMenuRole(tr("&Uncomment text"), this); unCommentAct->setShortcut(tr("Ctrl+Shift+B")); unCommentAct->setToolTip(tr("remove (single line) comment at the beginning of each line ")); connect(unCommentAct, SIGNAL(triggered()), ui->edtScript->getEditor(), SLOT(uncomment())); indentAct = new QFActionWithNoMenuRole(QIcon(":/qfe_helpeditor/script_indent.png"), tr("&Increase indention"), this); commentAct->setShortcut(tr("Ctrl+I")); indentAct->setToolTip(tr("increase indention ")); connect(indentAct, SIGNAL(triggered()), ui->edtScript->getEditor(), SLOT(indentInc())); unindentAct = new QFActionWithNoMenuRole(QIcon(":/qfe_helpeditor/script_unindent.png"), tr("&Decrease indention"), this); unindentAct->setShortcut(tr("Ctrl+Shift+I")); unindentAct->setToolTip(tr("decrease indention ")); connect(unindentAct, SIGNAL(triggered()), ui->edtScript->getEditor(), SLOT(indentDec())); gotoLineAct = new QFActionWithNoMenuRole(tr("&Goto line ..."), this); gotoLineAct->setShortcut(tr("Alt+G")); gotoLineAct->setToolTip(tr("goto a line in the opened file ")); connect(gotoLineAct, SIGNAL(triggered()), this, SLOT(gotoLine())); printAct = new QFActionWithNoMenuRole(QIcon(":/qfe_helpeditor/script_print.png"), tr("&Print ..."), this); printAct->setToolTip(tr("print the current SDFF file ")); connect(printAct, SIGNAL(triggered()), this, SLOT(print())); actInsertIcon = new QFActionWithNoMenuRole(QIcon(":/qfe_helpeditor/insert_image.png"), tr("&Insert icon ..."), this); actInsertIcon->setToolTip(tr("print the current SDFF file ")); connect(actInsertIcon, SIGNAL(triggered()), this, SLOT(insertIcon())); toEntityAct = new QFActionWithNoMenuRole(QIcon(":/qfe_helpeditor/toentity.png"), tr("&Convert characters to entities ..."), this); toEntityAct->setToolTip(tr("convert characters in the selected text to HTML entities")); connect(toEntityAct, SIGNAL(triggered()), this, SLOT(toEntity())); toCharAct = new QFActionWithNoMenuRole(QIcon(":/qfe_helpeditor/tochars.png"), tr("&Convert entities to characters ..."), this); toCharAct->setToolTip(tr("convert HTML entities in the selected text to characters")); connect(toCharAct, SIGNAL(triggered()), this, SLOT(toChars())); cutAct->setEnabled(false); copyAct->setEnabled(false); undoAct->setEnabled(false); redoAct->setEnabled(false); connect(ui->edtScript->getEditor(), SIGNAL(copyAvailable(bool)), cutAct, SLOT(setEnabled(bool))); connect(ui->edtScript->getEditor(), SIGNAL(copyAvailable(bool)), copyAct, SLOT(setEnabled(bool))); connect(ui->edtScript->getEditor(), SIGNAL(undoAvailable(bool)), undoAct, SLOT(setEnabled(bool))); connect(ui->edtScript->getEditor(), SIGNAL(redoAvailable(bool)), redoAct, SLOT(setEnabled(bool))); connect(ui->edtScript->getEditor(), SIGNAL(findNextAvailable(bool)), findNextAct, SLOT(setEnabled(bool))); QMenu* menuMore=new QMenu(ui->tbMoreOptions); menuMore->addAction(indentAct); menuMore->addAction(unindentAct); menuMore->addAction(commentAct); menuMore->addAction(unCommentAct); menuMore->addSeparator(); menuMore->addAction(toEntityAct); menuMore->addAction(toCharAct); menuMore->addSeparator(); menuMore->addAction(actInsertIcon); menuMore->addSeparator(); menuMore->addAction(gotoLineAct); menuMore->addAction(findAct); menuMore->addAction(replaceAct); menuMore->addAction(findNextAct); menuMore->addSeparator(); menuMore->addAction(actLoadAutosave); ui->tbMoreOptions->setMenu(menuMore); ui->tbFind->setDefaultAction(findAct); ui->tbFindNext->setDefaultAction(findNextAct); ui->tbReplace->setDefaultAction(replaceAct); ui->tbPrint->setDefaultAction(printAct); ui->tbCopy->setDefaultAction(copyAct); ui->tbCut->setDefaultAction(cutAct); ui->tbPaste->setDefaultAction(pasteAct); ui->tbRedo->setDefaultAction(redoAct); ui->tbUndo->setDefaultAction(undoAct); ui->tbEntity->setDefaultAction(toEntityAct); ui->tbChars->setDefaultAction(toCharAct); setScriptFilename(""); QMenu* menu; menu=new QMenu(tr("directories"), this); ui->edtScript->getEditor()->addAction(menu->menuAction()); addInsertAction(menu, "$$mainhelpdir$$"); addInsertAction(menu, "$$mainhelppicdir$$"); addInsertAction(menu, "$$assetsdir$$"); addInsertAction(menu, "$$examplesdir$$"); addInsertAction(menu, "$$configdir$$"); addInsertAction(menu, "$$maindir$$"); addInsertAction(menu, "$$sourcedir$$"); menu=new QMenu(tr("version/copyright info"), this); ui->edtScript->getEditor()->addAction(menu->menuAction()); addInsertAction(menu, "$$version.svnrevision$$"); addInsertAction(menu, "$$version.status$$"); addInsertAction(menu, "$$version.date$$"); addInsertAction(menu, "$$version$$"); addInsertAction(menu, "$$version_full$$"); menu->addSeparator(); addInsertAction(menu, "$$thanksto$$"); addInsertAction(menu, "$$copyright$$"); addInsertAction(menu, "$$author$$"); addInsertAction(menu, "$$weblink$$"); addInsertAction(menu, "$$license$$"); addInsertAction(menu, "$$maillist$$"); addInsertAction(menu, "$$maillistrequest$$"); menu->addSeparator(); addInsertAction(menu, "$$qfcitation$$"); addInsertAction(menu, "$$qfcitation_bibtex$$"); addInsertAction(menu, "$$jankrieger_phdthesis$$"); addInsertAction(menu, "$$jankrieger_phdthesis_ref$$"); menu=new QMenu(tr("general help links"), this); ui->edtScript->getEditor()->addAction(menu->menuAction()); addInsertAction(menu, tr("Link: RDR general help"), "<a href=\"$qf_ui_rdr_helpfile$$\">$$qf_ui_rdr_helpfiletitle$$</a>" ); addInsertAction(menu, tr("Link: Evaluation general help"), "<a href=\"$$qf_ui_eval_helpfile$$\">$$qf_ui_eval_helpfiletitle$$</a>" ); addInsertAction(menu, tr("Link: Plotter Widget general help"), "<a href=\"$$qf_ui_jkqtplotter_helpfile$$\">$$qf_ui_jkqtplotter_helpfiletitle$$</a>" ); addInsertAction(menu, tr("Link: LaTeX parser general help"), "<a href=\"$$qf_ui_latex_helpfile$$\">$$qf_ui_latex_helpfiletitle$$</a>" ); addInsertAction(menu, tr("Link: Expression parser help"), "<a href=\"$$qf_mathparser_helpfile$$\">$$qf_mathparser_helpfiletitle$$</a>" ); //addInsertAction(menu, tr("Link: help"), "<a href=\"$$aa$$\">$$aa$$</a>" ); //addInsertAction(menu, tr("Link: help"), QString("<a href=\"$$mainhelpdir$$aa\">aa</a>") ); addInsertAction(menu, tr("Link: Custom color palettes help"), QString("<a href=\"$$mainhelpdir$$colorpalettes.html\">custom color paletes</a>") ); addInsertAction(menu, tr("Link: Available color palettes"), QString("<a href=\"$$mainhelpdir$$installedcolorpalettes.html\">available color paletes</a>") ); addInsertAction(menu, tr("Link: Regular Expressions"), QString("<a href=\"$$mainhelpdir$$qf3_qtregexp.html\">regular expressions</a>") ); addInsertAction(menu, tr("Link: Fit Functions"), QString("<a href=\"$$mainhelpdir$$qf3_fitfunc.html\">fit functions</a>") ); addInsertAction(menu, tr("Link: Fit Algorithms"), QString("<a href=\"$$mainhelpdir$$qf3_fitalg.html\">fit algorithms</a>") ); addInsertAction(menu, tr("Link: File Formats"), QString("<a href=\"$$mainhelpdir$$qf3_fileformats.html\">file formats</a>") ); addInsertAction(menu, tr("Link: GPL 3.0"), QString("<a href=\"$$mainhelpdir$$gpl3_0.html\">GPL 3.0</a>") ); addInsertAction(menu, tr("Link: FAQs"), QString("<a href=\"$$qf_faqfile$$\">Frequently asked questions</a>") ); menu->addSeparator(); addInsertAction(menu, "$$qf_ui_rdr_helpfile$$"); addInsertAction(menu, "$$qf_ui_rdr_helpfiletitle$$"); addInsertAction(menu, "$$qf_ui_eval_helpfile$$"); addInsertAction(menu, "$$qf_ui_eval_helpfiletitle$$"); addInsertAction(menu, "$$qf_ui_jkqtplotter_helpfile$$"); addInsertAction(menu, "$$qf_ui_jkqtplotter_helpfiletitle$$"); addInsertAction(menu, "$$qf_ui_latex_helpfile$$"); addInsertAction(menu, "$$qf_ui_latex_helpfiletitle$$"); addInsertAction(menu, "$$qf_mathparser_helpfile$$"); addInsertAction(menu, "$$qf_mathparser_helpfiletitle$$"); addInsertAction(menu, "$$qf_faqfile$$"); menu=new QMenu(tr("page header/footer"), this); ui->edtScript->getEditor()->addAction(menu->menuAction()); addInsertAction(menu, "$$qf_commondoc_backtop$$"); menu->addSeparator(); addInsertAction(menu, "$$qf_commondoc_footer.start$$"); addInsertAction(menu, "$$qf_commondoc_footer.end$$"); menu->addSeparator(); addInsertAction(menu, "$$qf_commondoc_header.start$$"); addInsertAction(menu, "$$qf_commondoc_header.end$$"); addInsertAction(menu, "$$qf_commondoc_header.end_notitle$$"); addInsertAction(menu, "$$qf_commondoc_header.rdr$$"); addInsertAction(menu, "$$qf_commondoc_header.eval$$"); addInsertAction(menu, "$$qf_commondoc_header.extension$$"); addInsertAction(menu, "$$qf_commondoc_header.fitfunc$$"); addInsertAction(menu, "$$qf_commondoc_header.fitalg$$"); addInsertAction(menu, "$$qf_commondoc_header.separator$$"); menu=new QMenu(tr("plugin info"), this); ui->edtScript->getEditor()->addAction(menu->menuAction()); addInsertAction(menu, "$$local_plugin_icon$$"); addInsertAction(menu, "$$local_plugin_iconfilename$$"); addInsertAction(menu, "$$local_plugin_name$$"); addInsertAction(menu, "$$local_plugin_author$$"); addInsertAction(menu, "$$local_plugin_copyright$$"); addInsertAction(menu, "$$local_plugin_weblink_url$$"); addInsertAction(menu, "$$local_plugin_weblink$$"); addInsertAction(menu, "$$local_plugin_id$$"); addInsertAction(menu, "$$local_plugin_subid$$"); addInsertAction(menu, "$$local_plugin_subname$$"); addInsertAction(menu, "$$local_plugin_subshortname$$"); addInsertAction(menu, "$$local_plugin_tutorial_file$$"); addInsertAction(menu, "$$local_plugin_tutorial_link$$"); addInsertAction(menu, "$$local_plugin_mainhelp_file$$"); addInsertAction(menu, "$$local_plugin_mainhelp_link$$"); addInsertAction(menu, "$$local_plugin_version$$"); addInsertAction(menu, "$$local_plugin_typehelp_link$$"); addInsertAction(menu, "$$local_plugin_typehelp_file$$"); addInsertAction(menu, "$$local_plugin_assets$$"); addInsertAction(menu, "$$local_plugin_examples$$"); addInsertAction(menu, "$$local_plugin_help$$"); addInsertAction(menu, "$$local_plugin_config$$"); addInsertAction(menu, "$$local_plugin_tutorials$$"); menu->addSeparator(); addInsertAction(menu, "$$plugin_info:help:PLUGINID$$"); addInsertAction(menu, "$$plugin_info:tutorial:PLUGINID$$"); addInsertAction(menu, "$$plugin_info:helpdir:PLUGINID$$"); addInsertAction(menu, "$$plugin_info:assetsdir:PLUGINID$$"); addInsertAction(menu, "$$plugin_info:examplesdir:PLUGINID$$"); addInsertAction(menu, "$$plugin_info:configdir:PLUGINID$$"); menu->addSeparator(); addInsertAction(menu, "$$fitfunction:help:PLUGINID$$"); addInsertAction(menu, "$$fitfunction:name:PLUGINID$$"); addInsertAction(menu, "$$fitfunction:short_name:PLUGINID$$"); menu->addSeparator(); addInsertAction(menu, "$$fitalgorithm:help:PLUGINID$$"); addInsertAction(menu, "$$fitalgorithm:name:PLUGINID$$"); addInsertAction(menu, "$$fitalgorithm:short_name:PLUGINID$$"); menu->addSeparator(); addInsertAction(menu, "$$importer:help:PLUGINID$$"); addInsertAction(menu, "$$importer:name:PLUGINID$$"); addInsertAction(menu, "$$exporter:help:PLUGINID$$"); addInsertAction(menu, "$$exporter:name:PLUGINID$$"); menu=new QMenu(tr("plugin lists"), this); ui->edtScript->getEditor()->addAction(menu->menuAction()); addInsertAction(menu, "$$list:extension:INTERFACENAME$$"); addInsertAction(menu, "$$list:fitfunc:$$"); addInsertAction(menu, "$$list:fitfunc:STARTSWITH$$"); addInsertAction(menu, "$$list:fitfunc_inplugin:PLUGIN_ID|STARTSWITH$$"); addInsertAction(menu, "$$list:fitfunc_inplugin:PLUGIN_ID$$"); addInsertAction(menu, "$$list:fitalg:$$"); addInsertAction(menu, "$$list:fitalg:STARTSWITH$$"); addInsertAction(menu, "$$list:importers:STARTSWITH$$"); addInsertAction(menu, "$$list:exporters:STARTSWITH$$"); addInsertAction(menu, "$$list:plugin_tutorials:PLUGIN_ID$$"); menu=new QMenu(tr("help lists"), this); ui->edtScript->getEditor()->addAction(menu->menuAction()); addInsertAction(menu, "$$tutorials_contents$$"); addInsertAction(menu, "$$help_contents$$"); addInsertAction(menu, "$$settings_contents$$"); menu=new QMenu(tr("insert files"), this); ui->edtScript->getEditor()->addAction(menu->menuAction()); addInsertAction(menu, "$$insert:FILENAME$$"); addInsertAction(menu, "$$insertglobal:FILENAME$$"); menu=new QMenu(tr("insert Equations (LaTeX)"), this); ui->edtScript->getEditor()->addAction(menu->menuAction()); addInsertAction(menu, "$$math:LATEX$$"); addInsertAction(menu, "$(LATEX)$"); addInsertAction(menu, "$$bmath:LATEX$$"); addInsertAction(menu, "$[LATEX]$"); menu=new QMenu(tr("insert Literature References"), this); ui->edtScript->getEditor()->addAction(menu->menuAction()); addInsertAction(menu, "$$ref:<ID>:Text$$"); addInsertAction(menu, "$$ref:<ID>:$$"); addInsertAction(menu, "$$invisibleref:<ID>:Text$$"); addInsertAction(menu, "$$references$$"); menu=new QMenu(tr("insert Figures"), this); ui->edtScript->getEditor()->addAction(menu->menuAction()); addInsertAction(menu, "$$fig:FILENAME:CAPTION$$"); menu=new QMenu(tr("insert Info boxes"), this); ui->edtScript->getEditor()->addAction(menu->menuAction()); addInsertAction(menu, "$$see:Text$$"); addInsertAction(menu, "$$note:Text$$"); addInsertAction(menu, "$$info:Text$$"); addInsertAction(menu, "$$warning:Text$$"); addInsertAction(menu, "$$example:Text$$"); addInsertAction(menu, "$$codeexample:Text$$"); addInsertAction(menu, "$$bqtt:Text$$"); addInsertAction(menu, "$$bqcode:Text$$"); menu->addSeparator(); addInsertAction(menu, "$$startbox$$"); addInsertAction(menu, "$$startbox_info$$"); addInsertAction(menu, "$$startbox_note$$"); addInsertAction(menu, "$$startbox_see$$"); addInsertAction(menu, "$$startbox_warning$$"); addInsertAction(menu, "$$startbox_example$$"); addInsertAction(menu, "$$startbox:backgroundcolor:bordercolor$$"); addInsertAction(menu, "$$startbox:lightgrey:midnightblue$$"); addInsertAction(menu, "$$endbox$$"); menu=new QMenu(tr("insert Tooltips"), this); ui->edtScript->getEditor()->addAction(menu->menuAction()); addInsertAction(menu, "$$tooltip:PHRASE$$"); menu=new QMenu(tr("FAQs"), this); ui->edtScript->getEditor()->addAction(menu->menuAction()); addInsertAction(menu, tr("FAQ entry"), "$$faq_start$$\n <a name=\"FAQ1\"><b>Question?</b>\n$$faq_answer$$\n Answer ...\n$$faq_end$$"); menu->addSeparator(); addInsertAction(menu, "$$faq_start"); addInsertAction(menu, "$$faq_answer"); addInsertAction(menu, "$$faq_end"); menu=new QMenu(tr("Function References"), this); ui->edtScript->getEditor()->addAction(menu->menuAction()); addInsertAction(menu, tr("Function reference entry"), "$$funcref_start$$<a name=\"NAME\"/><!-- func:NAME -->\n <b><tt><!-- template -->NAME<!-- /template --></tt> - <i> DESCRIPTION </i>:</b>\n$$funcref_description$$\n DESCRIPTION\n <!-- /func:NAME -->\n$$funcref_end$$"); menu->addSeparator(); addInsertAction(menu, "$$funcref_start"); addInsertAction(menu, "$$funcref_description"); addInsertAction(menu, "$$funcref_end"); menu=new QMenu(tr("insert other markups"), this); ui->edtScript->getEditor()->addAction(menu->menuAction()); addInsertAction(menu, "$$tt:Text$$"); menu=new QMenu(tr("LaTeX"), this); ui->edtScript->getEditor()->addAction(menu->menuAction()); addInsertAction(menu, "\\left(%1#\\right)"); addInsertAction(menu, "\\left[%1#\\right]"); addInsertAction(menu, "\\left\\{%1#\\right\\}"); addInsertAction(menu, "\\left\\langle%1#\\right\\rangle"); menu->addSeparator(); addInsertAction(menu, "\\sqrt{%1#}"); menu->addSeparator(); addInsertAction(menu, "\\sum_{#}^{}%1"); addInsertAction(menu, "\\prod_{#}^{}%1"); addInsertAction(menu, "\\int_{#}^{}%1\\;\\mathrm{d}x"); addInsertAction(menu, "\\iint_{#}^{}%1\\;\\mathrm{d}^2x"); addInsertAction(menu, "\\iiint_{#}^{}%1\\;\\mathrm{d}^3x"); addInsertAction(menu, "\\oint_{#}^{}%1\\;\\mathrm{d}x"); addInsertAction(menu, "\\lim_{%1#}"); addInsertAction(menu, "\\argmin_{%1#}"); addInsertAction(menu, "\\argmax_{%1#}"); menu->addSeparator(); addInsertAction(menu, "\\vec{%1#}"); addInsertAction(menu, "\\hat{%1#}"); addInsertAction(menu, "\\tilde{%1#}"); addInsertAction(menu, "\\mathbf{%1#}"); addInsertAction(menu, "\\mathrm{%1#}"); addInsertAction(menu, "\\mathit{%1#}"); addInsertAction(menu, "\\mathsf{%1#}"); addInsertAction(menu, "\\mathbb{%1#}"); addInsertAction(menu, "\\mathscript{%1#}"); addInsertAction(menu, "\\underline{%1#}"); //addInsertAction(menu, "$$$$"); menu=new QMenu(tr("Special Characters"), this); ui->edtScript->getEditor()->addAction(menu->menuAction()); addInsertAction(menu, "$" "$"); addInsertAction(menu, "$$" "$$"); QTimer::singleShot(AUTOSAVE_INTERVAL_MSEC, this, SLOT(autosave())); }
DialogPacket::DialogPacket(QString type, QByteArray packet, QString scriptPath, QWidget *parent) : QDialog(parent), ui(new Ui::DialogPacket) { ui->setupUi(this); m_packet = NULL; m_filename = QString(); m_textChanged = false; m_scriptEditor = new TextEdit(this); m_scriptEditor->setGeometry(5, 5, 725, 545); m_completer = new QCompleter(this); m_completer->setModel(modelFromFile()); m_completer->setModelSorting(QCompleter::CaseInsensitivelySortedModel); m_completer->setCaseSensitivity(Qt::CaseInsensitive); m_completer->setWrapAround(false); m_scriptEditor->setCompleter(m_completer); QFont font; font.setFamily("Myriad"); font.setStyleHint(QFont::Monospace); font.setFixedPitch(true); font.setPointSize(10); QFontMetrics metrics(font); Highlighter* highlighter = new Highlighter(m_scriptEditor->document()); m_scriptEditor->setFont(font); m_scriptEditor->setTabStopWidth(4 * metrics.width(" ")); ui->tabWidget->removeTab(0); ui->tabWidget->insertTab(0, m_scriptEditor, tr("Script Editor")); ui->tabWidget->setCurrentIndex(0); m_scriptEditor->setFocus(); if (!packet.isEmpty()) { m_packet = new PacketReader(type, packet); m_packet->ReadHeader(); ui->Opcode->setText(QString::number(m_packet->GetOpcode())); ui->Opcode->setDisabled(true); ui->Type->setCurrentIndex((m_packet->GetType() == "CMSG") ? 0 : 1); ui->Type->setDisabled(true); ui->Size->setText(QString::number(m_packet->GetSize())); if (m_packet->CompileScript()) ui->tabWidget->setCurrentIndex(1); ui->ParsedPacket->setPlainText(m_packet->GetAnalyzedPacket()); } if (m_packet && !m_packet->GetScript().isEmpty()) m_scriptEditor->setPlainText(m_packet->GetScript()); else if (!scriptPath.isEmpty()) LoadFile(scriptPath); else m_scriptEditor->setPlainText("function ReadPacket()\n{\n\t// Code\n}\n\nReadPacket();"); connect(ui->Close, SIGNAL(clicked()), this, SLOT(close())); connect(ui->Save, SIGNAL(clicked()), this, SLOT(Save())); connect(ui->tabWidget, SIGNAL(currentChanged(int)), this, SLOT(OnTabChanged(int))); connect(m_scriptEditor, SIGNAL(textChanged()), this, SLOT(OnTextChanged())); }
QFESPIMB040ScriptedAcquisition::QFESPIMB040ScriptedAcquisition(QFESPIMB040MainWindow2* mainWindow, QFESPIMB040AcquisitionTools* acqTools, QFPluginLogService* log, QWidget* parent, QFPluginServices* pluginServices, QFESPIMB040OpticsSetupBase* opticsSetup, QFESPIMB040AcquisitionDescription* acqDescription, QFESPIMB040ExperimentDescription* expDescription, QString /*configDirectory*/) : QWidget(parent), ui(new Ui::QFESPIMB040ScriptedAcquisition) { this->m_pluginServices=pluginServices; this->opticsSetup=opticsSetup; this->acqDescription=acqDescription; this->expDescription=expDescription; this->log=log; this->acqTools=acqTools; this->mainWindow=mainWindow; acquisitionTools=new QFESPIMB040ScriptedAcquisitionTools(this, mainWindow, acqTools, log, this, pluginServices, opticsSetup, acqDescription, expDescription); instrumentControl=new QFESPIMB040ScriptedAcquisitionInstrumentControl(this, mainWindow, acqTools, log, this, pluginServices, opticsSetup, acqDescription, expDescription); acquisitionControl=new QFESPIMB040ScriptedAcquisitionAcquisitionControl(this, mainWindow, acqTools, log, this, pluginServices, opticsSetup, acqDescription, expDescription); engine=new QScriptEngine(); ui->setupUi(this); findDlg=new QFESPIMB040FindDialog(this); replaceDlg=new QFESPIMB040ReplaceDialog(this); highlighter=new QFQtScriptHighlighter("", ui->edtScript->getEditor()->document()); completer = new QCompleter(ui->edtScript->getEditor()); completermodel=modelFromFile(ProgramOptions::getInstance()->getAssetsDirectory()+"/qtscript/completer.txt"); completer->setModel(completermodel); completer->setModelSorting(QCompleter::CaseInsensitivelySortedModel); completer->setCaseSensitivity(Qt::CaseInsensitive); completer->setWrapAround(false); ui->edtScript->getEditor()->setCompleter(completer); recentMaskFiles=new QRecentFilesMenu(this); recentMaskFiles->setUseSystemFileIcons(false); recentMaskFiles->setAlwaysEnabled(true); connect(recentMaskFiles, SIGNAL(openRecentFile(QString)), this, SLOT(openScriptNoAsk(QString))); ui->btnOpen->setMenu(recentMaskFiles); connect(ui->edtScript->getEditor(), SIGNAL(cursorPositionChanged()), this, SLOT(edtScript_cursorPositionChanged())); cutAct = new QFActionWithNoMenuRole(QIcon(":/spimb040/script_cut.png"), tr("Cu&t"), this); cutAct->setShortcut(tr("Ctrl+X")); cutAct->setStatusTip(tr("Cut the current selection's contents to the " "clipboard")); connect(cutAct, SIGNAL(triggered()), ui->edtScript->getEditor(), SLOT(cut())); copyAct = new QFActionWithNoMenuRole(QIcon(":/spimb040/script_copy.png"), tr("&Copy"), this); copyAct->setShortcut(tr("Ctrl+C")); copyAct->setStatusTip(tr("Copy the current selection's contents to the " "clipboard")); connect(copyAct, SIGNAL(triggered()), ui->edtScript->getEditor(), SLOT(copy())); pasteAct = new QFActionWithNoMenuRole(QIcon(":/spimb040/script_paste.png"), tr("&Paste"), this); pasteAct->setShortcut(tr("Ctrl+V")); pasteAct->setStatusTip(tr("Paste the clipboard's contents into the current " "selection")); connect(pasteAct, SIGNAL(triggered()), ui->edtScript->getEditor(), SLOT(paste())); undoAct = new QFActionWithNoMenuRole(QIcon(":/spimb040/script_undo.png"), tr("&Undo"), this); undoAct->setShortcut(tr("Ctrl+Z")); undoAct->setStatusTip(tr("Undo the last change ")); connect(undoAct, SIGNAL(triggered()), ui->edtScript->getEditor(), SLOT(undo())); redoAct = new QFActionWithNoMenuRole(QIcon(":/spimb040/script_redo.png"), tr("&Redo"), this); redoAct->setShortcut(tr("Ctrl+Shift+Z")); redoAct->setStatusTip(tr("Redo the last undone change ")); connect(redoAct, SIGNAL(triggered()), ui->edtScript->getEditor(), SLOT(redo())); findAct = new QFActionWithNoMenuRole(QIcon(":/spimb040/script_find.png"), tr("&Find ..."), this); findAct->setShortcut(tr("Ctrl+F")); findAct->setStatusTip(tr("Find a string in sequence ")); connect(findAct, SIGNAL(triggered()), this, SLOT(findFirst())); findNextAct = new QFActionWithNoMenuRole(QIcon(":/spimb040/script_find_next.png"), tr("Find &next"), this); findNextAct->setShortcut(tr("F3")); findNextAct->setStatusTip(tr("Find the next occurence ")); connect(findNextAct, SIGNAL(triggered()), this, SLOT(findNext())); findNextAct->setEnabled(false); replaceAct = new QFActionWithNoMenuRole(QIcon(":/spimb040/script_find_replace.png"), tr("Find && &replace ..."), this); replaceAct->setShortcut(tr("Ctrl+R")); replaceAct->setStatusTip(tr("Find a string in sequence and replace it with another string ")); connect(replaceAct, SIGNAL(triggered()), this, SLOT(replaceFirst())); commentAct = new QFActionWithNoMenuRole(tr("&Comment text"), this); commentAct->setShortcut(tr("Ctrl+B")); commentAct->setStatusTip(tr("add (single line) comment at the beginning of each line ")); connect(commentAct, SIGNAL(triggered()), ui->edtScript->getEditor(), SLOT(comment())); unCommentAct = new QFActionWithNoMenuRole(tr("&Uncomment text"), this); unCommentAct->setShortcut(tr("Ctrl+Shift+B")); unCommentAct->setStatusTip(tr("remove (single line) comment at the beginning of each line ")); connect(unCommentAct, SIGNAL(triggered()), ui->edtScript->getEditor(), SLOT(uncomment())); indentAct = new QFActionWithNoMenuRole(QIcon(":/spimb040/script_indent.png"), tr("&Increase indention"), this); commentAct->setShortcut(tr("Ctrl+I")); indentAct->setStatusTip(tr("increase indention ")); connect(indentAct, SIGNAL(triggered()), ui->edtScript->getEditor(), SLOT(indentInc())); unindentAct = new QFActionWithNoMenuRole(QIcon(":/spimb040/script_unindent.png"), tr("&Decrease indention"), this); unindentAct->setShortcut(tr("Ctrl+Shift+I")); unindentAct->setStatusTip(tr("decrease indention ")); connect(unindentAct, SIGNAL(triggered()), ui->edtScript->getEditor(), SLOT(indentDec())); gotoLineAct = new QFActionWithNoMenuRole(tr("&Goto line ..."), this); gotoLineAct->setShortcut(tr("Alt+G")); gotoLineAct->setStatusTip(tr("goto a line in the opened file ")); connect(gotoLineAct, SIGNAL(triggered()), this, SLOT(gotoLine())); printAct = new QFActionWithNoMenuRole(QIcon(":/spimb040/script_print.png"), tr("&Print ..."), this); printAct->setStatusTip(tr("print the current SDFF file ")); connect(printAct, SIGNAL(triggered()), this, SLOT(print())); cutAct->setEnabled(false); copyAct->setEnabled(false); undoAct->setEnabled(false); redoAct->setEnabled(false); connect(ui->edtScript->getEditor(), SIGNAL(copyAvailable(bool)), cutAct, SLOT(setEnabled(bool))); connect(ui->edtScript->getEditor(), SIGNAL(copyAvailable(bool)), copyAct, SLOT(setEnabled(bool))); connect(ui->edtScript->getEditor(), SIGNAL(undoAvailable(bool)), undoAct, SLOT(setEnabled(bool))); connect(ui->edtScript->getEditor(), SIGNAL(redoAvailable(bool)), redoAct, SLOT(setEnabled(bool))); connect(ui->edtScript->getEditor(), SIGNAL(findNextAvailable(bool)), findNextAct, SLOT(setEnabled(bool))); QMenu* menuMore=new QMenu(ui->tbMoreOptions); menuMore->addAction(indentAct); menuMore->addAction(unindentAct); menuMore->addAction(commentAct); menuMore->addAction(unCommentAct); menuMore->addSeparator(); menuMore->addAction(gotoLineAct); menuMore->addAction(findAct); menuMore->addAction(replaceAct); menuMore->addAction(findNextAct); ui->tbMoreOptions->setMenu(menuMore); ui->tbFind->setDefaultAction(findAct); ui->tbFindNext->setDefaultAction(findNextAct); ui->tbReplace->setDefaultAction(replaceAct); ui->tbPrint->setDefaultAction(printAct); ui->tbCopy->setDefaultAction(copyAct); ui->tbCut->setDefaultAction(cutAct); ui->tbPaste->setDefaultAction(pasteAct); ui->tbRedo->setDefaultAction(redoAct); ui->tbUndo->setDefaultAction(undoAct); updateReplaces(); //bindLineEdit(ui->edtPrefix1); ui->btnCancel->setVisible(false); ui->widProgress->setVisible(false); ui->labStatus->setVisible(false); setScriptFilename(tr("new_acquisition_script.js")); QDir d(QFPluginServices::getInstance()->getPluginHelpDirectory("ext_spimb040")+"acquisition_script/"); QStringList filter; filter<<"*.html"<<"*.htm"<<"*.txt"; QStringList files=d.entryList(filter, QDir::Files); threadsFinished=0; maxThreads=2; QList<QStringList> absFiles; for (int i=0; i<maxThreads; i++) { QStringList sl; absFiles.push_back(sl); } for (int i=0; i<files.size(); i++) { QString file=d.absoluteFilePath(files[i]); absFiles[i%maxThreads].append(file); } for (int i=0; i<maxThreads; i++) { threads.append(new QFESPIMB040ScriptedAcquisitionDocSearchThread(absFiles[i], this)); connect(threads[i], SIGNAL(finished()), this, SLOT(threadFinished())); connect(threads[i], SIGNAL(foundFunction(QString,QString,QString)), this, SLOT(addFunction(QString,QString,QString))); } QTimer::singleShot(10, this, SLOT(delayedStartSearchThreads())); }