File indexing completed on 2025-01-05 04:54:21

0001 /*
0002    SPDX-FileCopyrightText: 2013-2024 Laurent Montel <montel@kde.org>
0003 
0004    SPDX-License-Identifier: GPL-2.0-or-later
0005 */
0006 #pragma once
0007 
0008 #include "knotes_part.h"
0009 #include <QListWidget>
0010 #include <QMultiHash>
0011 class KNoteDisplaySettings;
0012 class KNotesIconViewItem;
0013 class KNotesIconView : public QListWidget
0014 {
0015     Q_OBJECT
0016 public:
0017     explicit KNotesIconView(KNotesPart *part, QWidget *parent);
0018     ~KNotesIconView() override;
0019 
0020     void addNote(const Akonadi::Item &item);
0021 
0022     KNotesIconViewItem *iconView(Akonadi::Item::Id id) const;
0023     QHash<Akonadi::Item::Id, KNotesIconViewItem *> noteList() const;
0024 
0025 protected:
0026     void mousePressEvent(QMouseEvent *) override;
0027 
0028     bool event(QEvent *e) override;
0029 
0030 private:
0031     KNotesPart *m_part = nullptr;
0032     QHash<Akonadi::Item::Id, KNotesIconViewItem *> mNoteList;
0033 };
0034 
0035 class KNotesIconViewItem : public QObject, public QListWidgetItem
0036 {
0037     Q_OBJECT
0038 public:
0039     KNotesIconViewItem(const Akonadi::Item &item, QListWidget *parent);
0040     ~KNotesIconViewItem() override;
0041 
0042     bool readOnly() const;
0043     void setReadOnly(bool b, bool save = true);
0044 
0045     void setIconText(const QString &text, bool save = true);
0046     QString realName() const;
0047 
0048     int tabSize() const;
0049     bool autoIndent() const;
0050     QFont textFont() const;
0051     bool isRichText() const;
0052     QString description() const;
0053     void setDescription(const QString &);
0054     KNoteDisplaySettings *displayAttribute() const;
0055     Akonadi::Item item();
0056 
0057     void setChangeItem(const Akonadi::Item &item, const QSet<QByteArray> &set);
0058     void saveNoteContent(const QString &subject = QString(), const QString &description = QString(), int position = -1);
0059     void updateSettings();
0060     void setChangeIconTextAndDescription(const QString &iconText, const QString &description, int position);
0061     QColor textBackgroundColor() const;
0062     QColor textForegroundColor() const;
0063 
0064     int cursorPositionFromStart() const;
0065 
0066 private Q_SLOTS:
0067     void slotNoteSaved(KJob *job);
0068 
0069 private:
0070     void prepare();
0071     void setDisplayDefaultValue();
0072     QPixmap mDefaultPixmap;
0073 
0074     Akonadi::Item mItem;
0075     KNoteDisplaySettings *mDisplayAttribute = nullptr;
0076     bool mReadOnly;
0077 };