/*
Copyright (c) 2007 Matt Williams matt@milliams.com

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) version 3 or, at the discretion of KDE e.V. (which shall
act as a proxy as in section 14 of the GPLv3), 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, see <http://www.gnu.org/licenses/>.
*/

#ifndef KEDUCAMAINWIDGETT_H
#define KEDUCAMAINWIDGETT_H

#include "ui_keducamainwidget.h"

#include <QModelIndex>
#include <QDomDocument>
#include <QStandardItem>

class KQtiAssessmentTest;
class KQtiAssessmentItemRef;

/**
 * \class KEducaMainWidget
 * 
 * The list view represents the assessmentTest file. The data for the itemRef
 * items is an object of type KQtiAssessmentItem.
 */

class KEducaMainWidget : public QWidget, public Ui::KEducaMainWidget
{
    Q_OBJECT
    
    public:
        KEducaMainWidget(QWidget* parent = 0);
        ~KEducaMainWidget();
        
        void setAssessmentTest(KQtiAssessmentTest* testItem);
        /**
         * 
         * @return a list of items which refer to an assessmentItemRef
         */
        QMap<KQtiAssessmentItem*,KQtiAssessmentItemRef*> assessmentItemRefs() const;
        
    protected:
        KQtiAssessmentTest* mTestItem;
        QDomDocument documentFromFile(const QString& fileName);
        
        QList<QStandardItem*> assessmentItemRefSearch(const QModelIndex& index, QList<QStandardItem*> list) const;
        
    protected slots:
        /**
         * Called when a tree item is clicked. This sets up the editor widget
         */
        void setWidgetItem(const QModelIndex& index);
        /**
         * Called from KEducaAssessmentSectionEditor
         */
        void addQuestion(bool);
};

#endif
