Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
phrase.h
Go to the documentation of this file.
1// Copyright (C) 2016 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
3
4#ifndef PHRASE_H
5#define PHRASE_H
6
7#include <QObject>
8#include <QString>
9#include <QList>
10#include <QtCore/QLocale>
11
12#include "simtexth.h"
13
15
16class PhraseBook;
17
18class Phrase
19{
20public:
21 Phrase();
22 Phrase(const QString &source, const QString &target, const QString &definition,
23 const Candidate &candidate, int sc = -1);
24 Phrase(const QString &source, const QString &target,
25 const QString &definition, PhraseBook *phraseBook);
26
27 QString source() const { return s; }
28 void setSource(const QString &ns);
29 QString target() const {return t;}
30 void setTarget(const QString &nt);
31 QString definition() const {return d;}
32 void setDefinition (const QString &nd);
33 int shortcut() const { return shrtc; }
34 Candidate candidate() const { return cand; }
35 PhraseBook *phraseBook() const { return m_phraseBook; }
36 void setPhraseBook(PhraseBook *book) { m_phraseBook = book; }
37
38private:
39 int shrtc;
40 QString s;
41 QString t;
42 QString d;
43 Candidate cand;
44 PhraseBook *m_phraseBook;
45};
46
47bool operator==(const Phrase &p, const Phrase &q);
48inline bool operator!=(const Phrase &p, const Phrase &q) {
49 return !(p == q);
50}
51
52class QphHandler;
53
54class PhraseBook : public QObject
55{
57
58public:
59 PhraseBook();
60 ~PhraseBook();
61 bool load(const QString &fileName, bool *langGuessed);
62 bool save(const QString &fileName);
63 QList<Phrase *> phrases() const { return m_phrases; }
64 void append(Phrase *phrase);
65 void remove(Phrase *phrase);
66 QString fileName() const { return m_fileName; }
68 bool isModified() const { return m_changed; }
69
70 void setLanguageAndTerritory(QLocale::Language lang, QLocale::Territory territory);
71 QLocale::Language language() const { return m_language; }
72 QLocale::Territory territory() const { return m_territory; }
73 void setSourceLanguageAndTerritory(QLocale::Language lang, QLocale::Territory territory);
74 QLocale::Language sourceLanguage() const { return m_sourceLanguage; }
75 QLocale::Territory sourceTerritory() const { return m_sourceTerritory; }
76
80
81private:
82 // Prevent copying
83 PhraseBook(const PhraseBook &);
84 PhraseBook& operator=(const PhraseBook &);
85
86 void setModified(bool modified);
87 void phraseChanged(Phrase *phrase);
88
89 QList<Phrase *> m_phrases;
90 QString m_fileName;
91 bool m_changed;
92
93 QLocale::Language m_language;
94 QLocale::Language m_sourceLanguage;
95 QLocale::Territory m_territory;
96 QLocale::Territory m_sourceTerritory;
97
98 friend class QphHandler;
99 friend class Phrase;
100};
101
102QT_END_NAMESPACE
103
104#endif
int main(int argc, char *argv[])
[2]
Definition buffer.cpp:77
void closeEvent(QCloseEvent *event) override
[21]
bool openFiles(const QStringList &names, bool readWrite=true)
~MainWindow() override
void writeConfig()
static RecentFiles & recentFiles()
bool eventFilter(QObject *obj, QEvent *ev) override
Filters events if this object has been installed as an event filter for the watched object.
static QString friendlyString(const QString &str)
void readConfig()
QLocale::Language sourceLanguage() const
Definition phrase.h:74
void append(Phrase *phrase)
Definition phrase.cpp:269
QLocale::Territory territory() const
Definition phrase.h:72
QLocale::Language language() const
Definition phrase.h:71
QString friendlyPhraseBookName() const
Definition phrase.cpp:300
bool isModified() const
Definition phrase.h:68
void setSourceLanguageAndTerritory(QLocale::Language lang, QLocale::Territory territory)
Definition phrase.cpp:186
bool load(const QString &fileName, bool *langGuessed)
Definition phrase.cpp:195
void listChanged()
QList< Phrase * > phrases() const
Definition phrase.h:63
void setLanguageAndTerritory(QLocale::Language lang, QLocale::Territory territory)
Definition phrase.cpp:177
QLocale::Territory sourceTerritory() const
Definition phrase.h:75
QString fileName() const
Definition phrase.h:66
bool save(const QString &fileName)
Definition phrase.cpp:237
void remove(Phrase *phrase)
Definition phrase.cpp:277
void setPhraseBook(PhraseBook *book)
Definition phrase.h:36
PhraseBook * phraseBook() const
Definition phrase.h:35
void setDefinition(const QString &nd)
Definition phrase.cpp:64
void setSource(const QString &ns)
Definition phrase.cpp:46
QString definition() const
Definition phrase.h:31
QString target() const
Definition phrase.h:29
int shortcut() const
Definition phrase.h:33
Phrase()
Definition phrase.cpp:28
Candidate candidate() const
Definition phrase.h:34
Phrase(const QString &source, const QString &target, const QString &definition, PhraseBook *phraseBook)
Definition phrase.cpp:39
Phrase(const QString &source, const QString &target, const QString &definition, const Candidate &candidate, int sc=-1)
Definition phrase.cpp:33
void setTarget(const QString &nt)
Definition phrase.cpp:55
QString source() const
Definition phrase.h:27
Combined button and popup list for selecting options.
bool operator==(const Phrase &p, const Phrase &q)
Definition phrase.cpp:73
bool operator!=(const Phrase &p, const Phrase &q)
Definition phrase.h:48