File indexing completed on 2024-05-12 16:40:54
0001 /* This file is part of the KDE project 0002 Copyright (C) 2016-2018 Jarosław Staniek <staniek@kde.org> 0003 0004 This program is free software; you can redistribute it and/or 0005 modify it under the terms of the GNU Library General Public 0006 License as published by the Free Software Foundation; either 0007 version 2 of the License, or (at your option) any later version. 0008 0009 This program is distributed in the hope that it will be useful, 0010 but WITHOUT ANY WARRANTY; without even the implied warranty of 0011 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 0012 Library General Public License for more details. 0013 0014 You should have received a copy of the GNU Library General Public License 0015 along with this program; see the file COPYING. If not, write to 0016 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 0017 * Boston, MA 02110-1301, USA. 0018 */ 0019 0020 #ifndef KEXIFILEREQUESTER_H 0021 #define KEXIFILEREQUESTER_H 0022 0023 #include "KexiFileWidgetInterface.h" 0024 #include <QWidget> 0025 0026 //! @brief A widget showing a line edit and a button, which invokes a file dialog 0027 class KEXIEXTWIDGETS_EXPORT KexiFileRequester : public QWidget, public KexiFileWidgetInterface 0028 { 0029 Q_OBJECT 0030 public: 0031 KexiFileRequester(const QUrl &fileOrVariable, KexiFileFilters::Mode mode, 0032 const QString &fileName, QWidget *parent = nullptr); 0033 0034 KexiFileRequester(const QUrl &fileOrVariable, KexiFileFilters::Mode mode, 0035 QWidget *parent = nullptr); 0036 0037 KexiFileRequester(const QString &selectedFile, KexiFileFilters::Mode mode, 0038 QWidget *parent = nullptr); 0039 0040 ~KexiFileRequester() override; 0041 0042 /** 0043 * Returns the full path of the selected file in the local filesystem. 0044 * (Local files only) 0045 */ 0046 QString selectedFile() const override; 0047 0048 /** 0049 * Returns the full path of the highlighted file in the local filesystem. 0050 * (Local files only) 0051 */ 0052 QString highlightedFile() const override; 0053 0054 /** 0055 * @return the currently shown directory. 0056 */ 0057 QString currentDir() const override; 0058 0059 //! Sets file mode 0060 //void setFileMode(KexiFileFilters::Mode mode); 0061 0062 //! @return additional mime types 0063 //QStringList additionalMimeTypes() const; 0064 0065 //! @return excluded mime types 0066 //QStringList excludedMimeTypes() const; 0067 0068 //! @return the default filter, used when an empty filter is set 0069 //QString defaultFilter() const; 0070 0071 Q_SIGNALS: 0072 void fileHighlighted(const QString &name); 0073 void fileSelected(const QString &name); 0074 0075 public Q_SLOTS: 0076 //! Sets the url 0077 void setSelectedFile(const QString &name) override; 0078 0079 /** 0080 * Sets whether the line edit draws itself with a frame. 0081 */ 0082 void setWidgetFrame(bool set) override; 0083 0084 protected: 0085 /** 0086 * Updates filters in the widget based on current filter selection. 0087 */ 0088 void updateFilters() override; 0089 0090 void applyEnteredFileName() override; 0091 0092 QStringList currentFilters() const override; 0093 0094 void showEvent(QShowEvent *event) override; 0095 0096 private: 0097 void init(); 0098 0099 Q_DISABLE_COPY(KexiFileRequester) 0100 class Private; 0101 Private * const d; 0102 }; 0103 0104 #endif // KEXIFILEREQUESTER_H