File indexing completed on 2025-01-26 05:06:21

0001 /*
0002     SPDX-FileCopyrightText: 2013-2014 Eike Hein <hein@kde.org>
0003 
0004     SPDX-License-Identifier: GPL-2.0-or-later
0005 */
0006 
0007 #pragma once
0008 
0009 #include <QObject>
0010 #include <QPointer>
0011 
0012 class KFilePlacesModel;
0013 class FolderModel;
0014 
0015 class LabelGenerator : public QObject
0016 {
0017     Q_OBJECT
0018 
0019     Q_PROPERTY(FolderModel *folderModel READ folderModel WRITE setFolderModel NOTIFY folderModelChanged)
0020     Q_PROPERTY(bool rtl READ rtl WRITE setRtl NOTIFY rtlChanged)
0021     Q_PROPERTY(int labelMode READ labelMode WRITE setLabelMode NOTIFY labelModeChanged)
0022     Q_PROPERTY(QString labelText READ labelText WRITE setLabelText NOTIFY labelTextChanged)
0023     Q_PROPERTY(QString displayLabel READ displayLabel NOTIFY displayLabelChanged)
0024 
0025 public:
0026     explicit LabelGenerator(QObject *parent = nullptr);
0027     ~LabelGenerator() override;
0028 
0029     FolderModel *folderModel() const;
0030     void setFolderModel(FolderModel *folderModel);
0031 
0032     bool rtl() const;
0033     void setRtl(bool rtl);
0034 
0035     int labelMode() const;
0036     void setLabelMode(int mode);
0037 
0038     QString labelText() const;
0039     void setLabelText(const QString &text);
0040 
0041     QString displayLabel() const;
0042 
0043 Q_SIGNALS:
0044     void folderModelChanged();
0045     void rtlChanged();
0046     void labelModeChanged();
0047     void labelTextChanged();
0048     void displayLabelChanged();
0049 
0050 private:
0051     void updateDisplayLabel();
0052     QString generatedDisplayLabel();
0053 
0054     static int s_instanceCount;
0055     static KFilePlacesModel *s_placesModel;
0056     bool m_placesConnected = false;
0057 
0058     void connectPlacesModel();
0059 
0060     QPointer<FolderModel> m_folderModel;
0061     bool m_rtl;
0062     int m_labelMode;
0063     QString m_displayLabel;
0064     QString m_labelText;
0065 };