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

parley

  • sources
  • kde-4.12
  • kdeedu
  • parley
  • src
  • settings
documentproperties.cpp
Go to the documentation of this file.
1 /***************************************************************************
2 
3  enter document title and author
4 
5  -----------------------------------------------------------------------
6 
7  begin : Thu Mar 11 20:50:53 MET 1999
8 
9  copyright : (C) 1999-2001 Ewald Arnold <kvoctrain@ewald-arnold.de>
10  (C) 2005 Peter Hedlund <peter.hedlund@kdemail.net>
11  (C) 2007 Frederik Gladhorn <frederik.gladhorn@kdemail.net>
12 
13  -----------------------------------------------------------------------
14 
15  ***************************************************************************
16 
17  ***************************************************************************
18  * *
19  * This program is free software; you can redistribute it and/or modify *
20  * it under the terms of the GNU General Public License as published by *
21  * the Free Software Foundation; either version 2 of the License, or *
22  * (at your option) any later version. *
23  * *
24  ***************************************************************************/
25 
26 #include "documentproperties.h"
27 
28 #include "parleymainwindow.h"
29 #include "parleydocument.h"
30 
31 #include <keduvocdocument.h>
32 #include <KLineEdit>
33 
34 #include <QTextEdit>
35 #include <QLabel>
36 
37 DocumentProperties::DocumentProperties(KEduVocDocument * doc, bool languageSetup, QWidget* parent)
38  :QWidget(parent), m_doc(doc), m_showLanguages(languageSetup)
39 {
40  setupUi(this);
41 
42  titleLineEdit->setText(doc->title());
43  authorLineEdit->setText(doc->author());
44  contactLineEdit->setText(doc->authorContact());
45  licenseComboBox->setEditText(doc->license());
46  commentTextEdit->setText(doc->documentComment());
47  categoryComboBox->setEditText(doc->category());
48 
49  if (languageSetup) {
50  prepareLanguageSelection();
51  } else {
52  languageGroupBox->setVisible(false);
53  }
54 }
55 
56 void DocumentProperties::prepareLanguageSelection()
57 {
58  QStringList codes = KGlobal::locale()->allLanguagesList();
59  QStringList languageNames;
60  foreach (const QString &code, codes){
61  languageNames.append( KGlobal::locale()->languageCodeToName(code) );
62  }
63  languageNames.sort();
64 
65  firstLanguageComboBox->addItems(languageNames);
66  firstLanguageComboBox->completionObject()->insertItems(languageNames);
67  firstLanguageComboBox->completionObject()->setIgnoreCase(true);
68  secondLanguageComboBox->addItems(languageNames);
69  secondLanguageComboBox->completionObject()->insertItems(languageNames);
70  secondLanguageComboBox->completionObject()->setIgnoreCase(true);
71 
72  languageGroupBox->setVisible(true);
73 }
74 
75 void DocumentProperties::accept()
76 {
77  m_doc->setTitle(titleLineEdit->text());
78  ParleyMainWindow::instance()->slotUpdateWindowCaption();
79  m_doc->setAuthor(authorLineEdit->text());
80  m_doc->setAuthorContact(contactLineEdit->text());
81  m_doc->setLicense(licenseComboBox->currentText());
82  m_doc->setDocumentComment(commentTextEdit->toPlainText());
83  m_doc->setCategory(categoryComboBox->currentText());
84 
85  if (m_showLanguages) {
86  acceptLanguageConfiguration();
87  }
88 }
89 
90 void DocumentProperties::acceptLanguageConfiguration()
91 {
92  QString firstLanguage = firstLanguageComboBox->currentText();
93  QString firstLocale;
94  QString secondLanguage = secondLanguageComboBox->currentText();
95  QString secondLocale;
96 
97  // ugly but works for now: iterate over languages to check which code we have
98  foreach ( const QString &code, KGlobal::locale()->allLanguagesList() ) {
99  if ( firstLanguage == KGlobal::locale()->languageCodeToName(code) ) {
100  firstLocale = code;
101  }
102  if ( secondLanguage == KGlobal::locale()->languageCodeToName(code) ) {
103  secondLocale = code;
104  }
105  }
106 
107  m_doc->identifier(0).setLocale(firstLocale);
108  m_doc->identifier(0).setName(firstLanguage);
109  m_doc->identifier(1).setLocale(secondLocale);
110  m_doc->identifier(1).setName(secondLanguage);
111 }
112 
113 #include "documentproperties.moc"
DocumentProperties::accept
void accept()
Apply the settings. This is not a KDialog, so accept is not automatically called! ...
Definition: documentproperties.cpp:75
QWidget
parleydocument.h
DocumentProperties::DocumentProperties
DocumentProperties(KEduVocDocument *doc, bool languageSetup, QWidget *parent)
Definition: documentproperties.cpp:37
ParleyMainWindow::instance
static ParleyMainWindow * instance()
Definition: parleymainwindow.cpp:56
documentproperties.h
parleymainwindow.h
ParleyMainWindow::slotUpdateWindowCaption
void slotUpdateWindowCaption()
Update the title bar of the main window with the current document.
Definition: parleymainwindow.cpp:132
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 22:42:05 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

parley

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

kdeedu API Reference

Skip menu "kdeedu API Reference"
  • Analitza
  •     lib
  • kalgebra
  • kalzium
  •   libscience
  • kanagram
  • kig
  •   lib
  • klettres
  • kstars
  • libkdeedu
  •   keduvocdocument
  • marble
  • parley
  • rocs
  •   App
  •   RocsCore
  •   VisualEditor
  •   stepcore

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal