]> git.sur5r.net Git - bacula/bacula/blob - bacula/src/qt-console/mainwin.h
Massive bat notifier rewrite + fix seg fault + implement text input dialog
[bacula/bacula] / bacula / src / qt-console / mainwin.h
1 /*
2    Bacula® - The Network Backup Solution
3
4    Copyright (C) 2007-2009 Free Software Foundation Europe e.V.
5
6    The main author of Bacula is Kern Sibbald, with contributions from
7    many others, a complete list can be found in the file AUTHORS.
8    This program is Free Software; you can redistribute it and/or
9    modify it under the terms of version three of the GNU Affero General Public
10    License as published by the Free Software Foundation and included
11    in the file LICENSE.
12
13    This program is distributed in the hope that it will be useful, but
14    WITHOUT ANY WARRANTY; without even the implied warranty of
15    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16    General Public License for more details.
17
18    You should have received a copy of the GNU Affero General Public License
19    along with this program; if not, write to the Free Software
20    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
21    02110-1301, USA.
22
23    Bacula® is a registered trademark of Kern Sibbald.
24    The licensor of Bacula is the Free Software Foundation Europe
25    (FSFE), Fiduciary Program, Sumatrastrasse 25, 8006 Zürich,
26    Switzerland, email:ftf@fsfeurope.org.
27 */
28 /* 
29  *   Version $Id$
30  *
31  * qt-console main window class definition.
32  *
33  *  Written by Kern Sibbald, January MMVII
34  */
35
36 #ifndef _MAINWIN_H_
37 #define _MAINWIN_H_
38
39 #include <QtGui>
40 #include <QList>
41 #include "ui_main.h"
42
43 class Console;
44 class Pages;
45
46 class MainWin : public QMainWindow, public Ui::MainForm    
47 {
48    Q_OBJECT
49
50 public:
51    MainWin(QWidget *parent = 0);
52    void set_statusf(const char *fmt, ...);
53    void set_status_ready();
54    void set_status(const char *buf);
55    void set_status(const QString &str);
56    void writeSettings();
57    void readSettings();
58    void resetFocus() { lineEdit->setFocus(); };
59    void hashInsert(QTreeWidgetItem *, Pages *);
60    void hashRemove(Pages *);
61    void hashRemove(QTreeWidgetItem *, Pages *);
62    void setMessageIcon();
63    bool getWaitState() {return m_waitState; };
64    bool isClosing() {return m_isClosing; };
65    Console *currentConsole();
66    QTreeWidgetItem *currentTopItem();
67    Pages* getFromHash(QTreeWidgetItem *);
68    QTreeWidgetItem* getFromHash(Pages *);
69    /* This hash is to get the page when the page selector widget is known */
70    QHash<QTreeWidgetItem*,Pages*> m_pagehash;
71    /* This hash is to get the page selector widget when the page is known */
72    QHash<Pages*,QTreeWidgetItem*> m_widgethash;
73    /* This is a list of consoles */
74    QHash<QTreeWidgetItem*,Console*> m_consoleHash;
75    void createPageJobList(const QString &, const QString &,
76             const QString &, const QString &, QTreeWidgetItem *);
77    QString m_dtformat;
78    /* Begin Preferences variables */
79    bool m_commDebug;
80    bool m_connDebug;
81    bool m_displayAll;
82    bool m_sqlDebug;
83    bool m_commandDebug;
84    bool m_miscDebug;
85    bool m_recordLimitCheck;
86    int m_recordLimitVal;
87    bool m_daysLimitCheck;
88    int m_daysLimitVal;
89    bool m_checkMessages;
90    int m_checkMessagesInterval;
91    bool m_longList;
92    bool m_rtPopDirDebug;
93    bool m_rtDirCurICDebug;
94    bool m_rtDirICDebug;
95    bool m_rtFileTabICDebug;
96    bool m_rtVerTabICDebug;
97    bool m_rtUpdateFTDebug;
98    bool m_rtUpdateVTDebug;
99    bool m_rtChecksDebug;
100    bool m_rtIconStateDebug;
101    bool m_rtRestore1Debug;
102    bool m_rtRestore2Debug;
103    bool m_rtRestore3Debug;
104    bool m_openBrowser;
105    bool m_openPlot;
106    bool m_openDirStat;
107
108    /* Global */
109    bool m_notify;                     /* global flag to turn on/off all notifiers */
110
111 public slots:
112    void input_line();
113    void about();
114    void help();
115    void treeItemClicked(QTreeWidgetItem *item, int column);
116    void labelButtonClicked();
117    void runButtonClicked();
118    void estimateButtonClicked();
119    void browseButtonClicked();
120    void statusPageButtonClicked();
121    void jobPlotButtonClicked();
122    void restoreButtonClicked();
123    void undockWindowButton();
124    void treeItemChanged(QTreeWidgetItem *, QTreeWidgetItem *);
125    void stackItemChanged(int);
126    void toggleDockContextWindow();
127    void closePage();
128    void setPreferences();
129    void readPreferences();
130    void waitEnter();
131    void waitExit();
132    void repopLists();
133    void reloadRepopLists();
134    void popLists();
135    void goToPreviousPage();
136
137 protected:
138    void closeEvent(QCloseEvent *event);
139    void keyPressEvent(QKeyEvent *event);
140
141 private:
142    void connectConsole();
143    void createPages();
144    void connectSignals(); 
145    void disconnectSignals(); 
146    void connectConsoleSignals();
147    void disconnectConsoleSignals(Console *console);
148
149 private:
150    Console *m_currentConsole;
151    Pages *m_pagespophold;
152    QStringList m_cmd_history;
153    int m_cmd_last;
154    QTreeWidgetItem *m_firstItem;
155    QTreeWidgetItem *m_waitTreeItem;
156    bool m_isClosing;
157    bool m_waitState;
158    bool m_doConnect;
159    QList<QTreeWidgetItem *> m_treeWidgetStack;
160    bool m_treeStackTrap;
161 };
162
163 #include "ui_prefs.h"
164
165 class prefsDialog : public QDialog, public Ui::PrefsForm
166 {
167    Q_OBJECT
168
169 public:
170    prefsDialog();
171
172 private slots:
173    void accept();
174    void reject();
175 };
176
177 #endif /* _MAINWIN_H_ */