OpenMW
apps/opencs/view/settings/abstractpage.hpp
Go to the documentation of this file.
00001 #ifndef ABSTRACTPAGE_HPP
00002 #define ABSTRACTPAGE_HPP
00003 
00004 #include <QWidget>
00005 #include <QList>
00006 #include <QLayout>
00007 
00008 #include "abstractblock.hpp"
00009 
00010 class SettingMap;
00011 class SettingList;
00012 
00013 namespace CSVSettings {
00014 
00015     typedef QList<AbstractBlock *> AbstractBlockList;
00016 
00018 
00022     class AbstractPage: public QWidget
00023     {
00024 
00025     protected:
00026 
00027         AbstractBlockList mAbstractBlocks;
00028 
00029     public:
00030 
00031         AbstractPage(QWidget *parent = 0);
00032         AbstractPage (const QString &pageName, QWidget* parent = 0);
00033 
00034         ~AbstractPage();
00035 
00036         virtual void setupUi() = 0;
00037 
00040         virtual void initializeWidgets (const CSMSettings::SettingMap &settings) = 0;
00041 
00043         CSMSettings::SettingList *getSettings();
00044 
00045         void setObjectName();
00046 
00047     protected:
00048 
00052         template <typename S, typename T>
00053         AbstractBlock *buildBlock (T *def)
00054         {
00055             S *block = new S (this);
00056             int ret = block->build (def);
00057 
00058             if (ret < 0)
00059                 return 0;
00060 
00061             QGroupBox *box = block->getGroupBox();
00062             QWidget::layout()->addWidget (box);
00063 
00064             return block;
00065         }
00066 
00067     };
00068 }
00069 
00070 #endif // ABSTRACTPAGE_HPP