int PythonEditorsTabWidget::addEditor(const QString &fileName) { PythonCodeEditor *codeEditor = new PythonCodeEditor(); QFileInfo fileInfo(fileName); codeEditor->loadCodeFromFile(fileName); codeEditor->analyseScriptCode(true); codeEditor->setFocus(Qt::ActiveWindowFocusReason); codeEditor->installEventFilter(this); connect(codeEditor, SIGNAL(textChanged()), this, SLOT(scriptTextChanged())); int idx = addTab(codeEditor, fileInfo.fileName()); setTabToolTip(idx, fileInfo.absoluteFilePath()); setCurrentIndex(idx); if (_fontZoom < 0) { for (int i = _fontZoom ; i < 0 ; ++i) { codeEditor->zoomOut(); } } if (_fontZoom > 0) { for (int i = _fontZoom ; i > 0 ; --i) { codeEditor->zoomIn(); } } return idx; }
bool PythonEditorsTabWidget::reloadCodeInEditorIfNeeded(int index) { PythonCodeEditor *codeEditor = getEditor(index); QString fileName = codeEditor->getFileName(); if (fileName != "") { QFileInfo fileInfo(fileName); if (fileInfo.exists() && fileInfo.lastModified() != codeEditor->getLastSavedTime()) { if (codeEditor->loadCodeFromFile(fileName)) { setTabText(index, fileInfo.fileName()); } return true; } } return false; }