diff options
author | toma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2009-11-25 17:56:58 +0000 |
---|---|---|
committer | toma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2009-11-25 17:56:58 +0000 |
commit | ce599e4f9f94b4eb00c1b5edb85bce5431ab3df2 (patch) | |
tree | d3bb9f5d25a2dc09ca81adecf39621d871534297 /kanagram/src/vocabsettings.cpp | |
download | tdeedu-ce599e4f9f94b4eb00c1b5edb85bce5431ab3df2.tar.gz tdeedu-ce599e4f9f94b4eb00c1b5edb85bce5431ab3df2.zip |
Copy the KDE 3.5 branch to branches/trinity for new KDE 3.5 features.
BUG:215923
git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdeedu@1054174 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'kanagram/src/vocabsettings.cpp')
-rw-r--r-- | kanagram/src/vocabsettings.cpp | 93 |
1 files changed, 93 insertions, 0 deletions
diff --git a/kanagram/src/vocabsettings.cpp b/kanagram/src/vocabsettings.cpp new file mode 100644 index 00000000..c7b41ba7 --- /dev/null +++ b/kanagram/src/vocabsettings.cpp @@ -0,0 +1,93 @@ +#include "vocabsettings.h" +#include "vocabedit.h" + +#include <qpushbutton.h> + +#include <kdebug.h> +#include <kstandarddirs.h> +#include <qstringlist.h> +#include <qlistview.h> +#include <qvaluevector.h> +#include <qfile.h> +#include <qfileinfo.h> + +#include <kurl.h> + +#include "keduvocdocument.h" +#include "kanagramsettings.h" + +VocabSettings::VocabSettings(QWidget *parent) : VocabSettingsWidget(parent) +{ + connect(btnCreateNew, SIGNAL(clicked()), this, SLOT(slotCreateNew())); + connect(btnEdit, SIGNAL(clicked()), this, SLOT(slotEdit())); + connect(btnDelete, SIGNAL(clicked()), this, SLOT(slotDelete())); + connect(lviewVocab, SIGNAL(selectionChanged(QListViewItem *)), this, SLOT(slotSelectionChanged(QListViewItem *))); + + refreshView(); +} + +VocabSettings::~VocabSettings() +{ +} + +void VocabSettings::refreshView() +{ + lviewVocab->clear(); + + m_fileList = KGlobal::dirs()->findAllResources("appdata", "data/" + KanagramSettings::dataLanguage() + "/" + "*.kvtml"); + for(uint i = 0; i < m_fileList.size(); i++) + { + KEduVocDocument *doc = new KEduVocDocument(this); + doc->open(KURL(m_fileList[i]), false); + QListViewItem *item = new QListViewItem(lviewVocab, 0); + item->setText( 0, doc->getTitle() ); + item->setText( 1, doc->getDocRemark() ); + m_itemMap[item] = i; + } +} + +void VocabSettings::slotEdit() +{ + if(lviewVocab->selectedItem()) + { + int index = m_itemMap[lviewVocab->selectedItem()]; + VocabEdit *vocabEdit = new VocabEdit(this, m_fileList[index]); + vocabEdit->show(); + } +} + +void VocabSettings::slotDelete() +{ + if(lviewVocab->selectedItem()) + { + int index = m_itemMap[lviewVocab->selectedItem()]; + /*bool itWorked = */QFile::remove(m_fileList[index]); + } + + refreshView(); +} + +void VocabSettings::slotCreateNew() +{ + VocabEdit *vocabEdit = new VocabEdit(this, ""); + vocabEdit->show(); +} + +void VocabSettings::slotSelectionChanged(QListViewItem *item) +{ + int index = m_itemMap[item]; + QFileInfo info = QFileInfo(m_fileList[index]); + if(!info.isWritable()) + { + btnDelete->setEnabled(false); + btnEdit->setEnabled(false); + } + else + { + btnDelete->setEnabled(true); + btnEdit->setEnabled(true); + } +} + +#include "vocabsettings.moc" + |