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

parley

documentproperties.cpp

Go to the documentation of this file.
00001 /***************************************************************************
00002 
00003                    enter document title and author
00004 
00005     -----------------------------------------------------------------------
00006 
00007     begin          : Thu Mar 11 20:50:53 MET 1999
00008 
00009     copyright      : (C) 1999-2001 Ewald Arnold <kvoctrain@ewald-arnold.de>
00010                      (C) 2005 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 "documentproperties.h"
00027 
00028 #include "parleydocument.h"
00029 
00030 #include <keduvocdocument.h>
00031 #include <KDebug>
00032 #include <KLineEdit>
00033 
00034 #include <QTextEdit>
00035 #include <QLabel>
00036 
00037 
00038 DocumentProperties::DocumentProperties(KEduVocDocument * doc, bool languageSetup, QWidget* parent)
00039     :QWidget(parent), m_doc(doc), m_showLanguages(languageSetup)
00040 {
00041     setupUi(this);
00042 
00043     titleLineEdit->setText(doc->title());
00044     authorLineEdit->setText(doc->author());
00045     contactLineEdit->setText(doc->authorContact());
00046     licenseComboBox->setEditText(doc->license());
00047     commentTextEdit->setText(doc->documentComment());
00048     categoryComboBox->setEditText(doc->category());
00049 
00050     if (languageSetup) {
00051         prepareLanguageSelection();
00052     } else {
00053         languageGroupBox->setVisible(false);
00054     }
00055 }
00056 
00057 void DocumentProperties::prepareLanguageSelection()
00058 {
00059     QStringList codes = KGlobal::locale()->allLanguagesList();
00060     QStringList languageNames;
00061     foreach (const QString &code, codes){
00062         languageNames.append( KGlobal::locale()->languageCodeToName(code) );
00063     }
00064     languageNames.sort();
00065 
00066     firstLanguageComboBox->addItems(languageNames);
00067     firstLanguageComboBox->completionObject()->insertItems(languageNames);
00068     firstLanguageComboBox->completionObject()->setIgnoreCase(true);
00069     secondLanguageComboBox->addItems(languageNames);
00070     secondLanguageComboBox->completionObject()->insertItems(languageNames);
00071     secondLanguageComboBox->completionObject()->setIgnoreCase(true);
00072 
00073     languageGroupBox->setVisible(true);
00074 }
00075 
00076 void DocumentProperties::accept()
00077 {
00078     ParleyDocument::instance()->setTitle(titleLineEdit->text());
00079     m_doc->setAuthor(authorLineEdit->text());
00080     m_doc->setAuthorContact(contactLineEdit->text());
00081     m_doc->setLicense(licenseComboBox->currentText());
00082     m_doc->setDocumentComment(commentTextEdit->toPlainText());
00083     m_doc->setCategory(categoryComboBox->currentText());
00084 
00085     if (m_showLanguages) {
00086         acceptLanguageConfiguration();
00087     }
00088 }
00089 
00090 void DocumentProperties::acceptLanguageConfiguration()
00091 {
00092     QString firstLanguage = firstLanguageComboBox->currentText();
00093     QString firstLocale;
00094     QString secondLanguage = secondLanguageComboBox->currentText();
00095     QString secondLocale;
00096 
00097     // ugly but works for now: iterate over languages to check which code we have
00098     foreach ( const QString &code, KGlobal::locale()->allLanguagesList() ) {
00099         if ( firstLanguage == KGlobal::locale()->languageCodeToName(code) ) {
00100             firstLocale = code;
00101         }
00102         if ( secondLanguage == KGlobal::locale()->languageCodeToName(code) ) {
00103             secondLocale = code;
00104         }
00105     }
00106 
00107     m_doc->identifier(0).setLocale(firstLocale);
00108     m_doc->identifier(0).setName(firstLanguage);
00109     m_doc->identifier(1).setLocale(secondLocale);
00110     m_doc->identifier(1).setName(secondLanguage);
00111 }
00112 
00113 #include "documentproperties.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"
  •     lib
  • kalzium
  • kanagram
  • kig
  •   lib
  • klettres
  • kstars
  • libkdeedu
  •   keduvocdocument
  • marble
  • parley
  •   stepcore
Generated for kdeedu by doxygen 1.5.9-20090814
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