gSAFE  1.3.8
dconsole.h
1 /* gSAFE - LIB
2  general Sql dAtabase FrontEnd
3  http://hyperprog.com/gsafe/
4 
5  (C) 2006-2013 Peter Deak (hyper80@gmail.com)
6 
7  License: GPLv2 http://www.gnu.org/licenses/gpl-2.0.html
8 
9  dconsole.h
10 */
11 
12 /* This module is not depend from gSAFE
13  * Can be used separatedly (Just add dconsole.h/dconsole.cpp to your project)
14  */
15 
16 #ifndef GSAFE_DCONSOLE__HEADER_
17 #define GSAFE_DCONSOLE__HEADER_
18 
19 #include <QtCore>
20 #include <QtGui>
21 
22 #ifndef COMPILED_WITH_QT4X
23 #include <QtWidgets>
24 #endif //COMPILED_WITH_QT4X
25 
27 /* @{ */
28 
29 #ifndef DCONSOLE_NO_SQL
30 
33 void sqldebug(QString s);
34 #endif // DCONSOLE_NO_SQL
35 
39 void sdebug(QString s);
40 
44 void dconsole(void);
48 void dconsole_close(void);
51 void dconsole_popup(QString t,QString txt);
52 
58 {
59  public:
63  virtual QString donsole_command_interpreter(QString commandString) = 0;
64 };
65 
67 void register_dconsole_command(QString command,HDConsoleCommandHolder *interpreter,QString descr="");
69 void unregister_dconsole_command(QString command);
72 
73 #ifndef GSAFE_DISABLE_DEBUG
74 
75 #define DCONSOLE_TYPE_TEXT 0
76 #define DCONSOLE_TYPE_MESSAGE 1
77 #define DCONSOLE_TYPE_SQL 2
78 #define DCONSOLE_TYPE_RESULT 3
79 #define DCONSOLE_TYPE_CMD 4
80 #define DCONSOLE_TYPE_QTDEBUG 5
81 
82 #ifndef COMPILED_WITH_QT4X
83 void dconsoleMessageHandler(QtMsgType type, const QMessageLogContext &context, const QString &msg);
84 #else
85 void dconsoleMessageHandler(QtMsgType type, const char *msg);
86 #endif
87 
88 class QFontMetrics;
89 class QCloseEvent;
90 class HConsolePanel;
91 class HDebugConsolePrivate;
175 class HDebugConsole : public QWidget
176 {
177  Q_OBJECT
178 
179 public:
182 
183 public:
185  HDebugConsole(QWidget *parent);
187  ~HDebugConsole(void);
188 
190  void add_text(QString s,int type);
191 #ifndef DCONSOLE_NO_SQL
192 
193  static void debug_sql(QString s);
194 #endif // DCONSOLE_NO_SQL
195 
196  static void debug_txt(QString s);
198  static void popup(QString title,QString str);
202  void setCommandExecution(bool enabled = true);
205 
206 protected:
207  void closeEvent(QCloseEvent *e);
208 
209 private slots:
210  int execCommand(QString query);
211  int tabPressed(QString query);
214  int checkIfIClose();
215 private:
216 
217  class HDebugConsolePrivate *p;
218 };
219 
220 class HConsoleLine;
221 class HConsolePanelPrivate;
222 
260 class HConsolePanel : public QFrame
261 {
262  Q_OBJECT
263 
264 public:
266  HConsolePanel(QWidget *parent);
267  ~HConsolePanel(void);
268 
273  void addText(QString t,char type = 0);
275  int maxSerial(void);
277  int topSerial(void);
283  QString lineBySerial(int serial,bool withWraps =false,bool onDisplay = true);
284 
286  void scrollUp(int lineCount = 1);
288  void scrollDown(int lineCount = 1);
290  void scrollToSerial(int serial);
292  QString selectedText(void);
295  void setTabStop(int count);
296 
298  void setMarginText(QString margin);
299 
304  void setColor(QString section,QColor color);
309  void setTextTypeColor(char type,QColor color);
310 
312  void setPromptString(QString prm);
314  QString promptString(void);
319  void setCommandLineCharacterEcho(bool disable = false);
321  QString commandLineText(void);
323  void cursorLeft(int charCount = 1,bool inSelection = false);
325  void cursorRight(int charCount = 1,bool inSelection = false);
327  void setCommandLineText(QString t,bool disableupdate=false);
330  int cursorPosition(void);
333  void setCursorPosition(int c);
335  void resetCommandLine(void);
338  void addTextToCursor(QString text);
343  void deleteFromCursor(bool forwardDel = false);
344 
346  void setFontSize(int point);
348  int fontSize(void);
349 
350 public slots:
352  void addNormalText(QString text);
354  void clearText(void);
356  void selectAll(void);
358  void clearSelection(void);
360  void copySelection(void);
362  void scrollTop(void);
364  void scrollReset(void);
366  void pasteToCommandLine(void);
368  void deleteCmdLineSelection(void);
369 
370  void biggerFontSize(void);
371  void smallerFontSize(void);
372  void normalFontSize(void);
373 
374 protected:
375  void paintEvent(QPaintEvent *e);
376  void resizeEvent(QResizeEvent *e);
377  void keyPressEvent(QKeyEvent *e);
378 
379  void mousePressEvent(QMouseEvent *e);
380  void mouseMoveEvent(QMouseEvent *e);
381  void mouseReleaseEvent(QMouseEvent *e);
382  void mouseDoubleClickEvent(QMouseEvent *e);
383  void wheelEvent(QWheelEvent *e);
384  bool event(QEvent *e);
385 
386 signals:
389  void commandEntered(QString commandText);
392  void tabPressed(QString commandText);
393 
394 private:
395  class HConsolePanelPrivate *p;
396 };
397 
398 #endif //GSAFE_DISABLE_DEBUG
399 
400 /* @} */
401 
402 #endif
void selectAll(void)
Definition: dconsole.cpp:1720
void commandEntered(QString commandText)
static HDebugConsole * myself
Definition: dconsole.h:181
void deleteCmdLineSelection(void)
Definition: dconsole.cpp:2383
static void popup(QString title, QString str)
Definition: dconsole.cpp:335
void deleteFromCursor(bool forwardDel=false)
Definition: dconsole.cpp:2331
int maxSerial(void)
Definition: dconsole.cpp:1678
HConsolePanel * consoleObject(void)
Definition: dconsole.cpp:330
void unregister_dconsole_command(QString command)
Definition: dconsole.cpp:104
void setCommandLineCharacterEcho(bool disable=false)
Definition: dconsole.cpp:1350
QString commandLineText(void)
Definition: dconsole.cpp:2245
void setMarginText(QString margin)
Definition: dconsole.cpp:1185
void dconsole_close(void)
Definition: dconsole.cpp:70
void pasteToCommandLine(void)
Definition: dconsole.cpp:2578
void sqldebug(QString s)
Definition: dconsole.cpp:36
void cursorLeft(int charCount=1, bool inSelection=false)
Definition: dconsole.cpp:2398
void addTextToCursor(QString text)
Definition: dconsole.cpp:2293
int cursorPosition(void)
Definition: dconsole.cpp:2257
void setTextTypeColor(char type, QColor color)
Definition: dconsole.cpp:1513
void copySelection(void)
Definition: dconsole.cpp:1800
void scrollUp(int lineCount=1)
Definition: dconsole.cpp:1608
void scrollReset(void)
Definition: dconsole.cpp:1654
void setTabStop(int count)
Definition: dconsole.cpp:1523
HDebugConsole(QWidget *parent)
Definition: dconsole.cpp:173
void setCursorPosition(int c)
Definition: dconsole.cpp:2272
void clearSelection(void)
Definition: dconsole.cpp:1733
void setPromptString(QString prm)
Definition: dconsole.cpp:2867
HConsolePanel(QWidget *parent)
Definition: dconsole.cpp:1088
QString promptString(void)
Definition: dconsole.cpp:2873
void setCommandLineText(QString t, bool disableupdate=false)
Definition: dconsole.cpp:2189
void resetCommandLine(void)
Definition: dconsole.cpp:2170
void add_text(QString s, int type)
Definition: dconsole.cpp:341
QString selectedText(void)
Definition: dconsole.cpp:1739
~HDebugConsole(void)
Definition: dconsole.cpp:296
void sdebug(QString s)
Definition: dconsole.cpp:48
virtual QString donsole_command_interpreter(QString commandString)=0
void setColor(QString section, QColor color)
Definition: dconsole.cpp:1495
void register_dconsole_command(QString command, HDConsoleCommandHolder *interpreter, QString descr)
Definition: dconsole.cpp:95
void addNormalText(QString text)
Definition: dconsole.cpp:1518
void scrollTop(void)
Definition: dconsole.cpp:1647
void setFontSize(int point)
Definition: dconsole.cpp:2878
int topSerial(void)
Definition: dconsole.cpp:1685
void cursorRight(int charCount=1, bool inSelection=false)
Definition: dconsole.cpp:2453
void tabPressed(QString commandText)
void scrollDown(int lineCount=1)
Definition: dconsole.cpp:1629
int fontSize(void)
Definition: dconsole.cpp:2889
void dconsole_popup(QString t, QString txt)
Definition: dconsole.cpp:82
static void debug_txt(QString s)
Definition: dconsole.cpp:382
void dconsole(void)
Definition: dconsole.cpp:59
void setCommandExecution(bool enabled=true)
Definition: dconsole.cpp:309
void clearText(void)
Definition: dconsole.cpp:1588
void scrollToSerial(int serial)
Definition: dconsole.cpp:1661
void addText(QString t, char type=0)
Definition: dconsole.cpp:1528
static void debug_sql(QString s)
Definition: dconsole.cpp:375
QString lineBySerial(int serial, bool withWraps=false, bool onDisplay=true)
Definition: dconsole.cpp:1692
void clear_dconsole_commands()
Definition: dconsole.cpp:113