0
0
mirror of https://github.com/yse/easy_profiler.git synced 2024-12-27 08:41:02 +08:00

Merge branch 'develop' of https://github.com/yse/easy_profiler into develop

This commit is contained in:
Victor Zarubkin 2016-08-04 23:35:49 +03:00
commit aac410d9f8
6 changed files with 115 additions and 27 deletions

View File

@ -28,6 +28,9 @@
#include <QMenu>
#include <QContextMenuEvent>
#include <QSignalBlocker>
#include <QSettings>
#include <qtextcodec.h>
#include "blocks_tree_widget.h"
//////////////////////////////////////////////////////////////////////////
@ -64,6 +67,7 @@ ProfTreeWidgetItem::ProfTreeWidgetItem(const ::profiler::BlocksTree* _treeBlock,
, m_customBGColor(0)
, m_customTextColor(0)
{
}
ProfTreeWidgetItem::~ProfTreeWidgetItem()
@ -234,9 +238,23 @@ ProfTreeWidget::ProfTreeWidget(QWidget* _parent) : Parent(_parent), m_beginTime(
header->setText(COL_NCALLS_TOTAL, "N Calls total");
setHeaderItem(header);
hideColumn(COL_END);
//hideColumn(COL_END);
connect(&::profiler_gui::EASY_GLOBALS.events, &::profiler_gui::ProfGlobalSignals::selectedThreadChanged, this, &This::onSelectedThreadChange);
QSettings settings(profiler_gui::ORGANAZATION_NAME, profiler_gui::APPLICATION_NAME);
settings.beginGroup("tree_widget");
auto color_rows_set = settings.value("color_rows");
if (!color_rows_set.isNull())
m_bColorRows = color_rows_set.toBool();
for (int i = 0; i < columnCount(); i++)
{
if (settings.value(QString("Column") + QString::number(i)).toBool())
hideColumn(i);
}
settings.endGroup();
}
ProfTreeWidget::ProfTreeWidget(const unsigned int _blocksNumber, const ::profiler::thread_blocks_tree_t& _blocksTree, QWidget* _parent) : This(_parent)
@ -252,6 +270,7 @@ ProfTreeWidget::ProfTreeWidget(const unsigned int _blocksNumber, const ::profile
ProfTreeWidget::~ProfTreeWidget()
{
saveSettings();
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@ -452,6 +471,10 @@ size_t ProfTreeWidget::setTreeInternal(const ::profiler_gui::TreeBlocks& _blocks
auto item = new ProfTreeWidgetItem(block.tree, thread_item);
duration = endTime - startTime;
/*QByteArray msg(block.tree->node->getBlockName());
QTextCodec *codec = QTextCodec::codecForName("Windows-1251");
QString strf = codec->toUnicode(msg);
*/
item->setText(COL_NAME, block.tree->node->getBlockName());
item->setTimeSmart(COL_DURATION, duration);
item->setTimeMs(COL_BEGIN, startTime - m_beginTime);
@ -577,6 +600,10 @@ size_t ProfTreeWidget::setTreeInternal(const ::profiler::BlocksTree::children_t&
continue;
}
/*QByteArray msg(child.node->getBlockName());
QTextCodec *codec = QTextCodec::codecForName("Windows-1251");
QString strf = codec->toUnicode(msg);*/
auto item = new ProfTreeWidgetItem(&child, _parent);
item->setText(COL_NAME, child.node->getBlockName());
item->setTimeSmart(COL_DURATION, duration);
@ -736,6 +763,7 @@ void ProfTreeWidget::contextMenuEvent(QContextMenuEvent* _event)
auto hidemenu = menu.addMenu("Select columns");
auto hdr = headerItem();
for (int i = 0; i < COL_COLUMNS_NUMBER; ++i)
{
auto columnAction = new ProfHideShowColumnAction(hdr->text(i), i);
@ -873,3 +901,18 @@ void ProfTreeWidget::onHideShowColumn(int _column)
}
//////////////////////////////////////////////////////////////////////////
void ProfTreeWidget::saveSettings()
{
QSettings settings(profiler_gui::ORGANAZATION_NAME, profiler_gui::APPLICATION_NAME);
settings.beginGroup("tree_widget");
settings.setValue("color_rows", m_bColorRows);
for (int i = 0; i < columnCount(); i++)
{
settings.setValue(QString("Column") + QString::number(i) , isColumnHidden(i));
}
settings.endGroup();
}

View File

@ -165,6 +165,10 @@ private slots:
void onHideShowColumn(int _column);
protected:
void saveSettings();
}; // END of class ProfTreeWidget.
//////////////////////////////////////////////////////////////////////////

View File

@ -32,6 +32,9 @@ class ProfTreeWidgetItem;
namespace profiler_gui {
const QString ORGANAZATION_NAME = "EasyProfiler";
const QString APPLICATION_NAME = "Easy profiler gui application";
//////////////////////////////////////////////////////////////////////////
class ProfGlobalSignals final : public QObject

View File

@ -8,6 +8,10 @@
#include "main_window.h"
#include "profiler/reader.h"
#ifdef WIN32
#pragma comment(linker, "/SUBSYSTEM:windows /ENTRY:mainCRTStartup")
#endif
int main(int argc, char **argv)
{
QApplication app(argc, argv);

View File

@ -28,6 +28,9 @@
#include <QMenu>
#include <QMenuBar>
#include <QCoreApplication>
#include <qevent.h>
#include <QSettings>
#include "main_window.h"
#include "blocks_tree_widget.h"
#include "blocks_graphics_view.h"
@ -90,6 +93,17 @@ ProfMainWindow::ProfMainWindow() : QMainWindow(), m_treeWidget(nullptr), m_graph
auto opened_filename = QCoreApplication::arguments().at(1).toStdString();
loadFile(opened_filename);
}
QSettings settings(profiler_gui::ORGANAZATION_NAME, profiler_gui::APPLICATION_NAME);
settings.beginGroup("main");
auto geometry = settings.value("geometry").toByteArray();
if (!geometry.isEmpty()){
restoreGeometry(geometry);
}
settings.endGroup();
}
ProfMainWindow::~ProfMainWindow()
@ -176,6 +190,23 @@ void ProfMainWindow::onTestViewportClicked(bool)
//////////////////////////////////////////////////////////////////////////
void ProfMainWindow::closeEvent(QCloseEvent *close_event)
{
saveSettings();
close_event->setAccepted(true);
QMainWindow::closeEvent(close_event);
}
//////////////////////////////////////////////////////////////////////////
void ProfMainWindow::saveSettings()
{
QSettings settings(profiler_gui::ORGANAZATION_NAME, profiler_gui::APPLICATION_NAME);
settings.beginGroup("main");
settings.setValue("geometry", this->saveGeometry());
settings.endGroup();
}

View File

@ -54,6 +54,9 @@ protected slots:
private:
void loadFile(const std::string& filename);
void closeEvent(QCloseEvent *close_event);
void saveSettings();
}; // END of class ProfMainWindow.