1 /**************************************************************************** 2 ** 3 ** Copyright (C) 2016 The Qt Company Ltd. 4 ** Contact: https://www.qt.io/licensing/ 5 ** 6 ** This file is part of Qt Creator. 7 ** 8 ** Commercial License Usage 9 ** Licensees holding valid commercial Qt licenses may use this file in 10 ** accordance with the commercial license agreement provided with the 11 ** Software or, alternatively, in accordance with the terms contained in 12 ** a written agreement between you and The Qt Company. For licensing terms 13 ** and conditions see https://www.qt.io/terms-conditions. For further 14 ** information use the contact form at https://www.qt.io/contact-us. 15 ** 16 ** GNU General Public License Usage 17 ** Alternatively, this file may be used under the terms of the GNU 18 ** General Public License version 3 as published by the Free Software 19 ** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT 20 ** included in the packaging of this file. Please review the following 21 ** information to ensure the GNU General Public License requirements will 22 ** be met: https://www.gnu.org/licenses/gpl-3.0.html. 23 ** 24 ****************************************************************************/ 25 26 #include "iexternaleditor.h" 27 28 #include "ieditorfactory_p.h" 29 30 namespace Core { 31 32 /*! 33 \class Core::IExternalEditor 34 \inheaderfile coreplugin/editormanager/iexternaleditor.h 35 \inmodule QtCreator 36 \ingroup mainclasses 37 38 \brief The IExternalEditor class enables registering an external 39 editor in the \uicontrol{Open With} dialog. 40 */ 41 42 /*! 43 \fn QString Core::IExternalEditor::displayName() const 44 Returns a user-visible description of the editor type. 45 */ 46 47 /*! 48 \fn Utils::Id Core::IExternalEditor::id() const 49 Returns the ID of the factory or editor type. 50 */ 51 52 /*! 53 \fn QStringList Core::IExternalEditor::mimeTypes() const 54 Returns a list of MIME types that the editor supports 55 */ 56 57 /*! 58 59 \fn bool Core::IExternalEditor::startEditor(const QString &fileName, QString *errorMessage) = 0; 60 61 Opens the editor with \a fileName. Returns \c true on success or \c false 62 on failure along with the error in \a errorMessage. 63 */ 64 65 static QList<IExternalEditor *> g_externalEditors; 66 67 /*! 68 \internal 69 */ IExternalEditor(QObject * parent)70IExternalEditor::IExternalEditor(QObject *parent) 71 : QObject(parent) 72 { 73 g_externalEditors.append(this); 74 } 75 76 /*! 77 \internal 78 */ ~IExternalEditor()79IExternalEditor::~IExternalEditor() 80 { 81 g_externalEditors.removeOne(this); 82 } 83 84 /*! 85 Returns all available external editors. 86 */ allExternalEditors()87const ExternalEditorList IExternalEditor::allExternalEditors() 88 { 89 return g_externalEditors; 90 } 91 92 /*! 93 Returns all external editors available for this \a mimeType in the default 94 order (editors ordered by MIME type hierarchy). 95 */ externalEditors(const Utils::MimeType & mimeType)96const ExternalEditorList IExternalEditor::externalEditors(const Utils::MimeType &mimeType) 97 { 98 ExternalEditorList rc; 99 const ExternalEditorList allEditors = IExternalEditor::allExternalEditors(); 100 Internal::mimeTypeFactoryLookup(mimeType, allEditors, &rc); 101 return rc; 102 } 103 104 } // Core 105