summaryrefslogtreecommitdiffstats
path: root/src/dialog.h
blob: 5c3af175428134e03f3ec6efdcb8dd7a180ce112 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
#ifndef DIALOG_H
#define DIALOG_H

#include <QDialog>
#include <QModelIndex>
#include <QList>
#include <QSettings>
#include <QNetworkReply>
#include <QKeyEvent>

#include "session.h"
#include "sessiontreemodel.h"
#include "sessionsiconholder.h"


namespace Ui {
    class Dialog;
}
class QTimer;

class Dialog : public QDialog {
    Q_OBJECT
  private: // Constants
    static const int STR_LOADING = 0;
    static const int STR_URL_ERROR = 1;
    static const int STR_NO_ITEMS = 2;
    static const int STR__MAX = 3;
    static const int TAB_NATIVE = 0;
    static const int TAB_RECENT_COURSES = 1;
    static const int TAB_ALL_VMS = 2;
    static const int TAB_COUNT = 3;

  public: // Public methods
    explicit Dialog(QWidget *parent = nullptr);
    ~Dialog();
    void addItems(const QList<Session*>&, int tab);
    void addStatusString(const int status);
    void removeStatusString(const int status);
    bool selectSession(const QString& name, int lastTab = -1);
    void selectPreviousSession();
    void setTheme();
    void startSession(const QString& name);
    void downloadData(const QString& locationIds);

  protected: // Overrides
    void changeEvent(QEvent *e);
    void mousePressEvent(QMouseEvent *event);
    bool eventFilter(QObject *target, QEvent *event);
    void keyPressEvent(QKeyEvent * e);

  private: // Private vars n methods
    Ui::Dialog *ui;
    SessionTreeModel *model_[TAB_COUNT];
    QPushButton *tabs_[TAB_COUNT];
    QPoint oldCenter_;
    QTimer *centerTimer_;
    QString autoStartEntry_;
    int activeTab_;
    int autoQuit_;
    bool userInteracted_;
    bool genericExpandedOnce_;
    QString strings_[STR__MAX];
    void onTabButtonChanged(int tab);
    void configClearButton();
    void setListModel(SessionTreeModel *model);
    void selectFirstElement();

    void checkAutostart();

  private slots:
    void on_pushButtonStart_clicked();
    void on_pushButtonAbort_clicked();
	void on_btnScreenSetup_clicked();
    void on_treeView_doubleClicked(const QModelIndex& index);
    void on_treeView_expanded(const QModelIndex& index);
    void on_tabButtonLocal_clicked();
    void on_tabButtonMyClasses_clicked();
    void on_tabButtonAllClasses_clicked();
    void on_filterEdit_textEdited();
    void on_filterEdit_textChanged();
    void treeView_selectionChanged(const QModelIndex& current, const QModelIndex&);
    void on_helpNewsButton_clicked();
    void onCenterTimer();
    void iconDownloaded(const QUrl& url, const QIcon& icon);

    void on_leftKey();
    void on_rightKey();
    void on_spaceKey();
};

#endif // DIALOG_H