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

kanagram

vocabsettings.cpp

Go to the documentation of this file.
00001 /***************************************************************************
00002  *   Copyright (C) 2005 by Joshua Keel <joshuakeel@gmail.com>              *
00003  *             (C) 2007 by Jeremy Whiting <jeremy@scitools.com>            *
00004  *                                                                         *
00005  *                                                                         *
00006  *   This program is free software; you can redistribute it and/or modify  *
00007  *   it under the terms of the GNU General Public License as published by  *
00008  *   the Free Software Foundation; either version 2 of the License, or     *
00009  *   (at your option) any later version.                                   *
00010  *                                                                         *
00011  *   This program is distributed in the hope that it will be useful,       *
00012  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
00013  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
00014  *   GNU General Public License for more details.                          *
00015  *                                                                         *
00016  *   You should have received a copy of the GNU General Public License     *
00017  *   along with this program; if not, write to the                         *
00018  *   Free Software Foundation, Inc.,                                       *
00019  *   51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.          *
00020  ***************************************************************************/
00021 
00022 #include "vocabsettings.h"
00023 #include "vocabedit.h"
00024 
00025 #include <qpushbutton.h>
00026 
00027 #include <kdebug.h>
00028 #include <kstandarddirs.h>
00029 #include <kconfigdialog.h>
00030 #include <qstringlist.h>
00031 #include <qlistwidget.h>
00032 #include <qvector.h>
00033 #include <qfile.h>
00034 #include <qfileinfo.h>
00035 
00036 #include <kurl.h>
00037 
00038 #include <sharedkvtmlfiles.h>
00039 #include <keduvocdocument.h>
00040 #include "kanagramsettings.h"
00041 
00042 VocabSettings::VocabSettings(QWidget *parent) : QWidget(parent), m_parent(NULL)
00043 {
00044     setupUi(this);
00045     m_parent = (KConfigDialog*)parent;
00046 
00047     connect(lviewVocab, SIGNAL(currentItemChanged(QTreeWidgetItem *, QTreeWidgetItem *)), this, SLOT(slotSelectionChanged(QTreeWidgetItem *)));
00048 
00049     refreshView();
00050 }
00051 
00052 VocabSettings::~VocabSettings()
00053 {
00054 }
00055 
00056 void VocabSettings::refreshView()
00057 {
00058     lviewVocab->clear();
00059 
00060     m_fileList = SharedKvtmlFiles::fileNames(KanagramSettings::dataLanguage());
00061     m_titleList = SharedKvtmlFiles::titles(KanagramSettings::dataLanguage());
00062     m_commentList = SharedKvtmlFiles::comments(KanagramSettings::dataLanguage());
00063 
00064     for(int i = 0; i < m_fileList.size(); i++)
00065     {
00066         QTreeWidgetItem *item = new QTreeWidgetItem(lviewVocab, 0);
00067         item->setText( 0, m_titleList[i] );
00068         item->setText( 1, m_commentList[i] );
00069         m_itemMap[item] = i;
00070     }
00071     m_parent->enableButtonApply(true);
00072 }
00073 
00074 void VocabSettings::on_btnEdit_clicked()
00075 {
00076     if(lviewVocab->currentItem())
00077     {
00078         int index = m_itemMap[lviewVocab->currentItem()];
00079         VocabEdit *vocabEdit = new VocabEdit(this, m_fileList[index]);
00080         vocabEdit->show();
00081     }
00082 }
00083 
00084 void VocabSettings::on_btnCreateNew_clicked()
00085 {
00086     VocabEdit *vocabEdit = new VocabEdit(this, "");
00087     vocabEdit->show();
00088 }
00089 
00090 void VocabSettings::slotSelectionChanged(QTreeWidgetItem *item)
00091 {
00092     int index = m_itemMap[item];
00093     bool writeable = QFileInfo(m_fileList[index]).isWritable();
00094     btnEdit->setEnabled(writeable);
00095 }
00096 
00097 #include "vocabsettings.moc"
00098 

kanagram

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