예제 #1
0
void PythonScriptViewWidget::scrollToEditorLine(const QUrl & link) {
    QStringList strList = link.toString().split(":");
    QString file = strList.at(0);
    int line = strList.at(1).toInt()-1;

    if (file == "<unnamed script>") {
        tabWidget->setCurrentIndex(0);
        scrollToLine(getCurrentMainScriptEditor(), line);
        return;
    }

    for (int i = 0 ; i < mainScriptsTabWidget->count() ; ++i) {
        PythonCodeEditor *codeEditor = getMainScriptEditor(i);

        if (file == codeEditor->getFileName()) {
            tabWidget->setCurrentIndex(0);
            mainScriptsTabWidget->setCurrentIndex(i);
            scrollToLine(codeEditor, line);
            return;
        }
    }

    for (int i = 0 ; i < modulesTabWidget->count() ; ++i) {
        PythonCodeEditor *codeEditor = getModuleEditor(i);

        if (file == codeEditor->getFileName()) {
            tabWidget->setCurrentIndex(1);
            modulesTabWidget->setCurrentIndex(i);
            scrollToLine(codeEditor, line);
            return;
        }
    }

    for (int i = 0 ; i < pluginsTabWidget->count() ; ++i) {
        PythonCodeEditor *codeEditor = getPluginEditor(i);

        if (file == codeEditor->getFileName()) {
            tabWidget->setCurrentIndex(3);
            pluginsTabWidget->setCurrentIndex(i);
            scrollToLine(codeEditor, line);
            return;
        }
    }
}
예제 #2
0
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;
}