File indexing completed on 2024-04-28 04:37:20
0001 /* 0002 SPDX-FileCopyrightText: 2008 Andreas Pakulat <apaku@gmx.de> 0003 0004 SPDX-License-Identifier: GPL-2.0-or-later 0005 */ 0006 0007 #ifndef KDEVPLATFORM_OPENPROJECTDIALOG_H 0008 #define KDEVPLATFORM_OPENPROJECTDIALOG_H 0009 0010 #include <util/scopeddialog.h> 0011 0012 #include <QUrl> 0013 0014 #include <KAssistantDialog> 0015 #include <KIO/UDSEntry> 0016 #include <KPluginMetaData> 0017 0018 class KPageWidgetItem; 0019 class QFileDialog; 0020 namespace KIO 0021 { 0022 class Job; 0023 } 0024 0025 namespace KDevelop 0026 { 0027 class ProjectSourcePage; 0028 class OpenProjectPage; 0029 class IPlugin; 0030 0031 class OpenProjectDialog : public KAssistantDialog 0032 { 0033 Q_OBJECT 0034 0035 public: 0036 OpenProjectDialog(bool fetch, const QUrl& startUrl, 0037 const QUrl& repoUrl = QUrl(), IPlugin* vcsOrProviderPlugin = nullptr, 0038 QWidget* parent = nullptr); 0039 ~OpenProjectDialog() override; 0040 0041 /** 0042 * Return a QUrl pointing to the project's .kdev file. 0043 */ 0044 QUrl projectFileUrl() const; 0045 /** 0046 * Return a QUrl pointing to the file, that was selected by the user. 0047 * Unlike projectFileUrl(), this can be a .kdev file, as well 0048 * as build system file (e.g. CMakeLists.txt). 0049 */ 0050 QUrl selectedUrl() const; 0051 QString projectName() const; 0052 QString projectManager() const; 0053 0054 int exec() override; 0055 0056 QStringList projectManagerForFile(const QString& file) const; 0057 0058 private Q_SLOTS: 0059 void validateSourcePage( bool ); 0060 void validateOpenUrl( const QUrl& ); 0061 void validateProjectName( const QString& ); 0062 void validateProjectManager( const QString&, const QString & ); 0063 void storeFileList(KIO::Job*, const KIO::UDSEntryList&); 0064 void openPageAccepted(); 0065 0066 private: 0067 bool execNativeDialog(); 0068 void validateProjectInfo(); 0069 QUrl m_url; 0070 QUrl m_selected; 0071 QString m_projectName; 0072 QString m_projectManager; 0073 bool m_urlIsDirectory; 0074 /// Used to select files when we aren't in KDE 0075 ScopedDialog<QFileDialog> nativeDialog{NullScopedDialog()}; 0076 KPageWidgetItem* sourcePage; 0077 KPageWidgetItem* openPage; 0078 KPageWidgetItem* projectInfoPage; 0079 QStringList m_fileList; 0080 QMap<QString, QStringList> m_projectFilters; 0081 QMap<QString, KPluginMetaData> m_projectPlugins; 0082 QStringList m_genericProjectPlugins; 0083 0084 KDevelop::OpenProjectPage* openPageWidget = nullptr; 0085 KDevelop::ProjectSourcePage* sourcePageWidget = nullptr; 0086 }; 0087 0088 } 0089 0090 #endif