2013-04-10 21:20:33 +00:00
|
|
|
/* syntax_line_edit.h
|
|
|
|
*
|
|
|
|
* Wireshark - Network traffic analyzer
|
|
|
|
* By Gerald Combs <gerald@wireshark.org>
|
|
|
|
* Copyright 1998 Gerald Combs
|
|
|
|
*
|
2018-04-30 07:47:58 +00:00
|
|
|
* SPDX-License-Identifier: GPL-2.0-or-later
|
|
|
|
*/
|
2013-04-10 21:20:33 +00:00
|
|
|
|
2012-10-08 20:01:59 +00:00
|
|
|
#ifndef SYNTAX_LINE_EDIT_H
|
|
|
|
#define SYNTAX_LINE_EDIT_H
|
|
|
|
|
|
|
|
#include <QLineEdit>
|
|
|
|
|
2015-05-19 17:18:54 +00:00
|
|
|
class QCompleter;
|
|
|
|
class QStringListModel;
|
|
|
|
|
|
|
|
// Autocompletion is partially implemented. Subclasses must:
|
|
|
|
// - Provide buildCompletionList
|
|
|
|
// - Call setCompletionTokenChars
|
|
|
|
|
2012-10-08 20:01:59 +00:00
|
|
|
class SyntaxLineEdit : public QLineEdit
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
Q_PROPERTY(SyntaxState syntaxState READ syntaxState)
|
|
|
|
Q_ENUMS(SyntaxState)
|
|
|
|
public:
|
|
|
|
explicit SyntaxLineEdit(QWidget *parent = 0);
|
2016-01-07 17:27:13 +00:00
|
|
|
enum SyntaxState { Empty, Busy, Invalid, Deprecated, Valid };
|
2012-10-08 20:01:59 +00:00
|
|
|
|
|
|
|
SyntaxState syntaxState() const { return syntax_state_; }
|
|
|
|
void setSyntaxState(SyntaxState state = Empty);
|
2015-01-18 10:22:19 +00:00
|
|
|
QString syntaxErrorMessage();
|
2012-10-08 20:01:59 +00:00
|
|
|
QString styleSheet() const;
|
Add a Qt I/O Graph dialog.
For each graph you can set:
- Its visibility
- A name
- A display filter
- Color, from a fixed list
- Plot style: Line, Impulse, Bar, Stacked Bar, Dot, Square, Diamond
- Basic Y Axes (packets/s, bytes/s, bits/s)
- Computed Y Axes (SUM, MIN, AVG, MAX)
- Smoothing
You can pan and zoom using the mouse and keyboard. Clicking on a graph
selects the last packet for that interval. If all graphs have the same Y
axis a single label is shown, otherwise a legend is shown.
The time scale (X axis) can be toggled between relative seconds and the
time of day.
Graphs can be saved as PDF, PNG, BMP, and JPEG. Settings are "sticky"
via the io_graphs UAT.
To do:
- Minimize graph drawing delays.
- Figure out why smoothing differs from GTK+
- Everything else at the top of io_graph_dialog.cpp
- Fix empty resets.
A fair amount of code was copied from TCPStreamDialog. We might want to
subclass QCustomPlot and place the shared code there.
Move common syntax checking to SyntaxLineEdit.
Move some common code from ui/gtk/io_stat.c to ui/io_graph_item.[ch] and
use it in both GTK+ and Qt.
Make the io_graph_item_t array allocation in io_stat.c static. The
behavior should be identical and this gives us additional compile-time
checks.
Change-Id: I9a3d544469b7048f0761fdbf7bcf20f44ae76577
Reviewed-on: https://code.wireshark.org/review/435
Reviewed-by: Gerald Combs <gerald@wireshark.org>
Tested-by: Gerald Combs <gerald@wireshark.org>
2014-02-12 00:07:10 +00:00
|
|
|
QString deprecatedToken();
|
|
|
|
|
2015-05-19 17:18:54 +00:00
|
|
|
void setCompleter(QCompleter *c);
|
|
|
|
QCompleter *completer() const { return completer_; }
|
|
|
|
|
Add a Qt I/O Graph dialog.
For each graph you can set:
- Its visibility
- A name
- A display filter
- Color, from a fixed list
- Plot style: Line, Impulse, Bar, Stacked Bar, Dot, Square, Diamond
- Basic Y Axes (packets/s, bytes/s, bits/s)
- Computed Y Axes (SUM, MIN, AVG, MAX)
- Smoothing
You can pan and zoom using the mouse and keyboard. Clicking on a graph
selects the last packet for that interval. If all graphs have the same Y
axis a single label is shown, otherwise a legend is shown.
The time scale (X axis) can be toggled between relative seconds and the
time of day.
Graphs can be saved as PDF, PNG, BMP, and JPEG. Settings are "sticky"
via the io_graphs UAT.
To do:
- Minimize graph drawing delays.
- Figure out why smoothing differs from GTK+
- Everything else at the top of io_graph_dialog.cpp
- Fix empty resets.
A fair amount of code was copied from TCPStreamDialog. We might want to
subclass QCustomPlot and place the shared code there.
Move common syntax checking to SyntaxLineEdit.
Move some common code from ui/gtk/io_stat.c to ui/io_graph_item.[ch] and
use it in both GTK+ and Qt.
Make the io_graph_item_t array allocation in io_stat.c static. The
behavior should be identical and this gives us additional compile-time
checks.
Change-Id: I9a3d544469b7048f0761fdbf7bcf20f44ae76577
Reviewed-on: https://code.wireshark.org/review/435
Reviewed-by: Gerald Combs <gerald@wireshark.org>
Tested-by: Gerald Combs <gerald@wireshark.org>
2014-02-12 00:07:10 +00:00
|
|
|
public slots:
|
|
|
|
void setStyleSheet(const QString &style_sheet);
|
2015-06-01 23:29:17 +00:00
|
|
|
// Insert filter text at the current position, adding spaces where needed.
|
|
|
|
void insertFilter(const QString &filter);
|
Add a Qt I/O Graph dialog.
For each graph you can set:
- Its visibility
- A name
- A display filter
- Color, from a fixed list
- Plot style: Line, Impulse, Bar, Stacked Bar, Dot, Square, Diamond
- Basic Y Axes (packets/s, bytes/s, bits/s)
- Computed Y Axes (SUM, MIN, AVG, MAX)
- Smoothing
You can pan and zoom using the mouse and keyboard. Clicking on a graph
selects the last packet for that interval. If all graphs have the same Y
axis a single label is shown, otherwise a legend is shown.
The time scale (X axis) can be toggled between relative seconds and the
time of day.
Graphs can be saved as PDF, PNG, BMP, and JPEG. Settings are "sticky"
via the io_graphs UAT.
To do:
- Minimize graph drawing delays.
- Figure out why smoothing differs from GTK+
- Everything else at the top of io_graph_dialog.cpp
- Fix empty resets.
A fair amount of code was copied from TCPStreamDialog. We might want to
subclass QCustomPlot and place the shared code there.
Move common syntax checking to SyntaxLineEdit.
Move some common code from ui/gtk/io_stat.c to ui/io_graph_item.[ch] and
use it in both GTK+ and Qt.
Make the io_graph_item_t array allocation in io_stat.c static. The
behavior should be identical and this gives us additional compile-time
checks.
Change-Id: I9a3d544469b7048f0761fdbf7bcf20f44ae76577
Reviewed-on: https://code.wireshark.org/review/435
Reviewed-by: Gerald Combs <gerald@wireshark.org>
Tested-by: Gerald Combs <gerald@wireshark.org>
2014-02-12 00:07:10 +00:00
|
|
|
|
|
|
|
// Built-in syntax checks. Connect textChanged to these as needed.
|
|
|
|
void checkDisplayFilter(QString filter);
|
|
|
|
void checkFieldName(QString field);
|
2015-12-11 08:34:08 +00:00
|
|
|
void checkCustomColumn(QString fields);
|
2015-01-01 19:41:03 +00:00
|
|
|
void checkInteger(QString number);
|
2012-10-08 20:01:59 +00:00
|
|
|
|
2015-05-19 17:18:54 +00:00
|
|
|
protected:
|
|
|
|
QCompleter *completer_;
|
|
|
|
QStringListModel *completion_model_;
|
|
|
|
void setCompletionTokenChars(const QString &token_chars) { token_chars_ = token_chars; }
|
|
|
|
bool isComplexFilter(const QString &filter);
|
|
|
|
virtual void buildCompletionList(const QString&) { }
|
|
|
|
// x = Start position, y = length
|
|
|
|
QPoint getTokenUnderCursor();
|
|
|
|
|
2016-03-22 23:17:31 +00:00
|
|
|
virtual bool event(QEvent *event);
|
2015-05-19 17:18:54 +00:00
|
|
|
void completionKeyPressEvent(QKeyEvent *event);
|
|
|
|
void completionFocusInEvent(QFocusEvent *event);
|
2016-06-24 15:59:48 +00:00
|
|
|
virtual void focusOutEvent(QFocusEvent *event);
|
2018-12-05 23:37:27 +00:00
|
|
|
virtual void paintEvent(QPaintEvent *event);
|
2015-05-19 17:18:54 +00:00
|
|
|
|
2012-10-08 20:01:59 +00:00
|
|
|
private:
|
|
|
|
SyntaxState syntax_state_;
|
|
|
|
QString style_sheet_;
|
|
|
|
QString state_style_sheet_;
|
2015-01-18 10:22:19 +00:00
|
|
|
QString syntax_error_message_;
|
2015-05-19 17:18:54 +00:00
|
|
|
QString token_chars_;
|
2016-01-07 17:27:13 +00:00
|
|
|
QColor busy_fg_;
|
2015-05-19 17:18:54 +00:00
|
|
|
|
|
|
|
private slots:
|
|
|
|
void insertFieldCompletion(const QString &completion_text);
|
2012-10-08 20:01:59 +00:00
|
|
|
|
|
|
|
signals:
|
2014-02-25 20:42:35 +00:00
|
|
|
|
2012-10-08 20:01:59 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // SYNTAX_LINE_EDIT_H
|