-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathinterlineardisplaywidget.h
135 lines (102 loc) · 3.87 KB
/
interlineardisplaywidget.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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
/*!
\class InterlinearDisplayWidget
\ingroup Interlinear
\brief A widget for an interlinear text display. The widget's layout is populated with a series of FlowLayout layouts corresponding to phrases.
This widget will be contained by TextTabWidget.
*/
#ifndef INTERLINEARDISPLAYWIDGET_H
#define INTERLINEARDISPLAYWIDGET_H
#include <QScrollArea>
#include <QList>
#include <QSet>
class QVBoxLayout;
class QScrollArea;
class Text;
class Project;
class FlowLayout;
class LingEdit;
class TextBit;
class InterlinearLineLabel;
class WordDisplayWidget;
class PunctuationDisplayWidget;
class GlossItem;
class Phrase;
class Focus;
class Tab;
class Paragraph;
class ParagraphMarkWidget;
#include "annotationmarkwidget.h"
#include "interlinearitemtype.h"
class InterlinearDisplayWidget : public QScrollArea
{
Q_OBJECT
public:
enum MouseMode { Normal, ChangeBaseline };
InterlinearDisplayWidget(const Tab * tab, Text *text, Project *project, QWidget *parent = nullptr);
~InterlinearDisplayWidget();
void setPhrasalGloss(int lineNumber, const TextBit & bit);
public slots:
void scrollToLine(int line);
void requestLineRefresh( int line );
void setLayoutFromText();
void setLines( const QList<int> lines );
void setFocus( const QList<Focus> & foci );
// Returns the line number of \a wdw. If \a wdw is not a WordDisplayWidget, returns -1. If \a wdw cannot be found, returns -1.
int lineNumberOfWdw(QWidget *wdw) const;
void resetGui();
protected:
void scrollContentsBy ( int dx, int dy );
void clearWidgetsFromLine(int lineNumber);
void setLinesToDefault();
private slots:
void saveText();
void saveTextVerbose();
void approveAll( WordDisplayWidget * wdw );
void playSound( WordDisplayWidget * wdw );
void leftGlossItem( WordDisplayWidget * wdw );
void rightGlossItem( WordDisplayWidget * wdw );
void moveToNextGlossItem( WordDisplayWidget * wdw );
void moveToPreviousGlossItem( WordDisplayWidget * wdw );
void findPreviousWdw(int &lineNumber, int &position);
void findNextWdw(int &lineNumber, int &position);
void enterChangeBaselineMode(QAction * action);
void wdwClicked( WordDisplayWidget * wdw );
void clearFocus();
protected:
const Tab * mTab;
Text *mText;
Project *mProject;
InterlinearDisplayWidget::MouseMode mMouseMode;
int mCurrentLine;
WritingSystem mChangeWritingSystemTo;
private:
void contextMenuEvent ( QContextMenuEvent * event );
void keyPressEvent ( QKeyEvent * event );
//! \brief Add the word display widgets for phrase \a i to \a flowLayout
void addWordWidgets(int i , Phrase *phrase, QLayout * flowLayout );
WordDisplayWidget* addWordDisplayWidget(GlossItem *item, Phrase *phrase);
PunctuationDisplayWidget* addPunctuationDisplayWidget(GlossItem *item);
protected:
QHash<int, QLayout*> mLineLayouts;
QHash<int, QVBoxLayout*> mPhrasalGlossLayouts;
QHash<int, InterlinearLineLabel*> mLineLabels;
QList<int> mLines;
QList<Focus> mFoci;
QSet<int> mLineRefreshRequests;
// WordDisplayWidget objects, keyed to line number
QList< QList<QWidget*> > mWordDisplayWidgets;
QMultiHash<int, LingEdit*> mPhrasalGlossEdits;
QMultiHash<int, ParagraphMarkWidget*> mParagraphMarkWidgets;
QLayout* addLine(int lineNumber);
QVBoxLayout* addPhrasalGlossLayout(int lineNumber);
QVBoxLayout *mLayout;
QList<InterlinearItemType> mPhrasalGlossLines;
//! \brief Add the phrasal gloss lines for phrase \a i
void addPhrasalGlossLines(int i, Phrase *phrase, QVBoxLayout *phrasalGlossLayout);
//! \brief Add a paragraph marker
void addParagraphMarker(int lineIndex, Paragraph *paragraph, QLayout * before = nullptr);
//! \brief Add a line label for phrase \a i
void addLineLabel(int i, Phrase *phrase, QLayout * flowLayout );
bool maybeFocus(QWidget *wdw);
};
#endif // INTERLINEARDISPLAYWIDGET_H