• Skip to content
  • Skip to link menu
KDE 4.0 API Reference
  • KDE API Reference
  • kdeedu
  • Sitemap
  • Contact Us
 

parley

additionaleditpage.cpp

Go to the documentation of this file.
00001 /***************************************************************************
00002 
00003                        edit "additional" properties
00004 
00005     -----------------------------------------------------------------------
00006 
00007     begin         : Thu Nov 25 17:29:44 1999
00008 
00009     copyright     : (C) 1999-2001 Ewald Arnold <kvoctrain@ewald-arnold.de>
00010                     (C) 2005-2007 Peter Hedlund <peter.hedlund@kdemail.net>
00011                     (C) 2007 Frederik Gladhorn <frederik.gladhorn@kdemail.net>
00012 
00013     -----------------------------------------------------------------------
00014 
00015  ***************************************************************************/
00016 
00017 /***************************************************************************
00018  *                                                                         *
00019  *   This program is free software; you can redistribute it and/or modify  *
00020  *   it under the terms of the GNU General Public License as published by  *
00021  *   the Free Software Foundation; either version 2 of the License, or     *
00022  *   (at your option) any later version.                                   *
00023  *                                                                         *
00024  ***************************************************************************/
00025 
00026 #include "additionaleditpage.h"
00027 #include "EntryDlg.h"
00028 #include <QTextEdit>
00029 #include <Phonon/MediaObject>
00030 
00031 AdditionalEditPage::AdditionalEditPage(KEduVocDocument *doc, QWidget *parent) : QWidget(parent)
00032 {
00033     m_doc = doc;
00034     m_player = 0;
00035 
00036     setupUi(this);
00037 
00038     connect(paraphraseLineEdit, SIGNAL(textChanged(const QString&)), SLOT(slotDataChanged()));
00039     connect(commentLineEdit, SIGNAL(textChanged(const QString&)), SLOT(slotDataChanged()));
00040     connect(exampleLineEdit, SIGNAL(textChanged(const QString&)), SLOT(slotDataChanged()));
00041     connect(antonymLineEdit, SIGNAL(textChanged(const QString&)), SLOT(slotDataChanged()));
00042     connect(synonymLineEdit, SIGNAL(textChanged(const QString&)), SLOT(slotDataChanged()));
00043     connect(audioUrlRequester, SIGNAL(textChanged(const QString&)), SLOT(slotDataChanged()));
00044     connect(imageUrlRequester, SIGNAL(textChanged(const QString&)), SLOT(slotImageChanged(const QString&)));
00045 
00046     connect(audioPlayButton, SIGNAL(clicked()), this, SLOT(playAudio()) );
00047 }
00048 
00049 
00050 bool AdditionalEditPage::isModified()
00051 {
00052     if ( m_currentRow < 0 || m_currentTranslation < 0 ) {
00053         return false;
00054     }
00055 
00056     bool modified = false;
00057 
00058     if (synonymLineEdit->text() != m_doc->entry(m_currentRow)->translation(m_currentTranslation).synonym()) {
00059         modified = true;
00060     }
00061     if (antonymLineEdit->text() != m_doc->entry(m_currentRow)->translation(m_currentTranslation).antonym()) {
00062         modified = true;
00063     }
00064     if (exampleLineEdit->text() != m_doc->entry(m_currentRow)->translation(m_currentTranslation).example()) {
00065         modified = true;
00066     }
00067     if (commentLineEdit->text() != m_doc->entry(m_currentRow)->translation(m_currentTranslation).comment()) {
00068         modified = true;
00069     }
00070     if (paraphraseLineEdit->text() != m_doc->entry(m_currentRow)->translation(m_currentTranslation).paraphrase()) {
00071         modified = true;
00072     }
00073     return modified;
00074 }
00075 
00076 
00077 void AdditionalEditPage::setData(int row, int col)
00078 {
00079     m_currentRow = row;
00080     m_currentTranslation = col;
00081 
00082     synonymLineEdit->setText(m_doc->entry(m_currentRow)->translation(m_currentTranslation).synonym());
00083     antonymLineEdit->setText(m_doc->entry(m_currentRow)->translation(m_currentTranslation).antonym());
00084     exampleLineEdit->setText(m_doc->entry(m_currentRow)->translation(m_currentTranslation).example());
00085     commentLineEdit->setText(m_doc->entry(m_currentRow)->translation(m_currentTranslation).comment());
00086     paraphraseLineEdit->setText(m_doc->entry(m_currentRow)->translation(m_currentTranslation).paraphrase());
00087 
00088     if ( !m_doc->entry(m_currentRow)->translation(m_currentTranslation).soundUrl().isEmpty() ) {
00089         audioUrlRequester->setUrl( m_doc->entry(
00090                     m_currentRow)->translation(m_currentTranslation).soundUrl() );
00091     } else {
00092         audioUrlRequester->clear();
00093     }
00094 
00095     imagePreviewLabel->setText(i18nc("@label image preview is empty", "No Image"));
00096 
00097     if ( !m_doc->entry(m_currentRow)->translation(m_currentTranslation).imageUrl().isEmpty() ) {
00098         imageUrlRequester->setUrl( m_doc->entry(
00099                     m_currentRow)->translation(m_currentTranslation).imageUrl() );
00100     } else {
00101         imageUrlRequester->clear();
00102     }
00103 }
00104 
00105 
00106 void AdditionalEditPage::commitData()
00107 {
00108     m_doc->entry(m_currentRow)->translation(m_currentTranslation).setComment(commentLineEdit->text());
00109     m_doc->entry(m_currentRow)->translation(m_currentTranslation).setSynonym(synonymLineEdit->text());
00110     m_doc->entry(m_currentRow)->translation(m_currentTranslation).setAntonym(antonymLineEdit->text());
00111     m_doc->entry(m_currentRow)->translation(m_currentTranslation).setExample(exampleLineEdit->text());
00112     m_doc->entry(m_currentRow)->translation(m_currentTranslation).setParaphrase(paraphraseLineEdit->text());
00113 
00114     // sound and image
00115     m_doc->entry(m_currentRow)->translation(m_currentTranslation).setSoundUrl( audioUrlRequester->url() );
00116 
00117     m_doc->entry(m_currentRow)->translation(m_currentTranslation).setImageUrl( imageUrlRequester->url() );
00118     foreach (int j, m_doc->entry(m_currentRow)->translationIndices()) {
00119         if ( m_doc->entry(m_currentRow)->translation(j).imageUrl().isEmpty() ) {
00120             m_doc->entry(m_currentRow)->translation(j).setImageUrl( imageUrlRequester->url() );
00121         }
00122     }
00123 }
00124 
00125 
00126 void AdditionalEditPage::clear()
00127 {
00128     synonymLineEdit->setText(QString());
00129     antonymLineEdit->setText(QString());
00130     exampleLineEdit->setText(QString());
00131     commentLineEdit->setText(QString());
00132     paraphraseLineEdit->setText(QString());
00133 }
00134 
00135 void AdditionalEditPage::slotDataChanged()
00136 {
00137     emit sigModified();
00138 }
00139 
00140 
00141 void AdditionalEditPage::playAudio()
00142 {
00143     KUrl soundFile = audioUrlRequester->url();
00144     kDebug() << "sound file: " << soundFile.url();
00145 
00146     if (!m_player)
00147     {
00148         m_player = Phonon::createPlayer(Phonon::NoCategory, soundFile);
00149         m_player->setParent(this);
00150     } else {
00151         m_player->setCurrentSource(soundFile);
00152     }
00153     m_player->play();
00154 }
00155 
00156 void AdditionalEditPage::slotImageChanged(const QString & url)
00157 {
00158     imagePreviewLabel->setPixmap(QPixmap(url).scaled(imagePreviewLabel->size(), Qt::KeepAspectRatio));
00159     slotDataChanged();
00160 }
00161 
00162 
00163 #include "additionaleditpage.moc"

parley

Skip menu "parley"
  • Main Page
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Namespace Members
  • Class Members
  • Related Pages

kdeedu

Skip menu "kdeedu"
  • kalzium
  • kanagram
  • kig
  • klettres
  • kstars
  • libkdeedu
  •   keduvocdocument
  •   docs
  •   src
  • parley
Generated for kdeedu by doxygen 1.5.4
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal