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

parley

  • sources
  • kde-4.14
  • 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  m_doc->setAuthor(authorLineEdit->text());
79  m_doc->setAuthorContact(contactLineEdit->text());
80  m_doc->setLicense(licenseComboBox->currentText());
81  m_doc->setDocumentComment(commentTextEdit->toPlainText());
82  m_doc->setCategory(categoryComboBox->currentText());
83 
84  if (m_showLanguages) {
85  acceptLanguageConfiguration();
86  }
87 }
88 
89 void DocumentProperties::acceptLanguageConfiguration()
90 {
91  QString firstLanguage = firstLanguageComboBox->currentText();
92  QString firstLocale;
93  QString secondLanguage = secondLanguageComboBox->currentText();
94  QString secondLocale;
95 
96  // ugly but works for now: iterate over languages to check which code we have
97  foreach(const QString & code, KGlobal::locale()->allLanguagesList()) {
98  if (firstLanguage == KGlobal::locale()->languageCodeToName(code)) {
99  firstLocale = code;
100  }
101  if (secondLanguage == KGlobal::locale()->languageCodeToName(code)) {
102  secondLocale = code;
103  }
104  }
105 
106  m_doc->identifier(0).setLocale(firstLocale);
107  m_doc->identifier(0).setName(firstLanguage);
108  m_doc->identifier(1).setLocale(secondLocale);
109  m_doc->identifier(1).setName(secondLanguage);
110 }
111 
112 #include "documentproperties.moc"
QWidget
DocumentProperties::accept
void accept()
Apply the settings. This is not a KDialog, so accept is not automatically called! ...
Definition: documentproperties.cpp:75
QWidget::setupUi
void setupUi(QWidget *widget)
parleydocument.h
DocumentProperties::DocumentProperties
DocumentProperties(KEduVocDocument *doc, bool languageSetup, QWidget *parent)
Definition: documentproperties.cpp:37
QList::append
void append(const T &value)
QString
documentproperties.h
QStringList
parleymainwindow.h
QStringList::sort
void sort()
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:15:56 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
  • 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