File: dbcmaineditor.h

package info (click to toggle)
savvycan 220-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 12,456 kB
  • sloc: cpp: 61,803; sh: 293; javascript: 91; python: 44; makefile: 8
file content (100 lines) | stat: -rw-r--r-- 2,903 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
#ifndef DBCMAINEDITOR_H
#define DBCMAINEDITOR_H

#include <QDialog>
#include <QDebug>
#include <QIcon>
#include <QTreeWidget>
#include <QRandomGenerator>
#include "dbchandler.h"
#include "dbcsignaleditor.h"
#include "dbcmessageeditor.h"
#include "dbcnodeeditor.h"
#include "dbcnoderebaseeditor.h"
#include "dbcnodeduplicateeditor.h"
#include "utility.h"

namespace Ui {
class DBCMainEditor;
}

enum DBCItemTypes
{
    NODE = 1,
    MESG = 2,
    SIG = 3
};

class DBCMainEditor : public QDialog
{
    Q_OBJECT

public:
    explicit DBCMainEditor(const QVector<CANFrame> *frames, QWidget *parent = 0);
    ~DBCMainEditor();
    void setFileIdx(int idx);

public slots:
    void updatedNode(DBC_NODE *node);
    void updatedMessage(DBC_MESSAGE *msg, quint32 orig_id);
    void updatedSignal(DBC_SIGNAL *sig);

private slots:
    void onTreeDoubleClicked(const QModelIndex &index);
    void onTreeContextMenu(const QPoint & pos);
    void currentItemChanged(QTreeWidgetItem *current, QTreeWidgetItem *prev);
    void onCustomMenuTree(QPoint);
    void deleteCurrentTreeItem();
    void deleteNode(DBC_NODE *node);
    void deleteMessage(DBC_MESSAGE *msg);
    void deleteSignal(DBC_SIGNAL *sig);
    void handleSearch();
    void handleSearchForward();
    void handleSearchBackward();
    void newNode(QString nodeName);
    void newNode();
    void copyMessageToNode(DBC_NODE *node, DBC_MESSAGE *source, uint newMsgId);
    void newMessage();
    void newSignal();    
    void onRebaseMessages();
    void onDuplicateNode();

private:
    Ui::DBCMainEditor *ui;
    DBCHandler *dbcHandler;
    const QVector<CANFrame> *referenceFrames;
    DBCSignalEditor *sigEditor;
    DBCMessageEditor *msgEditor;
    DBCNodeEditor *nodeEditor;
    DBCNodeRebaseEditor *nodeRebaseEditor;
    DBCNodeDuplicateEditor *nodeDuplicateEditor;
    DBCFile *dbcFile;
    int fileIdx;
    QIcon nodeIcon;
    QIcon messageIcon;
    QIcon signalIcon;
    QIcon multiplexorSignalIcon;
    QIcon multiplexedSignalIcon;
    QList<QTreeWidgetItem *> searchItems;
    int searchItemPos;
    //bidirectional mapping of QTreeWidget items back and forth to DBC objects
    QMap<DBC_NODE*, QTreeWidgetItem *> nodeToItem;
    QMap<DBC_MESSAGE*, QTreeWidgetItem *> messageToItem;
    QMap<DBC_SIGNAL*, QTreeWidgetItem *> signalToItem;
    QMap<QTreeWidgetItem*, DBC_NODE*> itemToNode;
    QMap<QTreeWidgetItem*, DBC_MESSAGE*> itemToMessage;
    QMap<QTreeWidgetItem*, DBC_SIGNAL*> itemToSignal;
    QRandomGenerator randGen;

    void showEvent(QShowEvent* event);
    void closeEvent(QCloseEvent *event);
    bool eventFilter(QObject *obj, QEvent *event);
    void readSettings();
    void writeSettings();
    void refreshTree();
    void processSignalToTree(QTreeWidgetItem *parent, DBC_SIGNAL *sig);
    uint32_t getParentMessageID(QTreeWidgetItem *cell);
    QString createSignalText(DBC_SIGNAL *sig);
};

#endif // DBCMAINEDITOR_H