forked from z1dev/zkanji
-
Notifications
You must be signed in to change notification settings - Fork 0
/
dictionaryeditorform.h
92 lines (72 loc) · 3.12 KB
/
dictionaryeditorform.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
/*
** Copyright 2007-2013, 2017-2018 Sólyom Zoltán
** This file is part of zkanji, a free software released under the terms of the
** GNU General Public License version 3. See the file LICENSE for details.
**/
#ifndef DICTIONARYEDITORFORM_H
#define DICTIONARYEDITORFORM_H
#include "dialogwindow.h"
#include "zlistboxmodel.h"
namespace Ui {
class DictionaryEditorForm;
}
class ZListView;
class DictionaryEditorModel : public ZAbstractListBoxModel
{
Q_OBJECT
public:
DictionaryEditorModel(ZListView *view, QWidget *parent = nullptr);
virtual ~DictionaryEditorModel();
bool orderChanged() const;
virtual int rowCount(const QModelIndex &index = QModelIndex()) const override;
virtual QVariant data(const QModelIndex &index = QModelIndex(), int role = Qt::DisplayRole) const override;
virtual bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::DisplayRole) override;
virtual Qt::ItemFlags flags(const QModelIndex &index) const override;
virtual Qt::DropActions supportedDragActions() const override;
virtual Qt::DropActions supportedDropActions(bool samesource, const QMimeData *mime) const override;
virtual bool canDropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent = QModelIndex()) const override;
virtual bool dropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent = QModelIndex()) override;
virtual QMimeData* mimeData(const QModelIndexList &indexes) const override;
protected slots:
void handleAdded();
void handleRemoved(int index, int order);
void handleMoved(int from, int to);
void handleRenamed(const QString &oldname, int index, int order);
void handleFlagChanged(int index, int order);
private:
ZListView *view;
// Set to true if the dictionary order has changed since the form was shown.
bool orderchanged;
typedef ZAbstractListBoxModel base;
};
class DictionaryEditorForm : public DialogWindow
{
Q_OBJECT
public:
virtual ~DictionaryEditorForm();
// Shows the single instance of the form, or brings the existing instance to the
// foreground.
static void execute();
public slots:
void on_upButton_clicked(bool checked);
void on_downButton_clicked(bool checked);
void on_createButton_clicked(bool checked);
void on_editButton_clicked(bool checked);
void on_delButton_clicked(bool checked);
void on_dictView_currentRowChanged(int curr, int prev);
protected:
virtual bool event(QEvent *e) override;
virtual void closeEvent(QCloseEvent *e) override;
private:
DictionaryEditorForm(QWidget *parent = nullptr);
void translateTexts();
DictionaryEditorForm(const DictionaryEditorForm &) = delete;
DictionaryEditorForm(DictionaryEditorForm &&) = delete;
DictionaryEditorForm& operator=(const DictionaryEditorForm &) = delete;
DictionaryEditorForm& operator=(DictionaryEditorForm &&) = delete;
static DictionaryEditorForm *instance;
Ui::DictionaryEditorForm *ui;
DictionaryEditorModel *model;
typedef DialogWindow base;
};
#endif // DICTIONARYEDITORFORM_H