00001 #ifndef MAINWINDOW_H
00002 #define MAINWINDOW_H
00003
00004 #include <QMainWindow>
00005 #include "ui_MainWindow.h"
00006 #include "../Updater/updaterthread.h"
00007 #include "../Updater/updatermanifestthread.h"
00008 #include "../Updater/manifestdata.h"
00009 #include "../Mail/mailerthread.h"
00010 #include "../Data/settings.h"
00011 #include "../Views/accountgraphicsproxywidget.h"
00012 #include "../Dialogs/accountdialog.h"
00013 #include "../Dialogs/settingsdialog.h"
00014 #include "../Widgets/datecalendar.h"
00015
00016 class QProgressBar;
00017 class PupilActions;
00018 class TeacherActions;
00019 class StartActions;
00020 class DataProject;
00021 class DataExercise;
00022 class DescriptionWidget;
00023 class AccountingRecordWidget;
00024 class AccountingModel;
00025 class SelectTableOfAccountDialog;
00026 class AboutData;
00027
00028 class MainWindow : public QMainWindow, private Ui::MainWindow
00029 {
00030 Q_OBJECT
00031
00032 public:
00033 MainWindow(QMainWindow *parent = 0);
00034
00035 protected:
00036 void closeEvent(QCloseEvent *event);
00037
00038 public slots:
00039 void showSettingsDialog();
00040 void restoreLastGemoetry(QByteArray);
00041 void createPupilTree(QModelIndex);
00042 void createTeacherTree(QModelIndex);
00043 void printErrorMessage(QString);
00044
00045 private slots:
00046 void showNewFileDialog();
00047 void createFile(FileType::Type fileType, QString fileName);
00048 void createStudentDocument();
00049 void finishStudentDocumentCreation(const QString &tableOfAccountsPath);
00050
00051 void openFile();
00052 void openStudentDocument();
00053 void openTableOfAccounts();
00054
00055 void saveFile();
00056 void saveFileAs();
00057 void closeFile();
00058
00059 void about();
00060
00061 void reportBugs();
00062 void bugReportSent();
00063 void bugReportSendError(QString message);
00064
00065 void showProjectInformation();
00066 void openHelpBrowser();
00067 void print();
00068 void printPreview();
00069 void showUpdaterDialog();
00070 void teacherPupilSwitch();
00071 void changeButtonAndDescriptionWidget(bool check);
00072 void changeButtonAndAccountingRecordWidget(bool check);
00073 void changeButtonAndSolutionWidget(bool check);
00074 void changeButtonAndOpeningStockWidget(bool check);
00075 void showSolution();
00076 void hideSolution();
00077 void clearEverything();
00078 void drawAccounts();
00079
00080 void setExerciseStates(QList<int> items);
00081
00082 void manifestParsed();
00083 void mainfestErrorOccured();
00084
00085 signals:
00086 void exerciseReadyForReading(QString path);
00087
00088 private:
00089 void applyApplicationName();
00090 void init();
00091 void initUpdateControls();
00092 void applyQtHacks();
00093 void setWindowTitle();
00094 void createActions();
00095 void createSideBar();
00096 void changeEntryStates(bool);
00097 void setCurrentSidebarTab(int index);
00098 void setEncoding();
00099 void initializePrinter();
00100 void switchApplicationMode();
00101 void refreshOpeningStocks();
00102 void refreshExistingAccountingRecords();
00103 bool existAccountByNumber(QString number);
00104 int positionInAccountListByAccountNumber(QString number);
00105 bool existsDialogInSizePositionList(QString title);
00106 int positionInSizePositionList(QString title);
00107 AccountDialog* makeAccountDialog(AccountingModel* model, QString title);
00108 double currentScaleFactor;
00109 void checkForUpdates();
00110 void closeAndCleanup();
00111 int askCloseFile();
00112 void saveAccountingRecordsIntoDataStructures();
00113
00114 QString path;
00115 FileType::Type f_type;
00116 DataProject *currentProject;
00117 AccountModel *currentAccountModel;
00118 DataExercise *currentExercise;
00119 QList<QPair<QPointer<AccountDialog>, QPointer<AccountingModel> > > p_accountList;
00120 QList<QPair<QString, QPointF> > p_accountListPosition;
00121 QList<QPair<QString, QSize> > p_accountListSize;
00122 QList<QPair<QString, QPointer<AccountGraphicsProxyWidget> > > p_accountProxyWidgetList;
00123 bool accountingRecodIsDrawn;
00124 bool solutionIsDrawn;
00125 bool descriptionIsDrawn;
00126 bool openingStockIsDrawn;
00127 bool fileOpen;
00128 QGraphicsScene *scene;
00129 DateCalendar *calendar;
00130
00131 AboutData *aboutData;
00132 Settings settings;
00133
00134 QLabel *updateInfo;
00135
00136
00137 StartActions *startActions;
00138 PupilActions *pupilActions;
00139 TeacherActions *teacherActions;
00140
00141
00142
00143 QPrinter *printer;
00144
00145
00146
00147 UpdaterManifestThread updaterManifestThread;
00148
00149
00150
00151 MailerThread mailerThread;
00152 };
00153
00154 #endif