void KEduVocDocumentValidatorTest::testDocumentAboutInfo()
{
    KTemporaryFile temp;
    temp.setSuffix(".kvtml");
    temp.open();
    KUrl fileName = KUrl(temp.fileName());
    temp.close();

    const QString generator = QString::fromLatin1( "Validator Unit Tests" );
    const QString author = QString::fromLatin1( "Validator Test" );
    const QString license = QString::fromLatin1( "test license" );
    const QString comment = QString::fromLatin1( "comment" );
    const QString category = QString::fromLatin1( "test document" );
    const QString title = QString::fromLatin1( "Validator Test Title" );

    KEduVocDocument doc;
    doc.setAuthor( author );
    doc.setLicense( license );
    doc.setDocumentComment( comment );
    doc.setCategory( category );
    doc.setTitle( title );

    doc.saveAs(fileName, KEduVocDocument::Kvtml, generator);

    KEduVocDocument docRead;
    docRead.open(fileName);

    QCOMPARE( docRead.generator(), generator );
    QCOMPARE( docRead.author(), author );
    QCOMPARE( docRead.license(), license );
    QCOMPARE( docRead.documentComment(), comment );
    QCOMPARE( docRead.category(), category );
    QCOMPARE( docRead.title(), title );
}
示例#2
0
void KanagramGame::nextVocab()
{
	m_index++;
	if((uint)m_index >= m_fileList.size())
		m_index = 0;
	m_filename = m_fileList[m_index];
	checkFile();
	KEduVocDocument *doc = new KEduVocDocument(this);
	doc->open(KURL(locate("appdata", m_filename)), false);
	m_docTitle = doc->getTitle();
	m_answeredWords.clear();
}
示例#3
0
void KanagramGame::previousVocab()
{
	m_index--;
	if(m_index < 0)
		m_index = m_fileList.size() - 1;
	m_filename = m_fileList[m_index];
	checkFile();
	KEduVocDocument *doc = new KEduVocDocument(this);
	doc->open(KURL(locate("appdata", m_filename)), false);
	m_docTitle = doc->getTitle();
	m_answeredWords.clear();
}
示例#4
0
void KanagramGame::nextAnagram()
{
	checkFile();
	KEduVocDocument	*doc = new KEduVocDocument(this);
	doc->open(KURL(locate("appdata", m_filename)), false);
	int totalWords = doc->numEntries();
	int wordNumber = m_random.getLong(totalWords);
	if(doc->numEntries() == (int)m_answeredWords.size())
	{
		m_answeredWords.clear();
	}
	while(m_answeredWords.findIndex(doc->getEntry(wordNumber)->getOriginal()) != -1)
	{
		wordNumber = m_random.getLong(totalWords);
	}
	m_originalWord = doc->getEntry(wordNumber)->getOriginal();
	m_answeredWords.append(m_originalWord);
	m_anagram = createAnagram(m_originalWord);
	m_hint = doc->getEntry(wordNumber)->getRemark(0);
}
示例#5
0
void KanagramGame::loadDefaultVocab()
{
	m_filename = KanagramSettings::defaultVocab();
	if (m_filename.isEmpty())
	{
		// first run
		m_filename = locate("appdata", "data/" + KanagramSettings::dataLanguage() + "/objects.kvtml");
		if (m_filename.isEmpty())
		{
			refreshVocabList();
			nextVocab();
		}
	}
	
        kdDebug() << "in game " << m_filename <<endl;
	KEduVocDocument *doc = new KEduVocDocument(this);
	doc->open(KURL(locate("appdata", m_filename)), false);
	m_docTitle = doc->getTitle();
        kdDebug() << m_docTitle <<endl; //Animals
	nextAnagram();
}
示例#6
0
VocabEdit::VocabEdit(QWidget *parent, const QString  &fileName) : QDialog(parent), m_fileName("")
{
    setupUi(this);

    if (!fileName.isEmpty())
    {
        m_fileName = fileName;
        KEduVocDocument	*doc = new KEduVocDocument(this);
        doc->open(QUrl::fromLocalFile(m_fileName), KEduVocDocument::FileIgnoreLock);
        for (int i = 0; i < doc->lesson()->entryCount(KEduVocLesson::Recursive); i++)
        {
            KEduVocExpression expr = *doc->lesson()->entries(KEduVocLesson::Recursive).value(i);
            m_vocabList.append(expr);
            lboxWords->addItem(doc->lesson()->entries(KEduVocLesson::Recursive).value(i)->translation(0)->text());
        }
        txtVocabName->setText(doc->title());
        txtDescription->setText(doc->documentComment());
        delete doc;
    }

    connect(btnSave, &QPushButton::clicked, this, &VocabEdit::slotSave);
    connect(btnNewWord, &QPushButton::clicked, this, &VocabEdit::slotNewWord);
    connect(btnRemoveWord, &QPushButton::clicked, this, &VocabEdit::slotRemoveWord);
    connect(btnClose, &QPushButton::clicked, this, &VocabEdit::slotClose);

    connect(txtWord, &QLineEdit::textChanged, this, &VocabEdit::slotWordTextChanged);
    connect(txtHint, &QLineEdit::textChanged, this, &VocabEdit::slotHintTextChanged);

    //Connect the name and description boxes to a general textChanged slot, so that we can keep track of
    //whether they've been changed or not
    connect(txtVocabName, &QLineEdit::textChanged, this, &VocabEdit::slotTextChanged);
    connect(txtDescription, &QLineEdit::textChanged, this, &VocabEdit::slotTextChanged);

    connect(lboxWords, &QListWidget::itemSelectionChanged, this, &VocabEdit::slotSelectionChanged);

    //Has anything in the dialog changed?
    m_textChanged = false;
}