File indexing completed on 2024-04-28 04:37:04

0001 /*
0002     SPDX-FileCopyrightText: 2008 Aleix Pol <aleixpol@gmail.com>
0003 
0004     SPDX-License-Identifier: LGPL-2.0-or-later
0005 */
0006 
0007 #ifndef KDEVPLATFORM_PROJECTITEMLINEEDIT_H
0008 #define KDEVPLATFORM_PROJECTITEMLINEEDIT_H
0009 
0010 #include <QLineEdit>
0011 #include "projectexport.h"
0012 
0013 namespace KDevelop { 
0014 class ProjectBaseItem;
0015 class IProject;
0016 }
0017 class ProjectItemLineEditPrivate;
0018 
0019 class KDEVPLATFORMPROJECT_EXPORT ProjectItemLineEdit : public QLineEdit
0020 {
0021     Q_OBJECT
0022 public:
0023     explicit ProjectItemLineEdit(QWidget* parent=nullptr);
0024     ~ProjectItemLineEdit() override;
0025 
0026     /**
0027      * Sets this lineedit to show the given @p path, eventually removing
0028      * parts from the beginning if a base item is set
0029      * @note This should be preferred over using setText()
0030      */
0031     void setItemPath( const QStringList& path );
0032     
0033     /**
0034      * Generates a path from the content of the lineedit, including
0035      * the base item if present
0036      * @returns a path identifying the item selected in this lineedit
0037      */
0038     QStringList itemPath() const;
0039     
0040     /**
0041      * Sets @p item as the base item for this lineedit, the user
0042      * then doesn't need to specify the path leading to this item
0043      * and can just start typing the name of one of the subitems
0044      */
0045     void setBaseItem( KDevelop::ProjectBaseItem* item );
0046     
0047     /**
0048      * @returns the currently used base item
0049      */
0050     KDevelop::ProjectBaseItem* baseItem() const;
0051     
0052     KDevelop::ProjectBaseItem* currentItem() const;
0053     
0054     void setSuggestion(KDevelop::IProject* project);
0055 
0056 public Q_SLOTS:
0057     bool selectItemDialog();
0058     
0059 private Q_SLOTS:
0060     void showCtxMenu(const QPoint& p);
0061     
0062 private:
0063     const QScopedPointer<class ProjectItemLineEditPrivate> d_ptr;
0064     Q_DECLARE_PRIVATE(ProjectItemLineEdit)
0065 };
0066 
0067 #endif