parley
AdjEntryPage.cpp
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026 #include "AdjEntryPage.h"
00027
00028 #include <QLineEdit>
00029
00030 #include "EntryDlg.h"
00031
00032 AdjEntryPage::AdjEntryPage(KEduVocDocument *doc, QWidget *parent) : QWidget(parent)
00033 {
00034 m_doc = doc;
00035 m_currentTranslation = -1;
00036 m_currentRow = -1;
00037
00038 setupUi(this);
00039
00040 connect(lev1Field, SIGNAL(textChanged(const QString&)), SLOT(slotDataChanged(const QString&)));
00041 connect(lev2Field, SIGNAL(textChanged(const QString&)), SLOT(slotDataChanged(const QString&)));
00042 connect(lev3Field, SIGNAL(textChanged(const QString&)), SLOT(slotDataChanged(const QString&)));
00043 }
00044
00045
00046 void AdjEntryPage::slotDataChanged(const QString& s)
00047 {
00048 Q_UNUSED(s)
00049 emit sigModified();
00050 }
00051
00052
00053 bool AdjEntryPage::isModified()
00054 {
00055 if ( m_currentRow < 0 || m_currentTranslation < 0 ) {
00056 return false;
00057 }
00058
00059 KEduVocExpression *expr = m_doc->entry(m_currentRow);
00060 if ( expr->translation(m_currentTranslation).comparison().l1() != lev1Field->text() ) {
00061 return true;
00062 }
00063 if ( expr->translation(m_currentTranslation).comparison().l2() != lev2Field->text() ) {
00064 return true;
00065 }
00066 if ( expr->translation(m_currentTranslation).comparison().l3() != lev3Field->text() ) {
00067 return true;
00068 }
00069 return false;
00070 }
00071
00072
00073 void AdjEntryPage::setData(int row, int col)
00074 {
00075 m_currentRow = row;
00076 m_currentTranslation = col;
00077 KEduVocExpression *expr = m_doc->entry(m_currentRow);
00078 lev1Field->setText(expr->translation(m_currentTranslation).comparison().l1());
00079 lev2Field->setText(expr->translation(m_currentTranslation).comparison().l2());
00080 lev3Field->setText(expr->translation(m_currentTranslation).comparison().l3());
00081 }
00082
00083 void AdjEntryPage::commitData()
00084 {
00085 KEduVocComparison comp;
00086 comp.setL1(lev1Field->text());
00087 comp.setL2(lev2Field->text());
00088 comp.setL3(lev3Field->text());
00089
00090 m_doc->entry(m_currentRow)->translation(m_currentTranslation).setComparison( comp );
00091 }
00092
00093 void AdjEntryPage::clear()
00094 {
00095 lev1Field->setText(QString());
00096 lev2Field->setText(QString());
00097 lev3Field->setText(QString());
00098 }
00099
00100 #include "AdjEntryPage.moc"