#ifndef UNSAVEDDOCUMENTSDIALOG_H #define UNSAVEDDOCUMENTSDIALOG_H #include "SqlDocument.h" #include #include #include #include class QListWidget; /** Lists modified documents with a checkbox per document. The user picks * whether the checked documents should be saved or discarded. */ class UnsavedDocumentsDialog : public QDialog { Q_OBJECT public: enum class Choice { Cancel, Save, Discard }; UnsavedDocumentsDialog(const QList> &docs, QWidget *parent = nullptr); Choice choice() const { return m_choice; } QList> checkedDocuments() const; QList> uncheckedDocuments() const; private: QList> m_docs; QListWidget *m_list; Choice m_choice = Choice::Cancel; }; /** Selects the documents that are closed when every editor for which * isClosing returns true is closed. Only modified documents are returned. */ QList> documentsClosedWith(const QList> &docs, const std::function &isClosing); /** Asks the user what to do with the modified documents. Returns true when * the close may continue, i.e. nothing was cancelled, no save failed and * every listed document was checked. */ bool confirmClose(QWidget *parent, const QList> &docs); #endif // UNSAVEDDOCUMENTSDIALOG_H