blob: a0fd5f305a632b64d80094decff2cebd6470aa88 [file] [log] [blame]
Amaury Poulyfe1fed82014-09-26 10:46:48 +02001/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2014 by Amaury Pouly
11 *
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
16 *
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
19 *
20 ****************************************************************************/
Amaury Poulyc3233812013-08-21 20:16:26 +020021#ifndef REGTAB_H
22#define REGTAB_H
23
24#include <QComboBox>
Amaury Poulyc3233812013-08-21 20:16:26 +020025#include <QTreeWidget>
26#include <QVBoxLayout>
27#include <QTabWidget>
28#include <QSplitter>
29#include <QLineEdit>
30#include <QPushButton>
31#include <QLabel>
32#include <QListWidget>
Amaury Pouly04fc97b2014-02-10 23:10:55 +010033#include <QGroupBox>
34#include <QToolButton>
35#include <QMenu>
36#include <QCheckBox>
Amaury Poulyc3233812013-08-21 20:16:26 +020037#include "backend.h"
38#include "settings.h"
Amaury Pouly43566662014-04-07 11:28:04 +020039#include "mainwindow.h"
Amaury Poulya01bf8d2014-09-18 19:02:54 +020040#include "utils.h"
Amaury Poulyc3233812013-08-21 20:16:26 +020041
Amaury Pouly43566662014-04-07 11:28:04 +020042class RegTabPanel
Amaury Pouly3d077062014-02-09 02:13:53 +010043{
44public:
Amaury Pouly43566662014-04-07 11:28:04 +020045 RegTabPanel() {}
46 virtual ~RegTabPanel() {}
47 virtual void AllowWrite(bool en) = 0;
48 virtual QWidget *GetWidget() = 0;
Amaury Pouly3d077062014-02-09 02:13:53 +010049};
50
Amaury Pouly43566662014-04-07 11:28:04 +020051class EmptyRegTabPanel : public QWidget, public RegTabPanel
Amaury Poulyc3233812013-08-21 20:16:26 +020052{
53public:
Amaury Pouly43566662014-04-07 11:28:04 +020054 EmptyRegTabPanel(QWidget *parent = 0);
Amaury Pouly04fc97b2014-02-10 23:10:55 +010055 void AllowWrite(bool en);
Amaury Pouly43566662014-04-07 11:28:04 +020056 QWidget *GetWidget();
Amaury Poulyc3233812013-08-21 20:16:26 +020057};
58
Amaury Pouly43566662014-04-07 11:28:04 +020059class RegTab : public QSplitter, public DocumentTab
Amaury Poulyc3233812013-08-21 20:16:26 +020060{
61 Q_OBJECT
62public:
Amaury Pouly43566662014-04-07 11:28:04 +020063 RegTab(Backend *backend, QWidget *parent = 0);
Amaury Poulyb8bad842014-02-09 02:17:14 +010064 ~RegTab();
Amaury Pouly43566662014-04-07 11:28:04 +020065 virtual bool Quit();
Amaury Pouly970c2482014-09-18 21:36:17 +020066 virtual QWidget *GetWidget();
Amaury Poulyc3233812013-08-21 20:16:26 +020067
68protected:
Amaury Pouly43566662014-04-07 11:28:04 +020069 void FillDevSubTree(QTreeWidgetItem *item);
Amaury Poulyef0299c2014-08-09 18:39:45 +020070 void FillSocSubTree(QTreeWidgetItem *item);
Amaury Poulyc3233812013-08-21 20:16:26 +020071 void FillRegTree();
72 void FillAnalyserList();
73 void UpdateSocList();
Amaury Pouly3d077062014-02-09 02:13:53 +010074 void DisplayRegister(const SocRegRef& ref);
Amaury Pouly43566662014-04-07 11:28:04 +020075 void DisplayDevice(const SocDevRef& ref);
Amaury Poulyef0299c2014-08-09 18:39:45 +020076 void DisplaySoc(const SocRef& ref);
Amaury Poulyc3233812013-08-21 20:16:26 +020077 void SetDataSocName(const QString& socname);
Amaury Pouly43566662014-04-07 11:28:04 +020078 void SetPanel(RegTabPanel *panel);
79 void UpdateSocFilename();
Amaury Pouly970c2482014-09-18 21:36:17 +020080 void UpdateTabName();
Amaury Pouly7749c4d2014-10-07 14:30:24 +020081 int SetMessage(MessageWidget::MessageType type, const QString& msg);
82 void HideMessage(int id);
Amaury Pouly43566662014-04-07 11:28:04 +020083
Amaury Poulyc3233812013-08-21 20:16:26 +020084 QComboBox *m_soc_selector;
Amaury Poulya01bf8d2014-09-18 19:02:54 +020085 BackendSelector *m_backend_selector;
Amaury Poulyc3233812013-08-21 20:16:26 +020086 Backend *m_backend;
87 QTreeWidget *m_reg_tree;
Amaury Pouly3d077062014-02-09 02:13:53 +010088 SocRef m_cur_soc;
Amaury Poulyc3233812013-08-21 20:16:26 +020089 QVBoxLayout *m_right_panel;
Amaury Pouly43566662014-04-07 11:28:04 +020090 RegTabPanel *m_right_content;
Amaury Pouly04fc97b2014-02-10 23:10:55 +010091 QCheckBox *m_readonly_check;
Amaury Poulyc3233812013-08-21 20:16:26 +020092 QLabel *m_data_soc_label;
93 QPushButton *m_data_sel_reload;
Amaury Pouly7b590a92014-05-11 19:51:55 +020094 QPushButton *m_dump;
Amaury Poulyc3233812013-08-21 20:16:26 +020095 IoBackend *m_io_backend;
96 QTabWidget *m_type_selector;
97 QListWidget *m_analysers_list;
Amaury Poulyb08620d2014-09-27 13:29:44 +020098 MessageWidget *m_msg;
Amaury Pouly7749c4d2014-10-07 14:30:24 +020099 int m_msg_select_id;
100 int m_msg_error_id;
Amaury Poulyc3233812013-08-21 20:16:26 +0200101
102private slots:
Amaury Poulya66a5af2014-02-09 02:16:43 +0100103 void SetReadOnlyIndicator();
Amaury Pouly43566662014-04-07 11:28:04 +0200104 void OnSocChanged(int index);
Amaury Poulyc3233812013-08-21 20:16:26 +0200105 void OnSocListChanged();
Amaury Poulyc3233812013-08-21 20:16:26 +0200106 void OnRegItemClicked(QTreeWidgetItem *clicked, int col);
Amaury Poulya01bf8d2014-09-18 19:02:54 +0200107 void OnBackendSelect(IoBackend *backend);
Amaury Poulyc3233812013-08-21 20:16:26 +0200108 void OnDataChanged();
109 void OnDataSocActivated(const QString&);
Amaury Poulyc3233812013-08-21 20:16:26 +0200110 void OnAnalyserClicked(QListWidgetItem *clicked);
Amaury Pouly04fc97b2014-02-10 23:10:55 +0100111 void OnReadOnlyClicked(bool);
Amaury Pouly7b590a92014-05-11 19:51:55 +0200112 void OnDumpRegs(bool);
Amaury Pouly0c633db2014-09-18 19:03:25 +0200113 void OnBackendReload(bool);
114 void OnTypeChanged(int index);
Amaury Poulyc3233812013-08-21 20:16:26 +0200115};
116
117#endif /* REGTAB_H */