summaryrefslogtreecommitdiffstats
path: root/keduca/keducabuilder
diff options
context:
space:
mode:
authortoma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2009-11-25 17:56:58 +0000
committertoma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2009-11-25 17:56:58 +0000
commitce599e4f9f94b4eb00c1b5edb85bce5431ab3df2 (patch)
treed3bb9f5d25a2dc09ca81adecf39621d871534297 /keduca/keducabuilder
downloadtdeedu-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 'keduca/keducabuilder')
-rw-r--r--keduca/keducabuilder/Makefile.am39
-rw-r--r--keduca/keducabuilder/kcontroladdedit.cpp303
-rw-r--r--keduca/keducabuilder/kcontroladdedit.h93
-rw-r--r--keduca/keducabuilder/kcontroladdeditbase.ui877
-rw-r--r--keduca/keducabuilder/kcontrolheader.cpp376
-rw-r--r--keduca/keducabuilder/kcontrolheader.h86
-rw-r--r--keduca/keducabuilder/kcontrolheaderbase.ui472
-rw-r--r--keduca/keducabuilder/keducabuilder.cpp600
-rw-r--r--keduca/keducabuilder/keducabuilder.h126
-rw-r--r--keduca/keducabuilder/keducabuilderui.rc28
-rw-r--r--keduca/keducabuilder/keducaeditorstartdialog.cpp114
-rw-r--r--keduca/keducabuilder/keducaeditorstartdialog.h59
-rw-r--r--keduca/keducabuilder/keducaeditorstartdialogbase.ui320
-rw-r--r--keduca/keducabuilder/klangcombo.cpp51
-rw-r--r--keduca/keducabuilder/klangcombo.h47
-rw-r--r--keduca/keducabuilder/ktagcombobox.cpp229
-rw-r--r--keduca/keducabuilder/ktagcombobox.h94
-rw-r--r--keduca/keducabuilder/main.cpp67
18 files changed, 3981 insertions, 0 deletions
diff --git a/keduca/keducabuilder/Makefile.am b/keduca/keducabuilder/Makefile.am
new file mode 100644
index 00000000..39fcb8d6
--- /dev/null
+++ b/keduca/keducabuilder/Makefile.am
@@ -0,0 +1,39 @@
+bin_PROGRAMS = keducabuilder
+keducabuilder_SOURCES = kcontroladdeditbase.ui keducaeditorstartdialogbase.ui keducaeditorstartdialog.cpp ktagcombobox.cpp klangcombo.cpp kcontrolheader.cpp keducabuilder.cpp kcontroladdedit.cpp main.cpp
+keducabuilder_LDADD = $(LIB_KFILE) ../libkeduca/libkeduca.la
+
+EXTRA_DIST = main.cpp kcontroladdedit.cpp kcontroladdedit.h keducabuilder.cpp keducabuilder.h kcontrolheader.cpp kcontrolheader.h keducabuilderui.rc klangcombo.cpp klangcombo.h ktagcombobox.cpp ktagcombobox.h keducaeditorstartdialog.cpp keducaeditorstartdialog.h
+
+# this 10 paths are KDE specific. Use them:
+# kde_htmldir Where your docs should go to. (contains lang subdirs)
+# kde_appsdir Where your application file (.kdelnk) should go to.
+# kde_icondir Where your icon should go to.
+# kde_minidir Where your mini icon should go to.
+# kde_datadir Where you install application data. (Use a subdir)
+# kde_locale Where translation files should go to.(contains lang subdirs)
+# kde_cgidir Where cgi-bin executables should go to.
+# kde_confdir Where config files should go to.
+# kde_mimedir Where mimetypes should go to.
+# kde_toolbardir Where general toolbar icons should go to.
+# kde_wallpaperdir Where general wallpapers should go to.
+
+# set the include path for X, qt and KDE
+INCLUDES= -I../libkeduca $(all_includes)
+
+METASOURCES = AUTO
+
+# the library search path.
+keducabuilder_LDFLAGS = $(all_libraries) $(KDE_RPATH)
+
+# Uncomment the following two lines if you add a ui.rc file for your application to make use of
+# KDE´s XML GUI builing
+rcdir = $(kde_datadir)/keduca
+rc_DATA = keducabuilderui.rc
+
+messages: rc.cpp
+ LIST=`find . -name \*.h -o -name \*.hh -o -name \*.H -o -name \*.hxx -o -name \*.hpp -o -name \*.cpp -o -name \*.cc -o -name \*.cxx -o -name \*.ecpp -o -name \*.C`; \
+ if test -n "$$LIST"; then \
+ $(XGETTEXT) $$LIST -o $(podir)/keduca.pot; \
+ fi
+
+include ../../admin/Doxyfile.am
diff --git a/keduca/keducabuilder/kcontroladdedit.cpp b/keduca/keducabuilder/kcontroladdedit.cpp
new file mode 100644
index 00000000..76715e27
--- /dev/null
+++ b/keduca/keducabuilder/kcontroladdedit.cpp
@@ -0,0 +1,303 @@
+/***************************************************************************
+ kcontroladdedit.cpp - description
+ -------------------
+ begin : Sun May 27 2001
+ copyright : (C) 2001 by Javier Campos
+ email : javi@asyris.org
+***************************************************************************/
+
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+
+#include "kcontroladdedit.h"
+#include "kcontroladdedit.moc"
+
+// KDE includes
+#include <klocale.h>
+#include <kconfig.h>
+#include <kurlrequester.h>
+#include <kcombobox.h>
+#include <knuminput.h>
+#include <klistview.h>
+//#include <.h>
+
+// Qt includes
+#include <qlabel.h>
+#include <qtextedit.h>
+
+KControlAddEdit::KControlAddEdit(QWidget *parent, const char *name, bool modal, WFlags f)
+ : KControlAddEditBase(parent, name, modal, f),
+ _currentAnswerItem(0)
+{
+ configRead();
+}
+
+KControlAddEdit::~KControlAddEdit()
+{
+}
+
+/** Init _keducaFile pointer and EditMode */
+void KControlAddEdit::init(FileRead *keducaFile, bool edit)
+{
+ setCurrentAnswerItem(0);
+ _keducaFile = keducaFile;
+ _editMode = edit;
+
+ _listAnswers->setSorting(-1);
+
+ if( _editMode )
+ {
+ setCaption(i18n("Modify Question"));
+ fillPage();
+ }else{
+ setCaption(i18n("Add Questions"));
+ slotQuestionTypeChanged( 0 );
+ }
+
+ // settings for Question page
+ setHelpEnabled ( _pageQuestion, false );
+ setNextEnabled( _pageQuestion, false );
+
+ // settings for Answer page
+ setHelpEnabled ( _pageAnswer, false );
+ setFinishEnabled( _pageAnswer, true );
+}
+
+/** Fill page of current record */
+void KControlAddEdit::fillPage()
+{
+ _questionText->setText( _keducaFile->getQuestion( FileRead::QF_TEXT ) );
+ if( !_keducaFile->getQuestion( FileRead::QF_PICTURE ).isEmpty() )
+ {
+ _questionPreview->setPixmap(_keducaFile->getQuestion(FileRead::QF_PICTURE));
+ _answerPreview->setPixmap(_keducaFile->getQuestion(FileRead::QF_PICTURE));
+ _questionPicture->setURL( _keducaFile->getQuestion( FileRead::QF_PICTURE ) );
+ }
+ _questionType->setCurrentItem( _keducaFile->getQuestionInt( FileRead::QF_TYPE )-1 );
+ slotQuestionTypeChanged( _questionType->currentItem() );
+ _questionPoint->setValue( _keducaFile->getQuestionInt( FileRead::QF_POINTS ) );
+ _questionTip->setText( _keducaFile->getQuestion( FileRead::QF_TIP ) );
+ _questionExplain->setText( _keducaFile->getQuestion( FileRead::QF_EXPLAIN ) );
+ _questionTime->setValue( _keducaFile->getQuestionInt( FileRead::QF_TIME ) );
+
+ _listAnswers->clear();
+ _keducaFile->recordAnswerFirst();
+ while( !_keducaFile->recordAnswerEOF() )
+ {
+ QListViewItem *newItem = new QListViewItem(_listAnswers);
+ newItem->setText(0,_keducaFile->getAnswer( FileRead::AF_TEXT ));
+ newItem->setText(1,_keducaFile->getAnswerValue()?i18n("True"):i18n("False"));
+ newItem->setText(2,QString::number(_keducaFile->getAnswerPoints()));
+
+ _keducaFile->recordAnswerNext();
+ };
+}
+
+void KControlAddEdit::setCurrentAnswerItem(QListViewItem *item)
+{
+ _currentAnswerItem = item;
+ if (item)
+ _buttonInsert->setText(i18n("&Apply"));
+ else
+ _buttonInsert->setText(i18n("&Add"));
+}
+
+/** Button insert */
+void KControlAddEdit::slotAddAnswer()
+{
+ if( !_answerText->text().isEmpty() )
+ {
+ // add new listview item
+ QListViewItem *newItem = _currentAnswerItem
+ ? _currentAnswerItem
+ : new QListViewItem(_listAnswers,_listAnswers->lastItem());
+ newItem->setText(0,_answerText->text());
+ newItem->setText(1,_answerValue->currentItem() == 1 ?i18n("True"):i18n("False"));
+ newItem->setText(2,QString::number(_answerPoints->value()));
+
+ // reset values
+ newItem->setSelected(false);
+ resetAnswerValues();
+ }
+}
+
+void KControlAddEdit::resetAnswerValues()
+{
+ _answerText->setText("");
+ _answerValue->setCurrentItem( 0 );
+ _answerPoints->setValue(0);
+ _answerText->setFocus();
+ setCurrentAnswerItem(0);
+ _buttonUp->setEnabled(false);
+ _buttonDown->setEnabled(false);
+ _buttonRemove->setEnabled(false);
+ _buttonInsert->setEnabled(false);
+}
+
+/** Remove answer */
+void KControlAddEdit::slotRemoveAnswer()
+{
+ delete _listAnswers->currentItem();
+ resetAnswerValues();
+}
+
+/** Button Up */
+void KControlAddEdit::slotMoveUpAnswer()
+{
+ QListViewItem *item = _listAnswers->currentItem();
+
+ if (item && item->itemAbove())
+ item->itemAbove()->moveItem(item);
+
+ _buttonUp->setEnabled(item->itemAbove()!=0);
+ _buttonDown->setEnabled(item->itemBelow()!=0);
+}
+
+/** Button Down */
+void KControlAddEdit::slotMoveDownAnswer()
+{
+ QListViewItem *item = _listAnswers->currentItem();
+
+ if (item)
+ item->moveItem(item->itemBelow());
+
+ _buttonUp->setEnabled(item->itemAbove()!=0);
+ _buttonDown->setEnabled(item->itemBelow()!=0);
+}
+
+void KControlAddEdit::slotAnswerSelected(QListViewItem *item)
+{
+ if (!item)
+ return;
+
+ setCurrentAnswerItem(item);
+
+ // set the answer fields to the value of the selected answer
+ _answerText->setText(item->text(0));
+ _answerValue->setCurrentItem(item->text(1) == i18n("True")?1:0);
+ _answerPoints->setValue(item->text(2).toInt());
+
+ // enable/disable the buttons as appropriate
+ _buttonRemove->setEnabled(true);
+ _buttonInsert->setEnabled(true);
+ _buttonDown->setEnabled(item->itemBelow()!=0);
+ _buttonUp->setEnabled(item->itemAbove()!=0);
+}
+
+/** Accept changes */
+void KControlAddEdit::accept()
+{
+ if( !_editMode )
+ _keducaFile->insertQuestion();
+
+ addQuestion();
+ configWrite();
+ done( QDialog::Accepted );
+}
+
+/** Add question with form data */
+void KControlAddEdit::addQuestion()
+{
+ _keducaFile->setQuestion( FileRead::QF_TEXT, _questionText->text() );
+ _keducaFile->setQuestion( FileRead::QF_TYPE, _questionType->currentItem()+1 );
+ _keducaFile->setQuestion( FileRead::QF_PICTURE, _questionPicture->url() );
+ _keducaFile->setQuestion( FileRead::QF_POINTS, _questionPoint->value() );
+ _keducaFile->setQuestion( FileRead::QF_TIME, _questionTime->value() );
+ _keducaFile->setQuestion( FileRead::QF_TIP, _questionTip->text() );
+ _keducaFile->setQuestion( FileRead::QF_EXPLAIN, _questionExplain->text() );
+
+ _keducaFile->clearAnswers();
+ QListViewItem *item = _listAnswers->firstChild();
+ while (item) {
+ _keducaFile->setAnswer(
+ item->text(0), // The Answer text
+ item->text(1)==i18n("True"), // the validity of the answer
+ item->text(2).toInt()); // the points
+ item = item->nextSibling();
+ }
+}
+/** Read config settings */
+void KControlAddEdit::configRead()
+{
+ KConfig *config = KGlobal::config();
+ config->setGroup("AddModify Window");
+ QSize defaultSize(500,400);
+ resize( config->readSizeEntry("Geometry", &defaultSize ) );
+}
+
+/** Write config settings */
+void KControlAddEdit::configWrite()
+{
+ KConfig *config = KGlobal::config();
+ config->setGroup("AddModify Window");
+ config->writeEntry("Geometry", size() );
+ config->sync();
+}
+
+/** Question data changed */
+void KControlAddEdit::slotDataChanged()
+{
+ if( _pageQuestion == currentPage() )
+ {
+ nextButton()->setEnabled( !_questionText->text().isEmpty() );
+ }
+ if( _pageAnswer == currentPage() )
+ {
+ _buttonInsert->setEnabled( !_answerText->text().isEmpty() );
+ }
+}
+
+
+/** Preview image */
+void KControlAddEdit::slotPreviewImage( const QString &text)
+{
+ if( text.isEmpty() ) { _questionPreview->setText(""); _answerPreview->setText(""); return; }
+
+ _questionPreview->setPixmap( QPixmap( text ) );
+ _answerPreview->setPixmap( QPixmap( text ) );
+}
+
+/** show current Page */
+void KControlAddEdit::showPage(QWidget *page)
+{
+ QWizard::showPage(page);
+ slotDataChanged();
+
+ if ( page == _pageQuestion ) {
+ _questionText->setFocus();
+ } else if ( page == _pageAnswer ) {
+ _answerText->setFocus();
+ }
+}
+
+/** Change question type */
+void KControlAddEdit::slotQuestionTypeChanged( int index )
+{
+ switch( index+1 )
+ {
+ case 1:
+ _questionPoint->setEnabled( false );
+ _answerPoints->setEnabled( false );
+ _questionPoint->setValue(0);
+ _answerPoints->setValue(0);
+ break;
+ case 2:
+ _questionPoint->setEnabled( true );
+ _answerPoints->setEnabled( false );
+ _answerPoints->setValue(0);
+ break;
+ case 3:
+ _questionPoint->setEnabled( false );
+ _answerPoints->setEnabled( true );
+ _questionPoint->setValue(0);
+ break;
+ default:
+ break;
+ }
+}
diff --git a/keduca/keducabuilder/kcontroladdedit.h b/keduca/keducabuilder/kcontroladdedit.h
new file mode 100644
index 00000000..d700ec43
--- /dev/null
+++ b/keduca/keducabuilder/kcontroladdedit.h
@@ -0,0 +1,93 @@
+/***************************************************************************
+ kcontroladdedit.h - description
+ -------------------
+ begin : Sun May 27 2001
+ copyright : (C) 2001 by Javier Campos
+ email : javi@asyris.org
+***************************************************************************/
+
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+
+#ifndef KCONTROLADDEDIT_H
+#define KCONTROLADDEDIT_H
+
+#include "../libkeduca/fileread.h"
+#include "kcontroladdeditbase.h"
+
+// Qt forward declarations
+class QListViewItem;
+
+/**Add or edit questions
+ * This is the Wizard that allows adding and editing of
+ * Questions (and corresponding possible answers) to the
+ * KEduca Document.
+ * This will be called from the Editor (class KEducaBuilder)
+ *@author Javier Campos
+ * @author Klas Kalass (2003)
+ */
+
+class KControlAddEdit : public KControlAddEditBase {
+ Q_OBJECT
+
+public:
+ KControlAddEdit(QWidget *parent = 0, const char *name = 0, bool modal = true, WFlags f = 0);
+ ~KControlAddEdit();
+ /** Init keducaFile pointer and EditMode */
+ void init(FileRead *keducaFile, bool editMode);
+ /** show current Page */
+ void showPage(QWidget *page);
+
+private:
+
+ // Private methods
+
+ /** Init graphical interface */
+// void initGUI();
+ /** Fill page of current record */
+ void fillPage();
+ /** Add question with form data */
+ void addQuestion();
+ /** Write config settings */
+ void configWrite();
+ /** Read config settings */
+ void configRead();
+ void setCurrentAnswerItem(QListViewItem *item);
+ void resetAnswerValues();
+
+ // Private attributes
+ /** Pointer to keduca of kcontrol page */
+ FileRead *_keducaFile;
+ /** The currently selected answer item, important for editing of the answer*/
+ QListViewItem *_currentAnswerItem;
+ /** Is a edit modify? */
+ bool _editMode;
+
+private slots:
+ /** Accept changes */
+ void accept();
+ /** An Answer has been selected */
+ void slotAnswerSelected(QListViewItem *item);
+ /** Remove answer */
+ void slotRemoveAnswer();
+ /** Button insert */
+ void slotAddAnswer();
+ /** Button Down */
+ void slotMoveDownAnswer();
+ /** Button Up */
+ void slotMoveUpAnswer();
+ /** Question or Answer data changed */
+ void slotDataChanged();
+ /** Preview image */
+ void slotPreviewImage( const QString & );
+ /** Change question type */
+ void slotQuestionTypeChanged( int index );
+};
+
+#endif
diff --git a/keduca/keducabuilder/kcontroladdeditbase.ui b/keduca/keducabuilder/kcontroladdeditbase.ui
new file mode 100644
index 00000000..0292edf2
--- /dev/null
+++ b/keduca/keducabuilder/kcontroladdeditbase.ui
@@ -0,0 +1,877 @@
+<!DOCTYPE UI><UI version="3.1" stdsetdef="1">
+<class>KControlAddEditBase</class>
+<widget class="QWizard">
+ <property name="name">
+ <cstring>KControlAddEditBase</cstring>
+ </property>
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>600</width>
+ <height>480</height>
+ </rect>
+ </property>
+ <widget class="QWidget">
+ <property name="name">
+ <cstring>_pageQuestion</cstring>
+ </property>
+ <attribute name="title">
+ <string>Question</string>
+ </attribute>
+ <hbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <property name="margin">
+ <number>0</number>
+ </property>
+ <widget class="QFrame">
+ <property name="name">
+ <cstring>frame3</cstring>
+ </property>
+ <property name="minimumSize">
+ <size>
+ <width>125</width>
+ <height>0</height>
+ </size>
+ </property>
+ <property name="maximumSize">
+ <size>
+ <width>125</width>
+ <height>32767</height>
+ </size>
+ </property>
+ <property name="paletteBackgroundPixmap">
+ <pixmap>editbase_image0</pixmap>
+ </property>
+ <property name="frameShape">
+ <enum>Box</enum>
+ </property>
+ <property name="frameShadow">
+ <enum>Plain</enum>
+ </property>
+ <vbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QLabel">
+ <property name="name">
+ <cstring>_questionPreview</cstring>
+ </property>
+ <property name="minimumSize">
+ <size>
+ <width>100</width>
+ <height>100</height>
+ </size>
+ </property>
+ <property name="maximumSize">
+ <size>
+ <width>100</width>
+ <height>100</height>
+ </size>
+ </property>
+ <property name="paletteBackgroundColor">
+ <color>
+ <red>255</red>
+ <green>255</green>
+ <blue>255</blue>
+ </color>
+ </property>
+ <property name="frameShape">
+ <enum>Box</enum>
+ </property>
+ <property name="frameShadow">
+ <enum>Plain</enum>
+ </property>
+ <property name="text">
+ <string></string>
+ </property>
+ <property name="scaledContents">
+ <bool>true</bool>
+ </property>
+ </widget>
+ <spacer>
+ <property name="name">
+ <cstring>spacer1</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Vertical</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>20</width>
+ <height>21</height>
+ </size>
+ </property>
+ </spacer>
+ <widget class="QLabel">
+ <property name="name">
+ <cstring>textLabel1</cstring>
+ </property>
+ <property name="text">
+ <string>&lt;span style="color:black"&gt;
+ &lt;p&gt;&lt;b&gt;Question&lt;/b&gt;&lt;/p&gt;
+&lt;hr&gt;
+ &lt;p&gt;Only the question and type is required.&lt;/p&gt;
+&lt;/span&gt;</string>
+ </property>
+ </widget>
+ <spacer>
+ <property name="name">
+ <cstring>spacer2</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Vertical</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>20</width>
+ <height>41</height>
+ </size>
+ </property>
+ </spacer>
+ </vbox>
+ </widget>
+ <widget class="QFrame">
+ <property name="name">
+ <cstring>frame5</cstring>
+ </property>
+ <property name="frameShape">
+ <enum>Box</enum>
+ </property>
+ <property name="frameShadow">
+ <enum>Sunken</enum>
+ </property>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QLabel" row="0" column="0">
+ <property name="name">
+ <cstring>textLabel2</cstring>
+ </property>
+ <property name="text">
+ <string>&amp;Question:</string>
+ </property>
+ <property name="alignment">
+ <set>AlignTop|AlignRight</set>
+ </property>
+ <property name="buddy" stdset="0">
+ <cstring>_questionText</cstring>
+ </property>
+ </widget>
+ <widget class="QLabel" row="2" column="0">
+ <property name="name">
+ <cstring>textLabel4</cstring>
+ </property>
+ <property name="text">
+ <string>&amp;Type:</string>
+ </property>
+ <property name="alignment">
+ <set>AlignVCenter|AlignRight</set>
+ </property>
+ <property name="buddy" stdset="0">
+ <cstring>_questionType</cstring>
+ </property>
+ </widget>
+ <widget class="QLabel" row="1" column="0">
+ <property name="name">
+ <cstring>textLabel3</cstring>
+ </property>
+ <property name="text">
+ <string>&amp;Picture:</string>
+ </property>
+ <property name="alignment">
+ <set>AlignVCenter|AlignRight</set>
+ </property>
+ <property name="buddy" stdset="0">
+ <cstring>_questionPicture</cstring>
+ </property>
+ </widget>
+ <widget class="KURLRequester" row="1" column="1">
+ <property name="name">
+ <cstring>_questionPicture</cstring>
+ </property>
+ </widget>
+ <widget class="KComboBox" row="2" column="1">
+ <item>
+ <property name="text">
+ <string>Test</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>Test with Question Points</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>Test with Answers Points</string>
+ </property>
+ </item>
+ <property name="name">
+ <cstring>_questionType</cstring>
+ </property>
+ </widget>
+ <widget class="QLabel" row="3" column="0">
+ <property name="name">
+ <cstring>textLabel5</cstring>
+ </property>
+ <property name="text">
+ <string>P&amp;oint:</string>
+ </property>
+ <property name="alignment">
+ <set>AlignVCenter|AlignRight</set>
+ </property>
+ <property name="buddy" stdset="0">
+ <cstring>_questionPoint</cstring>
+ </property>
+ </widget>
+ <widget class="QLabel" row="4" column="0">
+ <property name="name">
+ <cstring>textLabel6</cstring>
+ </property>
+ <property name="text">
+ <string>Ti&amp;me:</string>
+ </property>
+ <property name="alignment">
+ <set>AlignVCenter|AlignRight</set>
+ </property>
+ <property name="buddy" stdset="0">
+ <cstring>_questionTime</cstring>
+ </property>
+ </widget>
+ <widget class="QLabel" row="5" column="0">
+ <property name="name">
+ <cstring>textLabel7</cstring>
+ </property>
+ <property name="text">
+ <string>T&amp;ip:</string>
+ </property>
+ <property name="alignment">
+ <set>AlignVCenter|AlignRight</set>
+ </property>
+ <property name="buddy" stdset="0">
+ <cstring>_questionTip</cstring>
+ </property>
+ </widget>
+ <widget class="QLineEdit" row="5" column="1">
+ <property name="name">
+ <cstring>_questionTip</cstring>
+ </property>
+ </widget>
+ <widget class="QLabel" row="6" column="0">
+ <property name="name">
+ <cstring>textLabel8</cstring>
+ </property>
+ <property name="text">
+ <string>&amp;Explain:</string>
+ </property>
+ <property name="alignment">
+ <set>AlignTop|AlignRight</set>
+ </property>
+ <property name="buddy" stdset="0">
+ <cstring>_questionExplain</cstring>
+ </property>
+ </widget>
+ <widget class="QTextEdit" row="0" column="1">
+ <property name="name">
+ <cstring>_questionText</cstring>
+ </property>
+ </widget>
+ <widget class="QTextEdit" row="6" column="1">
+ <property name="name">
+ <cstring>_questionExplain</cstring>
+ </property>
+ </widget>
+ <widget class="QLayoutWidget" row="4" column="1">
+ <property name="name">
+ <cstring>layout1</cstring>
+ </property>
+ <hbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="KIntNumInput">
+ <property name="name">
+ <cstring>_questionTime</cstring>
+ </property>
+ </widget>
+ <spacer>
+ <property name="name">
+ <cstring>spacer4</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Horizontal</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>81</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </hbox>
+ </widget>
+ <widget class="QLayoutWidget" row="3" column="1">
+ <property name="name">
+ <cstring>layout2</cstring>
+ </property>
+ <hbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="KIntNumInput">
+ <property name="name">
+ <cstring>_questionPoint</cstring>
+ </property>
+ </widget>
+ <spacer>
+ <property name="name">
+ <cstring>spacer3</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Horizontal</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>131</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </hbox>
+ </widget>
+ </grid>
+ </widget>
+ </hbox>
+ </widget>
+ <widget class="QWidget">
+ <property name="name">
+ <cstring>_pageAnswer</cstring>
+ </property>
+ <attribute name="title">
+ <string>Answer</string>
+ </attribute>
+ <hbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <property name="margin">
+ <number>0</number>
+ </property>
+ <widget class="QFrame">
+ <property name="name">
+ <cstring>frame3_2</cstring>
+ </property>
+ <property name="minimumSize">
+ <size>
+ <width>125</width>
+ <height>0</height>
+ </size>
+ </property>
+ <property name="maximumSize">
+ <size>
+ <width>125</width>
+ <height>32767</height>
+ </size>
+ </property>
+ <property name="paletteBackgroundPixmap">
+ <pixmap>editbase_image0</pixmap>
+ </property>
+ <property name="frameShape">
+ <enum>Box</enum>
+ </property>
+ <property name="frameShadow">
+ <enum>Plain</enum>
+ </property>
+ <vbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QLabel">
+ <property name="name">
+ <cstring>_answerPreview</cstring>
+ </property>
+ <property name="minimumSize">
+ <size>
+ <width>100</width>
+ <height>100</height>
+ </size>
+ </property>
+ <property name="maximumSize">
+ <size>
+ <width>100</width>
+ <height>100</height>
+ </size>
+ </property>
+ <property name="paletteBackgroundColor">
+ <color>
+ <red>255</red>
+ <green>255</green>
+ <blue>255</blue>
+ </color>
+ </property>
+ <property name="frameShape">
+ <enum>Box</enum>
+ </property>
+ <property name="frameShadow">
+ <enum>Plain</enum>
+ </property>
+ <property name="text">
+ <string></string>
+ </property>
+ <property name="scaledContents">
+ <bool>true</bool>
+ </property>
+ </widget>
+ <spacer>
+ <property name="name">
+ <cstring>spacer1_2</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Vertical</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>20</width>
+ <height>21</height>
+ </size>
+ </property>
+ </spacer>
+ <widget class="QLabel">
+ <property name="name">
+ <cstring>textLabel2_2</cstring>
+ </property>
+ <property name="text">
+ <string>&lt;span style="color:black"&gt;
+ &lt;p&gt;&lt;b&gt;Answers&lt;/b&gt;&lt;/p&gt;
+&lt;hr&gt;
+ &lt;p&gt;Only the answer and value is required.&lt;/p&gt;
+&lt;/span&gt;</string>
+ </property>
+ </widget>
+ <spacer>
+ <property name="name">
+ <cstring>spacer2_2</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Vertical</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>20</width>
+ <height>41</height>
+ </size>
+ </property>
+ </spacer>
+ </vbox>
+ </widget>
+ <widget class="QFrame">
+ <property name="name">
+ <cstring>frame6</cstring>
+ </property>
+ <property name="frameShape">
+ <enum>Box</enum>
+ </property>
+ <property name="frameShadow">
+ <enum>Sunken</enum>
+ </property>
+ <vbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QLayoutWidget">
+ <property name="name">
+ <cstring>layout11</cstring>
+ </property>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QLayoutWidget" row="2" column="1">
+ <property name="name">
+ <cstring>layout3</cstring>
+ </property>
+ <hbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="KIntNumInput">
+ <property name="name">
+ <cstring>_answerPoints</cstring>
+ </property>
+ </widget>
+ <spacer>
+ <property name="name">
+ <cstring>spacer9</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Horizontal</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>31</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </hbox>
+ </widget>
+ <widget class="QTextEdit" row="0" column="1">
+ <property name="name">
+ <cstring>_answerText</cstring>
+ </property>
+ </widget>
+ <widget class="QLabel" row="0" column="0">
+ <property name="name">
+ <cstring>textLabel1_2</cstring>
+ </property>
+ <property name="text">
+ <string>&amp;Answer:</string>
+ </property>
+ <property name="alignment">
+ <set>AlignTop|AlignRight</set>
+ </property>
+ <property name="buddy" stdset="0">
+ <cstring>_answerText</cstring>
+ </property>
+ </widget>
+ <widget class="QLabel" row="1" column="0">
+ <property name="name">
+ <cstring>textLabel2_3</cstring>
+ </property>
+ <property name="text">
+ <string>&amp;Value:</string>
+ </property>
+ <property name="alignment">
+ <set>AlignVCenter|AlignRight</set>
+ </property>
+ <property name="buddy" stdset="0">
+ <cstring>_answerValue</cstring>
+ </property>
+ </widget>
+ <widget class="QLayoutWidget" row="1" column="1">
+ <property name="name">
+ <cstring>layout7</cstring>
+ </property>
+ <hbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QComboBox">
+ <item>
+ <property name="text">
+ <string>False</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>True</string>
+ </property>
+ </item>
+ <property name="name">
+ <cstring>_answerValue</cstring>
+ </property>
+ </widget>
+ </hbox>
+ </widget>
+ <widget class="QLabel" row="2" column="0">
+ <property name="name">
+ <cstring>textLabel3_2</cstring>
+ </property>
+ <property name="text">
+ <string>&amp;Points:</string>
+ </property>
+ <property name="alignment">
+ <set>AlignVCenter|AlignRight</set>
+ </property>
+ <property name="buddy" stdset="0">
+ <cstring>_answerPoints</cstring>
+ </property>
+ </widget>
+ </grid>
+ </widget>
+ <widget class="Line">
+ <property name="name">
+ <cstring>line2</cstring>
+ </property>
+ <property name="frameShape">
+ <enum>HLine</enum>
+ </property>
+ <property name="frameShadow">
+ <enum>Sunken</enum>
+ </property>
+ <property name="orientation">
+ <enum>Horizontal</enum>
+ </property>
+ </widget>
+ <widget class="QLayoutWidget">
+ <property name="name">
+ <cstring>layout17</cstring>
+ </property>
+ <hbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="KListView">
+ <column>
+ <property name="text">
+ <string>Answer</string>
+ </property>
+ <property name="clickable">
+ <bool>true</bool>
+ </property>
+ <property name="resizable">
+ <bool>true</bool>
+ </property>
+ </column>
+ <column>
+ <property name="text">
+ <string>Value</string>
+ </property>
+ <property name="clickable">
+ <bool>true</bool>
+ </property>
+ <property name="resizable">
+ <bool>true</bool>
+ </property>
+ </column>
+ <column>
+ <property name="text">
+ <string>Points</string>
+ </property>
+ <property name="clickable">
+ <bool>true</bool>
+ </property>
+ <property name="resizable">
+ <bool>true</bool>
+ </property>
+ </column>
+ <property name="name">
+ <cstring>_listAnswers</cstring>
+ </property>
+ <property name="allColumnsShowFocus">
+ <bool>true</bool>
+ </property>
+ </widget>
+ <widget class="QLayoutWidget">
+ <property name="name">
+ <cstring>layout16</cstring>
+ </property>
+ <vbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QPushButton">
+ <property name="name">
+ <cstring>_buttonInsert</cstring>
+ </property>
+ <property name="enabled">
+ <bool>false</bool>
+ </property>
+ <property name="text">
+ <string>&amp;Add</string>
+ </property>
+ </widget>
+ <widget class="QPushButton">
+ <property name="name">
+ <cstring>_buttonRemove</cstring>
+ </property>
+ <property name="enabled">
+ <bool>false</bool>
+ </property>
+ <property name="text">
+ <string>&amp;Remove</string>
+ </property>
+ </widget>
+ <spacer>
+ <property name="name">
+ <cstring>spacer11</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Vertical</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Fixed</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>20</width>
+ <height>10</height>
+ </size>
+ </property>
+ </spacer>
+ <widget class="QPushButton">
+ <property name="name">
+ <cstring>_buttonUp</cstring>
+ </property>
+ <property name="enabled">
+ <bool>false</bool>
+ </property>
+ <property name="text">
+ <string>Move &amp;Up</string>
+ </property>
+ </widget>
+ <widget class="QPushButton">
+ <property name="name">
+ <cstring>_buttonDown</cstring>
+ </property>
+ <property name="enabled">
+ <bool>false</bool>
+ </property>
+ <property name="text">
+ <string>Move &amp;Down</string>
+ </property>
+ </widget>
+ <spacer>
+ <property name="name">
+ <cstring>spacer12</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Vertical</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>20</width>
+ <height>21</height>
+ </size>
+ </property>
+ </spacer>
+ </vbox>
+ </widget>
+ </hbox>
+ </widget>
+ </vbox>
+ </widget>
+ </hbox>
+ </widget>
+</widget>
+<images>
+ <image name="editbase_image0">
+ <data format="XPM.GZ" length="2314">789ced95bd6e83301485f73c8515b6a84a14a4b0547d844a1d2b551d8cb181947fdca1aafaeec5f75e830d51105397de230f9f50823987634e07f6faf2cc0ea75dafb9ce051319efd821f92ccbafb7f7a7efddfe1c5ed8f9c2c2909df70fbb7dc5040b642443a50c968411e21551291919ac01a5bdda1072c48e50227e200ebf95065b832ab2577b4445f7d584f4cf05a15270df0050c910b7c10923c4e38870a39890230a42899858c47f9688c33600156184988e08bbca08e979734285780c0671d231e6f1114423e2045622ac6422cd4ae4384aa646ca2a53590a1a27472d07c232f301cbd3620a5f052c6772589e725877065e9eaaaeead2aaa91bb3ea86a66dba610deaacfaae6f41e3a4bd1e56aaad8667d71b1c0838c8c981430e3c8ea71c2889290701393829284cc2cf414dbbc86fee02de79dff785f7c5dcfd85f70be7577c9f6da02a2b9342e9e650420ee374a0450edd94828614b49b83ce308b550766eedb1ed050077cf713bf05e9dcfd947ab0a105373a705d496291c3f60ee0066ab705b603f5e47e3b77bfa51e38fea77e0bf4a673803ac0fd16f029056c8158e620fc1640126e0b308bd577e07ad7fb1bcedfe840b1d9fb790b66a7119e475e0b2009b7059d9f829e9f46f63c5a75e0ff5bf0b7df829fc7dd2faa1761dd</data>
+ </image>
+</images>
+<connections>
+ <connection>
+ <sender>_questionText</sender>
+ <signal>textChanged()</signal>
+ <receiver>KControlAddEditBase</receiver>
+ <slot>slotDataChanged()</slot>
+ </connection>
+ <connection>
+ <sender>_questionPicture</sender>
+ <signal>urlSelected(const QString&amp;)</signal>
+ <receiver>KControlAddEditBase</receiver>
+ <slot>slotPreviewImage(const QString&amp;)</slot>
+ </connection>
+ <connection>
+ <sender>_questionType</sender>
+ <signal>activated(int)</signal>
+ <receiver>KControlAddEditBase</receiver>
+ <slot>slotQuestionTypeChanged(int)</slot>
+ </connection>
+ <connection>
+ <sender>_buttonInsert</sender>
+ <signal>clicked()</signal>
+ <receiver>KControlAddEditBase</receiver>
+ <slot>slotAddAnswer()</slot>
+ </connection>
+ <connection>
+ <sender>_buttonRemove</sender>
+ <signal>clicked()</signal>
+ <receiver>KControlAddEditBase</receiver>
+ <slot>slotRemoveAnswer()</slot>
+ </connection>
+ <connection>
+ <sender>_buttonUp</sender>
+ <signal>clicked()</signal>
+ <receiver>KControlAddEditBase</receiver>
+ <slot>slotMoveUpAnswer()</slot>
+ </connection>
+ <connection>
+ <sender>_buttonDown</sender>
+ <signal>clicked()</signal>
+ <receiver>KControlAddEditBase</receiver>
+ <slot>slotMoveDownAnswer()</slot>
+ </connection>
+ <connection>
+ <sender>_listAnswers</sender>
+ <signal>selectionChanged(QListViewItem*)</signal>
+ <receiver>KControlAddEditBase</receiver>
+ <slot>slotAnswerSelected(QListViewItem*)</slot>
+ </connection>
+ <connection>
+ <sender>_answerText</sender>
+ <signal>textChanged()</signal>
+ <receiver>KControlAddEditBase</receiver>
+ <slot>slotDataChanged()</slot>
+ </connection>
+</connections>
+<tabstops>
+ <tabstop>_answerText</tabstop>
+ <tabstop>_answerValue</tabstop>
+ <tabstop>_answerPoints</tabstop>
+ <tabstop>_listAnswers</tabstop>
+ <tabstop>_buttonInsert</tabstop>
+ <tabstop>_buttonRemove</tabstop>
+ <tabstop>_buttonUp</tabstop>
+ <tabstop>_buttonDown</tabstop>
+ <tabstop>_questionText</tabstop>
+ <tabstop>_questionPicture</tabstop>
+ <tabstop>_questionType</tabstop>
+ <tabstop>_questionPoint</tabstop>
+ <tabstop>_questionTime</tabstop>
+ <tabstop>_questionTip</tabstop>
+ <tabstop>_questionExplain</tabstop>
+</tabstops>
+<slots>
+ <slot access="private" specifier="pure virtual">slotAddAnswer()</slot>
+ <slot access="private" specifier="pure virtual">slotRemoveAnswer()</slot>
+ <slot access="private" specifier="pure virtual">slotMoveUpAnswer()</slot>
+ <slot access="private" specifier="pure virtual">slotMoveDownAnswer()</slot>
+ <slot access="private" specifier="pure virtual">slotPreviewImage(const QString &amp;)</slot>
+ <slot access="private" specifier="pure virtual">slotQuestionTypeChanged(int index)</slot>
+ <slot access="private" specifier="pure virtual">slotDataChanged()</slot>
+ <slot access="private" specifier="pure virtual">slotAnswerSelected(QListViewItem *)</slot>
+</slots>
+<layoutdefaults spacing="6" margin="11"/>
+<includehints>
+ <includehint>kurlrequester.h</includehint>
+ <includehint>klineedit.h</includehint>
+ <includehint>kpushbutton.h</includehint>
+ <includehint>kcombobox.h</includehint>
+ <includehint>knuminput.h</includehint>
+ <includehint>knuminput.h</includehint>
+ <includehint>knuminput.h</includehint>
+ <includehint>knuminput.h</includehint>
+ <includehint>knuminput.h</includehint>
+ <includehint>knuminput.h</includehint>
+ <includehint>klistview.h</includehint>
+</includehints>
+</UI>
diff --git a/keduca/keducabuilder/kcontrolheader.cpp b/keduca/keducabuilder/kcontrolheader.cpp
new file mode 100644
index 00000000..d7a2090a
--- /dev/null
+++ b/keduca/keducabuilder/kcontrolheader.cpp
@@ -0,0 +1,376 @@
+/***************************************************************************
+ kcontrolheader.cpp - description
+ -------------------
+ begin : Tue May 29 2001
+ copyright : (C) 2001 by Javier Campos
+ email : javi@asyris.org
+***************************************************************************/
+
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+
+#include "kcontrolheader.h"
+#include "kcontrolheader.moc"
+
+#include <klocale.h>
+#include <kstandarddirs.h>
+#include <ksimpleconfig.h>
+#include <klineedit.h>
+#include <kcombobox.h>
+
+#include <qlayout.h>
+#include <qlabel.h>
+
+KControlHeader::KControlHeader(FileRead *keducaFile, QWidget *parent, const char *name ) : KDialogBase(Swallow, i18n("Document Information"), Ok|Cancel, Ok, parent, name, true, true)
+{
+ _keducaFile = keducaFile;
+ init();
+ configRead();
+}
+
+KControlHeader::~KControlHeader(){}
+
+/** Init graphical interface */
+void KControlHeader::init()
+{
+ QWidget *mainView = new QWidget(this);
+
+ QVBoxLayout *Form2Layout = new QVBoxLayout( mainView );
+ Form2Layout->setSpacing( 6 );
+ Form2Layout->setMargin( 0 );
+
+ QFrame *Frame16 = new QFrame( mainView, "Frame16" );
+ Frame16->setMinimumSize( QSize( 0, 50 ) );
+ Frame16->setMaximumSize( QSize( 32767, 50 ) );
+ Frame16->setFrameShape( QFrame::Box );
+ Frame16->setFrameShadow( QFrame::Plain );
+ Frame16->setPalette( QPalette( QColor(255, 255, 255) ) );
+ QHBoxLayout *Frame16Layout = new QHBoxLayout( Frame16 );
+ Frame16Layout->setSpacing( 6 );
+ Frame16Layout->setMargin( 1 );
+
+ QFrame *Frame17 = new QFrame( Frame16, "Frame17" );
+ Frame17->setMinimumSize( QSize( 125, 0 ) );
+ Frame17->setMaximumSize( QSize( 125, 32767 ) );
+ Frame17->setFrameShape( QFrame::NoFrame );
+ Frame17->setFrameShadow( QFrame::Raised );
+ Frame17->setBackgroundPixmap( QPixmap(locate("appdata","pics/bk_frame.png") ) );
+ QVBoxLayout *Frame17Layout = new QVBoxLayout( Frame17 );
+ Frame17Layout->setSpacing( 6 );
+ Frame17Layout->setMargin( 11 );
+
+ QLabel *TextLabel1 = new QLabel( Frame17, "TextLabel1" );
+ TextLabel1->setText( "<b style=\"text-decoration:underline;\">"+i18n("Information")+"</b>" );
+ TextLabel1->setBackgroundPixmap( QPixmap(locate("appdata","pics/bk_frame.png") ) );
+ Frame17Layout->addWidget( TextLabel1 );
+ Frame16Layout->addWidget( Frame17 );
+ QSpacerItem* spacer = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum );
+ Frame16Layout->addItem( spacer );
+
+ QLabel *TextLabel2 = new QLabel( Frame16, "TextLabel2" );
+ TextLabel2->setText( i18n( "Description and rules of the project." ) );
+ TextLabel2->setPalette( QPalette( QColor(255, 255, 255) ) );
+ Frame16Layout->addWidget( TextLabel2 );
+ Form2Layout->addWidget( Frame16 );
+
+ QGroupBox *GroupBox7 = new QGroupBox( mainView, "GroupBox7" );
+ GroupBox7->setTitle( i18n( "Description" ) );
+ GroupBox7->setColumnLayout(0, Qt::Vertical );
+ GroupBox7->layout()->setSpacing( 0 );
+ GroupBox7->layout()->setMargin( 0 );
+ QVBoxLayout *GroupBox7Layout = new QVBoxLayout( GroupBox7->layout() );
+ GroupBox7Layout->setAlignment( Qt::AlignTop );
+ GroupBox7Layout->setSpacing( 6 );
+ GroupBox7Layout->setMargin( 11 );
+
+ QGridLayout *Layout13 = new QGridLayout;
+ Layout13->setSpacing( 6 );
+ Layout13->setMargin( 0 );
+
+ QLabel *TextLabel10 = new QLabel( GroupBox7, "TextLabel10" );
+ TextLabel10->setText( i18n( "Type:" ));
+ TextLabel10->setAlignment( int( QLabel::AlignVCenter | QLabel::AlignRight ) );
+
+ Layout13->addWidget( TextLabel10, 2, 0 );
+
+ QHBoxLayout *Layout12 = new QHBoxLayout;
+ Layout12->setSpacing( 6 );
+ Layout12->setMargin( 0 );
+
+ _headerType = new KComboBox( FALSE, GroupBox7, "_headerType" );
+ Layout12->addWidget( _headerType );
+
+ QLabel *TextLabel11 = new QLabel( GroupBox7, "TextLabel11" );
+ TextLabel11->setText( i18n( "Level:" ));
+ TextLabel11->setAlignment( int( QLabel::AlignVCenter | QLabel::AlignRight ) );
+ Layout12->addWidget( TextLabel11 );
+
+ _headerLevel = new KComboBox( FALSE, GroupBox7, "_headerLevel" );
+ Layout12->addWidget( _headerLevel );
+ Layout13->addLayout( Layout12, 2, 1 );
+
+ QLabel *TextLabel12 = new QLabel( GroupBox7, "TextLabel12" );
+ TextLabel12->setText( i18n( "Language:" ));
+ TextLabel12->setAlignment( int( QLabel::AlignVCenter | QLabel::AlignRight ) );
+ Layout13->addWidget( TextLabel12, 3, 0 );
+
+ _headerLang = new KLanguageCombo( GroupBox7, "_headerLang" );
+ loadCountryList( _headerLang );
+ Layout13->addWidget( _headerLang, 3, 1 );
+
+ QLabel *TextLabel9 = new QLabel( GroupBox7, "TextLabel9" );
+ TextLabel9->setText( i18n( "Category:" ));
+ TextLabel9->setAlignment( int( QLabel::AlignVCenter | QLabel::AlignRight ) );
+
+ Layout13->addWidget( TextLabel9, 1, 0 );
+
+ _headerCategory = new KComboBox( true, GroupBox7, "_headerCategory" );
+ Layout13->addWidget( _headerCategory, 1, 1 );
+
+ _headerTitle = new QLineEdit( GroupBox7, "_headerTitle" );
+ Layout13->addWidget( _headerTitle, 0, 1 );
+
+ QLabel *TextLabel8 = new QLabel( GroupBox7, "TextLabel8" );
+ TextLabel8->setText( i18n( "Title:" ));
+ TextLabel8->setAlignment( int( QLabel::AlignVCenter | QLabel::AlignRight ) );
+
+ Layout13->addWidget( TextLabel8, 0, 0 );
+ GroupBox7Layout->addLayout( Layout13 );
+ Form2Layout->addWidget( GroupBox7 );
+
+ QGroupBox *GroupBox8 = new QGroupBox( mainView, "GroupBox8" );
+ GroupBox8->setTitle( i18n( "Picture" ) );
+ GroupBox8->setColumnLayout(0, Qt::Vertical );
+ GroupBox8->layout()->setSpacing( 0 );
+ GroupBox8->layout()->setMargin( 0 );
+ QHBoxLayout *GroupBox8Layout = new QHBoxLayout( GroupBox8->layout() );
+ GroupBox8Layout->setAlignment( Qt::AlignTop );
+ GroupBox8Layout->setSpacing( 6 );
+ GroupBox8Layout->setMargin( 11 );
+
+ QLabel *TextLabel13 = new QLabel( GroupBox8, "TextLabel13" );
+ TextLabel13->setText( i18n( "Default picture:" ));
+ GroupBox8Layout->addWidget( TextLabel13 );
+
+ _headerPicture = new KURLRequester( GroupBox8, "_headerPicture" );
+ GroupBox8Layout->addWidget( _headerPicture );
+ Form2Layout->addWidget( GroupBox8 );
+
+ QGroupBox *GroupBox6 = new QGroupBox( mainView, "GroupBox6" );
+ GroupBox6->setTitle( i18n( "Author" ) );
+ GroupBox6->setColumnLayout(0, Qt::Vertical );
+ GroupBox6->layout()->setSpacing( 0 );
+ GroupBox6->layout()->setMargin( 0 );
+ QGridLayout *GroupBox6Layout = new QGridLayout( GroupBox6->layout() );
+ GroupBox6Layout->setAlignment( Qt::AlignTop );
+ GroupBox6Layout->setSpacing( 6 );
+ GroupBox6Layout->setMargin( 11 );
+
+ _headerName = new QLineEdit( GroupBox6, "_headerName" );
+
+ GroupBox6Layout->addWidget( _headerName, 0, 1 );
+
+ _headerEmail = new QLineEdit( GroupBox6, "_headerEmail" );
+
+ GroupBox6Layout->addWidget( _headerEmail, 1, 1 );
+
+ QLabel *TextLabel7 = new QLabel( GroupBox6, "TextLabel7" );
+ TextLabel7->setText( i18n( "Web page:" ));
+ TextLabel7->setAlignment( int( QLabel::AlignVCenter | QLabel::AlignRight ) );
+
+ GroupBox6Layout->addWidget( TextLabel7, 2, 0 );
+
+ QLabel *TextLabel6 = new QLabel( GroupBox6, "TextLabel6" );
+ TextLabel6->setText( i18n( "Email:" ));
+ TextLabel6->setAlignment( int( QLabel::AlignVCenter | QLabel::AlignRight ) );
+
+ GroupBox6Layout->addWidget( TextLabel6, 1, 0 );
+
+ QLabel *TextLabel5 = new QLabel( GroupBox6, "TextLabel5" );
+ TextLabel5->setText( i18n( "Name:" ));
+ TextLabel5->setAlignment( int( QLabel::AlignVCenter | QLabel::AlignRight ) );
+
+ GroupBox6Layout->addWidget( TextLabel5, 0, 0 );
+
+ _headerWWW = new QLineEdit( GroupBox6, "_headerWWW" );
+
+ GroupBox6Layout->addWidget( _headerWWW, 2, 1 );
+ Form2Layout->addWidget( GroupBox6 );
+
+ // tab order
+ setTabOrder( _headerTitle, _headerCategory );
+ setTabOrder( _headerCategory, _headerType );
+ setTabOrder( _headerType, _headerLevel );
+ setTabOrder( _headerLevel, _headerLang );
+ setTabOrder( _headerLang, _headerPicture->lineEdit() );
+ setTabOrder( _headerPicture->lineEdit(), _headerPicture->comboBox() );
+ setTabOrder( _headerPicture->comboBox(), _headerName );
+ setTabOrder( _headerName, _headerEmail );
+ setTabOrder( _headerEmail, _headerWWW );
+
+ // set a sensible focus
+ _headerTitle->setFocus();
+
+ setMainWidget(mainView);
+}
+
+/** Insert header */
+void KControlHeader::insertHeader()
+{
+ QStringList tmpResult = _defaultCategories.grep( _headerCategory->currentText() );
+ if( tmpResult.count() == 0 )
+ {
+ KConfig *appconfig = KGlobal::config();
+ _defaultCategories.append( _headerCategory->currentText() );
+ appconfig->setGroup("General");
+ appconfig->writeEntry( "Categories", _defaultCategories);
+ appconfig->sync();
+ }
+ _keducaFile->setHeader( "category", _headerCategory->currentText() );
+ _keducaFile->setHeader( "title", _headerTitle->text() );
+ _keducaFile->setHeader( "image", _headerPicture->url() );
+ _keducaFile->setHeader( "type", QString().setNum( _headerType->currentItem() + 1 ) );
+ _keducaFile->setHeader( "level", QString().setNum( _headerLevel->currentItem() + 1 ) );
+ _keducaFile->setHeader( "language", _headerLang->currentTag() );
+ _keducaFile->setHeader( "name", _headerName->text() );
+ _keducaFile->setHeader( "email", _headerEmail->text() );
+ _keducaFile->setHeader( "www", _headerWWW->text() );
+}
+
+/** Load country list */
+void KControlHeader::loadCountryList(KLanguageCombo *combo)
+{
+ QString sub = QString::fromLatin1("l10n/");
+
+ // clear the list
+ combo->clear();
+
+ QStringList regionlist = KGlobal::dirs()->findAllResources("locale", sub + QString::fromLatin1("*.desktop"));
+ regionlist.sort();
+
+ for ( QStringList::ConstIterator it = regionlist.begin();
+ it != regionlist.end();
+ ++it )
+ {
+ QString tag = *it;
+ int index;
+
+ index = tag.findRev('/');
+ if (index != -1) tag = tag.mid(index + 1);
+
+ index = tag.findRev('.');
+ if (index != -1) tag.truncate(index);
+
+ KSimpleConfig entry(*it);
+ entry.setGroup(QString::fromLatin1("KCM Locale"));
+ QString name = entry.readEntry(QString::fromLatin1("Name"));
+
+ combo->insertSubmenu( name, '-' + tag, sub );
+ }
+
+ // add all languages to the list
+ QStringList countrylist = KGlobal::dirs()->findAllResources("locale", sub + QString::fromLatin1("*/entry.desktop"));
+ countrylist.sort();
+
+ for ( QStringList::ConstIterator it = countrylist.begin();
+ it != countrylist.end(); ++it )
+ {
+ KSimpleConfig entry(*it);
+ entry.setGroup(QString::fromLatin1("KCM Locale"));
+ QString name = entry.readEntry(QString::fromLatin1("Name"));
+ QString submenu = '-' + entry.readEntry(QString::fromLatin1("Region"));
+
+ QString tag = *it;
+ int index = tag.findRev('/');
+ tag.truncate(index);
+ index = tag.findRev('/');
+ tag = tag.mid(index+1);
+ combo->insertLanguage(tag, name, sub, submenu);
+ }
+}
+
+/** Ok push */
+void KControlHeader::slotOk()
+{
+ insertHeader();
+ configWrite();
+ accept();
+}
+
+/** Read settings */
+void KControlHeader::configRead()
+{
+ KConfig *config = new KConfig("emaildefaults");
+ KConfig *appconfig = KGlobal::config();
+
+ config->setGroup("UserInfo");
+
+ if( _keducaFile->getHeader( "name" ).isEmpty() )
+ _headerName->setText(config->readEntry("FullName", QString::null ));
+ else
+ _headerName->setText( _keducaFile->getHeader("name") );
+
+ if( _keducaFile->getHeader( "email" ).isEmpty() )
+ _headerEmail->setText(config->readEntry("EmailAddress", QString::null ));
+ else
+ _headerEmail->setText( _keducaFile->getHeader("email") );
+
+ _headerWWW->setText( _keducaFile->getHeader("www") );
+
+ if( !_keducaFile->getHeader("language").isEmpty() )
+ {
+ _headerLang->setCurrentItem( _keducaFile->getHeader("language") );
+ }
+ else
+ {
+ config->setGroup("Locale");
+ _headerLang->setCurrentItem( config->readEntry("Country") );
+ }
+
+ appconfig->setGroup("General");
+ _defaultCategories = appconfig->readListEntry("Categories");
+ if( _defaultCategories.count() == 0 )
+ {
+ _defaultCategories.append(i18n("Computers"));
+ }
+ _defaultCategories.sort();
+ _headerCategory->insertStringList( _defaultCategories );
+ if( !_keducaFile->getHeader( "category" ).isEmpty() ) _headerCategory->setEditText( _keducaFile->getHeader("category") );
+
+ _headerType->insertItem( i18n("Test") );
+ _headerType->insertItem( i18n("Test with Question Points") );
+ _headerType->insertItem( i18n("Test with Answers Points") );
+ _headerType->insertItem( i18n("Slidershow") );
+ _headerType->insertItem( i18n("Exam") );
+ _headerType->insertItem( i18n("Psychotechnic Test") );
+ if( QString(_keducaFile->getHeader("type")).toInt() > 0 ) _headerType->setCurrentItem( QString(_keducaFile->getHeader("type")).toInt() -1 );
+
+ _headerLevel->insertItem( i18n("Easy") );
+ _headerLevel->insertItem( i18n("Normal") );
+ _headerLevel->insertItem( i18n("Expert") );
+ _headerLevel->insertItem( i18n("Supreme") );
+ if( QString(_keducaFile->getHeader("level")).toInt() >0 ) _headerLevel->setCurrentItem( QString(_keducaFile->getHeader("level")).toInt() -1 );
+
+ _headerPicture->setURL( _keducaFile->getHeader("image") );
+ _headerTitle->setText( _keducaFile->getHeader("title") );
+
+ appconfig->setGroup("kcontrolheader");
+ QSize *defaultSize = new QSize(500,400);
+ resize( appconfig->readSizeEntry("Geometry", defaultSize ) );
+ delete config;
+}
+
+/** Write settings */
+void KControlHeader::configWrite()
+{
+ KConfig *config = KGlobal::config();
+ config->setGroup("kcontrolheader");
+ config->writeEntry("Geometry", size() );
+ config->sync();
+}
diff --git a/keduca/keducabuilder/kcontrolheader.h b/keduca/keducabuilder/kcontrolheader.h
new file mode 100644
index 00000000..86752ae0
--- /dev/null
+++ b/keduca/keducabuilder/kcontrolheader.h
@@ -0,0 +1,86 @@
+/***************************************************************************
+ kcontrolheader.h - description
+ -------------------
+ begin : Tue May 29 2001
+ copyright : (C) 2001 by Javier Campos
+ email : javi@asyris.org
+***************************************************************************/
+
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+
+#ifndef KCONTROLHEADER_H
+#define KCONTROLHEADER_H
+
+#include "../libkeduca/fileread.h"
+#include "klangcombo.h"
+
+#include <kdialogbase.h>
+#include <kurlrequester.h>
+
+
+/**Information header
+ * Options Dialog for KEduca Document.
+ * Will be called for each new KEduca Document and from the Editor (class KEducaBuilder)
+ *@author Javier Campos
+ */
+
+class KControlHeader : public KDialogBase {
+ Q_OBJECT
+
+public:
+ KControlHeader(FileRead *keducaFile, QWidget *parent=0, const char *name=0);
+ ~KControlHeader();
+
+private:
+
+ // Private attributes
+
+ /** Keduca pointer */
+ FileRead *_keducaFile;
+ /** Title */
+ QLineEdit *_headerTitle;
+ /** Header type */
+ KComboBox *_headerType;
+ /** Header category */
+ KComboBox *_headerCategory;
+ /** Header level */
+ KComboBox *_headerLevel;
+ /** Header lang */
+ KLanguageCombo *_headerLang;
+ /** Header picture */
+ KURLRequester *_headerPicture;
+ /** Header name */
+ QLineEdit *_headerName;
+ /** Header email */
+ QLineEdit *_headerEmail;
+ /** Header www */
+ QLineEdit *_headerWWW;
+ /** Default categories */
+ QStringList _defaultCategories;
+
+ // Private methods
+
+ /** Init graphical interface */
+ void init();
+ /** Insert header */
+ void insertHeader();
+ /** Load country list */
+ void loadCountryList(KLanguageCombo *combo);
+ /** Write settings */
+ void configWrite();
+ /** Read settings */
+ void configRead();
+
+private slots:
+ /** Ok push */
+ void slotOk();
+};
+
+#endif
diff --git a/keduca/keducabuilder/kcontrolheaderbase.ui b/keduca/keducabuilder/kcontrolheaderbase.ui
new file mode 100644
index 00000000..04f2411b
--- /dev/null
+++ b/keduca/keducabuilder/kcontrolheaderbase.ui
@@ -0,0 +1,472 @@
+<!DOCTYPE UI><UI version="3.2" stdsetdef="1">
+<class>MyDialog</class>
+<widget class="QDialog">
+ <property name="name">
+ <cstring>MyDialog</cstring>
+ </property>
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>512</width>
+ <height>534</height>
+ </rect>
+ </property>
+ <property name="sizeGripEnabled">
+ <bool>true</bool>
+ </property>
+ <vbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QFrame">
+ <property name="name">
+ <cstring>frame3</cstring>
+ </property>
+ <property name="minimumSize">
+ <size>
+ <width>0</width>
+ <height>50</height>
+ </size>
+ </property>
+ <property name="maximumSize">
+ <size>
+ <width>32767</width>
+ <height>50</height>
+ </size>
+ </property>
+ <property name="paletteBackgroundColor">
+ <color>
+ <red>255</red>
+ <green>255</green>
+ <blue>255</blue>
+ </color>
+ </property>
+ <property name="frameShape">
+ <enum>Box</enum>
+ </property>
+ <property name="frameShadow">
+ <enum>Sunken</enum>
+ </property>
+ <hbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <property name="margin">
+ <number>2</number>
+ </property>
+ <widget class="QFrame">
+ <property name="name">
+ <cstring>frame4</cstring>
+ </property>
+ <property name="minimumSize">
+ <size>
+ <width>125</width>
+ <height>0</height>
+ </size>
+ </property>
+ <property name="maximumSize">
+ <size>
+ <width>125</width>
+ <height>32767</height>
+ </size>
+ </property>
+ <property name="paletteBackgroundPixmap">
+ <pixmap>image0</pixmap>
+ </property>
+ <property name="frameShape">
+ <enum>NoFrame</enum>
+ </property>
+ <property name="frameShadow">
+ <enum>Raised</enum>
+ </property>
+ <vbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QLabel">
+ <property name="name">
+ <cstring>textLabel1</cstring>
+ </property>
+ <property name="text">
+ <string>&lt;b style="text-decoration:underline;"&gt;Information&lt;/b&gt;</string>
+ </property>
+ </widget>
+ </vbox>
+ </widget>
+ <spacer>
+ <property name="name">
+ <cstring>spacer2</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Horizontal</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>60</width>
+ <height>21</height>
+ </size>
+ </property>
+ </spacer>
+ <widget class="QLabel">
+ <property name="name">
+ <cstring>textLabel6</cstring>
+ </property>
+ <property name="text">
+ <string>Description and rules of the project.</string>
+ </property>
+ </widget>
+ </hbox>
+ </widget>
+ <widget class="QGroupBox">
+ <property name="name">
+ <cstring>groupBox1</cstring>
+ </property>
+ <property name="title">
+ <string>Description</string>
+ </property>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QLabel" row="0" column="0">
+ <property name="name">
+ <cstring>textLabel11</cstring>
+ </property>
+ <property name="text">
+ <string>Title:</string>
+ </property>
+ <property name="alignment">
+ <set>AlignVCenter|AlignRight</set>
+ </property>
+ </widget>
+ <widget class="QLabel" row="3" column="0">
+ <property name="name">
+ <cstring>textLabel9</cstring>
+ </property>
+ <property name="text">
+ <string>Language:</string>
+ </property>
+ <property name="alignment">
+ <set>AlignVCenter|AlignRight</set>
+ </property>
+ </widget>
+ <widget class="QLabel" row="1" column="0">
+ <property name="name">
+ <cstring>textLabel10</cstring>
+ </property>
+ <property name="text">
+ <string>Category:</string>
+ </property>
+ <property name="alignment">
+ <set>AlignVCenter|AlignRight</set>
+ </property>
+ </widget>
+ <widget class="QLabel" row="2" column="0">
+ <property name="name">
+ <cstring>textLabel7</cstring>
+ </property>
+ <property name="text">
+ <string>Type:</string>
+ </property>
+ <property name="alignment">
+ <set>AlignVCenter|AlignRight</set>
+ </property>
+ </widget>
+ <widget class="KComboBox" row="3" column="1">
+ <property name="name">
+ <cstring>_headerLang</cstring>
+ </property>
+ </widget>
+ <widget class="KLineEdit" row="0" column="1">
+ <property name="name">
+ <cstring>_headerTitle</cstring>
+ </property>
+ </widget>
+ <widget class="QLayoutWidget" row="2" column="1">
+ <property name="name">
+ <cstring>layout2</cstring>
+ </property>
+ <hbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="KComboBox">
+ <property name="name">
+ <cstring>_headerType</cstring>
+ </property>
+ </widget>
+ <spacer>
+ <property name="name">
+ <cstring>spacer4</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Horizontal</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>61</width>
+ <height>21</height>
+ </size>
+ </property>
+ </spacer>
+ <widget class="QLabel">
+ <property name="name">
+ <cstring>textLabel8</cstring>
+ </property>
+ <property name="text">
+ <string>Level:</string>
+ </property>
+ <property name="alignment">
+ <set>AlignVCenter|AlignRight</set>
+ </property>
+ </widget>
+ <widget class="KComboBox">
+ <property name="name">
+ <cstring>_headerLevel</cstring>
+ </property>
+ </widget>
+ </hbox>
+ </widget>
+ <widget class="KComboBox" row="1" column="1">
+ <property name="name">
+ <cstring>_headerCategory</cstring>
+ </property>
+ <property name="editable">
+ <bool>true</bool>
+ </property>
+ </widget>
+ </grid>
+ </widget>
+ <widget class="QGroupBox">
+ <property name="name">
+ <cstring>groupBox2</cstring>
+ </property>
+ <property name="title">
+ <string>Picture</string>
+ </property>
+ <hbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QLabel">
+ <property name="name">
+ <cstring>textLabel2</cstring>
+ </property>
+ <property name="text">
+ <string>Default picture:</string>
+ </property>
+ <property name="alignment">
+ <set>AlignJustify|AlignVCenter</set>
+ </property>
+ </widget>
+ <widget class="KURLRequester">
+ <property name="name">
+ <cstring>_headerPicture</cstring>
+ </property>
+ </widget>
+ </hbox>
+ </widget>
+ <widget class="QGroupBox">
+ <property name="name">
+ <cstring>groupBox3</cstring>
+ </property>
+ <property name="title">
+ <string>Author</string>
+ </property>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QLabel" row="0" column="0">
+ <property name="name">
+ <cstring>textLabel3</cstring>
+ </property>
+ <property name="text">
+ <string>Name:</string>
+ </property>
+ <property name="alignment">
+ <set>AlignVCenter|AlignRight</set>
+ </property>
+ </widget>
+ <widget class="KLineEdit" row="0" column="1">
+ <property name="name">
+ <cstring>_headerName</cstring>
+ </property>
+ </widget>
+ <widget class="KLineEdit" row="2" column="1">
+ <property name="name">
+ <cstring>_headerWWW</cstring>
+ </property>
+ </widget>
+ <widget class="KLineEdit" row="1" column="1">
+ <property name="name">
+ <cstring>_headerEmail</cstring>
+ </property>
+ </widget>
+ <widget class="QLabel" row="2" column="0">
+ <property name="name">
+ <cstring>textLabel5</cstring>
+ </property>
+ <property name="text">
+ <string>Web page:</string>
+ </property>
+ <property name="alignment">
+ <set>AlignVCenter|AlignRight</set>
+ </property>
+ </widget>
+ <widget class="QLabel" row="1" column="0">
+ <property name="name">
+ <cstring>textLabel4</cstring>
+ </property>
+ <property name="text">
+ <string>Email:</string>
+ </property>
+ <property name="alignment">
+ <set>AlignVCenter|AlignRight</set>
+ </property>
+ </widget>
+ </grid>
+ </widget>
+ <spacer>
+ <property name="name">
+ <cstring>spacer3</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Vertical</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>31</width>
+ <height>40</height>
+ </size>
+ </property>
+ </spacer>
+ <widget class="Line">
+ <property name="name">
+ <cstring>line1</cstring>
+ </property>
+ <property name="frameShape">
+ <enum>HLine</enum>
+ </property>
+ <property name="frameShadow">
+ <enum>Sunken</enum>
+ </property>
+ <property name="orientation">
+ <enum>Horizontal</enum>
+ </property>
+ </widget>
+ <widget class="QLayoutWidget">
+ <property name="name">
+ <cstring>Layout1</cstring>
+ </property>
+ <hbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <property name="margin">
+ <number>0</number>
+ </property>
+ <property name="spacing">
+ <number>6</number>
+ </property>
+ <spacer>
+ <property name="name">
+ <cstring>Horizontal Spacing2</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Horizontal</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>20</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ <widget class="QPushButton">
+ <property name="name">
+ <cstring>buttonOk</cstring>
+ </property>
+ <property name="text">
+ <string>&amp;OK</string>
+ </property>
+ <property name="autoDefault">
+ <bool>true</bool>
+ </property>
+ <property name="default">
+ <bool>true</bool>
+ </property>
+ </widget>
+ <widget class="QPushButton">
+ <property name="name">
+ <cstring>buttonCancel</cstring>
+ </property>
+ <property name="text">
+ <string>&amp;Cancel</string>
+ </property>
+ <property name="autoDefault">
+ <bool>true</bool>
+ </property>
+ </widget>
+ </hbox>
+ </widget>
+ </vbox>
+</widget>
+<customwidgets>
+</customwidgets>
+<images>
+ <image name="image0">
+ <data format="XPM.GZ" length="2314">789ced95bd6e83301485f73c8515b6a84a14a4b0547d844a1d2b551d8cb181947fdca1aafaeec5f75e830d51105397de230f9f50823987634e07f6faf2cc0ea75dafb9ce051319efd821f92ccbafb7f7a7efddfe1c5ed8f9c2c2909df70fbb7dc5040b642443a50c968411e21551291919ac01a5bdda1072c48e50227e200ebf95065b832ab2577b4445f7d584f4cf05a15270df0050c910b7c10923c4e38870a39890230a42899858c47f9688c33600156184988e08bbca08e979734285780c0671d231e6f1114423e2045622ac6422cd4ae4384aa646ca2a53590a1a27472d07c232f301cbd3620a5f052c6772589e725877065e9eaaaeead2aaa91bb3ea86a66dba610deaacfaae6f41e3a4bd1e56aaad8667d71b1c0838c8c981430e3c8ea71c2889290701393829284cc2cf414dbbc86fee02de79dff785f7c5dcfd85f70be7577c9f6da02a2b9342e9e650420ee374a0450edd94828614b49b83ce308b550766eedb1ed050077cf713bf05e9dcfd947ab0a105373a705d496291c3f60ee0066ab705b603f5e47e3b77bfa51e38fea77e0bf4a673803ac0fd16f029056c8158e620fc1640126e0b308bd577e07ad7fb1bcedfe840b1d9fb790b66a7119e475e0b2009b7059d9f829e9f46f63c5a75e0ff5bf0b7df829fc7dd2faa1761dd</data>
+ </image>
+</images>
+<connections>
+ <connection>
+ <sender>buttonOk</sender>
+ <signal>clicked()</signal>
+ <receiver>MyDialog</receiver>
+ <slot>accept()</slot>
+ </connection>
+ <connection>
+ <sender>buttonCancel</sender>
+ <signal>clicked()</signal>
+ <receiver>MyDialog</receiver>
+ <slot>reject()</slot>
+ </connection>
+</connections>
+<tabstops>
+ <tabstop>_headerTitle</tabstop>
+ <tabstop>_headerCategory</tabstop>
+ <tabstop>_headerType</tabstop>
+ <tabstop>_headerLevel</tabstop>
+ <tabstop>_headerLang</tabstop>
+ <tabstop>_headerPicture</tabstop>
+ <tabstop>_headerName</tabstop>
+ <tabstop>_headerEmail</tabstop>
+ <tabstop>_headerWWW</tabstop>
+ <tabstop>buttonOk</tabstop>
+ <tabstop>buttonCancel</tabstop>
+</tabstops>
+<layoutdefaults spacing="6" margin="11"/>
+<includehints>
+ <includehint>klineedit.h</includehint>
+ <includehint>klineedit.h</includehint>
+ <includehint>klineedit.h</includehint>
+ <includehint>kpushbutton.h</includehint>
+ <includehint>klineedit.h</includehint>
+ <includehint>klineedit.h</includehint>
+ <includehint>klineedit.h</includehint>
+</includehints>
+</UI>
diff --git a/keduca/keducabuilder/keducabuilder.cpp b/keduca/keducabuilder/keducabuilder.cpp
new file mode 100644
index 00000000..08487cc9
--- /dev/null
+++ b/keduca/keducabuilder/keducabuilder.cpp
@@ -0,0 +1,600 @@
+/***************************************************************************
+ keducabuilder.cpp - description
+ -------------------
+ begin : Sat May 26 2001
+ copyright : (C) 2001 by Javier Campos
+ email : javi@asyris.org
+***************************************************************************/
+
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+
+#include "keducabuilder.h"
+#include "keducabuilder.moc"
+
+#include "kcontroladdedit.h"
+#include "kcontrolheader.h"
+#include "keducaeditorstartdialog.h"
+#include "../libkeduca/kgallerydialog.h"
+
+#include <kiconloader.h>
+#include <klocale.h>
+#include <kfiledialog.h>
+#include <kedittoolbar.h>
+#include <kdebug.h>
+#include <kio/netaccess.h>
+#include <kmessagebox.h>
+#include <kprinter.h>
+
+#include <qlayout.h>
+#include <qcheckbox.h>
+#include <qpaintdevicemetrics.h>
+#include <qpainter.h>
+
+static const char* const keducabuilder_data[] = {
+ "15 16 4 1",
+ "a c #0000ff",
+ "# c #008183",
+ "b c #c5c2c5",
+ ". c #ffffff",
+ "...............",
+ ".#############.",
+ ".#...........#.",
+ ".#...aaaa....#.",
+ ".#..aa.baa...#.",
+ ".#......aa...#.",
+ ".#.....aab...#.",
+ ".#....aab....#.",
+ ".#....aab....#.",
+ ".#.....b.....#.",
+ ".#....aa.....#.",
+ ".#....aa.....#.",
+ ".#...........#.",
+ ".#...........#.",
+ ".#############.",
+ "..............."};
+
+KEducaBuilder::KEducaBuilder(QWidget* parent, const char *name, WFlags f )
+ : KMainWindow(parent,name,f),
+ _nativeFormat("application/x-edu")
+{
+ _keducaFile = new FileRead();
+ initMenuBar();
+ init();
+ configRead();
+ setIcon( KGlobal::iconLoader()->loadIcon("control.png",
+ KIcon::Small) );
+ _isOpenFile = false;
+}
+
+KEducaBuilder::~KEducaBuilder()
+{
+ delete _keducaFile;
+}
+
+/** Init graphical interface */
+void KEducaBuilder::init()
+{
+ QWidget *mainView = new QWidget(this, "mainview");
+
+ QVBoxLayout *form2Layout = new QVBoxLayout( mainView );
+ form2Layout->setSpacing( 2 );
+ form2Layout->setMargin( 0 );
+
+ _split = new QSplitter( mainView );
+ _split->setOrientation( QSplitter::Vertical );
+
+ _listAnswer = new KListBox( _split, "_listAnswer" );
+ _listAnswer->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)7, (QSizePolicy::SizeType)7, _listAnswer->sizePolicy().hasHeightForWidth() ) );
+ connect( _listAnswer, SIGNAL( highlighted(QListBoxItem *) ), this, SLOT( slotPreview(QListBoxItem *) ) );
+ connect( _listAnswer, SIGNAL( doubleClicked(QListBoxItem *) ), this, SLOT( slotEditbyList(QListBoxItem *) ) );
+
+ _preview = new QTextView( _split, "_preview" );
+ _preview->setFrameShape( QTextView::NoFrame );
+ _preview->setLineWidth( 1 );
+
+ form2Layout->addWidget( _split );
+
+ setCentralWidget( mainView );
+ if (!initialGeometrySet())
+ resize( QSize(500, 400).expandedTo(minimumSizeHint()));
+ setupGUI( ToolBar | Keys | StatusBar | Create, "keducabuilderui.rc" );
+ setAutoSaveSettings();
+}
+
+/** Init menu bar settings */
+void KEducaBuilder::initMenuBar()
+{
+ KStdAction::openNew(this, SLOT( slotFileOpenNew() ), actionCollection());
+ KStdAction::open (this, SLOT( slotFileOpen() ), actionCollection());
+ (void)new KAction(i18n("Open &Gallery..."), 0, 0, this, SLOT( slotGallery() ), actionCollection(), "open_gallery");
+ _recentFiles = KStdAction::openRecent(this, SLOT ( slotFileOpenURL(const KURL &)), actionCollection());
+ KStdAction::save (this, SLOT( slotFileSave() ), actionCollection());
+ KStdAction::saveAs (this, SLOT( slotFileSaveAs() ), actionCollection());
+ KStdAction::print (this, SLOT( slotFilePrint() ), actionCollection());
+ (void)new KAction(i18n("Document Info"), "info", 0, this, SLOT( slotHeader() ), actionCollection(), "info_doc");
+ KStdAction::quit(this, SLOT( close() ), actionCollection());
+
+ (void)new KAction(i18n("&Add..."), "addquestion", 0, this, SLOT( slotAdd() ), actionCollection(), "question_add");
+ (void)new KAction(i18n("&Edit..."), "editquestion", 0, this, SLOT( slotEdit() ), actionCollection(), "question_edit");
+ (void)new KAction(i18n("&Remove"), "delquestion", 0, this, SLOT( slotRemove() ), actionCollection(), "question_remove");
+ (void)new KAction(i18n("&Up"), "up", 0, this, SLOT( slotUp() ), actionCollection(), "question_up");
+ (void)new KAction(i18n("&Down"), "down", 0, this, SLOT( slotDown() ), actionCollection(), "question_down");
+}
+
+/** Delete current document and start new */
+void KEducaBuilder::slotFileOpenNew()
+{
+ if (!currentFileMayBeReplaced())
+ return;
+
+ if( _keducaFile ) delete _keducaFile;
+ _listAnswer->clear();
+ _preview->setText("<qt><br><center><h1>"+i18n("Welcome To KEduca!")+"</h1>"+
+ i18n("Add a new Question by using the Edit Menu or by choosing one of the icons above.")+
+ "</center></qt>");
+ _keducaFile = new FileRead();
+ _isOpenFile = false;
+ // ask for meta information
+ slotHeader();
+}
+
+/** Open new document. */
+void KEducaBuilder::slotFileOpen()
+{
+ KURL url = KFileDialog::getOpenURL( QString::null, _nativeFormat, this, i18n("Open Educa File") );
+
+ if( !url.isEmpty() )
+ slotFileOpenURL( url );
+}
+
+/** Open new file */
+void KEducaBuilder::slotFileOpenURL( const KURL &url )
+{
+ if (!currentFileMayBeReplaced())
+ return;
+
+ QPixmap image0( ( const char** ) keducabuilder_data );
+ delete _keducaFile;
+ _keducaFile = new FileRead();
+ if( !_keducaFile->openFile(url) ) { return; }
+ _recentFiles->addURL( url );
+ _listAnswer->clear();
+ _isOpenFile = true;
+
+ _keducaFile->recordFirst();
+ while( !_keducaFile->recordEOF() )
+ {
+ _listAnswer->insertItem( image0, _keducaFile->getQuestion( FileRead::QF_TEXT ) );
+ _keducaFile->recordNext();
+ }
+}
+
+/** Item select */
+void KEducaBuilder::slotPreview( QListBoxItem *item )
+{
+// bool match = false;
+ QString tmpListanswer;
+
+ // FIND THE SELECT RECORD
+ if( !item ) return;
+
+// kdDebug() << "Item : " << _listAnswer->currentItem() <<endl;
+ _keducaFile->recordAt( _listAnswer->currentItem() );
+
+ // START THE PREVIEW VALUES
+ tmpListanswer = "<p><b>" + i18n("Answers") + "</b></p><hr>";
+ tmpListanswer += "<p>";
+
+ tmpListanswer +="<TABLE WIDTH=98%>";
+ _keducaFile->recordAnswerFirst();
+ while( !_keducaFile->recordAnswerEOF() )
+ {
+ tmpListanswer += "<TR>";
+ tmpListanswer += "<TD WIDTH=3% BGCOLOR=";
+ _keducaFile->getAnswerValue() ? tmpListanswer += "#006b6b>" : tmpListanswer += "#b84747>";
+ if( _keducaFile->getQuestionInt( FileRead::QF_TYPE ) == 3 )
+ {
+ tmpListanswer += "<FONT COLOR=#ffffff><b>"
+ + _keducaFile->getAnswer( FileRead::AF_POINT )
+ + "</b></FONT>";
+ }
+ tmpListanswer += "</TD>";
+ tmpListanswer += "<TD WIDTH=95% BGCOLOR=";
+ _keducaFile->getAnswerValue() ? tmpListanswer += "#daeaea>" : tmpListanswer += "#eadada>";
+ tmpListanswer += "<span style=\"color:black;\">"+_keducaFile->getAnswer( FileRead::AF_TEXT )+"</span>";
+ tmpListanswer += "</TD></TR>";
+ _keducaFile->recordAnswerNext();
+ };
+ tmpListanswer += "</TABLE>";
+
+ if( !_keducaFile->getQuestion( FileRead::QF_PICTURE ).isEmpty() )
+ {
+ tmpListanswer += "<table><tr><td><img src=";
+ tmpListanswer += _keducaFile->getPicture();
+ tmpListanswer += "></td>";
+ tmpListanswer += "<td align=right><b>" + i18n("Question Image") + "</b><hr>";
+ tmpListanswer += _keducaFile->getQuestion( FileRead::QF_PICTURE ) + "</td></tr></table>";
+ };
+
+ if( _keducaFile->getQuestionInt( FileRead::QF_POINTS ) > 0 )
+ {
+ tmpListanswer += "<p><b>" + i18n("Question point") + ":</b> ";
+ tmpListanswer += _keducaFile->getQuestion( FileRead::QF_POINTS );
+ }
+
+ if( _keducaFile->getQuestionInt( FileRead::QF_TIME ) > 0 )
+ {
+ tmpListanswer += "<p><b>"+i18n("Time")+":</b> ";
+ tmpListanswer += _keducaFile->getQuestion( FileRead::QF_TIME );
+ tmpListanswer += i18n(" seconds</p>");
+ }
+
+ if( !_keducaFile->getQuestion( FileRead::QF_TIP ).isEmpty() )
+ {
+ tmpListanswer += "<p><b>" + i18n("Tip") +":</b> ";
+ tmpListanswer += _keducaFile->getQuestion( FileRead::QF_TIP );
+ tmpListanswer += "</p>";
+ }
+
+ if( !_keducaFile->getQuestion( FileRead::QF_EXPLAIN ).isEmpty() )
+ {
+ tmpListanswer += "<p><b>"
+ + i18n("Explain") + ":</b>"
+ + _keducaFile->getQuestion( FileRead::QF_EXPLAIN )
+ + "</p>";
+ }
+
+ _preview->setText( tmpListanswer );
+}
+
+/** Read config data */
+void KEducaBuilder::configRead()
+{
+ KConfig *config = KGlobal::config();
+
+ config->setGroup( "keducacontrol" );
+ applyMainWindowSettings( config, "keducacontrol" );
+ _split->setSizes( config->readIntListEntry("Splitter_size") );
+ _recentFiles->loadEntries(config);
+}
+
+/** Write settings */
+void KEducaBuilder::configWrite()
+{
+ KConfig *config = KGlobal::config();
+
+ config->setGroup( "keducacontrol" );
+ saveMainWindowSettings( config, "keducacontrol" );
+ config->writeEntry("Splitter_size", _split->sizes() );
+ _recentFiles->saveEntries(config);
+ config->sync();
+}
+
+bool KEducaBuilder::currentFileMayBeReplaced()
+{
+ if (_keducaFile->changed())
+ {
+ int res = KMessageBox::warningYesNoCancel( widget(),
+ // ask the user to save
+ i18n( "The document \"%1\" has been modified.\n"
+ "Do you want to save it?" ).arg( _keducaFile->getCurrentURL().fileName() ),
+ i18n( "Save Document?" ), KStdGuiItem::save(), KStdGuiItem::discard() );
+ switch (res)
+ {
+ case KMessageBox::Yes:
+ // If the saving was successful, then the file may be replaced
+ return fileSave();
+ break;
+ case KMessageBox::Cancel:
+ // User cancels operation, do not replace the file
+ return false;
+ break;
+ default: ;
+ }
+ }
+
+ // file was not changed, it may be replaced
+ return true;
+}
+
+/** Close the window */
+bool KEducaBuilder::queryClose ()
+{
+ if (_keducaFile) {
+ if (!currentFileMayBeReplaced())
+ return false;
+ }
+ configWrite();
+ return( TRUE );
+}
+
+/** Add question */
+void KEducaBuilder::slotAdd()
+{
+ QPixmap image0( ( const char** ) keducabuilder_data );
+
+ KControlAddEdit edit(this);
+ edit.init( _keducaFile, false );
+ if( !edit.exec() ) return;
+
+ _listAnswer->insertItem( image0, _keducaFile->getQuestion( FileRead::QF_TEXT ) );
+ _listAnswer->setCurrentItem( _listAnswer->count()-1 );
+ slotPreview( _listAnswer->item(_listAnswer->currentItem()) );
+}
+
+/** Edit question */
+void KEducaBuilder::slotEdit()
+{
+ if( _listAnswer->currentItem() == -1 ) return;
+
+ QPixmap image0( ( const char** ) keducabuilder_data );
+
+ KControlAddEdit edit(this);
+ edit.init( _keducaFile, true );
+ if( edit.exec() )
+ {
+ _listAnswer->changeItem( image0, _keducaFile->getQuestion( FileRead::QF_TEXT ), _listAnswer->currentItem() );
+ slotPreview( _listAnswer->item(_listAnswer->currentItem()) );
+ }
+}
+
+/** Edit question */
+void KEducaBuilder::slotRemove()
+{
+ if( _listAnswer->currentItem() == -1 ) return;
+ _keducaFile->recordDelete();
+ _listAnswer->removeItem( _listAnswer->currentItem() );
+}
+
+/** Up record */
+void KEducaBuilder::slotUp()
+{
+ int current = _listAnswer->currentItem();
+
+ if( current < 1 ) return;
+ QPixmap image0( ( const char** ) keducabuilder_data );
+
+ _keducaFile->recordSwap( true );
+ QString tmpString = _listAnswer->text( current-1 );
+ _listAnswer->changeItem( image0, _listAnswer->text( current ), current-1 );
+ _listAnswer->changeItem( image0, tmpString, current );
+ _listAnswer->setCurrentItem( current-1 );
+}
+
+/** Down record */
+void KEducaBuilder::slotDown()
+{
+ int current = _listAnswer->currentItem();
+
+ if( current == -1 || current == (signed)(_listAnswer->count()-1) ) return;
+ QPixmap image0( ( const char** ) keducabuilder_data );
+
+ _keducaFile->recordSwap( true );
+ QString tmpString = _listAnswer->text( current+1 );
+ _listAnswer->changeItem( image0, _listAnswer->text( current ), current+1 );
+ _listAnswer->changeItem( image0, tmpString, current );
+ _listAnswer->setCurrentItem( current+1 );
+}
+
+/** Save file */
+void KEducaBuilder::slotFileSave()
+{
+ fileSave();
+}
+bool KEducaBuilder::fileSave()
+{
+ if( !_isOpenFile ) { return fileSaveAs(); }
+
+ if( checkSave() ) return _keducaFile->saveFile();
+ return false;
+}
+
+/** Save As... */
+void KEducaBuilder::slotFileSaveAs()
+{
+ fileSaveAs();
+}
+
+bool KEducaBuilder::fileSaveAs()
+{
+ if( !checkSave() ) return false;
+
+ QCheckBox *saveCompressedCheckBox = new QCheckBox( i18n( "Compress the file" ), 0 );
+ saveCompressedCheckBox->setChecked( true );
+
+ KFileDialog *dialog=new KFileDialog(QString::null, QString::null, this, "file dialog", true, saveCompressedCheckBox);
+ dialog->setCaption( i18n("Save Document As") );
+ dialog->setKeepLocation( true );
+ dialog->setOperationMode( KFileDialog::Saving );
+ QStringList mimeFilter(_nativeFormat);
+ dialog->setMimeFilter( mimeFilter, _nativeFormat );
+ KURL newURL;
+ QString outputFormat (_nativeFormat);
+
+ bool bOk;
+ do {
+ bOk=true;
+ if(dialog->exec()==QDialog::Accepted) {
+ newURL=dialog->selectedURL();
+ outputFormat=dialog->currentMimeFilter();
+ }
+ else
+ {
+ bOk = false;
+ break;
+ }
+ kdDebug()<<"Requested saving to file "<<newURL.prettyURL() <<endl;
+ if ( newURL.isEmpty() )
+ {
+ bOk = false;
+ break;
+ }
+
+ if ( QFileInfo( newURL.path() ).extension().isEmpty() ) {
+ // No more extensions in filters. We need to get it from the mimetype.
+ KMimeType::Ptr mime = KMimeType::mimeType( outputFormat );
+ QString extension = mime->property( "X-KDE-NativeExtension" ).toString();
+ kdDebug() << "KEducaBuilder::slotFileSaveAs outputFormat=" << outputFormat << " extension=" << extension << endl;
+ newURL.setPath( newURL.path() + extension );
+ }
+
+ if ( KIO::NetAccess::exists( newURL, false, this ) ) { // this file exists => ask for confirmation
+ bOk = KMessageBox::warningContinueCancel( this,
+ i18n("A document with this name already exists.\n"\
+ "Do you want to overwrite it?"),
+ i18n("Warning"), i18n("Overwrite") ) == KMessageBox::Continue;
+ }
+ } while ( !bOk );
+
+ bool saveCompressed = saveCompressedCheckBox->isChecked();
+
+ delete dialog;
+
+ if (bOk) {
+ bool copyImages = KMessageBox::questionYesNo( this,
+ i18n("If you want to share this document, it is better to copy the images to the same folder as the document.\n"\
+ "Do you want to copy images?"),
+ i18n("Warning"), i18n("Copy Images"), i18n("Do Not Copy") ) == KMessageBox::Yes;
+ if (_keducaFile->saveFile( newURL, copyImages, saveCompressed ) ) {
+ _recentFiles->addURL(newURL);
+ // we saved the file, so the internal representation is now present as a file
+ _isOpenFile=true;
+ return true;
+ }else {
+ kdDebug()<< "saving of file failed" <<endl;
+ return false;
+ }
+ }else {
+ kdDebug()<< "KEducaBuilder: no valid filename selected" <<endl;
+ return false;
+ }
+}
+
+/** Print file */
+void KEducaBuilder::slotFilePrint()
+{
+ KPrinter *printer = new KPrinter();
+
+ QString file = _keducaFile->getCurrentURL().fileName();
+ if (file.isEmpty())
+ file = i18n("Test");
+ if(printer->setup(this, i18n("Print %1").arg(file)))
+ {
+ QPaintDeviceMetrics metrics(printer);
+ QPainter p;
+
+ const int margin=20;
+ int yPos=0;
+ QString text;
+
+ p.begin(printer);
+ p.setFont( QFont(font().family(), 12, QFont::Bold) );
+ QFontMetrics fm = p.fontMetrics();
+
+ _keducaFile->recordFirst();
+ while(!_keducaFile->recordEOF())
+ {
+ p.drawText( 10, yPos+margin, metrics.width(), fm.lineSpacing(),
+ ExpandTabs | DontClip, _keducaFile->getQuestion(FileRead::QF_TEXT) );
+ yPos += fm.lineSpacing();
+
+ p.drawLine(10, yPos+margin, metrics.width(), yPos+margin);
+ yPos += 2*fm.lineSpacing();
+
+ _keducaFile->recordNext();
+ }
+
+ p.end();
+ }
+
+ delete printer;
+
+}
+
+/** Header info */
+int KEducaBuilder::slotHeader() {
+ KControlHeader infoDoc(_keducaFile);
+ return infoDoc.exec();
+}
+
+/** Check if the current document can save */
+bool KEducaBuilder::checkSave()
+{
+ if( _keducaFile->getHeader("title").isEmpty() ||
+ _keducaFile->getHeader("category").isEmpty() ||
+ _keducaFile->getHeader("type").isEmpty() ||
+ _keducaFile->getHeader("level").isEmpty() ||
+ _keducaFile->getHeader("language").isEmpty() )
+ {
+ if (KMessageBox::warningContinueCancel(this, i18n("Unable to save file.\n\nYou must complete the Document Info\n(Only the description is necessary)"), QString::null, i18n("Complete Document Info..."))
+ == KMessageBox::Continue) {
+ if (slotHeader()!=KControlHeader::Accepted)
+ return false;
+ }else
+ return false;
+ }
+
+ if( _listAnswer->count() < 1 )
+ {
+ if (KMessageBox::warningContinueCancel(this, i18n("Unable to save file.\n\nYou must insert a question."),
+ QString::null, i18n("Insert Question"))==KMessageBox::Continue)
+ slotAdd();
+ else
+ return false;
+ }
+
+ return true;
+}
+
+bool KEducaBuilder::startChooser() {
+ KEducaEditorStartDialog startDialog(this, "KEducaEditorStartDialog", true);
+
+ switch (startDialog.exec()) {
+ case KEducaEditorStartDialog::OpenDoc:
+ case KEducaEditorStartDialog::OpenRecentDoc:
+ slotFileOpenURL(startDialog.getURL());
+ break;
+ case KEducaEditorStartDialog::NewDoc:
+ slotFileOpenNew();
+ break;
+ case KEducaEditorStartDialog::Gallery:
+ initGallery();
+ break;
+ default:
+ close();
+ break;
+ }
+
+ return true;
+}
+/** Init Internet Gallery Servers */
+void KEducaBuilder::initGallery(const KURL &urlFile)
+{
+ KGalleryDialog galleries;
+
+ if( !urlFile.url().isEmpty() )
+ galleries.putURL( urlFile );
+
+ if( galleries.exec() == QDialog::Accepted )
+ slotFileOpenURL( galleries.getURL() );
+}
+
+/** Init Gallery */
+void KEducaBuilder::slotGallery()
+{
+ initGallery();
+}
+
+/** Double click in list, edit question */
+void KEducaBuilder::slotEditbyList(QListBoxItem *item)
+{
+ if( item )
+ slotEdit();
+}
diff --git a/keduca/keducabuilder/keducabuilder.h b/keduca/keducabuilder/keducabuilder.h
new file mode 100644
index 00000000..74c5eb58
--- /dev/null
+++ b/keduca/keducabuilder/keducabuilder.h
@@ -0,0 +1,126 @@
+/***************************************************************************
+ keducabuilder.h - description
+ -------------------
+ begin : Sat May 26 2001
+ copyright : (C) 2001 by Javier Campos
+ email : javi@asyris.org
+***************************************************************************/
+
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+
+#ifndef KEDUCABUILDER_H
+#define KEDUCABUILDER_H
+
+#include "../libkeduca/fileread.h"
+
+#include <kmainwindow.h>
+
+#include <klistbox.h>
+#include <kaction.h>
+
+#include <qtextview.h>
+#include <qsplitter.h>
+
+/**Main control documents
+ * The Editor. This is the new main window of KEduca.
+ * You can edit a KEduca Document (i.e. Test/Examen) here.
+ *@author Javier Campos
+ */
+
+class KEducaBuilder : public KMainWindow {
+ Q_OBJECT
+
+public:
+ KEducaBuilder(QWidget* parent=0, const char *name=0, WFlags f = WType_TopLevel | WDestructiveClose);
+ ~KEducaBuilder();
+ /** start a dialog that asks the user what he wants to do to start*/
+ bool startChooser();
+ /** Init Internet Gallery Servers */
+ void initGallery(const KURL &urlFile = KURL());
+
+private:
+
+ // Private methods
+
+ /** Init graphical interface */
+ void init();
+ /** Init menu bar settings */
+ void initMenuBar();
+ /** Write settings */
+ void configWrite();
+ /** Read config data */
+ void configRead();
+ /** Check if the current document can save */
+ bool checkSave();
+
+ /** Save the file, return false if save failed for any reason */
+ bool fileSave();
+ /** Save the file under a user-chosen filename, return false if save as
+ failed for any reason */
+ bool fileSaveAs();
+
+ /** Ask the user if he wants to save the file if it has been changed.
+ Returns true if the file may be replaced (that is when he successfully saved it or said "Discard") */
+ bool currentFileMayBeReplaced();
+
+ // Private attributes
+
+ /** KEDUCA file */
+ FileRead *_keducaFile;
+ /** Recent files */
+ KRecentFilesAction *_recentFiles;
+ /** List of answers */
+ KListBox *_listAnswer;
+ /** Preview */
+ QTextView *_preview;
+ /** Main splitter */
+ QSplitter *_split;
+ /** I open a file */
+ bool _isOpenFile;
+ QString _nativeFormat;
+
+public slots:
+ /** Open new file */
+ void slotFileOpenURL( const KURL &url );
+ /** Delete current document and start new */
+ void slotFileOpenNew();
+
+private slots:
+ /** Open new document. */
+ void slotFileOpen();
+ /** Item select */
+ void slotPreview( QListBoxItem *item );
+ /** Close the window */
+ bool queryClose();
+ /** Edit question */
+ void slotEdit();
+ /** Add question */
+ void slotAdd();
+ /** Remove question */
+ void slotRemove();
+ /** Down record */
+ void slotDown();
+ /** Up record */
+ void slotUp();
+ /** Save As... */
+ void slotFileSaveAs();
+ /** Save file */
+ void slotFileSave();
+ /** Print file */
+ void slotFilePrint();
+ /** Header info */
+ int slotHeader();
+ /** Init Gallery */
+ void slotGallery();
+ /** Double click in list, edit question */
+ void slotEditbyList(QListBoxItem *item);
+};
+
+#endif
diff --git a/keduca/keducabuilder/keducabuilderui.rc b/keduca/keducabuilder/keducabuilderui.rc
new file mode 100644
index 00000000..0942cea9
--- /dev/null
+++ b/keduca/keducabuilder/keducabuilderui.rc
@@ -0,0 +1,28 @@
+<!DOCTYPE kpartgui >
+<kpartgui version="2" name="keducaEditor" >
+<MenuBar>
+ <Menu name="file"><text>&amp;File</text>
+ <Action name="open_gallery"/>
+ <Action name="info_doc"/>
+ </Menu>
+ <Menu name="Edit" ><text>&amp;Edit</text>
+ <Action name="question_add" />
+ <Action name="question_edit" />
+ <Action name="question_remove" />
+ <Separator lineSeparator="true"/>
+ <Action name="question_up" icon="up"/>
+ <Action name="question_down" icon="down"/>
+ </Menu>
+</MenuBar>
+<ToolBar name="mainToolBar" >
+ <Action name="info_doc" />
+</ToolBar>
+<ToolBar name="mainQuestionBar" >
+ <Action name="question_add" />
+ <Action name="question_edit" />
+ <Action name="question_remove" />
+ <Separator lineSeparator="true"/>
+ <Action name="question_up" icon="up"/>
+ <Action name="question_down" icon="down"/>
+</ToolBar>
+</kpartgui>
diff --git a/keduca/keducabuilder/keducaeditorstartdialog.cpp b/keduca/keducabuilder/keducaeditorstartdialog.cpp
new file mode 100644
index 00000000..88cf9305
--- /dev/null
+++ b/keduca/keducabuilder/keducaeditorstartdialog.cpp
@@ -0,0 +1,114 @@
+/***************************************************************************
+ keducaeditorstartdialog.cpp - description
+ -------------------
+ begin : Fri May 10 2002
+ copyright : (C) 2002 by Klas Kalass
+ email : klas@kde.org
+***************************************************************************/
+
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+#include <qradiobutton.h>
+#include <qbuttongroup.h>
+
+#include <kdebug.h>
+#include <kurlrequester.h>
+#include <kmessagebox.h>
+#include <klocale.h>
+#include <kconfig.h>
+#include <kcombobox.h>
+
+#include "keducaeditorstartdialog.h"
+#include "keducabuilder.h"
+
+/**
+ */
+KEducaEditorStartDialog::KEducaEditorStartDialog(KEducaBuilder * parent, const char* name, bool modal, WFlags fl)
+ :KEducaEditorStartDialogBase(parent, name, modal, fl),
+ _choice(NewDoc),
+ _maxRecentDocumentItems(20)
+{
+ newDocumentRB->setFocus();
+
+ // read recent files
+ buildRecentFilesList();
+
+// setup connections
+ urlRequester->setFilter( "application/x-edu");
+
+ connect( startChoiceBtnGrp, SIGNAL( clicked(int) ),
+ this, SLOT( slotChoiceChanged(int) ) );
+}
+
+/** based on code in kaction.cpp
+ */
+void KEducaEditorStartDialog::buildRecentFilesList()
+{
+ QString key;
+ QString value;
+ QString oldGroup;
+ KConfig *config = KGlobal::config();
+
+ oldGroup = config->group();
+
+ config->setGroup( "RecentFiles" );
+
+ // read file list
+ for( unsigned int i = 1 ; i <= _maxRecentDocumentItems ; i++ )
+ {
+ key = QString( "File%1" ).arg( i );
+ value = config->readEntry( key, QString::null );
+
+ if (!value.isNull())
+ recentDocumentCB->insertURL( KURL(value) );
+ }
+
+ config->setGroup( oldGroup );
+}
+
+KEducaEditorStartDialog::~KEducaEditorStartDialog() {
+
+}
+
+void KEducaEditorStartDialog::slotChoiceChanged(int id) {
+ _choice = id+1;
+}
+
+KURL KEducaEditorStartDialog::getURL()const{
+ switch(_choice) {
+ case OpenDoc:
+ return KURL(urlRequester->url());
+ break;
+ case OpenRecentDoc:
+ return KURL(recentDocumentCB->currentText());
+ break;
+ default:
+ break;
+ }
+
+ return KURL();
+}
+
+int KEducaEditorStartDialog::exec() {
+ int ret = KEducaEditorStartDialogBase::exec();
+ if ( ret == KEducaEditorStartDialogBase::Rejected )
+ _choice = KEducaEditorStartDialog::Rejected;
+
+ return _choice;
+}
+
+void KEducaEditorStartDialog::accept() {
+ if (((_choice == OpenDoc || _choice == OpenRecentDoc)
+ && getURL().isEmpty())) {
+ KMessageBox::sorry(this, i18n("You need to specify the file to open!"));
+ }else
+ KEducaEditorStartDialogBase::accept();
+}
+
+#include "keducaeditorstartdialog.moc"
diff --git a/keduca/keducabuilder/keducaeditorstartdialog.h b/keduca/keducabuilder/keducaeditorstartdialog.h
new file mode 100644
index 00000000..dd163848
--- /dev/null
+++ b/keduca/keducabuilder/keducaeditorstartdialog.h
@@ -0,0 +1,59 @@
+/***************************************************************************
+ keducaeditorstartdialog.h - description
+ -------------------
+ begin : Fri May 10 2002
+ copyright : (C) 2002 by Klas Kalass
+ email : klas@kde.org
+***************************************************************************/
+
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+
+#ifndef KEDUCAEDITORSTARTDIALOG_H
+#define KEDUCAEDITORSTARTDIALOG_H
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include "keducaeditorstartdialogbase.h"
+
+// forward declarations
+class KEducaBuilder;
+
+/**
+ */
+class KEducaEditorStartDialog : public KEducaEditorStartDialogBase{
+ Q_OBJECT
+public:
+ enum {Rejected=0, OpenDoc=1, OpenRecentDoc=2, Gallery=3, NewDoc=4}StartChoice;
+ /** Constructor.
+ */
+ KEducaEditorStartDialog(KEducaBuilder * parent = 0, const char* name = 0, bool modal = FALSE, WFlags fl = 0 );
+ /** Destructor.
+ */
+ virtual ~KEducaEditorStartDialog();
+
+ KURL getURL()const;
+ int exec();
+
+private:
+ KURL _selectedURL;
+ int _choice;
+ unsigned int const _maxRecentDocumentItems;
+ void buildRecentFilesList();
+
+protected slots:
+ void accept();
+
+private slots:
+ void slotChoiceChanged(int id);
+
+};
+#endif
diff --git a/keduca/keducabuilder/keducaeditorstartdialogbase.ui b/keduca/keducabuilder/keducaeditorstartdialogbase.ui
new file mode 100644
index 00000000..0cb69e39
--- /dev/null
+++ b/keduca/keducabuilder/keducaeditorstartdialogbase.ui
@@ -0,0 +1,320 @@
+<!DOCTYPE UI><UI version="3.2" stdsetdef="1">
+<class>KEducaEditorStartDialogBase</class>
+<widget class="QDialog">
+ <property name="name">
+ <cstring>KEducaEditorStartDialogBase</cstring>
+ </property>
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>511</width>
+ <height>311</height>
+ </rect>
+ </property>
+ <property name="caption">
+ <string>Editor - Getting Started</string>
+ </property>
+ <property name="sizeGripEnabled">
+ <bool>true</bool>
+ </property>
+ <vbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <property name="margin">
+ <number>11</number>
+ </property>
+ <property name="spacing">
+ <number>6</number>
+ </property>
+ <widget class="QButtonGroup">
+ <property name="name">
+ <cstring>startChoiceBtnGrp</cstring>
+ </property>
+ <property name="frameShape">
+ <enum>NoFrame</enum>
+ </property>
+ <property name="frameShadow">
+ <enum>Plain</enum>
+ </property>
+ <property name="title">
+ <string></string>
+ </property>
+ <vbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <property name="margin">
+ <number>11</number>
+ </property>
+ <property name="spacing">
+ <number>6</number>
+ </property>
+ <widget class="QLayoutWidget">
+ <property name="name">
+ <cstring>Layout13</cstring>
+ </property>
+ <vbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <property name="margin">
+ <number>0</number>
+ </property>
+ <property name="spacing">
+ <number>6</number>
+ </property>
+ <widget class="QRadioButton">
+ <property name="name">
+ <cstring>openDocumentRB</cstring>
+ </property>
+ <property name="focusPolicy">
+ <enum>NoFocus</enum>
+ </property>
+ <property name="text">
+ <string>Open an &amp;existing document:</string>
+ </property>
+ </widget>
+ <widget class="QLayoutWidget">
+ <property name="name">
+ <cstring>Layout4</cstring>
+ </property>
+ <hbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <property name="margin">
+ <number>0</number>
+ </property>
+ <property name="spacing">
+ <number>6</number>
+ </property>
+ <spacer>
+ <property name="name">
+ <cstring>Spacer4</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Horizontal</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Fixed</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>20</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ <widget class="KURLRequester">
+ <property name="name">
+ <cstring>urlRequester</cstring>
+ </property>
+ </widget>
+ </hbox>
+ </widget>
+ </vbox>
+ </widget>
+ <widget class="QRadioButton">
+ <property name="name">
+ <cstring>openRecentDocumentRB</cstring>
+ </property>
+ <property name="focusPolicy">
+ <enum>NoFocus</enum>
+ </property>
+ <property name="text">
+ <string>Open a &amp;recent document:</string>
+ </property>
+ <property name="checked">
+ <bool>false</bool>
+ </property>
+ </widget>
+ <widget class="QLayoutWidget">
+ <property name="name">
+ <cstring>Layout15</cstring>
+ </property>
+ <hbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <property name="margin">
+ <number>0</number>
+ </property>
+ <property name="spacing">
+ <number>6</number>
+ </property>
+ <spacer>
+ <property name="name">
+ <cstring>Spacer3</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Horizontal</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Fixed</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>20</width>
+ <height>21</height>
+ </size>
+ </property>
+ </spacer>
+ <widget class="KComboBox">
+ <property name="name">
+ <cstring>recentDocumentCB</cstring>
+ </property>
+ </widget>
+ </hbox>
+ </widget>
+ <widget class="QRadioButton">
+ <property name="name">
+ <cstring>radioButton4</cstring>
+ </property>
+ <property name="text">
+ <string>Open with Internet gallery browser</string>
+ </property>
+ </widget>
+ <widget class="QRadioButton">
+ <property name="name">
+ <cstring>newDocumentRB</cstring>
+ </property>
+ <property name="text">
+ <string>Start a &amp;new document</string>
+ </property>
+ <property name="checked">
+ <bool>true</bool>
+ </property>
+ </widget>
+ </vbox>
+ </widget>
+ <widget class="Line">
+ <property name="name">
+ <cstring>Line1</cstring>
+ </property>
+ <property name="frameShape">
+ <enum>HLine</enum>
+ </property>
+ <property name="frameShadow">
+ <enum>Sunken</enum>
+ </property>
+ <property name="orientation">
+ <enum>Horizontal</enum>
+ </property>
+ </widget>
+ <widget class="QLayoutWidget">
+ <property name="name">
+ <cstring>Layout1</cstring>
+ </property>
+ <hbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <property name="margin">
+ <number>0</number>
+ </property>
+ <property name="spacing">
+ <number>6</number>
+ </property>
+ <widget class="QPushButton">
+ <property name="name">
+ <cstring>buttonHelp</cstring>
+ </property>
+ <property name="text">
+ <string>&amp;Help</string>
+ </property>
+ <property name="autoDefault">
+ <bool>true</bool>
+ </property>
+ </widget>
+ <spacer>
+ <property name="name">
+ <cstring>Horizontal Spacing2</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Horizontal</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>20</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ <widget class="QPushButton">
+ <property name="name">
+ <cstring>buttonOk</cstring>
+ </property>
+ <property name="text">
+ <string>&amp;OK</string>
+ </property>
+ <property name="autoDefault">
+ <bool>true</bool>
+ </property>
+ <property name="default">
+ <bool>true</bool>
+ </property>
+ </widget>
+ <widget class="QPushButton">
+ <property name="name">
+ <cstring>buttonCancel</cstring>
+ </property>
+ <property name="text">
+ <string>&amp;Cancel</string>
+ </property>
+ <property name="autoDefault">
+ <bool>true</bool>
+ </property>
+ </widget>
+ </hbox>
+ </widget>
+ </vbox>
+</widget>
+<customwidgets>
+</customwidgets>
+<connections>
+ <connection>
+ <sender>buttonOk</sender>
+ <signal>clicked()</signal>
+ <receiver>KEducaEditorStartDialogBase</receiver>
+ <slot>accept()</slot>
+ </connection>
+ <connection>
+ <sender>buttonCancel</sender>
+ <signal>clicked()</signal>
+ <receiver>KEducaEditorStartDialogBase</receiver>
+ <slot>reject()</slot>
+ </connection>
+ <connection>
+ <sender>urlRequester</sender>
+ <signal>urlSelected(const QString&amp;)</signal>
+ <receiver>openDocumentRB</receiver>
+ <slot>animateClick()</slot>
+ </connection>
+ <connection>
+ <sender>recentDocumentCB</sender>
+ <signal>activated(int)</signal>
+ <receiver>openRecentDocumentRB</receiver>
+ <slot>animateClick()</slot>
+ </connection>
+</connections>
+<tabstops>
+ <tabstop>newDocumentRB</tabstop>
+ <tabstop>urlRequester</tabstop>
+ <tabstop>recentDocumentCB</tabstop>
+ <tabstop>buttonHelp</tabstop>
+ <tabstop>buttonOk</tabstop>
+ <tabstop>buttonCancel</tabstop>
+ <tabstop>openDocumentRB</tabstop>
+ <tabstop>openRecentDocumentRB</tabstop>
+</tabstops>
+<layoutdefaults spacing="6" margin="11"/>
+<includehints>
+ <includehint>klineedit.h</includehint>
+ <includehint>kpushbutton.h</includehint>
+</includehints>
+</UI>
diff --git a/keduca/keducabuilder/klangcombo.cpp b/keduca/keducabuilder/klangcombo.cpp
new file mode 100644
index 00000000..ebedd9dd
--- /dev/null
+++ b/keduca/keducabuilder/klangcombo.cpp
@@ -0,0 +1,51 @@
+/*
+ * klangcombo.cpp - Adds some methods for inserting languages.
+ *
+ * Copyright (c) 1999-2000 Hans Petter Bieker <bieker@kde.org>
+ *
+ * Requires the Qt widget libraries, available at no cost at
+ * http://www.troll.no/
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+
+#include <kstandarddirs.h>
+
+#include "klangcombo.h"
+#include "klangcombo.moc"
+
+KLanguageCombo::~KLanguageCombo ()
+{
+}
+
+KLanguageCombo::KLanguageCombo (QWidget * parent, const char *name)
+ : KTagComboBox(parent, name)
+{
+}
+
+void KLanguageCombo::insertLanguage(const QString& path, const QString& name, const QString& sub, const QString &submenu)
+{
+ QString output = name + QString::fromLatin1(" (") + path + QString::fromLatin1(")");
+ QPixmap flag(locate("locale", sub + path + QString::fromLatin1("/flag.png")));
+ insertItem(QIconSet(flag), output, path, submenu);
+}
+
+void KLanguageCombo::changeLanguage(const QString& name, int i)
+{
+ if (i < 0 || i >= count()) return;
+ QString output = name + QString::fromLatin1(" (") + tag(i) + QString::fromLatin1(")");
+ changeItem(output, i);
+}
diff --git a/keduca/keducabuilder/klangcombo.h b/keduca/keducabuilder/klangcombo.h
new file mode 100644
index 00000000..4c9fb801
--- /dev/null
+++ b/keduca/keducabuilder/klangcombo.h
@@ -0,0 +1,47 @@
+/*
+ * klangcombo.h - Adds some methods for inserting languages.
+ *
+ * Copyright (c) 1999-2000 Hans Petter Bieker <bieker@kde.org>
+ *
+ * Requires the Qt widget libraries, available at no cost at
+ * http://www.troll.no/
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+
+#ifndef __KLANGCOMBO_H__
+#define __KLANGCOMBO_H__
+
+#include "ktagcombobox.h"
+
+/*
+ * Extends KTagCombo to support adding and changing languages.
+ *
+ * It has also support for sub menues.
+ */
+class KLanguageCombo : public KTagComboBox
+{
+ Q_OBJECT
+
+public:
+ KLanguageCombo(QWidget *parent=0, const char *name=0);
+ ~KLanguageCombo();
+
+ void insertLanguage(const QString& path, const QString& name, const QString& sub = QString::null, const QString &submenu = QString::null);
+ void changeLanguage(const QString& name, int i);
+};
+
+#endif
diff --git a/keduca/keducabuilder/ktagcombobox.cpp b/keduca/keducabuilder/ktagcombobox.cpp
new file mode 100644
index 00000000..9b7e969e
--- /dev/null
+++ b/keduca/keducabuilder/ktagcombobox.cpp
@@ -0,0 +1,229 @@
+/*
+ * ktagcombobox.cpp - A combobox with support for submenues, icons and tags
+ *
+ * Copyright (c) 1999-2000 Hans Petter Bieker <bieker@kde.org>
+ *
+ * Requires the Qt widget libraries, available at no cost at
+ * http://www.troll.no/
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+#define INCLUDE_MENUITEM_DEF 1
+#include <qpainter.h>
+#include <qpopupmenu.h>
+#include <kdebug.h>
+
+
+#include "ktagcombobox.h"
+#include "ktagcombobox.moc"
+
+KTagComboBox::~KTagComboBox ()
+{
+ delete _popup;
+ delete _tags;
+}
+
+KTagComboBox::KTagComboBox (QWidget * parent, const char *name)
+ : QComboBox(parent, name)
+{
+ _popup = new QPopupMenu(this);
+ _tags = new QStringList;
+ connect( _popup, SIGNAL(activated(int)),
+ SLOT(internalActivate(int)) );
+ connect( _popup, SIGNAL(highlighted(int)),
+ SLOT(internalHighlight(int)) );
+}
+
+void KTagComboBox::popupMenu()
+{
+ _popup->popup( mapToGlobal( QPoint(0,0) ), _current );
+}
+
+void KTagComboBox::keyPressEvent( QKeyEvent *e )
+{
+ int c;
+
+ if ( ( e->key() == Key_F4 && e->state() == 0 ) ||
+ ( e->key() == Key_Down && (e->state() & AltButton) ) ||
+ ( e->key() == Key_Space ) ) {
+ if ( count() ) {
+ _popup->setActiveItem( _current );
+ popupMenu();
+ }
+ return;
+ } else {
+ e->ignore();
+ return;
+ }
+
+ c = currentItem();
+ emit highlighted( c );
+ emit activated( c );
+}
+
+void KTagComboBox::mousePressEvent( QMouseEvent * )
+{
+ popupMenu();
+}
+
+void KTagComboBox::internalActivate( int index )
+{
+ if (_current == index) return;
+ _current = index;
+ emit activated( index );
+ repaint();
+}
+
+void KTagComboBox::internalHighlight( int index )
+{
+ emit highlighted( index );
+}
+
+void KTagComboBox::clear()
+{
+ _popup->clear();
+ _tags->clear();
+}
+
+int KTagComboBox::count() const
+{
+ return _tags->count();
+}
+
+static inline QPopupMenu *checkInsertIndex(QPopupMenu *popup, const QStringList *tags, const QString &submenu, int *index)
+{
+ int pos = tags->findIndex(submenu);
+
+ QPopupMenu *pi = 0;
+ if (pos != -1)
+ {
+ QMenuItem *p = popup->findItem(popup->idAt(pos));
+ pi = p?p->popup():0;
+ }
+ if (!pi) pi = popup;
+
+ if (*index > (int)pi->count())
+ *index = -1;
+
+ return pi;
+}
+
+void KTagComboBox::insertItem(const QIconSet& icon, const QString &text, const QString &tag, const QString &submenu, int index )
+{
+ QPopupMenu *pi = checkInsertIndex(_popup, _tags, submenu, &index);
+ pi->insertItem(icon, text, count(), index);
+ _tags->append(tag);
+}
+
+void KTagComboBox::insertItem(const QString &text, const QString &tag, const QString &submenu, int index )
+{
+ QPopupMenu *pi = checkInsertIndex(_popup, _tags, submenu, &index);
+ pi->insertItem(text, count(), index);
+ _tags->append(tag);
+}
+
+void KTagComboBox::insertSeparator(const QString &submenu, int index)
+{
+ QPopupMenu *pi = checkInsertIndex(_popup, _tags, submenu, &index);
+ pi->insertSeparator(index);
+ _tags->append(QString::null);
+}
+
+void KTagComboBox::insertSubmenu(const QString &text, const QString &tag, const QString &submenu, int index)
+{
+ QPopupMenu *pi = checkInsertIndex(_popup, _tags, submenu, &index);
+ QPopupMenu *p = new QPopupMenu(pi);
+ pi->insertItem(text, p, count(), index);
+ _tags->append(tag);
+ connect( p, SIGNAL(activated(int)),
+ SLOT(internalActivate(int)) );
+ connect( p, SIGNAL(highlighted(int)),
+ SLOT(internalHighlight(int)) );
+}
+
+void KTagComboBox::changeItem( const QString &text, int index )
+{
+ _popup->changeItem( text, index);
+ if (index == _current)
+ repaint();
+}
+
+void KTagComboBox::paintEvent( QPaintEvent * ev)
+{
+ QComboBox::paintEvent(ev);
+
+ QPainter p (this);
+
+ // Text
+ QRect clip(2, 2, width() - 4, height() - 4);
+ if ( hasFocus())
+ p.setPen( colorGroup().highlightedText() );
+ p.drawText(clip, AlignCenter | SingleLine, _popup->text( _current ));
+
+ // Icon
+ QIconSet *icon = _popup->iconSet( _current );
+ if (icon) {
+ QPixmap pm = icon->pixmap();
+ p.drawPixmap( 4, (height()-pm.height())/2, pm );
+ }
+}
+
+bool KTagComboBox::containsTag( const QString &str ) const
+{
+ return _tags->contains(str) > 0;
+}
+
+QString KTagComboBox::currentTag() const
+{
+ return *_tags->at(currentItem());
+}
+
+QString KTagComboBox::tag(int i) const
+{
+ if (i < 0 || i >= count())
+ {
+ kdDebug() << "KTagComboBox::tag(), unknown tag " << i << endl;
+ return QString::null;
+ }
+ return *_tags->at(i);
+}
+
+int KTagComboBox::currentItem() const
+{
+ return _current;
+}
+
+void KTagComboBox::setCurrentItem(int i)
+{
+ if (i < 0 || i >= count()) return;
+ _current = i;
+ repaint();
+}
+
+void KTagComboBox::setCurrentItem(const QString &code)
+{
+ int i = _tags->findIndex(code);
+ if (code.isNull())
+ i = 0;
+ if (i != -1)
+ setCurrentItem(i);
+}
+
+void KTagComboBox::setFont( const QFont &font )
+{
+ QComboBox::setFont( font );
+ _popup->setFont( font );
+}
diff --git a/keduca/keducabuilder/ktagcombobox.h b/keduca/keducabuilder/ktagcombobox.h
new file mode 100644
index 00000000..099c6561
--- /dev/null
+++ b/keduca/keducabuilder/ktagcombobox.h
@@ -0,0 +1,94 @@
+/*
+ * ktagcombobox.h - A combobox with support for submenues, icons and tags
+ *
+ * Copyright (c) 1999-2000 Hans Petter Bieker <bieker@kde.org>
+ *
+ * Requires the Qt widget libraries, available at no cost at
+ * http://www.troll.no/
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+
+#ifndef __KTAGCOMBOBOX_H__
+#define __KTAGCOMBOBOX_H__
+
+#include <qcombobox.h>
+#include <qiconset.h>
+class QPopupMenu;
+class QStringList;
+
+/*
+ * This class should be just like qcombobox, but it should be possible
+ * to have have a QIconSet for each entry, and each entry should have a tag.
+ *
+ * It has also support for sub menues.
+ */
+class KTagComboBox : public QComboBox
+{
+ Q_OBJECT
+
+public:
+ KTagComboBox(QWidget *parent=0, const char *name=0);
+ ~KTagComboBox();
+
+ void insertItem(const QIconSet& icon, const QString &text, const QString &tag, const QString &submenu = QString::null, int index=-1 );
+ void insertItem(const QString &text, const QString &tag, const QString &submenu = QString::null, int index=-1 );
+ void insertSeparator(const QString &submenu = QString::null, int index=-1 );
+ void insertSubmenu(const QString &text, const QString &tag, const QString &submenu = QString::null, int index=-1);
+ void changeItem( const QString &text, int index );
+
+ int count() const;
+ void clear();
+
+ /*
+ * Tag of the selected item
+ */
+ QString currentTag() const;
+ QString tag ( int i ) const;
+ bool containsTag (const QString &str ) const;
+
+ /*
+ * Set the current item
+ */
+ int currentItem() const;
+ void setCurrentItem(int i);
+ void setCurrentItem(const QString &code);
+
+ // widget stuff
+ virtual void setFont( const QFont & );
+
+signals:
+ void activated( int index );
+ void highlighted( int index );
+
+private slots:
+ void internalActivate( int );
+ void internalHighlight( int );
+
+protected:
+ void paintEvent( QPaintEvent * );
+ void mousePressEvent( QMouseEvent * );
+ void keyPressEvent( QKeyEvent *e );
+ void popupMenu();
+
+private:
+ // work space for the new class
+ QStringList *_tags;
+ QPopupMenu *_popup;
+ int _current;
+};
+
+#endif
diff --git a/keduca/keducabuilder/main.cpp b/keduca/keducabuilder/main.cpp
new file mode 100644
index 00000000..93a49cdf
--- /dev/null
+++ b/keduca/keducabuilder/main.cpp
@@ -0,0 +1,67 @@
+/***************************************************************************
+ main.cpp - description
+ -------------------
+ begin : mié may 23 20:36:15 CEST 2001
+ copyright : (C) 2001 by Javier Campos
+ email : javi@asyris.org
+***************************************************************************/
+
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+
+#include <kcmdlineargs.h>
+#include <kapplication.h>
+#include <kaboutdata.h>
+#include <kdebug.h>
+
+#include <qfileinfo.h>
+#include "keducabuilder.h"
+
+static const char description[] = I18N_NOOP("Form-based tests and exams builder");
+static const char version[] = "1.2.0";
+
+static KCmdLineOptions options[] =
+{
+ { "+file", I18N_NOOP("File to load"), 0 },
+ KCmdLineLastOption
+};
+
+int main(int argc, char *argv[])
+{
+ KAboutData aboutData( "keduca", I18N_NOOP("KEducaBuilder"),
+ version, description, KAboutData::License_GPL,
+ "(c) 2001, Javier Campos", 0, "http://keduca.sourceforge.net", "submit@bugs.kde.org");
+ aboutData.addAuthor("Javier Campos",I18N_NOOP("Original Author"), "javi@asyris.org");
+ aboutData.addAuthor("Klas Kalass",I18N_NOOP("Maintainer 2002-2004"), "klas@kde.org");
+ aboutData.addAuthor("Anne-Marie Mahfouf",I18N_NOOP("Various fixes and cleanups"), "annma@kde.org");
+ aboutData.addCredit("Nenad Grujicic", I18N_NOOP("Icons"), "mengele@linuxo.org");
+ KCmdLineArgs::init( argc, argv, &aboutData );
+ KCmdLineArgs::addCmdLineOptions( options ); // Add our own options.
+
+ KApplication a;
+ KCmdLineArgs *args = KCmdLineArgs::parsedArgs();
+
+ // start as KEduca Builder
+ KEducaBuilder *keducaEditor = new KEducaBuilder();
+ a.setMainWidget(keducaEditor);
+ keducaEditor->show();
+
+ if ( args->count() > 0 ){
+ if( QFileInfo( KURL(args->url(0)).url() ).extension() == "edugallery" )
+ keducaEditor->initGallery( args->url(0) );
+ else
+ keducaEditor->slotFileOpenURL( args->url(0) );
+ }else
+ keducaEditor->startChooser();
+
+
+ args->clear();
+
+ return a.exec();
+}