/**************************************************************************
 *  This file is part of QXmlEdit                                         *
 *  Copyright (C) 2011 by Luca Bellonda and individual contributors       *
 *    as indicated in the AUTHORS file                                    *
 *  lbellonda _at_ gmail.com                                              *
 *                                                                        *
 * This library is free software; you can redistribute it and/or          *
 * modify it under the terms of the GNU Library General Public            *
 * License as published by the Free Software Foundation; either           *
 * version 2 of the License, or (at your option) any later version.       *
 *                                                                        *
 * This library 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      *
 * Library General Public License for more details.                       *
 *                                                                        *
 * You should have received a copy of the GNU Library General Public      *
 * License along with this library; if not, write to the                  *
 * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,       *
 * Boston, MA  02110-1301  USA                                            *
 **************************************************************************/
#ifndef QXMLEDITDATA_H
#define QXMLEDITDATA_H

#include <QObject>

#include "libQXmlEdit_global.h"

#include "xmlEdit.h"
#include "style.h"
#include "plugin.h"

#include <QtNetwork/QNetworkDiskCache>
#include <QtNetwork/QNetworkAccessManager>

#define STYLE_DIR_USESTD    "Standard"
#define STYLE_DIR_USEDIR    "Directory"
#define STYLE_DIR_USEAPPL    "Application"

enum EStylesDir {
    ESTYLE_DIR_USESTD,
    ESTYLE_DIR_USEDIR ,
    ESTYLE_DIR_USEAPPL
};


class XsdPlugin;

class LIBQXMLEDITSHARED_EXPORT QXmlEditData : public QObject
{

    Q_OBJECT
protected:
    QVector<VStyle*>  _styles;
    VStyle*  _defaultStyle;
    QNetworkAccessManager _networkAccessManager ;
    bool _experimentalFeaturesEnabled;

    VStyle *creatDefaultStyle();
    bool loadStyles();

public:
    QXmlEditData();
    virtual ~QXmlEditData();


    virtual void init();
    virtual void end();

    VStyle* getStyle(const QString &tag) const;
    VStyle* defaultStyle() const ;
    const QVector<VStyle*> &getStyles() const ;

    EStylesDir getStylesDirLocation();
    void setStylesDirLocation(const EStylesDir type);

    QString getStylesDirSpecific();
    QString getStylesDirStandard();
    QString getStylesDirApplication();

    QString snippetsLocalDir();
    QString snippetsProgramDir();
    static QString getResourceDir();
    static QString getDocsDir();

    IQXmlEditPlugIn *xsdPlugin();

    //--- region(xsd)
    bool isAutovalidationOn();
    void setAutovalidationOn(const bool newState);
    //--- endregion(xsd)

    //--- region(behaviour)
    void enableAutoscroll(const bool enabled);
    bool isAutoscroll();
    //--- endregion(behaviour)

    //--- region(network)
    QNetworkAccessManager *xsdNetworkAccessManager() ;
    //--- endregion(network)

    QString predefinedStyleName();

    //--- region(experimental)
    bool areExperimentalFeaturesEnabled();
    void setExperimentalFeaturesEnabled(const bool value);
    //--- endregion(experimental)

};


#endif // QXMLEDITDATA_H
