[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: playground/edu/kanagram/src
From: Joshua Keel <joshuakeel () gmail ! com>
Date: 2005-08-03 18:08:21
Message-ID: 1123092501.192026.16712.nullmailer () svn ! kde ! org
[Download RAW message or body]
SVN commit 442724 by jkeel:
Add correct url to newstuff dialog, fix vocab switcher/clean up vocab code
M +2 -0 kanagram.cpp
M +48 -32 kanagramgame.cpp
M +3 -0 kanagramgame.h
M +1 -1 newstuff.cpp
--- trunk/playground/edu/kanagram/src/kanagram.cpp #442723:442724
@@ -153,6 +153,8 @@
m_arrow = new QPixmap(locate("appdata", "images/arrow.png"));
m_arrowOver = new QPixmap(locate("appdata", "images/arrowover.png"));
}
+
+ m_game.refreshVocabList();
}
void Kanagram::paintEvent(QPaintEvent *)
--- trunk/playground/edu/kanagram/src/kanagramgame.cpp #442723:442724
@@ -31,64 +31,67 @@
KanagramGame::KanagramGame() : m_index(0)
{
- //m_fileList.append(KanagramSettings::defaultVocab());
- //KEduVocDocument *doc = new KEduVocDocument(this);
- //doc->open(KURL(locate("appdata", m_fileList[m_index])), false);
- //m_docTitle = doc->getTitle();
- nextAnagram();
+ loadDefaultVocab();
}
KanagramGame::~KanagramGame()
{
}
+void KanagramGame::loadDefaultVocab()
+{
+ m_filename = KanagramSettings::defaultVocab();
+ KEduVocDocument *doc = new KEduVocDocument(this);
+ doc->open(KURL(locate("appdata", m_filename)), false);
+ m_docTitle = doc->getTitle();
+ nextAnagram();
+}
+
+void KanagramGame::refreshVocabList()
+{
+ m_fileList = KGlobal::dirs()->findAllResources("appdata", "data/*.kvtml");
+ m_index = findIndex();
+}
+
+int KanagramGame::findIndex()
+{
+ int tempIndex = 0;
+ for(int i = 0; i < m_fileList.size(); i++)
+ {
+ if(m_filename == m_fileList[i])
+ {
+ tempIndex = i;
+ }
+ }
+ return tempIndex;
+}
+
void KanagramGame::previousVocab()
{
m_index--;
- m_fileList = KGlobal::dirs()->findAllResources("appdata", "data/*.kvtml");
if(m_index < 0)
m_index = m_fileList.size() - 1;
+ m_filename = m_fileList[m_index];
KEduVocDocument *doc = new KEduVocDocument(this);
- doc->open(KURL(locate("appdata", m_fileList[m_index])), false);
+ doc->open(KURL(locate("appdata", m_filename)), false);
m_docTitle = doc->getTitle();
}
void KanagramGame::nextVocab()
{
- if(!m_fileList.empty())
- m_index++;
- m_fileList = KGlobal::dirs()->findAllResources("appdata", "data/*.kvtml");
+ m_index++;
if(m_index >= m_fileList.size())
m_index = 0;
+ m_filename = m_fileList[m_index];
KEduVocDocument *doc = new KEduVocDocument(this);
- doc->open(KURL(locate("appdata", m_fileList[m_index])), false);
+ doc->open(KURL(locate("appdata", m_filename)), false);
m_docTitle = doc->getTitle();
}
-QString KanagramGame::getDocTitle()
-{
- return m_docTitle;
-}
-
-QString KanagramGame::getFilename()
-{
- if(m_fileList.empty())
- return m_filename;
- else
- return m_fileList[m_index];
-}
-
void KanagramGame::nextAnagram()
{
KEduVocDocument *doc = new KEduVocDocument(this);
- if(m_fileList.empty())
- {
- doc->open(KURL(locate("appdata", KanagramSettings::defaultVocab())), false);
- m_docTitle = doc->getTitle();
- m_filename = KanagramSettings::defaultVocab();
- }
- else
- doc->open(KURL(locate("appdata", m_fileList[m_index])), false);
+ doc->open(KURL(locate("appdata", m_filename)), false);
int totalWords = doc->numEntries();
int wordNumber = m_random.getLong(totalWords);
while(m_anagram == doc->getEntry(wordNumber)->getOriginal())
@@ -100,6 +103,19 @@
m_hint = doc->getEntry(wordNumber)->getRemark(0);
}
+QString KanagramGame::getDocTitle()
+{
+ return m_docTitle;
+}
+
+QString KanagramGame::getFilename()
+{
+ if(m_fileList.empty())
+ return m_filename;
+ else
+ return m_fileList[m_index];
+}
+
QString KanagramGame::getAnagram()
{
return m_anagram;
--- trunk/playground/edu/kanagram/src/kanagramgame.h #442723:442724
@@ -32,6 +32,9 @@
public:
KanagramGame();
~KanagramGame();
+ void refreshVocabList();
+ void loadDefaultVocab();
+ int findIndex();
void nextAnagram();
void nextVocab();
void previousVocab();
--- trunk/playground/edu/kanagram/src/newstuff.cpp #442723:442724
@@ -20,7 +20,7 @@
void NewStuff::slotGetNewVocabs()
{
KNS::DownloadDialog *dlgDownload = new KNS::DownloadDialog();
- dlgDownload->setProviderList("http://tuxipuxi.org/knewstuff/providers.xml");
+ dlgDownload->setProviderList("http://kde-edu.org/kanagram/providers.xml");
dlgDownload->load();
dlgDownload->show();
}
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic