File indexing completed on 2024-05-05 04:39:24

0001 /*
0002     SPDX-FileCopyrightText: 2007 Aleix Pol <aleixpol@gmail.com>
0003 
0004     SPDX-License-Identifier: GPL-2.0-or-later
0005 */
0006 
0007 #ifndef CMAKEBUILDDIRCHOOSER_H
0008 #define CMAKEBUILDDIRCHOOSER_H
0009 
0010 #include <QDialog>
0011 #include <QFlags>
0012 
0013 #include <util/path.h>
0014 
0015 #include "cmakeextraargumentshistory.h"
0016 #include "cmakecommonexport.h"
0017 
0018 class QDialogButtonBox;
0019 
0020 namespace Ui {
0021     class CMakeBuildDirChooser;
0022 }
0023 namespace KDevelop {
0024     class IProject;
0025 }
0026 
0027 class KDEVCMAKECOMMON_EXPORT CMakeBuildDirChooser : public QDialog
0028 {
0029     Q_OBJECT
0030     public:
0031         enum StatusType 
0032         { 
0033             BuildDirCreated = 1, 
0034             CorrectProject = 2, 
0035             BuildFolderEmpty = 4, 
0036             HaveCMake = 8,
0037             CorrectBuildDir = 16,
0038             DirAlreadyCreated = 32 //Error message in case it's already configured
0039         };
0040         Q_DECLARE_FLAGS( StatusTypes, StatusType )
0041 
0042         explicit CMakeBuildDirChooser(QWidget* parent = nullptr);
0043         ~CMakeBuildDirChooser() override;
0044 
0045         KDevelop::Path cmakeExecutable() const;
0046         KDevelop::Path installPrefix() const;
0047         KDevelop::Path buildFolder() const;
0048         QString buildType() const;
0049         QString extraArguments() const;
0050         int alreadyUsedIndex() const;
0051         bool reuseBuilddir();
0052 
0053         void setCMakeExecutable(const KDevelop::Path& path);
0054         void setInstallPrefix(const KDevelop::Path& path);
0055         void setBuildFolder(const KDevelop::Path& path);
0056         void setBuildType(const QString& buildType);
0057         void setProject( KDevelop::IProject* project );
0058         void setSourceFolder(const KDevelop::Path &path) { m_srcFolder = path; }
0059         void setAlreadyUsed(const QStringList& used);
0060         void setStatus(const QString& message, bool canApply);
0061         void setExtraArguments(const QString& args);
0062         void setShowAvailableBuildDirs(bool show);
0063 
0064     private Q_SLOTS:
0065         void updated();
0066     private:
0067         void adoptPreviousBuildDirectory(int index);
0068         void buildDirSettings(
0069             const KDevelop::Path& buildDir,
0070             QString& srcDir,
0071             QString& installDir,
0072             QString& buildType);
0073 
0074         QStringList m_alreadyUsed;
0075         CMakeExtraArgumentsHistory* m_extraArgumentsHistory;
0076 
0077         Ui::CMakeBuildDirChooser* m_chooserUi;
0078         QDialogButtonBox* m_buttonBox;
0079 
0080         KDevelop::IProject* m_project;
0081         KDevelop::Path m_srcFolder;
0082 };
0083 Q_DECLARE_OPERATORS_FOR_FLAGS( CMakeBuildDirChooser::StatusTypes )
0084 
0085 
0086 #endif