bool EditorTab::openFile(QString filename, int highlightLine) { // First, check if the file isn't already loaded Editor * textEdit = NULL; int index = fileIndex(filename); if (index >= 0) { setCurrentIndex(index); textEdit = (Editor *)widget(index); } else { if (QFileInfo(filename).exists() == false) { ErrorMessage("Could not load file: \n\n" + filename); return false; } textEdit = new Editor(this); textEdit->Open(filename); connect(textEdit, SIGNAL(textChanged()), this, SLOT(onEditorTextChanged())); connect(textEdit, SIGNAL(ctrlUPressed()), this, SLOT(onCtrlUPressed())); connect(textEdit, SIGNAL(searchPressed()), this, SLOT(onSearchUPressed())); addTab(textEdit, QFileInfo(filename).fileName()); setCurrentIndex(count() - 1); QApplication::restoreOverrideCursor(); } if (highlightLine >= 0) { textEdit->setCursorPosition(highlightLine-1, 0); textEdit->ensureLineVisible(highlightLine-1); textEdit->markerAdd (highlightLine-1, 0); textEdit->setCaretLineBackgroundColor(QColor(100, 20, 20)); } return true; }
void SearchWidget::buttonPressed() { emit searchPressed(); }