2009-02-05 14:21:47 +00:00
|
|
|
/* This file is (c) 2008-2009 Konstantin Isakov <ikm@users.berlios.de>
|
2009-01-28 20:55:45 +00:00
|
|
|
* Part of GoldenDict. Licensed under GPLv3 or later, see the LICENSE file */
|
|
|
|
|
|
|
|
#ifndef __SOURCES_HH_INCLUDED__
|
|
|
|
#define __SOURCES_HH_INCLUDED__
|
|
|
|
|
|
|
|
#include "ui_sources.h"
|
|
|
|
#include "config.hh"
|
2009-03-26 19:00:08 +00:00
|
|
|
#include <QAbstractItemModel>
|
|
|
|
|
|
|
|
/// A model to be projected into the mediawikis view, according to Qt's MVC model
|
|
|
|
class MediaWikisModel: public QAbstractItemModel
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
|
|
|
MediaWikisModel( QWidget * parent, Config::MediaWikis const & );
|
|
|
|
|
|
|
|
void removeWiki( int index );
|
|
|
|
void addNewWiki();
|
|
|
|
|
|
|
|
/// Returns the wikis the model currently has listed
|
|
|
|
Config::MediaWikis const & getCurrentWikis() const
|
|
|
|
{ return mediawikis; }
|
|
|
|
|
|
|
|
QModelIndex index( int row, int column, QModelIndex const & parent ) const;
|
|
|
|
QModelIndex parent( QModelIndex const & parent ) const;
|
|
|
|
Qt::ItemFlags flags( QModelIndex const & index ) const;
|
|
|
|
int rowCount( QModelIndex const & parent ) const;
|
|
|
|
int columnCount( QModelIndex const & parent ) const;
|
|
|
|
QVariant headerData( int section, Qt::Orientation orientation, int role ) const;
|
|
|
|
QVariant data( QModelIndex const & index, int role ) const;
|
|
|
|
bool setData( QModelIndex const & index, const QVariant & value, int role );
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
|
|
|
Config::MediaWikis mediawikis;
|
|
|
|
};
|
|
|
|
|
2009-03-28 22:37:03 +00:00
|
|
|
/// A model to be projected into the paths view, according to Qt's MVC model
|
|
|
|
class PathsModel: public QAbstractItemModel
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
|
|
|
PathsModel( QWidget * parent, Config::Paths const & );
|
|
|
|
|
|
|
|
void removePath( int index );
|
|
|
|
void addNewPath( QString const & );
|
|
|
|
|
|
|
|
/// Returns the paths the model currently has listed
|
|
|
|
Config::Paths const & getCurrentPaths() const
|
|
|
|
{ return paths; }
|
|
|
|
|
|
|
|
QModelIndex index( int row, int column, QModelIndex const & parent ) const;
|
|
|
|
QModelIndex parent( QModelIndex const & parent ) const;
|
|
|
|
Qt::ItemFlags flags( QModelIndex const & index ) const;
|
|
|
|
int rowCount( QModelIndex const & parent ) const;
|
|
|
|
int columnCount( QModelIndex const & parent ) const;
|
|
|
|
QVariant headerData( int section, Qt::Orientation orientation, int role ) const;
|
|
|
|
QVariant data( QModelIndex const & index, int role ) const;
|
|
|
|
bool setData( QModelIndex const & index, const QVariant & value, int role );
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
|
|
|
Config::Paths paths;
|
|
|
|
};
|
2009-01-28 20:55:45 +00:00
|
|
|
|
|
|
|
class Sources: public QDialog
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
2009-03-26 19:00:08 +00:00
|
|
|
Sources( QWidget * parent, Config::Paths const &, Config::MediaWikis const & );
|
2009-01-28 20:55:45 +00:00
|
|
|
|
|
|
|
Config::Paths const & getPaths() const
|
2009-03-28 22:37:03 +00:00
|
|
|
{ return pathsModel.getCurrentPaths(); }
|
2009-01-28 20:55:45 +00:00
|
|
|
|
2009-03-26 19:00:08 +00:00
|
|
|
Config::MediaWikis const & getMediaWikis() const
|
|
|
|
{ return mediawikisModel.getCurrentWikis(); }
|
|
|
|
|
2009-01-28 20:55:45 +00:00
|
|
|
private:
|
|
|
|
Ui::Sources ui;
|
2009-03-26 19:00:08 +00:00
|
|
|
MediaWikisModel mediawikisModel;
|
2009-03-28 22:37:03 +00:00
|
|
|
PathsModel pathsModel;
|
|
|
|
|
|
|
|
void fitPathsColumns();
|
2009-01-28 20:55:45 +00:00
|
|
|
|
|
|
|
private slots:
|
|
|
|
|
2009-03-28 22:37:03 +00:00
|
|
|
void on_addPath_clicked();
|
|
|
|
void on_removePath_clicked();
|
2009-03-26 19:00:08 +00:00
|
|
|
|
|
|
|
void on_addMediaWiki_clicked();
|
|
|
|
void on_removeMediaWiki_clicked();
|
2009-01-28 20:55:45 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|