OSDN Git Service

Allow empty editor id with openEditorWithContents.
authorcon <qtc-committer@nokia.com>
Wed, 1 Dec 2010 16:20:15 +0000 (17:20 +0100)
committercon <qtc-committer@nokia.com>
Thu, 2 Dec 2010 03:30:43 +0000 (04:30 +0100)
Tries to figure out the editor type from the title pattern in that case.

src/plugins/coreplugin/editormanager/editormanager.cpp

index 098ba06..669815a 100644 (file)
@@ -1282,28 +1282,11 @@ IEditor *EditorManager::openEditorWithContents(const QString &editorId,
     if (debugEditorManager)
         qDebug() << Q_FUNC_INFO << editorId << titlePattern << contents;
 
-    if (editorId.isEmpty())
-        return 0;
-
     QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
-    IEditor *edt = createEditor(editorId);
-    if (!edt) {
-        QApplication::restoreOverrideCursor();
-        return 0;
-    }
-
-    if (!edt->createNew(contents)) {
-        QApplication::restoreOverrideCursor();
-        delete edt;
-        edt = 0;
-        return 0;
-    }
-
-    QString title = edt->displayName();
 
+    QString title;
     if (titlePattern) {
         const QChar dollar = QLatin1Char('$');
-        const QChar dot = QLatin1Char('.');
 
         QString base = *titlePattern;
         if (base.isEmpty())
@@ -1315,7 +1298,6 @@ IEditor *EditorManager::openEditorWithContents(const QString &editorId,
                 QString name = editor->file()->fileName();
                 if (name.isEmpty()) {
                     name = editor->displayName();
-                    name.remove(QLatin1Char('*'));
                 } else {
                     name = QFileInfo(name).completeBaseName();
                 }
@@ -1331,6 +1313,23 @@ IEditor *EditorManager::openEditorWithContents(const QString &editorId,
         }
         *titlePattern = title;
     }
+
+    IEditor *edt = createEditor(editorId, title);
+    if (!edt) {
+        QApplication::restoreOverrideCursor();
+        return 0;
+    }
+
+    if (!edt->createNew(contents)) {
+        QApplication::restoreOverrideCursor();
+        delete edt;
+        edt = 0;
+        return 0;
+    }
+
+    if (title.isEmpty())
+        title = edt->displayName();
+
     edt->setDisplayName(title);
     addEditor(edt);
     QApplication::restoreOverrideCursor();