Root/Software/sie_cg/mainwindow.h

1/****************************************************************************
2**
3** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
4** All rights reserved.
5** Contact: Nokia Corporation (qt-info@nokia.com)
6**
7** This file is part of the examples of the Qt Toolkit.
8**
9** $QT_BEGIN_LICENSE:LGPL$
10** Commercial Usage
11** Licensees holding valid Qt Commercial licenses may use this file in
12** accordance with the Qt Commercial License Agreement provided with the
13** Software or, alternatively, in accordance with the terms contained in
14** a written agreement between you and Nokia.
15**
16** GNU Lesser General Public License Usage
17** Alternatively, this file may be used under the terms of the GNU Lesser
18** General Public License version 2.1 as published by the Free Software
19** Foundation and appearing in the file LICENSE.LGPL included in the
20** packaging of this file. Please review the following information to
21** ensure the GNU Lesser General Public License version 2.1 requirements
22** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
23**
24** In addition, as a special exception, Nokia gives you certain additional
25** rights. These rights are described in the Nokia Qt LGPL Exception
26** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
27**
28** GNU General Public License Usage
29** Alternatively, this file may be used under the terms of the GNU
30** General Public License version 3.0 as published by the Free Software
31** Foundation and appearing in the file LICENSE.GPL included in the
32** packaging of this file. Please review the following information to
33** ensure the GNU General Public License version 3.0 requirements will be
34** met: http://www.gnu.org/copyleft/gpl.html.
35**
36** If you have questions regarding the use of this file, please contact
37** Nokia at qt-info@nokia.com.
38** $QT_END_LICENSE$
39**
40****************************************************************************/
41
42#ifndef MAINWINDOW_H
43#define MAINWINDOW_H
44
45#include <QMainWindow>
46#include <QDir>
47#include <QtXml>
48#include <QtGui>
49#include <QHash>
50
51#include "diagramitem.h"
52#include "diagramscene.h"
53#include "diagramtextitem.h"
54#include "lineitem.h"
55#include "arrow.h"
56#include "ui_librarydialog.h"
57#include "ui_codedialog.h"
58#include "ui_optionsdialog.h"
59#include "callapp.h"
60
61class callApp;
62class DiagramScene;
63class DiagramTextItem;
64class DiagramItem;
65class Ui_libraryDialog;
66class Ui_cgDialog;
67class Ui_optionsDialog;
68class callexternappT;
69
70QT_BEGIN_NAMESPACE
71class QAction;
72class QToolBox;
73class QSpinBox;
74class QComboBox;
75class QFontComboBox;
76class QButtonGroup;
77class QLineEdit;
78class QGraphicsTextItem;
79class QFont;
80class QToolButton;
81class QAbstractButton;
82class QGraphicsView;
83QT_END_NAMESPACE
84
85class MainWindow : public QMainWindow
86{
87    Q_OBJECT
88
89public:
90   MainWindow();
91   QString filePath() const
92       { return myFilePath;}
93   QString currentDir() const
94   { return QDir::currentPath();}
95
96   int updateLibraries();
97
98   QStatusBar *statusBar;
99   void setFontSettings(QFont font);
100
101   // Options
102   QString templateDir;
103   QString templateFile;
104   QString makeFile;
105   QString workDir;
106   QString executableFile;
107   QString mipsToolChain;
108   QString mipsToolChainDir;
109   QString sieWorkDir;
110   QString fpgaFile;
111   QString sieIP;
112   QString configApp;
113   void writeSSH(QString);
114
115   //Undo-Redo
116   QList<QDomDocument> undoList;
117   QList<QDomDocument> redoList;
118   bool dontDelete;
119
120private slots:
121    void backgroundButtonGroupClicked(QAbstractButton *button);
122    void buttonGroupClicked(int id);
123    void cgGroupClicked();
124    void deleteItem();
125    void pointerGroupClicked(int id);
126    void bringToFront();
127    void sendToBack();
128    void itemInserted(DiagramItem *item);
129    void textInserted(QGraphicsTextItem *item);
130    void currentFontChanged(const QFont &font);
131    void fontSizeChanged(const QString &size);
132    void sceneScaleChanged(const QString &scale);
133    void textColorChanged();
134    void itemColorChanged();
135    void lineColorChanged();
136    void textButtonTriggered();
137    void fillButtonTriggered();
138    void lineButtonTriggered();
139    void handleFontChange();
140    void about();
141
142    int newDiagram(QString pathFile="");
143    int openDiagram();
144    int saveDiagram();
145    int saveAsDiagram();
146    int exportDiagram();
147
148    void undoDiagram();
149    void redoDiagram();
150
151    void setGridState();
152
153    int libraryForm();
154    void addLibPath();
155    void delLibPath();
156    void editLibPath();
157    void downLibPath();
158    void upLibPath();
159
160    int optionsForm();
161    void editTemplateDir();
162    void editWorkDir();
163    void editToolChain();
164    void editFPGABinary();
165
166    int codeForm();
167
168    void executeSSH();
169    void finishSSH();
170    void readSSH();
171    void sendCommand();
172
173    void executeCompile();
174    void finishCompile();
175    void readCompile();
176
177    void configFPGA();
178    void exeOnSie();
179
180    void saveTemplates();
181
182    void killProcess();
183    void lcdOn();
184    void lcdOff();
185
186private:
187    void cleanDomElementsByName();
188    int saveIfNeeded();
189    void addLibrariesButtons(QGridLayout *layout);
190    QDomDocument parseDocument(QString filePath);
191    void createLibraryDialog();
192    void createCgDialog();
193    void createOptionsDialog();
194    void createToolBox();
195    void createActions();
196    void createMenus();
197    void createToolbars();
198    void sendTo(bool value);
199    QWidget *createBackgroundCellWidget(const QString &text,
200                                        const QString &image);
201    QWidget *createCellWidget(QString text, QDomElement *customItem);
202
203    QMenu *createColorMenu(const char *slot, QColor defaultColor);
204    QIcon createColorToolButtonIcon(const QString &image, QColor color);
205    QIcon createColorIcon(QColor color);
206
207    DiagramScene *scene;
208    QGraphicsView *view;
209
210    QAction *newAction;
211    QAction *saveAction;
212    QAction *saveAsAction;
213    QAction *openAction;
214    QAction *exportImgAction;
215
216    QAction *exitAction;
217    QAction *addAction;
218    QAction *deleteAction;
219
220    QAction *libraryAction;
221    QAction *optionsAction;
222
223    QAction *toFrontAction;
224    QAction *sendBackAction;
225    QAction *aboutAction;
226
227    QAction *undoAction;
228    QAction *redoAction;
229
230    QMenu *fileMenu;
231    QMenu *itemMenu;
232    QMenu *preferencesMenu;
233    QMenu *aboutMenu;
234
235    QToolBar *fileToolBar;
236    QToolBar *cgToolbar;
237    QToolBar *textToolBar;
238    QToolBar *editToolBar;
239    QToolBar *colorToolBar;
240    QToolBar *pointerToolbar;
241
242    QComboBox *sceneScaleCombo;
243    QComboBox *itemColorCombo;
244    QComboBox *textColorCombo;
245    QComboBox *fontSizeCombo;
246    QFontComboBox *fontCombo;
247
248    QToolBox *toolBox;
249    QButtonGroup *buttonGroup;
250    QButtonGroup *pointerTypeGroup;
251    QButtonGroup *cgGroup;
252    QButtonGroup *backgroundButtonGroup;
253    QToolButton *fontColorToolButton;
254    QToolButton *fillColorToolButton;
255    QToolButton *lineColorToolButton;
256    QToolButton *gridButton;
257    QAction *boldAction;
258    QAction *underlineAction;
259    QAction *italicAction;
260    QAction *textAction;
261    QAction *fillAction;
262    QAction *lineAction;
263    QString myFilePath;
264    QDialog *libDialog;
265    Ui_libraryDialog *libUi;
266    QMainWindow *cgDialog;
267    Ui_codeDialog *cgUi;
268    QDialog *optionsDialog;
269    Ui_optionsDialog * optUi;
270    QStringList libraryList;
271    QHash<QString , QDomElement*> *domElementsByName;
272    QHash<QString , int> buttonIdByName;
273    static QString callexternapp(QString xexecFile, QString xexecParm);
274
275    void setDefaultOptions(){
276         templateDir = "templates/basic";
277         templateFile = "main.cpp";
278         makeFile = "Makefile";
279         workDir = "tmp";
280         executableFile = "SIE_APP";
281         mipsToolChainDir = "";
282         mipsToolChain = "mipsel-openwrt-linux";
283         sieWorkDir = "/tmp/CG";
284         fpgaFile = "templates/basic/basic.bit";
285         sieIP = "192.168.254.101";
286         configApp = "xc3sprog $FPGA_BINARY";
287    }
288
289    /* CG */
290    QString createPrototype(QList <DiagramTextItem *> &textItems,
291                            QList <QString> &ioTypes,
292                            QList <QString> &ioNames,
293                            QList <QString> &valueNames,
294                            QList <QString> &values,
295                            QString blockNameID,
296                            QList <DiagramTextItem *> &inputs,
297                            QList <DiagramTextItem *> &outputs);
298
299    bool itemIsHead(DiagramItem * item);
300    bool itemIsEnd(DiagramItem * item);
301    QString getIoType(DiagramTextItem * item);
302    QString passItem(DiagramItem * item,
303                     QList<DiagramItem *> &passItems,
304                     QList<Arrow *> &passArrows,
305                     QString &headerCode,
306                     QString &initCode,
307                     QString &blockCode,
308                     QString &extraCode,
309                     QString &mainCode,
310                     QString &iosCode,
311                     QString &warnings,
312                     QString &errors);
313
314    callApp *sieSSH;
315    callApp *compile;
316    bool sshReady;
317    int copyFileToSie(QString filepath);
318    QString appDir;
319};
320
321class callexternappT : public QThread
322{
323public:
324    QString execFile;
325    QString execParm;
326    QString retnValu;
327    void run()
328    {
329        QProcess lnexternapp;
330        lnexternapp.start(QString("%1 %2").arg(execFile).arg(execParm));
331        lnexternapp.waitForFinished(-1);
332        retnValu = QString(lnexternapp.readAll());
333    }
334};
335
336#endif
337

Archive Download this file

Branches:
master



interactive