23 m_phraseBook(phraseBook),
24 m_translationSettingsDialog(0)
28#define NewPhrase tr("(New Entry)")
31 setWindowTitle(tr(
"%1[*] - Qt Linguist").arg(m_phraseBook->friendlyPhraseBookName()));
32 setWindowModified(m_phraseBook->isModified());
34 phrMdl =
new PhraseModel(
this);
36 m_sortedPhraseModel =
new QSortFilterProxyModel(
this);
37 m_sortedPhraseModel->setSortCaseSensitivity(Qt::CaseInsensitive);
38 m_sortedPhraseModel->setSortLocaleAware(
true);
39 m_sortedPhraseModel->setDynamicSortFilter(
true);
40 m_sortedPhraseModel->setSourceModel(phrMdl);
42 phraseList->setModel(m_sortedPhraseModel);
43 phraseList->header()->setDefaultSectionSize(150);
44 phraseList->header()->setSectionResizeMode(QHeaderView::Interactive);
46 connect(sourceLed, &QLineEdit::textChanged,
47 this, &PhraseBookBox::sourceChanged);
48 connect(targetLed, &QLineEdit::textChanged,
49 this, &PhraseBookBox::targetChanged);
50 connect(definitionLed, &QLineEdit::textChanged,
51 this, &PhraseBookBox::definitionChanged);
52 connect(phraseList->selectionModel(), &QItemSelectionModel::currentChanged,
53 this, &PhraseBookBox::selectionChanged);
54 connect(newBut, &QAbstractButton::clicked,
55 this, &PhraseBookBox::newPhrase);
56 connect(removeBut, &QAbstractButton::clicked,
57 this, &PhraseBookBox::removePhrase);
58 connect(settingsBut, &QAbstractButton::clicked,
59 this, &PhraseBookBox::settings);
60 connect(saveBut, &QAbstractButton::clicked,
61 this, &PhraseBookBox::save);
62 connect(m_phraseBook, &PhraseBook::modifiedChanged,
63 this, &PhraseBookBox::setWindowModified);
65 sourceLed->installEventFilter(
this);
66 targetLed->installEventFilter(
this);
67 definitionLed->installEventFilter(
this);
69 const auto phrases = phraseBook->phrases();
70 for (Phrase *p : phrases)
73 phraseList->sortByColumn(0, Qt::AscendingOrder);
80 if (event->type() == QEvent::KeyPress &&
81 (obj == sourceLed || obj == targetLed || obj == definitionLed))
83 const QKeyEvent *keyEvent =
static_cast<QKeyEvent *>(event);
84 const int key = keyEvent->key();
89 case Qt::Key_PageDown:
91 return QApplication::sendEvent(phraseList, event);
94 return QDialog::eventFilter(obj, event);