2013-04-10 21:20:33 +00:00
|
|
|
/* syntax_line_edit.cpp
|
|
|
|
*
|
|
|
|
* Wireshark - Network traffic analyzer
|
|
|
|
* By Gerald Combs <gerald@wireshark.org>
|
|
|
|
* Copyright 1998 Gerald Combs
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
|
|
*/
|
|
|
|
|
2013-07-17 21:55:38 +00:00
|
|
|
#include "config.h"
|
|
|
|
|
|
|
|
#include <glib.h>
|
|
|
|
|
|
|
|
#include <epan/prefs.h>
|
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
|
|
|
#include <epan/proto.h>
|
|
|
|
#include <epan/dfilter/dfilter.h>
|
2013-07-17 21:55:38 +00:00
|
|
|
|
2012-10-08 20:01:59 +00:00
|
|
|
#include "syntax_line_edit.h"
|
|
|
|
|
2013-07-17 21:55:38 +00:00
|
|
|
#include "color_utils.h"
|
2012-10-08 20:01:59 +00:00
|
|
|
|
|
|
|
SyntaxLineEdit::SyntaxLineEdit(QWidget *parent) :
|
|
|
|
QLineEdit(parent)
|
|
|
|
{
|
2013-07-17 21:55:38 +00:00
|
|
|
setSyntaxState();
|
|
|
|
}
|
|
|
|
|
|
|
|
void SyntaxLineEdit::setSyntaxState(SyntaxState state) {
|
|
|
|
syntax_state_ = state;
|
2012-10-08 20:01:59 +00:00
|
|
|
state_style_sheet_ = QString(
|
|
|
|
"SyntaxLineEdit[syntaxState=\"%1\"] {"
|
2013-07-17 21:55:38 +00:00
|
|
|
" color: %4;"
|
|
|
|
" background-color: %5;"
|
2012-10-08 20:01:59 +00:00
|
|
|
"}"
|
|
|
|
|
|
|
|
"SyntaxLineEdit[syntaxState=\"%2\"] {"
|
2013-07-17 21:55:38 +00:00
|
|
|
" color: %4;"
|
|
|
|
" background-color: %6;"
|
2012-10-08 20:01:59 +00:00
|
|
|
"}"
|
|
|
|
|
|
|
|
"SyntaxLineEdit[syntaxState=\"%3\"] {"
|
2013-07-17 21:55:38 +00:00
|
|
|
" color: %4;"
|
|
|
|
" background-color: %7;"
|
2012-10-08 20:01:59 +00:00
|
|
|
"}"
|
|
|
|
)
|
2013-07-17 21:55:38 +00:00
|
|
|
.arg(Valid)
|
2012-10-08 20:01:59 +00:00
|
|
|
.arg(Invalid)
|
|
|
|
.arg(Deprecated)
|
2013-07-17 21:55:38 +00:00
|
|
|
.arg("palette(text)") // Foreground
|
2015-01-15 01:25:56 +00:00
|
|
|
.arg(ColorUtils::fromColorT(&prefs.gui_text_valid).name()) // Valid
|
|
|
|
.arg(ColorUtils::fromColorT(&prefs.gui_text_invalid).name()) // Invalid
|
|
|
|
.arg(ColorUtils::fromColorT(&prefs.gui_text_deprecated).name()) // VDeprecated
|
2012-10-08 20:01:59 +00:00
|
|
|
;
|
|
|
|
setStyleSheet(style_sheet_);
|
|
|
|
}
|
|
|
|
|
2015-01-18 10:22:19 +00:00
|
|
|
QString SyntaxLineEdit::syntaxErrorMessage() {
|
|
|
|
return syntax_error_message_;
|
|
|
|
}
|
|
|
|
|
2012-10-08 20:01:59 +00:00
|
|
|
QString SyntaxLineEdit::styleSheet() const {
|
|
|
|
return style_sheet_;
|
|
|
|
}
|
|
|
|
|
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 SyntaxLineEdit::deprecatedToken()
|
|
|
|
{
|
|
|
|
return deprecated_token_;
|
|
|
|
}
|
|
|
|
|
2012-10-08 20:01:59 +00:00
|
|
|
void SyntaxLineEdit::setStyleSheet(const QString &style_sheet) {
|
|
|
|
style_sheet_ = style_sheet;
|
|
|
|
QLineEdit::setStyleSheet(style_sheet_ + state_style_sheet_);
|
|
|
|
}
|
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
|
|
|
|
|
|
|
void SyntaxLineEdit::checkDisplayFilter(QString filter)
|
|
|
|
{
|
|
|
|
if (filter.isEmpty()) {
|
|
|
|
setSyntaxState(SyntaxLineEdit::Empty);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
deprecated_token_.clear();
|
|
|
|
dfilter_t *dfp = NULL;
|
2015-01-18 10:22:19 +00:00
|
|
|
gchar *err_msg;
|
|
|
|
if (dfilter_compile(filter.toUtf8().constData(), &dfp, &err_msg)) {
|
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
|
|
|
GPtrArray *depr = NULL;
|
|
|
|
if (dfp) {
|
|
|
|
depr = dfilter_deprecated_tokens(dfp);
|
|
|
|
}
|
|
|
|
if (depr) {
|
2015-01-18 10:22:19 +00:00
|
|
|
// You keep using that word. I do not think it means what you think it means.
|
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
|
|
|
setSyntaxState(SyntaxLineEdit::Deprecated);
|
|
|
|
deprecated_token_ = (const char *) g_ptr_array_index(depr, 0);
|
|
|
|
} else {
|
2015-01-18 10:22:19 +00:00
|
|
|
setSyntaxState(SyntaxLineEdit::Valid);
|
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
|
|
|
}
|
2015-01-18 10:22:19 +00:00
|
|
|
} else {
|
|
|
|
setSyntaxState(SyntaxLineEdit::Invalid);
|
|
|
|
syntax_error_message_ = QString::fromUtf8(err_msg);
|
|
|
|
g_free(err_msg);
|
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
|
|
|
}
|
|
|
|
dfilter_free(dfp);
|
|
|
|
}
|
|
|
|
|
|
|
|
void SyntaxLineEdit::checkFieldName(QString field)
|
|
|
|
{
|
|
|
|
if (field.isEmpty()) {
|
|
|
|
setSyntaxState(SyntaxLineEdit::Empty);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
char invalid_char = proto_check_field_name(field.toUtf8().constData());
|
|
|
|
if (invalid_char) {
|
|
|
|
setSyntaxState(SyntaxLineEdit::Invalid);
|
|
|
|
} else {
|
|
|
|
checkDisplayFilter(field);
|
|
|
|
}
|
|
|
|
}
|
2015-01-01 19:41:03 +00:00
|
|
|
|
|
|
|
void SyntaxLineEdit::checkInteger(QString number)
|
|
|
|
{
|
|
|
|
if (number.isEmpty()) {
|
|
|
|
setSyntaxState(SyntaxLineEdit::Empty);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool ok;
|
|
|
|
text().toInt(&ok);
|
|
|
|
if (ok) {
|
|
|
|
setSyntaxState(SyntaxLineEdit::Valid);
|
|
|
|
} else {
|
|
|
|
setSyntaxState(SyntaxLineEdit::Invalid);
|
|
|
|
}
|
|
|
|
}
|