summaryrefslogtreecommitdiff
path: root/src/main-view/MainWindow.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/main-view/MainWindow.h')
-rw-r--r--src/main-view/MainWindow.h218
1 files changed, 218 insertions, 0 deletions
diff --git a/src/main-view/MainWindow.h b/src/main-view/MainWindow.h
new file mode 100644
index 0000000..5165118
--- /dev/null
+++ b/src/main-view/MainWindow.h
@@ -0,0 +1,218 @@
+#ifndef MAINWINDOW_H
+#define MAINWINDOW_H
+
+#include <QtWidgets>
+
+class AppModel;
+class DictTableView;
+class Dictionary;
+class IStudyWindow;
+class FindPanel;
+class CardPreview;
+class RecentFilesManager;
+class DicRecord;
+class Card;
+class CardPack;
+class WelcomeScreen;
+
+#include "UndoCommands.h"
+#include "DictionaryTabWidget.h"
+
+class MainWindow: public QMainWindow
+{
+ Q_OBJECT
+
+public:
+ MainWindow(AppModel* model);
+ ~MainWindow();
+
+ const DictTableView* getCurDictView() const;
+ QList<QAction*> getContextMenuActions() const { return contextMenuActions; }
+
+ void showContinueSearch() { dictTabWidget->showContinueSearch(); }
+ void goToDictionaryRecord( const Dictionary* aDictionary, int aRecordRow );
+
+public slots:
+ void openFile(const QString& filePath);
+
+private:
+ void init();
+ void addDictTab(Dictionary* dict);
+
+ void createActions();
+ void createFileActions();
+ void createEditActions();
+ void createAddImageAct();
+ void createinsertRecordsAct();
+ void createInsertRecordsAfterAct();
+ void createRemoveRecordsAct();
+ void createDictContextMenuActions();
+ void createSelectionActions();
+ void createToolsActions();
+ void createSettingsActions();
+ void createHelpActions();
+ void initActions();
+
+ void createMenus();
+ void createToolBars();
+ void createStatusBar();
+
+ void createCentralWidget();
+ void updateMainStackedWidget(int tabIndex);
+ QWidget* createDictionaryView();
+
+ void createDockWindows();
+ void createPacksTreeDock();
+ void createCardPreviewDock();
+
+ void readSettings();
+ void writeSettings();
+ bool doSave( const QString& aFilePath, bool aChangeFilePath = true );
+ bool proposeToSave();
+ void openSession();
+ void closeEvent(QCloseEvent *event);
+ void saveGeneralSettings();
+ void saveSession();
+ void loadGeneralSettings();
+
+ void updatePackSelection( int aDic = -1 );
+ Dictionary* getCurDict();
+ QString selectAddImageFile();
+ void checkAddImagePath();
+ QString copyImageFileToImagesDir(const QString& filePath);
+ QString createNewImageFilePath(const QString& dicImagesDir, const QString& filePath);
+ QString createImagesDirFilePath(const QString& dicImagesDir, const QString& filePath,
+ int suffixNum);
+ int getCurEditorCursorPos();
+ int getCurRow();
+ int getCurColumn();
+ void insertImageIntoCurEditor(int cursorPos, const QString& filePath);
+
+ void createFileMenu();
+ void createOptionsMenu();
+ void createRecentFilesMenu();
+
+ CardPack* getCurCardPack() const;
+ const DicRecord* getCurDictRecord() const;
+ const DicRecord* getCurDictRecord(const Dictionary* dict,
+ const QAbstractItemView* dictView) const;
+ Card* getCurCardFromPack(CardPack* pack) const;
+ bool isDictOpened(int index);
+ void setCurDictionary(int index);
+ void openFileWithDialog(const QString& dirPath);
+ bool loadFile(const QString& filePath);
+ void showOpenFileError();
+ void updateAfterOpenedDictionary(const QString& filePath);
+
+public slots:
+ void updateDictTab();
+ void updateActions();
+ void updatePasteAction();
+ void updateSelectionActions();
+ bool proposeToSave(int i);
+
+private slots:
+ void activate();
+ void curTabChanged(int tabIndex);
+ void updatePacksTreeView();
+ void updateCardPreview();
+ void updateAddImageAction();
+ void newFile();
+ void openFileWithDialog();
+ void openOnlineDictionaries();
+ bool Save();
+ bool saveStudy();
+ bool SaveAs( bool aChangeFilePath = true );
+ void SaveCopy();
+ void importFromCsv();
+ void exportToCsv();
+
+ void copyEntries();
+ void cutEntries();
+ void pasteEntries();
+ void addImage();
+ void insertRecords();
+ void removeRecords();
+ void pushToUnoStack(QUndoCommand* command);
+ void find();
+ void findAgain();
+ void openDictionaryOptions();
+ void openFontColorSettings();
+ void openStudySettings();
+
+ void startStudy(int aStudyType);
+ void startSpacedRepetitionStudy();
+ void help();
+ void about();
+ void updateTotalRecordsLabel();
+ void setCurDictTab(int index);
+ void setCurDictTabByTreeIndex(const QModelIndex& aIndex);
+ void showStatistics();
+
+ void saveStudyWithDelay(bool studyModified);
+
+private:
+ static const int AutoSaveStudyInterval = 3 * 60 * 1000; // ms
+
+private:
+ QString workPath;
+ QString addImagePath;
+ AppModel* model; // not own
+
+ // UI elements
+ QStackedWidget* mainStackedWidget;
+ DictionaryTabWidget* dictTabWidget;
+ WelcomeScreen* welcomeScreen;
+ QLabel* totalRecordsLabel;
+ QPointer<IStudyWindow> studyWindow;
+ FindPanel* findPanel;
+ QTreeView* packsTreeView;
+ CardPreview* cardPreview;
+
+ QMenu* fileMenu;
+ QMenu* editMenu;
+ QMenu* viewMenu;
+ QMenu* toolsMenu;
+ QMenu* optionsMenu;
+ QMenu* helpMenu;
+
+ RecentFilesManager* recentFilesMan;
+
+ // Actions
+ QAction* newAct;
+ QAction* loadAct;
+ QAction* openFlashcardsAct;
+ QAction* saveAct;
+ QAction* saveAsAct;
+ QAction* saveCopyAct;
+ QAction* importAct;
+ QAction* exportAct;
+ QAction* removeTabAct;
+ QAction* quitAct;
+
+ QAction* undoAct;
+ QAction* redoAct;
+ QAction* cutAct;
+ QAction* copyAct;
+ QAction* pasteAct;
+ QAction* addImageAct;
+ QAction* insertRecordsAct;
+ QAction* removeRecordsAct;
+ QAction* findAgainAct;
+ QAction* findAct;
+ QList<QAction*> contextMenuActions;
+ QList<QAction*> selectionActions;
+
+ QAction* wordDrillAct;
+ QAction* spacedRepetitionAct;
+ QAction* statisticsAct;
+
+ QAction* dictionaryOptionsAct;
+ QAction* fontColorSettingsAct;
+ QAction* studySettingsAct;
+
+ QAction* helpAct;
+ QAction* aboutAct;
+};
+
+#endif