File indexing completed on 2023-05-30 10:45:27
0001 /* 0002 SPDX-FileCopyrightText: 2002-2010 Peter Hedlund <peter.hedlund@kdemail.net> 0003 SPDX-License-Identifier: GPL-2.0-or-later 0004 */ 0005 0006 #ifndef KWQTABLEVIEW_H 0007 #define KWQTABLEVIEW_H 0008 0009 #include <QKeyEvent> 0010 #include <QTableView> 0011 #include <QTextDocument> 0012 #include <QUndoStack> 0013 0014 #include "kwqsortfiltermodel.h" 0015 #include "kwqtabledelegate.h" 0016 #include "wqprintdialogpage.h" 0017 0018 /** 0019 @author Peter Hedlund 0020 */ 0021 0022 class QPrinter; 0023 0024 class KWQTableView : public QTableView 0025 { 0026 Q_OBJECT 0027 public: 0028 /** Constructor for the main view */ 0029 explicit KWQTableView(QUndoStack *undoStack, QWidget *parent = nullptr); 0030 0031 void setFilterModel(KWQSortFilterModel * model); 0032 KWQSortFilterModel * model() {return m_model;}; 0033 0034 /** contains the implementation for printing functionality */ 0035 void doPrint(); 0036 void doPrintPreview(); 0037 bool doHtmlExport(const QUrl &); 0038 0039 void doEditCut(); 0040 void doEditCopy(); 0041 void doEditPaste(); 0042 void doEditClear(); 0043 void doEditInsert(); 0044 void doEditDelete(); 0045 void doEditMarkBlank(); 0046 void doEditUnmarkBlank(); 0047 void doVocabImage(); 0048 void doVocabSound(); 0049 void doVocabShuffle(); 0050 0051 protected: 0052 void nextCell(); 0053 void keyPressEvent(QKeyEvent*) override; 0054 void updateKeyboardLayout(); 0055 0056 public Q_SLOTS: 0057 void adjustRow(int ); 0058 void slotSpecChar(const QChar &); 0059 void slotCheckedAnswer(int ); 0060 void slotModelReset(); 0061 0062 void slotHeaderClicked(int); 0063 void slotSortByColumn(int); 0064 0065 protected Q_SLOTS: 0066 void closeEditor(QWidget * editor, QAbstractItemDelegate::EndEditHint hint) override; 0067 void commitData (QWidget * editor) override; 0068 void verticalHeaderResized(int, int, int); 0069 void horizontalHeaderResized(int, int, int); 0070 void horizontalHeaderDataChanged(Qt::Orientation, int, int); 0071 void slotPrintPreviewRequested(QPrinter* printer); 0072 0073 private: 0074 // Disable from public calling; use setFilterModel() instead. 0075 //void setModel(QAbstractItemModel *model); 0076 0077 void createPages(QPrinter *, QTextDocument *, bool); 0078 bool selectionHasMoreThanText(); 0079 0080 QString m_currentText; 0081 0082 KWQTableDelegate * m_delegate; 0083 KWQSortFilterModel *m_model; 0084 QUndoStack *m_undoStack; 0085 }; 0086 0087 #endif // KWORDQUIZVIEW_H