File indexing completed on 2024-05-12 17:12:39

0001 /*************************************************************************
0002  *    Copyright (C) 2009 by Renaud Guezennec                             *
0003  *                                                                       *
0004  *    https://rolisteam.org/                                          *
0005  *                                                                       *
0006  *   Rolisteam is free software; you can redistribute it and/or modify   *
0007  *   it under the terms of the GNU General Public License as published   *
0008  *   by the Free Software Foundation; either version 2 of the License,   *
0009  *   or (at your option) any later version.                              *
0010  *                                                                       *
0011  *   This program is distributed in the hope that it will be useful,     *
0012  *   but WITHOUT ANY WARRANTY; without even the implied warranty of      *
0013  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the       *
0014  *   GNU General Public License for more details.                        *
0015  *                                                                       *
0016  *   You should have received a copy of the GNU General Public License   *
0017  *   along with this program; if not, write to the                       *
0018  *   Free Software Foundation, Inc.,                                     *
0019  *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.           *
0020  *************************************************************************/
0021 #ifndef DIRCHOOSER_H
0022 #define DIRCHOOSER_H
0023 
0024 #include "rwidgets_global.h"
0025 #include <QLineEdit>
0026 #include <QPushButton>
0027 #include <QStringList>
0028 #include <QWidget>
0029 /**
0030  * @brief A LineEdit with a button to choose a file or directory. It displays a QLineEdit and a QPushButton allowing to
0031  * show the current selection and to browse to select something else.
0032  *
0033  */
0034 class RWIDGET_EXPORT FileDirChooser : public QWidget
0035 {
0036     Q_OBJECT
0037 public:
0038     /**
0039      * @brief FileDirChooser
0040      * @param isDirectory
0041      * @param parent
0042      */
0043     FileDirChooser(bool isDirectory= true, QWidget* parent= nullptr);
0044     ~FileDirChooser();
0045     /**
0046      * @brief setPath define the value of the widget. Current selection.
0047      * @param dirname
0048      */
0049     void setPath(const QString& dirname);
0050     /**
0051      * @brief path
0052      * @return the path selected by the user.
0053      */
0054     QString path() const;
0055     /**
0056      * @brief setFilter defines filter to select the file.
0057      * @param filter
0058      */
0059     void setFilter(const QString& filter);
0060     /**
0061      * @brief getFilter
0062      * @return
0063      */
0064     QString getFilter();
0065     /**
0066      * @brief setMode
0067      * @param isDirectory
0068      */
0069     void setMode(bool isDirectory);
0070 
0071 signals:
0072     /**
0073      * @brief pathChanged
0074      */
0075     void pathChanged(const QString& path);
0076 
0077 public slots:
0078     void browse();
0079 
0080 private:
0081     QLineEdit* m_lineEdit= nullptr;
0082     QString m_filter;
0083     bool m_directory= true;
0084 };
0085 
0086 #endif // DIRCHOOSER_H