File indexing completed on 2025-03-09 04:56:49

0001 /*
0002  * SPDX-FileCopyrightText: 2014 Kevin Ottens <ervin@kde.org>
0003  * SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
0004  */
0005 
0006 
0007 
0008 #ifndef WIDGETS_EDITORVIEW_H
0009 #define WIDGETS_EDITORVIEW_H
0010 
0011 #include <QWidget>
0012 
0013 #include <QDate>
0014 
0015 #include <functional>
0016 
0017 #include "domain/task.h"
0018 
0019 class QAbstractButton;
0020 class QLabel;
0021 class QPlainTextEdit;
0022 
0023 class KDateComboBox;
0024 class KLineEdit;
0025 
0026 namespace Ui {
0027     class EditorView;
0028 }
0029 
0030 namespace Widgets {
0031 
0032 class EditorView : public QWidget
0033 {
0034     Q_OBJECT
0035 public:
0036     typedef std::function<QString(QWidget*)> RequestFileNameFunction;
0037 
0038     explicit EditorView(QWidget *parent = nullptr);
0039     ~EditorView();
0040 
0041     QObject *model() const;
0042     RequestFileNameFunction requestFileNameFunction() const;
0043 
0044 public slots:
0045     void setModel(QObject *model);
0046     void setRequestFileNameFunction(const RequestFileNameFunction &function);
0047 
0048 signals:
0049     void textChanged(const QString &text);
0050     void titleChanged(const QString &title);
0051     void startDateChanged(const QDate &start);
0052     void dueDateChanged(const QDate &due);
0053     void doneChanged(bool done);
0054     void recurrenceChanged(Domain::Task::Recurrence recurrence);
0055 
0056 protected:
0057     bool eventFilter(QObject *watched, QEvent *event) override;
0058 
0059 private slots:
0060     void onTaskChanged();
0061     void onTextOrTitleChanged();
0062     void onStartDateChanged();
0063     void onDueDateChanged();
0064     void onDoneChanged();
0065     void onRecurrenceChanged();
0066 
0067     void onTextEditChanged();
0068     void onStartEditEntered(const QDate &start);
0069     void onDueEditEntered(const QDate &due);
0070     void onDoneButtonChanged(bool checked);
0071     void onStartTodayClicked();
0072     void onRecurrenceComboChanged(int index);
0073 
0074     void onAttachmentSelectionChanged();
0075     void onAddAttachmentClicked();
0076     void onRemoveAttachmentClicked();
0077     void onAttachmentDoubleClicked(const QModelIndex &index);
0078 
0079 private:
0080     QObject *m_model;
0081     RequestFileNameFunction m_requestFileNameFunction;
0082 
0083     Ui::EditorView *ui;
0084 };
0085 
0086 }
0087 
0088 #endif // WIDGETS_EDITORVIEW_H