From 238f332ac43005c0136b1995b174fdf74b1ca90d Mon Sep 17 00:00:00 2001 From: "Srivats P." Date: Sun, 5 Apr 2009 07:19:37 +0000 Subject: [PATCH] - About Dialog added - Stream Dialog now remembers the "selected" tabs across close and reopen - Other trivial UI enhancements --- client/about.ui | 206 +++++++++++++++------------ client/icons/portstats_clear.png | Bin 0 -> 367 bytes client/icons/portstats_clear_all.png | Bin 0 -> 736 bytes client/mainwindow.cpp | 41 ++++-- client/mainwindow.h | 15 +- client/mainwindow.ui | 117 +-------------- client/ostinato.pro | 1 + client/ostinato.qrc | 2 + client/portstatsfilter.ui | 6 +- client/portstatsmodel.cpp | 4 +- client/portstatswindow.ui | 6 + client/portswindow.cpp | 3 + client/portswindow.ui | 122 ++++++++-------- client/stream.cpp | 5 +- client/stream.h | 3 + client/streamconfigdialog.cpp | 12 +- client/streamconfigdialog.h | 6 + client/streamconfigdialog.ui | 2 +- server/pcapextra.cpp | 3 + 19 files changed, 271 insertions(+), 283 deletions(-) create mode 100644 client/icons/portstats_clear.png create mode 100644 client/icons/portstats_clear_all.png diff --git a/client/about.ui b/client/about.ui index 2256d60..c7f914c 100644 --- a/client/about.ui +++ b/client/about.ui @@ -1,88 +1,118 @@ - - Dialog - - - - 0 - 0 - 400 - 300 - - - - Dialog - - - - - - QFrame::Box - - - QFrame::Raised - - - - - - <html><head><meta name="qrichtext" content="1" /><style type="text/css"> -p, li { white-space: pre-wrap; } -</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:29pt; font-weight:600;">Ostinato</span></p></body></html> - - - Qt::AlignCenter - - - - - - - - - - Qt::Horizontal - - - QDialogButtonBox::Cancel|QDialogButtonBox::NoButton|QDialogButtonBox::Ok - - - - - - - - - buttonBox - accepted() - Dialog - accept() - - - 248 - 254 - - - 157 - 274 - - - - - buttonBox - rejected() - Dialog - reject() - - - 316 - 260 - - - 286 - 274 - - - - - + + About + + + + 0 + 0 + 400 + 300 + + + + About + + + + + + QFrame::Box + + + QFrame::Raised + + + + + + Qt::Vertical + + + + 360 + 51 + + + + + + + + <html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:29pt; font-weight:600;">Ostinato</span></p></body></html> + + + Qt::AlignCenter + + + + + + + Copyright (c) 2007-2009 Srivats P. + + + Qt::AlignCenter + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + Icons (c): Mark James (http://www.famfamfam.com/lab/icons/silk/) + + + Qt::AlignCenter + + + + + + + + + + Qt::Horizontal + + + QDialogButtonBox::Ok + + + + + + + + + buttonBox + accepted() + About + accept() + + + 353 + 280 + + + 286 + 262 + + + + + diff --git a/client/icons/portstats_clear.png b/client/icons/portstats_clear.png new file mode 100644 index 0000000000000000000000000000000000000000..48cfa9756ffa84b209ef6e18cfdb75c139d1c9f5 GIT binary patch literal 367 zcmV-#0g(QQP)%zBB+uQIj;+Mu^GVlA1NAvn$4NnL{6}C{AT#~>o>#S z&z~7SfBN?S|KESVKw$uM1yKCYN7a}+;#ge(RJ8Ng=jT5^K70A|)5|wMSw;OAxH)7P z1!Y6n|NmiT|M&CHQe@3w0CE8?{ONMb|9h+S{@-4rG69zwtkDPp4>stWXXjRA`1|Xd zgi7@7mn5Zw`)jqX0{tr@8L*j=fe^svtUD{z&GC5+8KcAkIbh&369D%X=xO)W1B(Cv N002ovPDHLkV1h;6wt@@v-Jo56-xpcZCLFvFo+sh%yoi{VZ?9B7cjqH@ z8!|K0K+I4z)ErSm)DSg96%|L#evN4{_Y+flvN@i^7vC@LifQSMZsr<)pJA<0#?&w| zOa&KZT_b+%+Dp|_hzX*?r~AGp1Wm_0Rk|^m+?;%ybY_6erk!{YJP6vXQ(u{gS1-+DVsvCiz+&=4Z_!gK zprJ`^=?3>+I>|eGM~G4xHY`4{oCq*90 zHfq~Hqng;lg=?$CiB$~Pv85Boz}<0ozC3%&%PVDHJU8YKX5RO?@Ai3R;RkPKA6bUws5yfGJ=?vs`Qc_KTWo0goouiTL-$h^=J)M zL(O?@u!DuWRi0($mT-4AOn) #include "mainwindow.h" -#include "portswindow.h" -#include "portstatswindow.h" #include "portgrouplist.h" +#include "ui_about.h" + PortGroupList *pgl; MainWindow::MainWindow(QWidget *parent) @@ -11,20 +10,38 @@ MainWindow::MainWindow(QWidget *parent) { pgl = new PortGroupList; - PortsWindow *portsWindow = new PortsWindow(pgl, this); - PortStatsWindow *statsWindow = new PortStatsWindow(pgl, this); - QDockWidget *dock = new QDockWidget(tr("Ports"), this); - QDockWidget *dock2 = new QDockWidget(tr("Stats"), this); + portsWindow = new PortsWindow(pgl, this); + statsWindow = new PortStatsWindow(pgl, this); + portsDock = new QDockWidget(tr("Ports"), this); + statsDock = new QDockWidget(tr("Stats"), this); setupUi(this); - dock2->setWidget(statsWindow); - addDockWidget(Qt::BottomDockWidgetArea, dock2); - dock->setWidget(portsWindow); - addDockWidget(Qt::TopDockWidgetArea, dock); + statsDock->setWidget(statsWindow); + addDockWidget(Qt::BottomDockWidgetArea, statsDock); + portsDock->setWidget(portsWindow); + addDockWidget(Qt::TopDockWidgetArea, portsDock); + + connect(actionFileExit, SIGNAL(triggered()), this, SLOT(close())); } -void MainWindow::on_actionPreferences_triggered() +MainWindow::~MainWindow() { + delete statsDock; + delete portsDock; + delete statsWindow; + delete portsWindow; +} + +void MainWindow::on_actionHelpAbout_triggered() +{ + QDialog *aboutDialog = new QDialog; + + Ui::About about; + about.setupUi(aboutDialog); + + aboutDialog->exec(); + + delete aboutDialog; } diff --git a/client/mainwindow.h b/client/mainwindow.h index da412ec..a5d31a6 100644 --- a/client/mainwindow.h +++ b/client/mainwindow.h @@ -2,16 +2,29 @@ #define _MAIN_WINDOW_H #include +#include + #include "ui_mainwindow.h" +#include "portswindow.h" +#include "portstatswindow.h" + class MainWindow : public QMainWindow, private Ui::MainWindow { Q_OBJECT + +private: + PortsWindow *portsWindow; + PortStatsWindow *statsWindow; + QDockWidget *portsDock; + QDockWidget *statsDock; + public: MainWindow(QWidget *parent = 0); + ~MainWindow(); public slots: - void on_actionPreferences_triggered(); + void on_actionHelpAbout_triggered(); }; #endif diff --git a/client/mainwindow.ui b/client/mainwindow.ui index 98ab4c2..1f93f5e 100644 --- a/client/mainwindow.ui +++ b/client/mainwindow.ui @@ -10,7 +10,7 @@ - MainWindow + Ostinato @@ -26,131 +26,26 @@ File - - - - - View - - - - - - Window - - - - - - - - + Help - + - - - - - Open Config - - - - - Save Config - - - - - Save Config As ... - - - - - Open Capture - - - - - Save Capture - - - - - Save Capture As ... - - - + E&xit - + - Copy Port Config - - - - - Paste Port Config - - - - - Preferences - - - - - Minimize - - - - - Maximize/Restore - - - - - Minimize All - - - - - Maximize/Restoe All - - - - - Arrange All - Cascade - - - - - Arrange All - Tile - - - - - Dock - - - - - Help - - - - - About + &About diff --git a/client/ostinato.pro b/client/ostinato.pro index ec44eb0..9bb3cd2 100644 --- a/client/ostinato.pro +++ b/client/ostinato.pro @@ -24,6 +24,7 @@ HEADERS += \ streammodel.h FORMS += \ + about.ui \ mainwindow.ui \ portstatsfilter.ui \ portstatswindow.ui \ diff --git a/client/ostinato.qrc b/client/ostinato.qrc index 09fdd4a..7b735f7 100644 --- a/client/ostinato.qrc +++ b/client/ostinato.qrc @@ -12,6 +12,8 @@ icons/portgroup_connect.png icons/portgroup_delete.png icons/portgroup_disconnect.png + icons/portstats_clear.png + icons/portstats_clear_all.png icons/portstats_filter.png icons/sound_mute.png icons/sound_none.png diff --git a/client/portstatsfilter.ui b/client/portstatsfilter.ui index a681c65..8423db3 100644 --- a/client/portstatsfilter.ui +++ b/client/portstatsfilter.ui @@ -5,12 +5,12 @@ 0 0 - 588 - 320 + 319 + 193 - Dialog + Select Ports diff --git a/client/portstatsmodel.cpp b/client/portstatsmodel.cpp index bcc0f54..9961e12 100644 --- a/client/portstatsmodel.cpp +++ b/client/portstatsmodel.cpp @@ -171,9 +171,9 @@ QVariant PortStatsModel::headerData(int section, Qt::Orientation orientation, in getDomainIndexes(index(0, section), portGroupIdx, portIdx); #ifdef Q_OS_WIN32 - return QString("Port %1/%2 (*)").arg(portGroupIdx).arg(portIdx); + return QString("Port %1-%2 (*)").arg(portGroupIdx).arg(portIdx); #else - return QString("Port %1/%2").arg(portGroupIdx).arg(portIdx); + return QString("Port %1-%2").arg(portGroupIdx).arg(portIdx); #endif } else diff --git a/client/portstatswindow.ui b/client/portstatswindow.ui index a7fc8d5..07fe1b2 100644 --- a/client/portstatswindow.ui +++ b/client/portstatswindow.ui @@ -65,6 +65,9 @@ Clear + + :/icons/portstats_clear.png + @@ -78,6 +81,9 @@ Clear All + + :/icons/portstats_clear_all.png + diff --git a/client/portswindow.cpp b/client/portswindow.cpp index 1789e5e..8b75b65 100644 --- a/client/portswindow.cpp +++ b/client/portswindow.cpp @@ -61,6 +61,9 @@ PortsWindow::PortsWindow(PortGroupList *pgl, QWidget *parent) // Initially we don't have any ports/streams - so send signal triggers when_portView_currentChanged(QModelIndex(), QModelIndex()); when_streamView_currentChanged(QModelIndex(), QModelIndex()); + + //! \todo Hide the Aggregate Box till we add support + frAggregate->setHidden(true); } PortsWindow::~PortsWindow() diff --git a/client/portswindow.ui b/client/portswindow.ui index 99a32af..b58c356 100644 --- a/client/portswindow.ui +++ b/client/portswindow.ui @@ -6,7 +6,7 @@ 0 0 689 - 320 + 389 @@ -28,11 +28,11 @@ - 0 + 1 - - + + @@ -56,64 +56,59 @@ - - - - - - Qt::Horizontal - - - - 31 - 41 - - - - - - - - Capacity - - - - - - - - - - Aggr fps - - - - - - - - - - % age - - - - - - - - - - Aggr bps - - - - - - - + + + + QFrame::StyledPanel + + + QFrame::Raised + + + + + + Capacity + + + + + + + + + + Aggr fps + + + + + + + + + + % age + + + + + + + + + + Aggr bps + + + + + + + + - + 0 @@ -147,7 +142,10 @@ - Port Group Detail + Select a port to configure streams + + + Qt::AlignCenter diff --git a/client/stream.cpp b/client/stream.cpp index 2d82040..0afd8df 100644 --- a/client/stream.cpp +++ b/client/stream.cpp @@ -15,6 +15,7 @@ QString PayloadProtocol::fieldTextValue(int index) if (parentStream) { + qDebug("phs = %d", parentStream->protocolHeaderSize()); len = parentStream->frameLen() - parentStream->protocolHeaderSize(); pat = parentStream->pattern(); } @@ -48,6 +49,7 @@ QByteArray PayloadProtocol::fieldRawValue(int index) if (parentStream) { + qDebug("phs = %d", parentStream->protocolHeaderSize()); len = parentStream->frameLen() - parentStream->protocolHeaderSize(); pat = parentStream->pattern(); } @@ -1015,7 +1017,8 @@ bool Stream::update(OstProto::Stream *stream) mIp->update(stream->ip()); mArp->update(stream->arp()); - mTcp->update(stream->tcp()); + //mTcp->update(stream->tcp()); + mTcp->setProtoData(stream->mutable_tcp()); mUdp->update(stream->udp()); mIcmp->update(stream->icmp()); mIgmp->update(stream->igmp()); diff --git a/client/stream.h b/client/stream.h index 6e41702..434c008 100644 --- a/client/stream.h +++ b/client/stream.h @@ -33,6 +33,9 @@ public: void getConfig(::google::protobuf::Message *msg) { msg->CopyFrom(data()); } + bool setProtoData(::google::protobuf::Message *msg) + { data().MergeFrom(*msg); return true; } + virtual QString protocolName() { return QString("AbstractProtocol"); } virtual QString protocolShortName() diff --git a/client/streamconfigdialog.cpp b/client/streamconfigdialog.cpp index e7f1f0b..8b99561 100644 --- a/client/streamconfigdialog.cpp +++ b/client/streamconfigdialog.cpp @@ -4,6 +4,9 @@ #include "modeltest.h" +int StreamConfigDialog::lastTopLevelTabIndex = 0; +int StreamConfigDialog::lastProtoTabIndex = 0; + // TODO(HI): Write HexLineEdit::setNum() and num() and use it in // Load/Store stream methods @@ -177,6 +180,11 @@ StreamConfigDialog::StreamConfigDialog(Port &port, uint streamIndex, disconnect(rbActionGotoStream, SIGNAL(toggled(bool)), leStreamId, SLOT(setEnabled(bool))); //! \todo Support Continuous Mode rbModeContinuous->setDisabled(true); + + // Finally, restore the saved last selected tab for the various tab widgets + twTopLevel->setCurrentIndex(lastTopLevelTabIndex); + if (twProto->isTabEnabled(lastProtoTabIndex)) + twProto->setCurrentIndex(lastProtoTabIndex); } void StreamConfigDialog::setupUiExtra() @@ -230,8 +238,6 @@ void StreamConfigDialog::setupUiExtra() connect(rbModeContinuous, SIGNAL(toggled(bool)), this, SLOT(update_NumPacketsAndNumBursts())); - // Show "Packet Config" page by default - twTopLevel->setCurrentIndex(0); } StreamConfigDialog::~StreamConfigDialog() @@ -1115,6 +1121,8 @@ void StreamConfigDialog::on_pbOk_clicked() // Store dialog contents into stream StoreCurrentStream(); qDebug("stream stored"); + lastTopLevelTabIndex = twTopLevel->currentIndex(); + lastProtoTabIndex = twProto->currentIndex(); } //Junk Line for introducing a compiler error diff --git a/client/streamconfigdialog.h b/client/streamconfigdialog.h index a8fe510..7dbedbe 100644 --- a/client/streamconfigdialog.h +++ b/client/streamconfigdialog.h @@ -34,6 +34,12 @@ private: PacketModel *mpPacketModel; ModelTest *mpPacketModelTester; + // The following static variables are used to track the "selected" tab + // for the various tab widgets so that it can be restored when the dialog + // is opened the next time + static int lastTopLevelTabIndex; + static int lastProtoTabIndex; + void setupUiExtra(); void LoadCurrentStream(); void StoreCurrentStream(); diff --git a/client/streamconfigdialog.ui b/client/streamconfigdialog.ui index 178e966..70fea95 100644 --- a/client/streamconfigdialog.ui +++ b/client/streamconfigdialog.ui @@ -13,7 +13,7 @@ - Dialog + Edit Stream QLineEdit:enabled[inputMask = "HH; "], diff --git a/server/pcapextra.cpp b/server/pcapextra.cpp index 3246397..4ad8a51 100644 --- a/server/pcapextra.cpp +++ b/server/pcapextra.cpp @@ -85,6 +85,9 @@ _restart: if (returnToQIdx >= 0) { i = returnToQIdx; + + // FIXME: 1s fixed; Change this to ipg of last stream + (*pf_usleep)(1000000); goto _restart; }