#ifndef ISTUDYWINDOW_H #define ISTUDYWINDOW_H #include #include #include "../main-view/AppModel.h" class IStudyModel; class Card; class Dictionary; class QProgressBar; class CardSideView; class DictTableView; class CardEditDialog; class IStudyWindow: public QWidget { Q_OBJECT protected: enum { StateAnswerHidden, StateAnswerVisible, StateNoCards, StatesNum }; public: IStudyWindow(IStudyModel* aModel, QString aStudyName, QWidget* aParent); virtual ~IStudyWindow(); AppModel::StudyType getStudyType() const { return studyType; } IStudyModel* studyModel() const { return m_model; } const DictTableView* cardEditView() const; protected: void createUI(); virtual QVBoxLayout* createLowerPanel() = 0; virtual void setStateForNextCard(); virtual void processState() = 0; virtual void ReadSettings() = 0; virtual QWidget* getAnswerEdit() { return NULL; } virtual QWidget* getUserAnswerLabel() { return NULL; } QString ShortcutToStr( QAbstractButton* aButton ); bool bigScreen() { return QApplication::desktop()->screenGeometry().height()> 250; } private: QVBoxLayout* createMessageLayout(); QLabel* createMessageLabel(); QWidget* createWrapper(QBoxLayout* layout); QPushButton* createClosePackButton(); QHBoxLayout* createUpperPanel(); QToolButton* createEditCardButton(); QToolButton* createDeleteCardButton(); QVBoxLayout* createCardView(); QBoxLayout* createAnswerButtonLayout(); QPushButton* createAnswerButton(); QBoxLayout* createAnswerLayout(); protected slots: void OnDictionaryRemoved(); void showNextCard(); ///< Entry point for showing a new card void showAnswer(); ///< Entry point for showing the answer void updateCurCard(); ///< Update the card after pack re-generation void invalidateCurCard() { curCard = NULL; } void openCardEditDialog(); void deleteCard(); void updateToolBarVisibility(int index); protected: static const int AnsButtonPage; static const int AnsLabelPage; static const int CardPage; static const int MessagePage; AppModel::StudyType studyType; IStudyModel* m_model; const Card* curCard; int state; QString m_studyName; QToolButton* editCardBtn; QToolButton* deleteCardBtn; QStackedLayout* centralStackedLt; QLabel* messageLabel; QStackedLayout* answerStackedLt; QPushButton* answerBtn; CardSideView* questionLabel; CardSideView* answerLabel; private: static const int MinWidth = 500; static const int MaxWidth = 800; static const int ToolBarButtonSize = 24; static const int ToolBarIconSize = 16; static const int BigButtonWidth = 160; static const int BigButtonHeight = 50; QWidget* m_parentWidget; CardEditDialog* m_cardEditDialog; }; #endif