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

kanagram

  • sources
  • kde-4.12
  • kdeedu
  • kanagram
  • src
  • desktop
vocabsettings.cpp
Go to the documentation of this file.
1 /***************************************************************************
2  * Copyright (C) 2005 by Joshua Keel <joshuakeel@gmail.com> *
3  * (C) 2007 by Jeremy Whiting <jpwhiting@kde.org> *
4  * *
5  * *
6  * This program is free software; you can redistribute it and/or modify *
7  * it under the terms of the GNU General Public License as published by *
8  * the Free Software Foundation; either version 2 of the License, or *
9  * (at your option) any later version. *
10  * *
11  * This program is distributed in the hope that it will be useful, *
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
14  * GNU General Public License for more details. *
15  * *
16  * You should have received a copy of the GNU General Public License *
17  * along with this program; if not, write to the *
18  * Free Software Foundation, Inc., *
19  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
20  ***************************************************************************/
21 
22 #include "vocabsettings.h"
23 #include "vocabedit.h"
24 
25 #include <kstandarddirs.h>
26 #include <kconfigdialog.h>
27 #include <qfileinfo.h>
28 
29 #include <knewstuff3/downloaddialog.h>
30 #include <knewstuff3/knewstuffbutton.h>
31 #include <sharedkvtmlfiles.h>
32 #include <keduvocdocument.h>
33 #include <kanagramsettings.h>
34 
35 #include <QtCore/QPointer>
36 
37 VocabSettings::VocabSettings(QWidget *parent) : QWidget(parent), m_parent(NULL)
38 {
39  setupUi(this);
40  m_parent = (KConfigDialog*)parent;
41 
42  connect(lviewVocab, SIGNAL(currentItemChanged(QTreeWidgetItem*,QTreeWidgetItem*)), this, SLOT(slotSelectionChanged(QTreeWidgetItem*)));
43 
44  btnDownloadNew->setIcon(KIcon("get-hot-new-stuff"));
45 
46  refreshView();
47 }
48 
49 VocabSettings::~VocabSettings()
50 {
51 }
52 
53 void VocabSettings::refreshView()
54 {
55  lviewVocab->clear();
56 
57  SharedKvtmlFiles::sortDownloadedFiles();
58  m_fileList = SharedKvtmlFiles::fileNames(KanagramSettings::dataLanguage());
59  m_titleList = SharedKvtmlFiles::titles(KanagramSettings::dataLanguage());
60  m_commentList = SharedKvtmlFiles::comments(KanagramSettings::dataLanguage());
61 
62  for(int i = 0; i < m_fileList.size(); i++)
63  {
64  QTreeWidgetItem *item = new QTreeWidgetItem(lviewVocab, 0);
65  item->setText( 0, m_titleList[i] );
66  item->setText( 1, m_commentList[i] );
67  m_itemMap[item] = i;
68  }
69  m_parent->enableButtonApply(true);
70 }
71 
72 void VocabSettings::on_btnEdit_clicked()
73 {
74  if(lviewVocab->currentItem())
75  {
76  int index = m_itemMap[lviewVocab->currentItem()];
77  VocabEdit *vocabEdit = new VocabEdit(this, m_fileList[index]);
78  connect(vocabEdit, SIGNAL(finished(int)), this, SLOT(refreshView()));
79  vocabEdit->show();
80  }
81 }
82 
83 void VocabSettings::on_btnCreateNew_clicked()
84 {
85  VocabEdit *vocabEdit = new VocabEdit(this, "");
86  connect(vocabEdit, SIGNAL(finished(int)), this, SLOT(refreshView()));
87  vocabEdit->show();
88 }
89 
90 void VocabSettings::on_btnDownloadNew_clicked()
91 {
92  QPointer<KNS3::DownloadDialog> hotNewStuffdialog = new KNS3::DownloadDialog( "kanagram.knsrc" );
93  hotNewStuffdialog->exec();
94  if ( hotNewStuffdialog->changedEntries().size() > 0 ){
95  refreshView();
96  }
97 
98  delete hotNewStuffdialog;
99 }
100 
101 void VocabSettings::slotSelectionChanged(QTreeWidgetItem *item)
102 {
103  int index = m_itemMap[item];
104  bool writeable = QFileInfo(m_fileList[index]).isWritable();
105  btnEdit->setEnabled(writeable);
106 }
107 
108 #include "vocabsettings.moc"
VocabSettings::VocabSettings
VocabSettings(QWidget *parent)
default constructor
Definition: vocabsettings.cpp:37
QWidget
VocabSettings::refreshView
void refreshView()
reload the list of vocabularies from what's on disk
Definition: vocabsettings.cpp:53
VocabSettings::~VocabSettings
virtual ~VocabSettings()
default destructor
Definition: vocabsettings.cpp:49
kanagramsettings.h
vocabedit.h
VocabEdit
Definition: vocabedit.h:32
vocabsettings.h
KanagramSettings::dataLanguage
static QString dataLanguage()
Get Set the default translation.
Definition: kanagramsettings.h:127
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 22:35:35 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

kanagram

Skip menu "kanagram"
  • Main Page
  • Namespace List
  • 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