From 60893e2344ec048753e3a3489f0c001a0d5b3eb7 Mon Sep 17 00:00:00 2001 From: csoler Date: Sat, 30 Jan 2021 00:03:10 +0100 Subject: [PATCH 1/6] first modifications to improve BW graph --- retroshare-gui/src/gui/common/RSGraphWidget.h | 3 +- retroshare-gui/src/gui/images.qrc | 1 + .../src/gui/images/graph-line-inverted.png | Bin 0 -> 1583 bytes retroshare-gui/src/gui/statistics/BWGraph.h | 2 +- .../gui/statistics/BandwidthGraphWindow.cpp | 172 +++-- .../src/gui/statistics/BandwidthGraphWindow.h | 4 + .../gui/statistics/BandwidthGraphWindow.ui | 665 +++++++----------- 7 files changed, 385 insertions(+), 462 deletions(-) create mode 100644 retroshare-gui/src/gui/images/graph-line-inverted.png diff --git a/retroshare-gui/src/gui/common/RSGraphWidget.h b/retroshare-gui/src/gui/common/RSGraphWidget.h index 210402b12..e08a45eb9 100644 --- a/retroshare-gui/src/gui/common/RSGraphWidget.h +++ b/retroshare-gui/src/gui/common/RSGraphWidget.h @@ -180,7 +180,8 @@ public: void setFiltering(bool b) ; - void setFlags(uint32_t flag) { _flags |= flag ; } + uint32_t getFlags() const { return _flags ; } + void setFlags(uint32_t flag) { _flags |= flag ; } void resetFlags(uint32_t flag) { _flags &= ~flag ; } protected: /** Overloaded QWidget::paintEvent() */ diff --git a/retroshare-gui/src/gui/images.qrc b/retroshare-gui/src/gui/images.qrc index 248c5e1fd..af12479b5 100644 --- a/retroshare-gui/src/gui/images.qrc +++ b/retroshare-gui/src/gui/images.qrc @@ -181,6 +181,7 @@ images/go-bottom.png images/graph-area.png images/graph-line.png + images/graph-line-inverted.png images/gpgp_key_generate.png images/hide_toolbox_frame.png images/hide_frame.png diff --git a/retroshare-gui/src/gui/images/graph-line-inverted.png b/retroshare-gui/src/gui/images/graph-line-inverted.png new file mode 100644 index 0000000000000000000000000000000000000000..016fee6782149f47473300e8a5cd3746ef57f88c GIT binary patch literal 1583 zcmV+~2GIG5P) zaB^>EX>4U6ba`-PAZ2)IW&i+q+U=HGcH}4whTmDmECES?U^!gRnH}`<=Lb`ja*|5B zGU>N2jt!QDB=iZ&rvLhPn1AqNqG+7g7*YrpKbKtMj6t-=FReRSx9TEg6g#IAchB9M8JWc2gSlBS*r#v;z3bHY0kB;>Tbdjjoa zf=)@kjm-P(-$(C~&w0z`T`t4U5eA>WApd#tSBf7T%RM4Kzp%sVhvn>Rj26e}$Lg{R z$Y|IVWz8)+%f@I0DVH@ZpeZhov96ZTqRqAfPP5e(v`UE>RE8l(jWP}DtFKfMqT|kr zp1A_lltocaTo*An8x2-T(j&5TiJ zipa)$t`HZ`%0d{E+`K~zKxk}kekJ(UHh%k1KPXiY^efE~3(U40CW@!G+LFatpy$ya zyMm0iZ2&2PZ;xO|K)?nPPl2p5D-rS-0VpGK7RLny$a`)GlATCkqa1nq#vG-k%bo*I zG0rA{@DfD9CP@Y?=RE31T|^CKFW!0YgI6DoPd*0;F8C0FhIzUp5nh733S2t!94Y2-V#P4z>2ff{XUyhu$wy;FnK zsNPJ_JWl*%24d_8#B~xtLGxs0BRR*D++=3cJkvZQNI%(_Mw1v2x=!o|-Pyg7yTr}- zc!?YTj+~k3euA66$t7Gx3}ZNsdPxwMY%GnlnEW&tF4VO2S+;Q*B>NaTv^l;i(~MgAc`mqd}e z%9ifS))N^aJ~h{I5FYESGDx3qk#`0^n|N)n{gk2SOM33WJoE5sWIu8qO^4L)Mh#zyz1Umjz1ojN!5kIV)QxmK zw1E$=giqrC05HP`Rk_GTI{*Lyg=s@WP)S2WAaHVTW@&6?004NLeUUv#!%!53Pg6ya zii1T&6oOPI3!);9T7@E12(?114kj=CgC-40ii@M*T5#}ZvFhOBtgC~oAPD||xVbqg zx=4xlC509-UUt6(RCiIH<=^*bb*ov60RfSCmKml^yg@v@X&apPiNmZQtHkHTVt?1$8VhT zE(<&}Y^IX)#9?AF-@-}@vx2D+PZ38{O{aVz?Xk*vi?dd$u*N<43qx6bWtr==1`)?1 zmLNfdf(nW#!A6vJofHd6I*O@Fxt%zTnwZEBGtpl2JnxNd679&ot>^gkK0DZ5gT zmXON<0@=kGn9&(<7B_H)^TSvw3bCKw7p2$cUO-5~qYh5F2YRf&0r?X{ z4Eell6^7B6_U(4BB~`=3hORC?xs6Adh!`}b%mBbt2eZ31piNpRLyN%j7iIYl&o&8> hx32-P5&A^3Isg?{s59qGF>e3>002ovPDHLkV1iPT;OYPX literal 0 HcmV?d00001 diff --git a/retroshare-gui/src/gui/statistics/BWGraph.h b/retroshare-gui/src/gui/statistics/BWGraph.h index 81330c68b..5edb10e71 100644 --- a/retroshare-gui/src/gui/statistics/BWGraph.h +++ b/retroshare-gui/src/gui/statistics/BWGraph.h @@ -48,7 +48,7 @@ public: enum { SELECTOR_TYPE_FRIEND=0x00, SELECTOR_TYPE_SERVICE=0x01 }; enum { GRAPH_TYPE_SINGLE=0x00, GRAPH_TYPE_ALL=0x01, GRAPH_TYPE_SUM=0x02 }; enum { UNIT_KILOBYTES=0x00, UNIT_COUNT=0x01 }; - enum { DIRECTION_UP=0x00, DIRECTION_DOWN=0x01 }; + enum { DIRECTION_UP=0x02, DIRECTION_DOWN=0x01 }; // re-derived from RSGraphSource diff --git a/retroshare-gui/src/gui/statistics/BandwidthGraphWindow.cpp b/retroshare-gui/src/gui/statistics/BandwidthGraphWindow.cpp index d99a140fc..a4ac860e0 100644 --- a/retroshare-gui/src/gui/statistics/BandwidthGraphWindow.cpp +++ b/retroshare-gui/src/gui/statistics/BandwidthGraphWindow.cpp @@ -19,11 +19,13 @@ * * *******************************************************************************/ -#include -#include -#include -#include -#include +#include "rshare.h" +#include "control/bandwidthevent.h" +#include "gui/statistics/BandwidthGraphWindow.h" +#include "gui/common/FilesDefs.h" +#include "util/misc.h" +#include "retroshare-gui/RsAutoUpdatePage.h" +#include "retroshare/rsconfig.h" #include #include @@ -51,6 +53,12 @@ /* Images used in the graph style drop-down */ #define IMG_AREA_GRAPH ":/images/16x16/graph-area.png" #define IMG_LINE_GRAPH ":/images/16x16/graph-line.png" +#define IMG_SETTINGS ":/icons/system_128.png" +#define IMG_CLEANUP ":/images/global_switch_off.png" +#define IMG_SEND ":/images/go-up.png" +#define IMG_RECEIVE ":/images/go-down.png" +#define IMG_GRAPH_DARK ":/images/graph-line.png" +#define IMG_GRAPH_LIGHT ":/images/graph-line-inverted.png" /** Default constructor */ @@ -65,9 +73,6 @@ BandwidthGraph::BandwidthGraph(QWidget *parent, Qt::WindowFlags flags) setShortcut("Ctrl+W", SLOT(close())); #endif - /* Bind events to actions */ - createActions(); - /* Ask RetroShare core to notify us about bandwidth updates */ //_rsControl = RetroShare::rsControl(); //_rsControl->setEvent(REvents::Bandwidth, this, true); @@ -77,7 +82,6 @@ BandwidthGraph::BandwidthGraph(QWidget *parent, Qt::WindowFlags flags) /* Hide Bandwidth Graph Settings frame */ showSettingsFrame(false); /* Load the previously saved settings */ - loadSettings(); /* Turn off opacity group on unsupported platforms */ #if defined(Q_OS_WIN) @@ -88,18 +92,63 @@ BandwidthGraph::BandwidthGraph(QWidget *parent, Qt::WindowFlags flags) #if defined(Q_OS_LINUX) ui.frmOpacity->setVisible(false); + ui.chkAlwaysOnTop->setVisible(false); + ui.btnToggleSettings->setVisible(false); // this is only windows settings anyway #endif + + ui.btnToggleSettings->setIcon(FilesDefs::getIconFromQtResourcePath(IMG_SETTINGS)); + ui.btnToggleSettings->setText(""); + ui.btnReset->setIcon(FilesDefs::getIconFromQtResourcePath(IMG_CLEANUP)); + ui.btnReset->setText(""); + ui.chkSendRate->setIcon(FilesDefs::getIconFromQtResourcePath(IMG_SEND)); + ui.chkSendRate->setText(""); + ui.chkReceiveRate->setIcon(FilesDefs::getIconFromQtResourcePath(IMG_RECEIVE)); + ui.chkReceiveRate->setText(""); + + ui.frmGraph->setToolTip("Use Ctrl+mouse wheel to change line width, Shift+wheel to time-filter the curve."); + + loadSettings(); + + connect(ui.btnToggleSettings,SIGNAL(toggled(bool)),this,SLOT(showSettingsFrame(bool))); + connect(ui.btnReset, SIGNAL(clicked()), this, SLOT(reset())); + connect(ui.sldrOpacity, SIGNAL(valueChanged(int)), this, SLOT(setOpacity(int))); + connect(ui.btnGraphColor, SIGNAL(clicked()), this, SLOT(switchGraphColor())); + connect(ui.chkSendRate, SIGNAL(toggled(bool)), this, SLOT(toggleSendRate(bool))); + connect(ui.chkReceiveRate, SIGNAL(toggled(bool)), this, SLOT(toggleReceiveRate(bool))); } -/** Binds events to actions. */ -void -BandwidthGraph::createActions() +void BandwidthGraph::toggleSendRate(bool b) { - connect(ui.btnToggleSettings, SIGNAL(toggled(bool)), this, SLOT(showSettingsFrame(bool))); - connect(ui.btnReset, SIGNAL(clicked()), this, SLOT(reset())); - connect(ui.btnSaveSettings, SIGNAL(clicked()), this, SLOT(saveChanges())); - connect(ui.btnCancelSettings, SIGNAL(clicked()), this, SLOT(cancelChanges())); - connect(ui.sldrOpacity, SIGNAL(valueChanged(int)), this, SLOT(setOpacity(int))); + whileBlocking(ui.chkReceiveRate)->setChecked(!b); + + if(b) + ui.frmGraph->setDirection(BWGraphSource::DIRECTION_UP) ; + else + ui.frmGraph->setDirection(BWGraphSource::DIRECTION_DOWN) ; +} +void BandwidthGraph::toggleReceiveRate(bool b) +{ + whileBlocking(ui.chkSendRate)->setChecked(!b); + + if(b) + ui.frmGraph->setDirection(BWGraphSource::DIRECTION_DOWN) ; + else + ui.frmGraph->setDirection(BWGraphSource::DIRECTION_UP) ; +} + + +void BandwidthGraph::switchGraphColor() +{ + if(ui.frmGraph->getFlags() & RSGraphWidget::RSGRAPH_FLAGS_DARK_STYLE) + { + ui.frmGraph->resetFlags(RSGraphWidget::RSGRAPH_FLAGS_DARK_STYLE); + ui.btnGraphColor->setIcon(FilesDefs::getIconFromQtResourcePath(IMG_GRAPH_LIGHT)); + } + else + { + ui.frmGraph->setFlags(RSGraphWidget::RSGRAPH_FLAGS_DARK_STYLE); + ui.btnGraphColor->setIcon(FilesDefs::getIconFromQtResourcePath(IMG_GRAPH_DARK)); + } } /** Loads the saved Bandwidth Graph settings. */ @@ -110,15 +159,6 @@ BandwidthGraph::loadSettings() ui.sldrOpacity->setValue(getSetting(SETTING_OPACITY, DEFAULT_OPACITY).toInt()); setOpacity(ui.sldrOpacity->value()); - /* Set whether the window appears on top. */ - ui.chkAlwaysOnTop->setChecked(getSetting(SETTING_ALWAYS_ON_TOP, DEFAULT_ALWAYS_ON_TOP).toBool()); - - if (ui.chkAlwaysOnTop->isChecked()) { - setWindowFlags(windowFlags() | Qt::WindowStaysOnTopHint); - } else { - setWindowFlags(windowFlags() & ~Qt::WindowStaysOnTopHint); - } - /* Set the line filter checkboxes accordingly */ uint filter = getSetting(SETTING_FILTER, DEFAULT_FILTER).toUInt(); ui.chkReceiveRate->setChecked(filter & BWGRAPH_LINE_RECV); @@ -127,10 +167,10 @@ BandwidthGraph::loadSettings() /* Set whether we are plotting bandwidth as area graphs or not */ int graphStyle = getSetting(SETTING_STYLE, DEFAULT_STYLE).toInt(); - if (graphStyle < 0 || graphStyle >= ui.cmbGraphStyle->count()) { - graphStyle = DEFAULT_STYLE; - } - ui.cmbGraphStyle->setCurrentIndex(graphStyle); +// if (graphStyle < 0 || graphStyle >= ui.cmbGraphStyle->count()) { +// graphStyle = DEFAULT_STYLE; +// } +// ui.cmbGraphStyle->setCurrentIndex(graphStyle); if(graphStyle==0) ui.frmGraph->resetFlags(RSGraphWidget::RSGRAPH_FLAGS_PAINT_STYLE_PLAIN); @@ -140,28 +180,37 @@ BandwidthGraph::loadSettings() /* Set whether we are plotting bandwidth as area graphs or not */ int graphColor = getSetting(SETTING_GRAPHCOLOR, DEFAULT_GRAPHCOLOR).toInt(); - if (graphColor < 0 || graphColor >= ui.cmbGraphColor->count()) { - graphColor = DEFAULT_GRAPHCOLOR; - } - ui.cmbGraphColor->setCurrentIndex(graphColor); - - if(graphColor==0) + if(graphColor>0) + { ui.frmGraph->resetFlags(RSGraphWidget::RSGRAPH_FLAGS_DARK_STYLE); + ui.btnGraphColor->setIcon(FilesDefs::getIconFromQtResourcePath(IMG_GRAPH_DARK)); + } else + { + ui.btnGraphColor->setIcon(FilesDefs::getIconFromQtResourcePath(IMG_GRAPH_LIGHT)); ui.frmGraph->setFlags(RSGraphWidget::RSGRAPH_FLAGS_DARK_STYLE); + } /* Download & Upload */ int defaultdirection = getSetting(SETTING_DIRECTION, DEFAULT_DIRECTION).toInt(); + +// if (defaultdirection < 0 || defaultdirection >= ui.cmbDownUp->count()) { +// defaultdirection = DEFAULT_DIRECTION; +// } +// ui.cmbDownUp->setCurrentIndex(graphColor); - if (defaultdirection < 0 || defaultdirection >= ui.cmbDownUp->count()) { - defaultdirection = DEFAULT_DIRECTION; - } - ui.cmbDownUp->setCurrentIndex(graphColor); - - if(defaultdirection==0) - ui.frmGraph->setDirection(BWGraphSource::DIRECTION_UP) ; - else + if(defaultdirection>0) + { ui.frmGraph->setDirection(BWGraphSource::DIRECTION_DOWN) ; + whileBlocking(ui.chkSendRate)->setChecked(false); + whileBlocking(ui.chkReceiveRate)->setChecked(true); + } + else + { + ui.frmGraph->setDirection(BWGraphSource::DIRECTION_UP) ; + whileBlocking(ui.chkSendRate)->setChecked(true); + whileBlocking(ui.chkReceiveRate)->setChecked(false); + } /* Default Settings for the Graph */ ui.frmGraph->setSelector(BWGraphSource::SELECTOR_TYPE_FRIEND,BWGraphSource::GRAPH_TYPE_SUM) ; @@ -172,13 +221,11 @@ BandwidthGraph::loadSettings() ui.frmGraph->setShowEntry(1,ui.chkSendRate->isChecked()) ; } - - /** Resets the log start time. */ void BandwidthGraph::reset() { /* Set to current time */ - ui.statusbar->showMessage(tr("Since:") + " " + QDateTime::currentDateTime() .toString(DATETIME_FMT)); + ui.displayTime_LB->setText(tr("Since:") + " " + QDateTime::currentDateTime() .toString(DATETIME_FMT)); /* Reset the graph */ ui.frmGraph->resetGraph(); } @@ -191,8 +238,8 @@ void BandwidthGraph::saveChanges() /* Save the opacity and graph style */ saveSetting(SETTING_OPACITY, ui.sldrOpacity->value()); - saveSetting(SETTING_STYLE, ui.cmbGraphStyle->currentIndex()); - saveSetting(SETTING_GRAPHCOLOR, ui.cmbGraphColor->currentIndex()); +// saveSetting(SETTING_STYLE, ui.cmbGraphStyle->currentIndex()); + saveSetting(SETTING_GRAPHCOLOR, ui.btnGraphColor->isChecked()); /* Save the Always On Top setting */ saveSetting(SETTING_ALWAYS_ON_TOP, ui.chkAlwaysOnTop->isChecked()); @@ -213,21 +260,22 @@ void BandwidthGraph::saveChanges() /* Update the graph frame settings */ ui.frmGraph->setShowEntry(0,ui.chkReceiveRate->isChecked()) ; ui.frmGraph->setShowEntry(1,ui.chkSendRate->isChecked()) ; + ui.frmGraph->resetFlags(RSGraphWidget::RSGRAPH_FLAGS_PAINT_STYLE_PLAIN); - if(ui.cmbGraphStyle->currentIndex()==0) - ui.frmGraph->resetFlags(RSGraphWidget::RSGRAPH_FLAGS_PAINT_STYLE_PLAIN); - else - ui.frmGraph->setFlags(RSGraphWidget::RSGRAPH_FLAGS_PAINT_STYLE_PLAIN); +// if(ui.cmbGraphStyle->currentIndex()==0) +// ui.frmGraph->resetFlags(RSGraphWidget::RSGRAPH_FLAGS_PAINT_STYLE_PLAIN); +// else +// ui.frmGraph->setFlags(RSGraphWidget::RSGRAPH_FLAGS_PAINT_STYLE_PLAIN); - if(ui.cmbGraphColor->currentIndex()==0) + if(ui.btnGraphColor->isChecked()==0) ui.frmGraph->resetFlags(RSGraphWidget::RSGRAPH_FLAGS_DARK_STYLE); else ui.frmGraph->setFlags(RSGraphWidget::RSGRAPH_FLAGS_DARK_STYLE); - if(ui.cmbDownUp->currentIndex()==0) - ui.frmGraph->setDirection(BWGraphSource::DIRECTION_UP) ; - else - ui.frmGraph->setDirection(BWGraphSource::DIRECTION_DOWN) ; +// if(ui.cmbDownUp->currentIndex()==0) +// ui.frmGraph->setDirection(BWGraphSource::DIRECTION_UP) ; +// else +// ui.frmGraph->setDirection(BWGraphSource::DIRECTION_DOWN) ; /* A change in window flags causes the window to disappear, so make sure * it's still visible. */ @@ -255,16 +303,16 @@ BandwidthGraph::showSettingsFrame(bool show) if (show) { /* Extend the bottom of the bandwidth graph and show the settings */ ui.frmSettings->setVisible(true); - ui.btnToggleSettings->setChecked(true); - ui.btnToggleSettings->setText(tr("Hide Settings")); +// ui.btnToggleSettings->setChecked(true); +// ui.btnToggleSettings->setText(tr("Hide Settings")); /* 6 = vertical spacing between the settings frame and graph frame */ newSize.setHeight(newSize.height() + ui.frmSettings->height() + 6); } else { /* Shrink the height of the bandwidth graph and hide the settings */ ui.frmSettings->setVisible(false); - ui.btnToggleSettings->setChecked(false); - ui.btnToggleSettings->setText(tr("Show Settings")); +// ui.btnToggleSettings->setChecked(false); +// ui.btnToggleSettings->setText(tr("Show Settings")); /* 6 = vertical spacing between the settings frame and graph frame */ newSize.setHeight(newSize.height() - ui.frmSettings->height() - 6); diff --git a/retroshare-gui/src/gui/statistics/BandwidthGraphWindow.h b/retroshare-gui/src/gui/statistics/BandwidthGraphWindow.h index b1b4d9898..fb52d28b2 100644 --- a/retroshare-gui/src/gui/statistics/BandwidthGraphWindow.h +++ b/retroshare-gui/src/gui/statistics/BandwidthGraphWindow.h @@ -51,6 +51,10 @@ public slots: void showWindow(); private slots: + void switchGraphColor(); + void toggleReceiveRate(bool b); + void toggleSendRate(bool b); + /** Called when settings button is toggled */ void showSettingsFrame(bool show); /** Called when the settings button is toggled */ diff --git a/retroshare-gui/src/gui/statistics/BandwidthGraphWindow.ui b/retroshare-gui/src/gui/statistics/BandwidthGraphWindow.ui index 0bbf4dafe..56f1818f8 100644 --- a/retroshare-gui/src/gui/statistics/BandwidthGraphWindow.ui +++ b/retroshare-gui/src/gui/statistics/BandwidthGraphWindow.ui @@ -6,8 +6,8 @@ 0 0 - 418 - 305 + 620 + 432 @@ -18,8 +18,27 @@ :/images/logo/logo_16.png:/images/logo/logo_16.png - - + + + + + + 0 + 0 + + + + + 120 + 80 + + + + Qt::NoContextMenu + + + + 6 @@ -36,6 +55,70 @@ 0 + + + + PushButton + + + false + + + + + + + Qt::NoContextMenu + + + + + + Qt::RightToLeft + + + Up + + + true + + + false + + + + + + + Qt::NoContextMenu + + + + + + Qt::RightToLeft + + + Down + + + true + + + false + + + + + + + Clears the graph + + + Reset + + + @@ -60,15 +143,15 @@ - + - Reset + TextLabel - + @@ -97,166 +180,56 @@ QFrame::Raised - - - 9 - - - 9 - - - 9 - - - 9 - - - - - 6 - - - 3 - - - 3 - - - 3 - - - 3 - - - - - Qt::NoContextMenu - - - - - - Qt::RightToLeft - - - Receive Rate - - - false - - - - - - - Qt::NoContextMenu - - - - - - Qt::RightToLeft - - - Send Rate - - - false - - - - - - - Qt::RightToLeft - - - Always on Top - - - - - - - Qt::Vertical - - - - 20 - 21 - - - - - - - - - - 1 - - - 0 - - - 0 - - - 0 - - - 0 - - - - - Save - - - - - - - Cancel - - - - - - - - - Qt::Horizontal - - - - 21 - 20 - - - - - - - - 1 - - - 0 - - - 0 - - - 0 - - - 0 - - - + + + + 1 + + + 0 + + + 0 + + + 0 + + + 0 + + + + + 6 + + + 0 + + + 0 + + + 0 + + + 0 + + + + + + + Qt::NoContextMenu + + + QFrame::NoFrame + + + QFrame::Plain + + - 6 + 3 0 @@ -271,10 +244,47 @@ 0 - + + + Qt::NoContextMenu + + + Changes the transparency of the Bandwidth Graph + + + 30 + + + 100 + + + 100 + + + 100 + + + false + Qt::Horizontal + + false + + + QSlider::NoTicks + + + 10 + + + + + + + Qt::Vertical + 20 @@ -284,252 +294,111 @@ - - - Style + + + 0 + + + 0 + + + 0 + + + 0 + + + 0 - - - - - - - - - - :/images/graph-line.png:/images/graph-line.png - + + + Qt::Horizontal + + + + 21 + 0 + + + - - - - - - :/images/graph-area.png:/images/graph-area.png - - - - - - - - - Default - + + + + 25 + 0 + + + + Qt::NoContextMenu + + + Qt::RightToLeft + + + 100 + + - - Dark - - - - - - - - - Upload - + + + Qt::NoContextMenu + + + % Opaque + + - - Download - + + + Qt::Horizontal + + + + 21 + 0 + + + - + + + + Qt::RightToLeft + + + Always on Top + + + + - - - - - Qt::NoContextMenu - - - QFrame::NoFrame - - - QFrame::Plain - - - - 3 - - - 0 - - - 0 - - - 0 - - - 0 - - - - - Qt::NoContextMenu - - - Changes the transparency of the Bandwidth Graph - - - 30 - - - 100 - - - 100 - - - 100 - - - false - - - Qt::Horizontal - - - false - - - QSlider::NoTicks - - - 10 - - - - - - - Qt::Vertical - - - - 20 - 20 - - - - - - - - 0 - - - 0 - - - 0 - - - 0 - - - 0 - - - - - Qt::Horizontal - - - - 21 - 0 - - - - - - - - - 25 - 0 - - - - Qt::NoContextMenu - - - Qt::RightToLeft - - - 100 - - - - - - - Qt::NoContextMenu - - - % Opaque - - - - - - - Qt::Horizontal - - - - 21 - 0 - - - - - - - - - - - - - Qt::Vertical - - - - 21 - 20 - - - - - - - - - - - - - - 120 - 80 - - - - Qt::NoContextMenu - + + + + + + Qt::Vertical + + + + 21 + 20 + + + + + + - From f61b37e10b30cb094161863b912b8245308317b8 Mon Sep 17 00:00:00 2001 From: csoler Date: Sun, 31 Jan 2021 23:28:15 +0100 Subject: [PATCH 2/6] fixed bw graph window to display both up+dn --- libretroshare/src/ft/ftserver.cc | 3 +- retroshare-gui/src/gui/statistics/BWGraph.cpp | 39 +++-- retroshare-gui/src/gui/statistics/BWGraph.h | 4 +- .../gui/statistics/BandwidthGraphWindow.cpp | 134 ++++++------------ .../src/gui/statistics/BandwidthGraphWindow.h | 4 +- 5 files changed, 78 insertions(+), 106 deletions(-) diff --git a/libretroshare/src/ft/ftserver.cc b/libretroshare/src/ft/ftserver.cc index 8f13c91aa..341d4c360 100644 --- a/libretroshare/src/ft/ftserver.cc +++ b/libretroshare/src/ft/ftserver.cc @@ -819,8 +819,7 @@ bool ftServer::ExtraFileAdd(std::string fname, const RsFileHash& hash, uint64_t bool ftServer::ExtraFileRemove(const RsFileHash& hash) { return mFileDatabase->removeExtraFile(hash); } -bool ftServer::ExtraFileHash( - std::string localpath, rstime_t period, TransferRequestFlags flags ) +bool ftServer::ExtraFileHash( std::string localpath, rstime_t period, TransferRequestFlags flags ) { constexpr rstime_t uintmax = std::numeric_limits::max(); if(period > uintmax) diff --git a/retroshare-gui/src/gui/statistics/BWGraph.cpp b/retroshare-gui/src/gui/statistics/BWGraph.cpp index 1663cb3bd..293880e12 100644 --- a/retroshare-gui/src/gui/statistics/BWGraph.cpp +++ b/retroshare-gui/src/gui/statistics/BWGraph.cpp @@ -80,14 +80,26 @@ void BWGraphSource::update() std::cerr << " visible service: " << std::dec << mVisibleServices.size() << std::endl; #endif - // now, convert data to current curve points. + // Now, convert latest data measurement into points. convertTrafficToValues() returns + // a map of values corresponding to the latest point in time, doing all the requested calculations + // (sum over friends, sum over services, etc). + // std::map vals ; - - if(_current_direction == BWGraphSource::DIRECTION_UP) - convertTrafficClueToValues(thc.out_rstcl,vals) ; + + if(_current_direction == (DIRECTION_UP | DIRECTION_DOWN)) + { + std::map vals1,vals2 ; + convertTrafficClueToValues(thc.out_rstcl,vals1) ; + convertTrafficClueToValues(thc.in_rstcl,vals2) ; + + for(auto it:vals1) vals[it.first + " (sent)"] = it.second; + for(auto it:vals2) vals[it.first + " (received)"] = it.second; + } + else if(_current_direction & DIRECTION_UP) + convertTrafficClueToValues(thc.out_rstcl,vals) ; else - convertTrafficClueToValues(thc.in_rstcl,vals) ; + convertTrafficClueToValues(thc.in_rstcl,vals) ; qint64 ms = getTime() ; @@ -217,8 +229,6 @@ std::string BWGraphSource::makeSubItemName(uint16_t service_id,uint8_t sub_item_ void BWGraphSource::convertTrafficClueToValues(const std::list& lst,std::map& vals) const { - vals.clear() ; - switch(_friend_graph_type) { case GRAPH_TYPE_SINGLE: @@ -555,9 +565,18 @@ void BWGraphSource::recomputeCurrentCurves() std::set unused_values = used_values_ref ; - if(_current_direction==DIRECTION_UP) - convertTrafficClueToValues((*it).out_rstcl,vals) ; - else + if(_current_direction == (DIRECTION_UP | DIRECTION_DOWN)) + { + std::map vals1,vals2 ; + convertTrafficClueToValues((*it).out_rstcl,vals1) ; + convertTrafficClueToValues((*it).in_rstcl,vals2) ; + + for(auto it:vals1) vals[it.first + " (sent)"] = it.second; + for(auto it:vals2) vals[it.first + " (received)"] = it.second; + } + else if(_current_direction & DIRECTION_UP) + convertTrafficClueToValues((*it).out_rstcl,vals) ; + else convertTrafficClueToValues((*it).in_rstcl,vals) ; for(std::map::iterator it2=vals.begin();it2!=vals.end();++it2) diff --git a/retroshare-gui/src/gui/statistics/BWGraph.h b/retroshare-gui/src/gui/statistics/BWGraph.h index 5edb10e71..51ce3d3e3 100644 --- a/retroshare-gui/src/gui/statistics/BWGraph.h +++ b/retroshare-gui/src/gui/statistics/BWGraph.h @@ -48,7 +48,7 @@ public: enum { SELECTOR_TYPE_FRIEND=0x00, SELECTOR_TYPE_SERVICE=0x01 }; enum { GRAPH_TYPE_SINGLE=0x00, GRAPH_TYPE_ALL=0x01, GRAPH_TYPE_SUM=0x02 }; enum { UNIT_KILOBYTES=0x00, UNIT_COUNT=0x01 }; - enum { DIRECTION_UP=0x02, DIRECTION_DOWN=0x01 }; + enum { DIRECTION_DOWN=0x01,DIRECTION_UP=0x02 }; // can be combined using binary ops // re-derived from RSGraphSource @@ -113,6 +113,8 @@ class BWGraph: public RSGraphWidget void setDirection(int dir) { _local_source->setDirection(dir); } void setUnit(int unit) { _local_source->setUnit(unit) ;} + int direction() const { return _local_source->direction(); } + const std::map& visibleFriends() const { return _local_source->visibleFriends(); } const std::set& visibleServices() const { return _local_source->visibleServices(); } protected: diff --git a/retroshare-gui/src/gui/statistics/BandwidthGraphWindow.cpp b/retroshare-gui/src/gui/statistics/BandwidthGraphWindow.cpp index a4ac860e0..0cd4e25b9 100644 --- a/retroshare-gui/src/gui/statistics/BandwidthGraphWindow.cpp +++ b/retroshare-gui/src/gui/statistics/BandwidthGraphWindow.cpp @@ -105,7 +105,11 @@ BandwidthGraph::BandwidthGraph(QWidget *parent, Qt::WindowFlags flags) ui.chkReceiveRate->setIcon(FilesDefs::getIconFromQtResourcePath(IMG_RECEIVE)); ui.chkReceiveRate->setText(""); + ui.btnGraphColor->setIcon(FilesDefs::getIconFromQtResourcePath(IMG_GRAPH_LIGHT)); + ui.frmGraph->setFlags(RSGraphWidget::RSGRAPH_FLAGS_DARK_STYLE); + ui.frmGraph->setToolTip("Use Ctrl+mouse wheel to change line width, Shift+wheel to time-filter the curve."); + ui.frmGraph->setDirection(BWGraphSource::DIRECTION_UP | BWGraphSource::DIRECTION_DOWN); loadSettings(); @@ -119,21 +123,13 @@ BandwidthGraph::BandwidthGraph(QWidget *parent, Qt::WindowFlags flags) void BandwidthGraph::toggleSendRate(bool b) { - whileBlocking(ui.chkReceiveRate)->setChecked(!b); - - if(b) - ui.frmGraph->setDirection(BWGraphSource::DIRECTION_UP) ; - else - ui.frmGraph->setDirection(BWGraphSource::DIRECTION_DOWN) ; + ui.frmGraph->setShowEntry(0,b); + saveSettings(); } void BandwidthGraph::toggleReceiveRate(bool b) { - whileBlocking(ui.chkSendRate)->setChecked(!b); - - if(b) - ui.frmGraph->setDirection(BWGraphSource::DIRECTION_DOWN) ; - else - ui.frmGraph->setDirection(BWGraphSource::DIRECTION_UP) ; + ui.frmGraph->setShowEntry(1,b); + saveSettings(); } @@ -149,6 +145,8 @@ void BandwidthGraph::switchGraphColor() ui.frmGraph->setFlags(RSGraphWidget::RSGRAPH_FLAGS_DARK_STYLE); ui.btnGraphColor->setIcon(FilesDefs::getIconFromQtResourcePath(IMG_GRAPH_DARK)); } + + saveSettings(); } /** Loads the saved Bandwidth Graph settings. */ @@ -159,60 +157,29 @@ BandwidthGraph::loadSettings() ui.sldrOpacity->setValue(getSetting(SETTING_OPACITY, DEFAULT_OPACITY).toInt()); setOpacity(ui.sldrOpacity->value()); - /* Set the line filter checkboxes accordingly */ - uint filter = getSetting(SETTING_FILTER, DEFAULT_FILTER).toUInt(); - ui.chkReceiveRate->setChecked(filter & BWGRAPH_LINE_RECV); - ui.chkSendRate->setChecked(filter & BWGRAPH_LINE_SEND); - /* Set whether we are plotting bandwidth as area graphs or not */ - int graphStyle = getSetting(SETTING_STYLE, DEFAULT_STYLE).toInt(); - -// if (graphStyle < 0 || graphStyle >= ui.cmbGraphStyle->count()) { -// graphStyle = DEFAULT_STYLE; -// } -// ui.cmbGraphStyle->setCurrentIndex(graphStyle); - - if(graphStyle==0) - ui.frmGraph->resetFlags(RSGraphWidget::RSGRAPH_FLAGS_PAINT_STYLE_PLAIN); - else - ui.frmGraph->setFlags(RSGraphWidget::RSGRAPH_FLAGS_PAINT_STYLE_PLAIN); - - /* Set whether we are plotting bandwidth as area graphs or not */ int graphColor = getSetting(SETTING_GRAPHCOLOR, DEFAULT_GRAPHCOLOR).toInt(); if(graphColor>0) { - ui.frmGraph->resetFlags(RSGraphWidget::RSGRAPH_FLAGS_DARK_STYLE); + ui.frmGraph->setFlags(RSGraphWidget::RSGRAPH_FLAGS_DARK_STYLE); ui.btnGraphColor->setIcon(FilesDefs::getIconFromQtResourcePath(IMG_GRAPH_DARK)); } else { ui.btnGraphColor->setIcon(FilesDefs::getIconFromQtResourcePath(IMG_GRAPH_LIGHT)); - ui.frmGraph->setFlags(RSGraphWidget::RSGRAPH_FLAGS_DARK_STYLE); + ui.frmGraph->resetFlags(RSGraphWidget::RSGRAPH_FLAGS_DARK_STYLE); } /* Download & Upload */ int defaultdirection = getSetting(SETTING_DIRECTION, DEFAULT_DIRECTION).toInt(); -// if (defaultdirection < 0 || defaultdirection >= ui.cmbDownUp->count()) { -// defaultdirection = DEFAULT_DIRECTION; -// } -// ui.cmbDownUp->setCurrentIndex(graphColor); - - if(defaultdirection>0) - { - ui.frmGraph->setDirection(BWGraphSource::DIRECTION_DOWN) ; - whileBlocking(ui.chkSendRate)->setChecked(false); - whileBlocking(ui.chkReceiveRate)->setChecked(true); - } - else - { - ui.frmGraph->setDirection(BWGraphSource::DIRECTION_UP) ; - whileBlocking(ui.chkSendRate)->setChecked(true); - whileBlocking(ui.chkReceiveRate)->setChecked(false); - } + whileBlocking(ui.chkSendRate )->setChecked(bool(defaultdirection & BWGraphSource::DIRECTION_UP )); + whileBlocking(ui.chkReceiveRate)->setChecked(bool(defaultdirection & BWGraphSource::DIRECTION_DOWN)); /* Default Settings for the Graph */ + ui.frmGraph->setDirection(BWGraphSource::DIRECTION_UP | BWGraphSource::DIRECTION_DOWN); + ui.frmGraph->setSelector(BWGraphSource::SELECTOR_TYPE_FRIEND,BWGraphSource::GRAPH_TYPE_SUM) ; ui.frmGraph->resetFlags(RSGraphWidget::RSGRAPH_FLAGS_LOG_SCALE_Y) ; @@ -230,56 +197,41 @@ void BandwidthGraph::reset() ui.frmGraph->resetGraph(); } -/** Saves the Bandwidth Graph settings and adjusts the graph if necessary. */ -void BandwidthGraph::saveChanges() +BandwidthGraph::~BandwidthGraph() { - /* Hide the settings frame and reset toggle button */ - showSettingsFrame(false); - - /* Save the opacity and graph style */ - saveSetting(SETTING_OPACITY, ui.sldrOpacity->value()); -// saveSetting(SETTING_STYLE, ui.cmbGraphStyle->currentIndex()); - saveSetting(SETTING_GRAPHCOLOR, ui.btnGraphColor->isChecked()); + saveSettings(); +} +/** Saves the Bandwidth Graph settings and adjusts the graph if necessary. */ +void BandwidthGraph::saveSettings() +{ + /* Save the opacity and graph style */ + saveSetting(SETTING_OPACITY, ui.sldrOpacity->value()); + saveSetting(SETTING_GRAPHCOLOR, ui.btnGraphColor->isChecked()); - /* Save the Always On Top setting */ - saveSetting(SETTING_ALWAYS_ON_TOP, ui.chkAlwaysOnTop->isChecked()); - if (ui.chkAlwaysOnTop->isChecked()) { - setWindowFlags(windowFlags() | Qt::WindowStaysOnTopHint); - } else { - setWindowFlags(windowFlags() & ~Qt::WindowStaysOnTopHint); - } - setOpacity(ui.sldrOpacity->value()); + /* Save the Always On Top setting */ + saveSetting(SETTING_ALWAYS_ON_TOP, ui.chkAlwaysOnTop->isChecked()); - /* Save the line filter values */ - uint filter = 0; - ADD_TO_FILTER(filter, BWGRAPH_LINE_RECV, ui.chkReceiveRate->isChecked()); - ADD_TO_FILTER(filter, BWGRAPH_LINE_SEND, ui.chkSendRate->isChecked()); - saveSetting(SETTING_FILTER, filter); + /* Save the line filter values */ + saveSetting(SETTING_DIRECTION, ui.frmGraph->direction()); + /* Update the graph frame settings */ + // ui.frmGraph->setShowEntry(0,ui.chkReceiveRate->isChecked()) ; + // ui.frmGraph->setShowEntry(1,ui.chkSendRate->isChecked()) ; + // ui.frmGraph->resetFlags(RSGraphWidget::RSGRAPH_FLAGS_PAINT_STYLE_PLAIN); - /* Update the graph frame settings */ - ui.frmGraph->setShowEntry(0,ui.chkReceiveRate->isChecked()) ; - ui.frmGraph->setShowEntry(1,ui.chkSendRate->isChecked()) ; - ui.frmGraph->resetFlags(RSGraphWidget::RSGRAPH_FLAGS_PAINT_STYLE_PLAIN); + // if(ui.btnGraphColor->isChecked()==0) + // ui.frmGraph->resetFlags(RSGraphWidget::RSGRAPH_FLAGS_DARK_STYLE); + // else + // ui.frmGraph->setFlags(RSGraphWidget::RSGRAPH_FLAGS_DARK_STYLE); -// if(ui.cmbGraphStyle->currentIndex()==0) -// ui.frmGraph->resetFlags(RSGraphWidget::RSGRAPH_FLAGS_PAINT_STYLE_PLAIN); -// else -// ui.frmGraph->setFlags(RSGraphWidget::RSGRAPH_FLAGS_PAINT_STYLE_PLAIN); + // if(ui.cmbDownUp->currentIndex()==0) + // ui.frmGraph->setDirection(BWGraphSource::DIRECTION_UP) ; + // else + // ui.frmGraph->setDirection(BWGraphSource::DIRECTION_DOWN) ; - if(ui.btnGraphColor->isChecked()==0) - ui.frmGraph->resetFlags(RSGraphWidget::RSGRAPH_FLAGS_DARK_STYLE); - else - ui.frmGraph->setFlags(RSGraphWidget::RSGRAPH_FLAGS_DARK_STYLE); - -// if(ui.cmbDownUp->currentIndex()==0) -// ui.frmGraph->setDirection(BWGraphSource::DIRECTION_UP) ; -// else -// ui.frmGraph->setDirection(BWGraphSource::DIRECTION_DOWN) ; - - /* A change in window flags causes the window to disappear, so make sure + /* A change in window flags causes the window to disappear, so make sure * it's still visible. */ - showNormal(); + showNormal(); } /** Simply restores the previously saved settings. */ diff --git a/retroshare-gui/src/gui/statistics/BandwidthGraphWindow.h b/retroshare-gui/src/gui/statistics/BandwidthGraphWindow.h index fb52d28b2..276f7fa6a 100644 --- a/retroshare-gui/src/gui/statistics/BandwidthGraphWindow.h +++ b/retroshare-gui/src/gui/statistics/BandwidthGraphWindow.h @@ -45,6 +45,7 @@ public: /** Default constructor */ BandwidthGraph(QWidget *parent = 0, Qt::WindowFlags flags = 0); + virtual ~BandwidthGraph(); public slots: /** Overloaded QWidget.show */ @@ -59,8 +60,6 @@ private slots: void showSettingsFrame(bool show); /** Called when the settings button is toggled */ void setOpacity(int value); - /** Called when the user saves settings */ - void saveChanges(); /** Called when the user cancels changes settings */ void cancelChanges(); /** Called when the reset button is pressed */ @@ -71,6 +70,7 @@ private: void createActions(); /** Loads the saved Bandwidth Graph settings */ void loadSettings(); + void saveSettings(); /** Qt Designer generated object */ Ui::BandwidthGraph ui; From 1abd206443f87ed3603ab3e101cd50f3e6d7957e Mon Sep 17 00:00:00 2001 From: csoler Date: Mon, 1 Feb 2021 17:59:25 +0100 Subject: [PATCH 3/6] added missing delete causing mem leak in GXS distant search --- libretroshare/src/gxs/rsgxsnettunnel.cc | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/libretroshare/src/gxs/rsgxsnettunnel.cc b/libretroshare/src/gxs/rsgxsnettunnel.cc index 0237c4fb7..380491c5d 100644 --- a/libretroshare/src/gxs/rsgxsnettunnel.cc +++ b/libretroshare/src/gxs/rsgxsnettunnel.cc @@ -1045,6 +1045,8 @@ bool RsGxsNetTunnelService::receiveSearchRequest(unsigned char *search_request_d search_result_data_size = RsGxsNetTunnelSerializer().size(&search_result_item) ; search_result_data = (unsigned char*)rs_malloc(search_result_data_size) ; + delete item; + if(search_result_data == NULL) return false ; @@ -1082,10 +1084,12 @@ bool RsGxsNetTunnelService::receiveSearchRequest(unsigned char *search_request_d RsGxsNetTunnelSerializer().serialise(&search_result_item,search_result_data,&search_result_data_size); + delete item; return true ; } } + delete item; return false ; } From b5b490067bf39f6958b5eb49027824f96bae097b Mon Sep 17 00:00:00 2001 From: csoler Date: Mon, 1 Feb 2021 20:53:17 +0100 Subject: [PATCH 4/6] fixed random crash in forum search --- retroshare-gui/src/gui/gxsforums/GxsForumThreadWidget.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/retroshare-gui/src/gui/gxsforums/GxsForumThreadWidget.cpp b/retroshare-gui/src/gui/gxsforums/GxsForumThreadWidget.cpp index 457766fc0..d03f93ca0 100644 --- a/retroshare-gui/src/gui/gxsforums/GxsForumThreadWidget.cpp +++ b/retroshare-gui/src/gui/gxsforums/GxsForumThreadWidget.cpp @@ -257,6 +257,7 @@ GxsForumThreadWidget::GxsForumThreadWidget(const RsGxsGroupId &forumId, QWidget mThreadModel = new RsGxsForumModel(this); mThreadProxyModel = new ForumPostSortFilterProxyModel(ui->threadTreeWidget->header(),this); mThreadProxyModel->setSourceModel(mThreadModel); + mThreadProxyModel->setDynamicSortFilter(false); // causes crashes when true. mThreadProxyModel->setSortRole(RsGxsForumModel::SortRole); ui->threadTreeWidget->setModel(mThreadProxyModel); From 95e1073b8a1e60d6db835262eaabe50b61d40283 Mon Sep 17 00:00:00 2001 From: csoler Date: Tue, 2 Feb 2021 12:35:17 +0100 Subject: [PATCH 5/6] fixed error in reputation that prevented to account for delay after which banned identities are un-banned --- libretroshare/src/services/p3gxsreputation.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libretroshare/src/services/p3gxsreputation.cc b/libretroshare/src/services/p3gxsreputation.cc index a6fb352d2..4b7383a93 100644 --- a/libretroshare/src/services/p3gxsreputation.cc +++ b/libretroshare/src/services/p3gxsreputation.cc @@ -390,7 +390,7 @@ void p3GxsReputation::cleanup() #ifdef DEBUG_REPUTATION std::cerr << " ID " << it->first << ": own is negative for more than " << mMaxPreventReloadBannedIds/86400 << " days. Reseting it!" << std::endl; #endif - mChanged = true ; + should_delete = true; } // Delete slots with basically no information From d4141c493d5887328c55dabeac33d90e8af2e26e Mon Sep 17 00:00:00 2001 From: csoler Date: Tue, 2 Feb 2021 12:37:15 +0100 Subject: [PATCH 6/6] moved calls to setDynamicSortFilter(false) into constructors of sort proxy models --- .../src/gui/FileTransfer/SharedFilesDialog.cpp | 12 ++++++------ retroshare-gui/src/gui/common/NewFriendList.cpp | 6 ++++-- retroshare-gui/src/gui/common/RsCollectionDialog.cpp | 5 +++-- .../src/gui/gxsforums/GxsForumThreadWidget.cpp | 6 ++++-- retroshare-gui/src/gui/msgs/MessagesDialog.cpp | 6 ++++-- 5 files changed, 21 insertions(+), 14 deletions(-) diff --git a/retroshare-gui/src/gui/FileTransfer/SharedFilesDialog.cpp b/retroshare-gui/src/gui/FileTransfer/SharedFilesDialog.cpp index 974a2e5b1..20de4b9e9 100644 --- a/retroshare-gui/src/gui/FileTransfer/SharedFilesDialog.cpp +++ b/retroshare-gui/src/gui/FileTransfer/SharedFilesDialog.cpp @@ -99,6 +99,12 @@ public: SFDSortFilterProxyModel(RetroshareDirModel *dirModel, QObject *parent) : QSortFilterProxyModel(parent) { m_dirModel = dirModel; + + // Mr.Alice: I removed this because it causes a crash for some obscur reason. Apparently when the model is changed, the proxy model cannot + // deal with the change by itself. Should I call something specific? I've no idea. Removing this does not seem to cause any harm either. + //Ghibli: set false because by default in qt5 is true and makes rs crash when sorting, all this decided by Cyril not me :D it works + + setDynamicSortFilter(false); } protected: @@ -193,12 +199,6 @@ SharedFilesDialog::SharedFilesDialog(bool remote_mode, QWidget *parent) flat_proxyModel->setFilterRole(RetroshareDirModel::FilterRole); flat_proxyModel->setFilterRegExp(QRegExp(QString(RETROSHARE_DIR_MODEL_FILTER_STRING))) ; - // Mr.Alice: I removed this because it causes a crash for some obscur reason. Apparently when the model is changed, the proxy model cannot - // deal with the change by itself. Should I call something specific? I've no idea. Removing this does not seem to cause any harm either. - //Ghibli: set false because by default in qt5 is true and makes rs crash when sorting, all this decided by Cyril not me :D it works - tree_proxyModel->setDynamicSortFilter(false); - flat_proxyModel->setDynamicSortFilter(false); - connect(ui.filterClearButton, SIGNAL(clicked()), this, SLOT(clearFilter())); connect(ui.filterStartButton, SIGNAL(clicked()), this, SLOT(startFilter())); connect(ui.filterPatternLineEdit, SIGNAL(returnPressed()), this, SLOT(startFilter())); diff --git a/retroshare-gui/src/gui/common/NewFriendList.cpp b/retroshare-gui/src/gui/common/NewFriendList.cpp index 0329bc6af..4d794e6c4 100644 --- a/retroshare-gui/src/gui/common/NewFriendList.cpp +++ b/retroshare-gui/src/gui/common/NewFriendList.cpp @@ -111,7 +111,10 @@ public: : QSortFilterProxyModel(parent) , m_header(header) , m_sortingEnabled(false), m_sortByState(false) - , m_showOfflineNodes(true) {} + , m_showOfflineNodes(true) + { + setDynamicSortFilter(false); // causes crashes when true. + } bool lessThan(const QModelIndex& left, const QModelIndex& right) const override { @@ -184,7 +187,6 @@ NewFriendList::NewFriendList(QWidget */*parent*/) : /* RsAutoUpdatePage(5000,par mProxyModel->setSourceModel(mModel); mProxyModel->setSortRole(RsFriendListModel::SortRole); - mProxyModel->setDynamicSortFilter(false); mProxyModel->setSortCaseSensitivity(Qt::CaseInsensitive); mProxyModel->setFilterRole(RsFriendListModel::FilterRole); mProxyModel->setFilterRegExp(QRegExp(RsFriendListModel::FilterString)); diff --git a/retroshare-gui/src/gui/common/RsCollectionDialog.cpp b/retroshare-gui/src/gui/common/RsCollectionDialog.cpp index b3f53a220..417af69bc 100644 --- a/retroshare-gui/src/gui/common/RsCollectionDialog.cpp +++ b/retroshare-gui/src/gui/common/RsCollectionDialog.cpp @@ -64,7 +64,9 @@ class FSMSortFilterProxyModel : public QSortFilterProxyModel { public: FSMSortFilterProxyModel( QObject *parent) : QSortFilterProxyModel(parent) - {} + { + setDynamicSortFilter(false); // essential to avoid random crashes + } protected: virtual bool lessThan(const QModelIndex &left, const QModelIndex &right) const @@ -201,7 +203,6 @@ RsCollectionDialog::RsCollectionDialog(const QString& collectionFileName connect(_dirModel, SIGNAL(directoryLoaded(QString)), this, SLOT(directoryLoaded(QString))); _tree_proxyModel = new FSMSortFilterProxyModel(this); - _tree_proxyModel->setDynamicSortFilter(true); _tree_proxyModel->setSourceModel(_dirModel); _tree_proxyModel->setSortCaseSensitivity(Qt::CaseInsensitive); _tree_proxyModel->setSortRole(Qt::DisplayRole); diff --git a/retroshare-gui/src/gui/gxsforums/GxsForumThreadWidget.cpp b/retroshare-gui/src/gui/gxsforums/GxsForumThreadWidget.cpp index d03f93ca0..64b4fff7f 100644 --- a/retroshare-gui/src/gui/gxsforums/GxsForumThreadWidget.cpp +++ b/retroshare-gui/src/gui/gxsforums/GxsForumThreadWidget.cpp @@ -206,7 +206,10 @@ public: class ForumPostSortFilterProxyModel: public QSortFilterProxyModel { public: - explicit ForumPostSortFilterProxyModel(const QHeaderView *header,QObject *parent = NULL): QSortFilterProxyModel(parent),m_header(header) {} + explicit ForumPostSortFilterProxyModel(const QHeaderView *header,QObject *parent = NULL): QSortFilterProxyModel(parent),m_header(header) + { + setDynamicSortFilter(false); // causes crashes when true + } bool lessThan(const QModelIndex& left, const QModelIndex& right) const override { @@ -257,7 +260,6 @@ GxsForumThreadWidget::GxsForumThreadWidget(const RsGxsGroupId &forumId, QWidget mThreadModel = new RsGxsForumModel(this); mThreadProxyModel = new ForumPostSortFilterProxyModel(ui->threadTreeWidget->header(),this); mThreadProxyModel->setSourceModel(mThreadModel); - mThreadProxyModel->setDynamicSortFilter(false); // causes crashes when true. mThreadProxyModel->setSortRole(RsGxsForumModel::SortRole); ui->threadTreeWidget->setModel(mThreadProxyModel); diff --git a/retroshare-gui/src/gui/msgs/MessagesDialog.cpp b/retroshare-gui/src/gui/msgs/MessagesDialog.cpp index 0254461f1..b193d8920 100644 --- a/retroshare-gui/src/gui/msgs/MessagesDialog.cpp +++ b/retroshare-gui/src/gui/msgs/MessagesDialog.cpp @@ -98,7 +98,10 @@ class MessageSortFilterProxyModel: public QSortFilterProxyModel { public: - MessageSortFilterProxyModel(QObject *parent = NULL): QSortFilterProxyModel(parent), m_sortingEnabled(false) {} + MessageSortFilterProxyModel(QObject *parent = NULL): QSortFilterProxyModel(parent), m_sortingEnabled(false) + { + setDynamicSortFilter(false); // causes crashes when true + } bool lessThan(const QModelIndex& left, const QModelIndex& right) const override { @@ -145,7 +148,6 @@ MessagesDialog::MessagesDialog(QWidget *parent) mMessageProxyModel = new MessageSortFilterProxyModel(this); mMessageProxyModel->setSourceModel(mMessageModel); mMessageProxyModel->setSortRole(RsMessageModel::SortRole); - mMessageProxyModel->setDynamicSortFilter(false); mMessageProxyModel->setSortCaseSensitivity(Qt::CaseInsensitive); mMessageProxyModel->setFilterRole(RsMessageModel::FilterRole); mMessageProxyModel->setFilterRegExp(QRegExp(RsMessageModel::FilterString));