| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
#pragma once |
| 21 |
|
| 22 |
#include <QListView> |
| 23 |
|
| 24 |
#include "UserphraseDialog.h" |
| 25 |
#include "UserphraseSortFilterProxyModel.h" |
| 26 |
#include "UserphraseViewMenu.h" |
| 27 |
|
| 28 |
class UserphraseView final : public QListView { |
| 29 |
Q_OBJECT |
| 30 |
|
| 31 |
public: |
| 32 |
explicit UserphraseView(QWidget *parent = 0); |
| 33 |
UserphraseView(const UserphraseView&) = delete; |
| 34 |
UserphraseView& operator=(const UserphraseView&) = delete; |
| 35 |
virtual ~UserphraseView() = default; |
| 36 |
virtual void setModel(UserphraseSortFilterProxyModel *model) { |
| 37 |
QListView::setModel(model); |
| 38 |
} |
| 39 |
|
| 40 |
public slots: |
| 41 |
void showAddUserphraseDialog(); |
| 42 |
void showModifyUserphraseDialog(); |
| 43 |
void addPhrase(int result); |
| 44 |
void remove(); |
| 45 |
void setFilterString(const QString& text); |
| 46 |
void showContextMenu(const QPoint& point); |
| 47 |
|
| 48 |
|
| 49 |
protected: |
| 50 |
UserphraseSortFilterProxyModel* model() const { |
| 51 |
return dynamic_cast<UserphraseSortFilterProxyModel*>(QListView::model()); |
| 52 |
} |
| 53 |
|
| 54 |
private: |
| 55 |
enum DialogType { |
| 56 |
DIALOG_ADD, |
| 57 |
DIALOG_MODIFY, |
| 58 |
}; |
| 59 |
|
| 60 |
void setupContextMenu(); |
| 61 |
void setupAddUserphraseDialog(); |
| 62 |
|
| 63 |
UserphraseDialog *UserphraseDialog_; |
| 64 |
UserphraseViewMenu *menu_; |
| 65 |
|
| 66 |
bool dialogType_; |
| 67 |
|
| 68 |
QString originalphrase_; |
| 69 |
QString originalbopomofo_; |
| 70 |
}; |