File indexing completed on 2024-05-05 05:54:32
0001 /* 0002 SPDX-FileCopyrightText: 2015 Elvis Angelaccio <elvis.angelaccio@kde.org> 0003 0004 SPDX-License-Identifier: GPL-2.0-or-later 0005 */ 0006 0007 #ifndef SESSIONDIALOG_H 0008 #define SESSIONDIALOG_H 0009 0010 #include "ui_sessiondialog.h" 0011 #include "session.h" 0012 0013 #include <QDialog> 0014 0015 class SessionModel; 0016 0017 class KMessageWidget; 0018 0019 class QDialogButtonBox; 0020 class QSortFilterProxyModel; 0021 class QTableView; 0022 0023 /** 0024 * @brief Dialog for sessions interaction. 0025 */ 0026 class SessionDialog : public QDialog, public Ui::SessionDialog 0027 { 0028 Q_OBJECT 0029 0030 public: 0031 0032 explicit SessionDialog(SessionModel *sessionModel, QWidget *parent = nullptr); 0033 0034 Session selectedSession() const; 0035 0036 public Q_SLOTS: 0037 0038 virtual void accept() override; 0039 0040 protected: 0041 0042 virtual void keyPressEvent(QKeyEvent *event) override; 0043 0044 private Q_SLOTS: 0045 0046 /** 0047 * Call accept() if the selection's column is not editable. 0048 * @param index The selected index. 0049 */ 0050 void slotDoubleClicked(const QModelIndex& index); 0051 0052 /** 0053 * Disable the OK button if no session is selected. 0054 */ 0055 void slotSelectionChanged(); 0056 0057 /** 0058 * Enable the OK button after the first session is added. 0059 */ 0060 void slotSessionAdded(); 0061 0062 /** 0063 * Disable the OK button if no session is available. 0064 */ 0065 void slotEmptyModel(); 0066 0067 private: 0068 0069 SessionModel *m_sessionModel; 0070 QSortFilterProxyModel *m_proxyModel; 0071 Session m_selectedSession; 0072 0073 /** 0074 * @return The actual selected index in the view. 0075 */ 0076 QModelIndex selectedIndex(); 0077 0078 /** 0079 * Ask confirm to the user before removing a session. 0080 */ 0081 void removeDialog(); 0082 0083 Q_DISABLE_COPY(SessionDialog) 0084 }; 0085 0086 #endif