2016-06-30 21:39:04 +03:00
|
|
|
/************************************************************************
|
|
|
|
* file name : main_window.h
|
|
|
|
* ----------------- :
|
|
|
|
* creation time : 2016/06/26
|
|
|
|
* author : Victor Zarubkin
|
|
|
|
* email : v.s.zarubkin@gmail.com
|
|
|
|
* ----------------- :
|
|
|
|
* description : The file contains declaration of MainWindow for easy_profiler GUI.
|
|
|
|
* ----------------- :
|
|
|
|
* change log : * 2016/06/26 Victor Zarubkin: initial commit.
|
|
|
|
* : *
|
|
|
|
* ----------------- :
|
2016-09-06 21:49:32 +03:00
|
|
|
* license : Lightweight profiler library for c++
|
|
|
|
* : Copyright(C) 2016 Sergey Yagovtsev, Victor Zarubkin
|
|
|
|
* :
|
|
|
|
* : 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 3 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, see <http://www.gnu.org/licenses/>.
|
2016-06-26 20:54:16 +03:00
|
|
|
************************************************************************/
|
|
|
|
|
|
|
|
#ifndef EASY_PROFILER_GUI__MAIN_WINDOW__H
|
|
|
|
#define EASY_PROFILER_GUI__MAIN_WINDOW__H
|
|
|
|
|
|
|
|
#include <string>
|
2016-08-18 23:26:41 +03:00
|
|
|
#include <thread>
|
|
|
|
#include <atomic>
|
|
|
|
#include <QMainWindow>
|
|
|
|
#include <QTimer>
|
2016-09-08 21:03:05 +03:00
|
|
|
#include <QtNetwork>
|
2016-06-26 20:54:16 +03:00
|
|
|
#include "profiler/reader.h"
|
2016-09-08 21:03:05 +03:00
|
|
|
#include <sstream>
|
2016-06-26 20:54:16 +03:00
|
|
|
|
|
|
|
//////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
class QDockWidget;
|
|
|
|
|
2016-08-18 23:26:41 +03:00
|
|
|
//////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
class EasyFileReader final
|
|
|
|
{
|
2016-08-28 18:19:12 +03:00
|
|
|
::profiler::SerializedData m_serializedBlocks; ///<
|
|
|
|
::profiler::SerializedData m_serializedDescriptors; ///<
|
|
|
|
::profiler::descriptors_list_t m_descriptors; ///<
|
2016-08-30 22:51:18 +03:00
|
|
|
::profiler::blocks_t m_blocks; ///<
|
2016-08-28 18:19:12 +03:00
|
|
|
::profiler::thread_blocks_tree_t m_blocksTree; ///<
|
|
|
|
QString m_filename; ///<
|
|
|
|
::std::thread m_thread; ///<
|
|
|
|
::std::atomic_bool m_bDone; ///<
|
|
|
|
::std::atomic<int> m_progress; ///<
|
|
|
|
::std::atomic<unsigned int> m_size; ///<
|
2016-08-18 23:26:41 +03:00
|
|
|
|
|
|
|
public:
|
|
|
|
|
|
|
|
EasyFileReader();
|
|
|
|
~EasyFileReader();
|
|
|
|
|
|
|
|
bool done() const;
|
|
|
|
int progress() const;
|
|
|
|
unsigned int size() const;
|
2016-08-23 22:44:04 +03:00
|
|
|
const QString& filename() const;
|
2016-08-18 23:26:41 +03:00
|
|
|
|
2016-08-23 22:44:04 +03:00
|
|
|
void load(const QString& _filename);
|
2016-08-18 23:26:41 +03:00
|
|
|
void interrupt();
|
2016-08-28 18:19:12 +03:00
|
|
|
void get(::profiler::SerializedData& _serializedBlocks, ::profiler::SerializedData& _serializedDescriptors,
|
2016-08-30 22:51:18 +03:00
|
|
|
::profiler::descriptors_list_t& _descriptors, ::profiler::blocks_t& _blocks, ::profiler::thread_blocks_tree_t& _tree,
|
|
|
|
QString& _filename);
|
2016-08-18 23:26:41 +03:00
|
|
|
|
|
|
|
}; // END of class EasyFileReader.
|
|
|
|
|
|
|
|
//////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
class EasyMainWindow : public QMainWindow
|
2016-06-26 20:54:16 +03:00
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
protected:
|
|
|
|
|
2016-08-18 23:26:41 +03:00
|
|
|
typedef EasyMainWindow This;
|
|
|
|
typedef QMainWindow Parent;
|
2016-06-30 02:57:57 +03:00
|
|
|
|
2016-08-28 18:19:12 +03:00
|
|
|
QString m_lastFile;
|
|
|
|
QDockWidget* m_treeWidget;
|
|
|
|
QDockWidget* m_graphicsView;
|
|
|
|
class QProgressDialog* m_progress;
|
|
|
|
QTimer m_readerTimer;
|
|
|
|
::profiler::SerializedData m_serializedBlocks;
|
|
|
|
::profiler::SerializedData m_serializedDescriptors;
|
|
|
|
EasyFileReader m_reader;
|
2016-06-26 20:54:16 +03:00
|
|
|
|
2016-09-08 23:15:01 +03:00
|
|
|
QTcpServer* m_server = nullptr;
|
|
|
|
QTcpSocket* m_client = nullptr;
|
2016-09-08 21:03:05 +03:00
|
|
|
std::stringstream m_receivedProfileData;
|
|
|
|
bool m_recFrames = false;
|
2016-06-26 20:54:16 +03:00
|
|
|
public:
|
|
|
|
|
2016-08-18 23:26:41 +03:00
|
|
|
EasyMainWindow();
|
|
|
|
virtual ~EasyMainWindow();
|
2016-06-26 20:54:16 +03:00
|
|
|
|
2016-08-04 23:46:04 +03:00
|
|
|
// Public virtual methods
|
|
|
|
|
|
|
|
void closeEvent(QCloseEvent* close_event) override;
|
|
|
|
|
2016-06-26 20:54:16 +03:00
|
|
|
protected slots:
|
|
|
|
|
|
|
|
void onOpenFileClicked(bool);
|
|
|
|
void onReloadFileClicked(bool);
|
|
|
|
void onExitClicked(bool);
|
2016-08-09 00:45:45 +03:00
|
|
|
void onEncodingChanged(bool);
|
2016-08-24 01:00:24 +03:00
|
|
|
void onChronoTextPosChanged(bool);
|
2016-08-18 23:26:41 +03:00
|
|
|
void onDrawBordersChanged(bool);
|
2016-08-23 22:44:04 +03:00
|
|
|
void onCollapseItemsAfterCloseChanged(bool);
|
|
|
|
void onAllItemsExpandedByDefaultChange(bool);
|
2016-08-23 23:50:30 +03:00
|
|
|
void onBindExpandStatusChange(bool);
|
2016-08-21 22:44:03 +03:00
|
|
|
void onExpandAllClicked(bool);
|
|
|
|
void onCollapseAllClicked(bool);
|
2016-08-18 23:26:41 +03:00
|
|
|
void onFileReaderTimeout();
|
|
|
|
void onFileReaderCancel();
|
2016-09-08 21:03:05 +03:00
|
|
|
void onCaptureClicked(bool);
|
2016-06-26 20:54:16 +03:00
|
|
|
|
2016-09-08 21:03:05 +03:00
|
|
|
void readTcpData();
|
|
|
|
void onNewConnection();
|
2016-09-08 23:15:01 +03:00
|
|
|
void onDisconnection();
|
2016-06-30 21:39:04 +03:00
|
|
|
private:
|
|
|
|
|
2016-08-04 23:46:04 +03:00
|
|
|
// Private non-virtual methods
|
|
|
|
|
2016-08-23 22:44:04 +03:00
|
|
|
void loadFile(const QString& filename);
|
2016-08-04 23:12:41 +03:00
|
|
|
|
2016-08-07 19:35:58 +03:00
|
|
|
void loadSettings();
|
2016-08-23 23:50:30 +03:00
|
|
|
void loadGeometry();
|
2016-09-06 22:23:55 +03:00
|
|
|
void saveSettingsAndGeometry();
|
2016-06-30 21:39:04 +03:00
|
|
|
|
2016-09-08 21:03:05 +03:00
|
|
|
bool m_isClientPreparedBlocks = false;
|
|
|
|
bool m_isClientCaptured = false;
|
|
|
|
|
2016-08-18 23:26:41 +03:00
|
|
|
}; // END of class EasyMainWindow.
|
2016-06-26 20:54:16 +03:00
|
|
|
|
|
|
|
//////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
#endif // EASY_PROFILER_GUI__MAIN_WINDOW__H
|