• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

VIファイルから作成したLabVIEWバージョンを表示。by QtCreator(Mingw)


Commit MetaInfo

Revisiona2ba0dae542e367b1509dfae9587d4ae578b5e00 (tree)
Zeit2011-05-12 22:02:04
Autorarakaki <alucky4416@user...>
Commiterarakaki

Log Message

2'nd Commit

Ändern Zusammenfassung

Diff

--- a/GetVIVersion.pro
+++ b/GetVIVersion.pro
@@ -1,18 +1,18 @@
1-#-------------------------------------------------
2-#
3-# Project created by QtCreator 2011-05-10T12:46:26
4-#
5-#-------------------------------------------------
6-
7-QT += core gui
8-
9-TARGET = GetVIVersion
10-TEMPLATE = app
11-
12-
13-SOURCES += main.cpp\
14- mainwindow.cpp
15-
16-HEADERS += mainwindow.h
17-
18-FORMS += mainwindow.ui
1+#-------------------------------------------------
2+#
3+# Project created by QtCreator 2011-05-10T12:46:26
4+#
5+#-------------------------------------------------
6+
7+QT += core gui
8+
9+TARGET = GetVIVersion
10+TEMPLATE = app
11+
12+
13+SOURCES += main.cpp\
14+ mainwindow.cpp
15+
16+HEADERS += mainwindow.h
17+
18+FORMS += mainwindow.ui
--- a/main.cpp
+++ b/main.cpp
@@ -1,17 +1,17 @@
1-// GetVIVersion
2-// main.cpp -
3-//
4-// Time-stamp: "2011/05/11 16:53:20 +0900"
5-
6-#include <QtGui/QApplication>
7-#include "mainwindow.h"
8-
9-int main(int argc, char *argv[])
10-{
11- QApplication a(argc, argv);
12- MainWindow w;
13- w.args = a.arguments();
14- w.show();
15-
16- return a.exec();
17-}
1+// GetVIVersion
2+// main.cpp -
3+//
4+// Time-stamp: "2011/05/11 16:53:20 +0900"
5+
6+#include <QtGui/QApplication>
7+#include "mainwindow.h"
8+
9+int main(int argc, char *argv[])
10+{
11+ QApplication a(argc, argv);
12+ MainWindow w;
13+ w.args = a.arguments();
14+ w.show();
15+
16+ return a.exec();
17+}
--- a/mainwindow.cpp
+++ b/mainwindow.cpp
@@ -1,153 +1,153 @@
1-// GetVIVersion
2-// mainwindow.cpp -
3-//
4-// Time-stamp: "2011/05/11 16:53:24 +0900"
5-
6-#include <stdio.h> // for GetVersionOfVI() Function
7-
8-#include <QMessageBox>
9-#include <QFileDialog>
10-
11-#include <QDropEvent>
12-#include <QUrl>
13-
14-#include "mainwindow.h"
15-#include "ui_mainwindow.h"
16-
17-int GetVersionOfVI(const char *filename, char *ver)
18-{
19- FILE *ifp;
20- char tmp[16];
21- char verbuf1[2]; // バージョン情報 8.0 以前 (6.0, 6.1, 7.1)
22- char verbuf2[2]; // バージョン情報 8.0 以降 (8.0, 8.2, 8.5, 8.6)
23-
24- if (NULL == (ifp = fopen(filename, "rb"))) {
25- fputs("cannot open file\n", stderr);
26- return -1;
27- }
28-
29- // compare "RSRC"
30- memset(tmp, 0, sizeof(tmp));
31- fseek(ifp, 0x0L, SEEK_SET);
32- fread(tmp, sizeof(char), 4, ifp);
33- if (0 != strcmp(tmp, "RSRC")) {
34-// fputs("not VI File\n", stderr);
35- fclose(ifp);
36- return 1;
37- }
38-
39- // compare "LVINLBVW"
40- memset(tmp, 0, sizeof(tmp));
41- fseek(ifp, 0x8L, SEEK_SET);
42- fread(tmp, sizeof(char), 8, ifp);
43- if (0 != strcmp(tmp, "LVINLBVW")) {
44-// fputs("not VI File\n", stderr);
45- fclose(ifp);
46- return -1;
47- }
48-
49- // VersionNumber 8.0以降 (8.0, 8.20, 8.5 8.6)
50- fseek(ifp, 0x24L, SEEK_SET);
51- fread(verbuf2, sizeof(char), 2, ifp);
52-
53- // VersionNumber 8.0以前 (6.0, 6.1, 7.0 7.1)
54- fseek(ifp, 0x2CL, SEEK_SET);
55- fread(verbuf1, sizeof(char), 2, ifp);
56-
57- if (verbuf1[0] > 0x04 && verbuf1[0] < 0x08 ) {
58- sprintf(ver, "%02x.%02x", verbuf1[0], verbuf1[1]);
59- } else if (verbuf2[0] > 0x04 && verbuf2[0] < 0x30) {
60- sprintf(ver, "%02x.%02x", verbuf2[0], verbuf2[1]);
61- } else {
62- ;
63-// fputs("Version unkown.", stderr);
64- }
65-
66- fclose(ifp);
67-
68- return 0;
69-}
70-
71-MainWindow::MainWindow(QWidget *parent) :
72- QMainWindow(parent),
73- ui(new Ui::MainWindow)
74-{
75- ui->setupUi(this);
76-
77- firstShow = true; // 1'st Time only Exec flag
78-
79- setAcceptDrops(true); // for File Drop
80-}
81-
82-MainWindow::~MainWindow()
83-{
84- delete ui;
85-}
86-
87-void MainWindow::showEvent(QShowEvent *event)
88-{
89- if (firstShow) {
90- // Command-Line Parameter
91- if (1 < args.size()) {
92- QString stmp = args.at(1).toLocal8Bit().constData();
93- ui->lineEdit_FilePath->clear();
94- ui->lineEdit_FilePath->setText(stmp);
95- }
96- firstShow = false;
97- }
98- QMainWindow::showEvent(event);
99-}
100-
101-void MainWindow::dragEnterEvent(QDragEnterEvent *event)
102-{
103- if (event->mimeData()->hasFormat("text/uri-list"))
104- event->acceptProposedAction();
105-}
106-
107-void MainWindow::dropEvent(QDropEvent *event)
108-{
109- QString stmp = event->mimeData()->urls().at(0).path();
110-
111- QRegExp rx("^/[A-Z]:/"); // isDriveLetter?
112- if (0 > rx.indexIn(stmp)) {
113- ; // not match
114- } else {
115- // match, is filepath ("/C:/tmp/")
116- stmp = stmp.mid(1); // remove 1st '/' character, from url.path()
117- }
118- ui->lineEdit_FilePath->clear();
119- ui->lineEdit_FilePath->setText(stmp);
120-
121- event->acceptProposedAction();
122-}
123-
124-void MainWindow::on_lineEdit_FilePath_textChanged(QString s)
125-{
126- const char *Filepath;
127- char VerInfo[8] = {0};
128-
129- if (ui->lineEdit_FilePath->text().length() > 0) {
130- QByteArray stmp = ui->lineEdit_FilePath->text().toLocal8Bit();
131- Filepath = stmp.constData();
132- if (0 == GetVersionOfVI(Filepath, VerInfo)) {
133- ui->lineEdit_Version->setText(VerInfo);
134- } else {
135- ui->lineEdit_Version->setText(tr("Unknown..."));
136- }
137- }
138-}
139-
140-void MainWindow::on_toolButton_clicked()
141-{
142-// QMessageBox::information(this, tr("information"), tr("toolButton clicked."));
143- QString fileName = QFileDialog::getOpenFileName(
144- this,
145- tr("Select LabVIEW VI file"), // title
146- QDir::homePath(), // CurrentPath
147- tr("VI File(*.vi);;All Files (*)")); // Filter
148-
149- if (!fileName.isEmpty()) {
150- ui->lineEdit_FilePath->clear();
151- ui->lineEdit_FilePath->setText(fileName);
152- }
153-}
1+// GetVIVersion
2+// mainwindow.cpp -
3+//
4+// Time-stamp: "2011/05/11 16:53:24 +0900"
5+
6+#include <stdio.h> // for GetVersionOfVI() Function
7+
8+#include <QMessageBox>
9+#include <QFileDialog>
10+
11+#include <QDropEvent>
12+#include <QUrl>
13+
14+#include "mainwindow.h"
15+#include "ui_mainwindow.h"
16+
17+int GetVersionOfVI(const char *filename, char *ver)
18+{
19+ FILE *ifp;
20+ char tmp[16];
21+ char verbuf1[2]; // バージョン情報 8.0 以前 (6.0, 6.1, 7.1)
22+ char verbuf2[2]; // バージョン情報 8.0 以降 (8.0, 8.2, 8.5, 8.6)
23+
24+ if (NULL == (ifp = fopen(filename, "rb"))) {
25+ fputs("cannot open file\n", stderr);
26+ return -1;
27+ }
28+
29+ // compare "RSRC"
30+ memset(tmp, 0, sizeof(tmp));
31+ fseek(ifp, 0x0L, SEEK_SET);
32+ fread(tmp, sizeof(char), 4, ifp);
33+ if (0 != strcmp(tmp, "RSRC")) {
34+// fputs("not VI File\n", stderr);
35+ fclose(ifp);
36+ return 1;
37+ }
38+
39+ // compare "LVINLBVW"
40+ memset(tmp, 0, sizeof(tmp));
41+ fseek(ifp, 0x8L, SEEK_SET);
42+ fread(tmp, sizeof(char), 8, ifp);
43+ if (0 != strcmp(tmp, "LVINLBVW")) {
44+// fputs("not VI File\n", stderr);
45+ fclose(ifp);
46+ return -1;
47+ }
48+
49+ // VersionNumber 8.0以降 (8.0, 8.20, 8.5 8.6)
50+ fseek(ifp, 0x24L, SEEK_SET);
51+ fread(verbuf2, sizeof(char), 2, ifp);
52+
53+ // VersionNumber 8.0以前 (6.0, 6.1, 7.0 7.1)
54+ fseek(ifp, 0x2CL, SEEK_SET);
55+ fread(verbuf1, sizeof(char), 2, ifp);
56+
57+ if (verbuf1[0] > 0x04 && verbuf1[0] < 0x08 ) {
58+ sprintf(ver, "%02x.%02x", verbuf1[0], verbuf1[1]);
59+ } else if (verbuf2[0] > 0x04 && verbuf2[0] < 0x30) {
60+ sprintf(ver, "%02x.%02x", verbuf2[0], verbuf2[1]);
61+ } else {
62+ ;
63+// fputs("Version unkown.", stderr);
64+ }
65+
66+ fclose(ifp);
67+
68+ return 0;
69+}
70+
71+MainWindow::MainWindow(QWidget *parent) :
72+ QMainWindow(parent),
73+ ui(new Ui::MainWindow)
74+{
75+ ui->setupUi(this);
76+
77+ firstShow = true; // 1'st Time only Exec flag
78+
79+ setAcceptDrops(true); // for File Drop
80+}
81+
82+MainWindow::~MainWindow()
83+{
84+ delete ui;
85+}
86+
87+void MainWindow::showEvent(QShowEvent *event)
88+{
89+ if (firstShow) {
90+ // Command-Line Parameter
91+ if (1 < args.size()) {
92+ QString stmp = args.at(1).toLocal8Bit().constData();
93+ ui->lineEdit_FilePath->clear();
94+ ui->lineEdit_FilePath->setText(stmp);
95+ }
96+ firstShow = false;
97+ }
98+ QMainWindow::showEvent(event);
99+}
100+
101+void MainWindow::dragEnterEvent(QDragEnterEvent *event)
102+{
103+ if (event->mimeData()->hasFormat("text/uri-list"))
104+ event->acceptProposedAction();
105+}
106+
107+void MainWindow::dropEvent(QDropEvent *event)
108+{
109+ QString stmp = event->mimeData()->urls().at(0).path();
110+
111+ QRegExp rx("^/[A-Z]:/"); // isDriveLetter?
112+ if (0 > rx.indexIn(stmp)) {
113+ ; // not match
114+ } else {
115+ // match, is filepath ("/C:/tmp/")
116+ stmp = stmp.mid(1); // remove 1st '/' character, from url.path()
117+ }
118+ ui->lineEdit_FilePath->clear();
119+ ui->lineEdit_FilePath->setText(stmp);
120+
121+ event->acceptProposedAction();
122+}
123+
124+void MainWindow::on_lineEdit_FilePath_textChanged(QString s)
125+{
126+ const char *Filepath;
127+ char VerInfo[8] = {0};
128+
129+ if (ui->lineEdit_FilePath->text().length() > 0) {
130+ QByteArray stmp = ui->lineEdit_FilePath->text().toLocal8Bit();
131+ Filepath = stmp.constData();
132+ if (0 == GetVersionOfVI(Filepath, VerInfo)) {
133+ ui->lineEdit_Version->setText(VerInfo);
134+ } else {
135+ ui->lineEdit_Version->setText(tr("Unknown..."));
136+ }
137+ }
138+}
139+
140+void MainWindow::on_toolButton_clicked()
141+{
142+// QMessageBox::information(this, tr("information"), tr("toolButton clicked."));
143+ QString fileName = QFileDialog::getOpenFileName(
144+ this,
145+ tr("Select LabVIEW VI file"), // title
146+ QDir::homePath(), // CurrentPath
147+ tr("VI File(*.vi);;All Files (*)")); // Filter
148+
149+ if (!fileName.isEmpty()) {
150+ ui->lineEdit_FilePath->clear();
151+ ui->lineEdit_FilePath->setText(fileName);
152+ }
153+}
--- a/mainwindow.h
+++ b/mainwindow.h
@@ -1,35 +1,35 @@
1-#ifndef MAINWINDOW_H
2-#define MAINWINDOW_H
3-
4-#include <QMainWindow>
5-
6-namespace Ui {
7- class MainWindow;
8-}
9-
10-class MainWindow : public QMainWindow
11-{
12- Q_OBJECT
13-
14-public:
15- explicit MainWindow(QWidget *parent = 0);
16- ~MainWindow();
17-
18- QStringList args;
19-
20-private slots:
21- void on_lineEdit_FilePath_textChanged(QString );
22-
23- void showEvent(QShowEvent *event);
24- void dragEnterEvent(QDragEnterEvent *event);
25- void dropEvent(QDropEvent *event);
26-
27- void on_toolButton_clicked();
28-
29-private:
30- Ui::MainWindow *ui;
31-
32- bool firstShow;
33-};
34-
35-#endif // MAINWINDOW_H
1+#ifndef MAINWINDOW_H
2+#define MAINWINDOW_H
3+
4+#include <QMainWindow>
5+
6+namespace Ui {
7+ class MainWindow;
8+}
9+
10+class MainWindow : public QMainWindow
11+{
12+ Q_OBJECT
13+
14+public:
15+ explicit MainWindow(QWidget *parent = 0);
16+ ~MainWindow();
17+
18+ QStringList args;
19+
20+private slots:
21+ void on_lineEdit_FilePath_textChanged(QString );
22+
23+ void showEvent(QShowEvent *event);
24+ void dragEnterEvent(QDragEnterEvent *event);
25+ void dropEvent(QDropEvent *event);
26+
27+ void on_toolButton_clicked();
28+
29+private:
30+ Ui::MainWindow *ui;
31+
32+ bool firstShow;
33+};
34+
35+#endif // MAINWINDOW_H
--- a/mainwindow.ui
+++ b/mainwindow.ui
@@ -1,128 +1,128 @@
1-<?xml version="1.0" encoding="UTF-8"?>
2-<ui version="4.0">
3- <class>MainWindow</class>
4- <widget class="QMainWindow" name="MainWindow">
5- <property name="geometry">
6- <rect>
7- <x>0</x>
8- <y>0</y>
9- <width>450</width>
10- <height>118</height>
11- </rect>
12- </property>
13- <property name="minimumSize">
14- <size>
15- <width>450</width>
16- <height>110</height>
17- </size>
18- </property>
19- <property name="maximumSize">
20- <size>
21- <width>450</width>
22- <height>120</height>
23- </size>
24- </property>
25- <property name="windowTitle">
26- <string>GetVIVersion</string>
27- </property>
28- <widget class="QWidget" name="centralWidget">
29- <widget class="QLineEdit" name="lineEdit_FilePath">
30- <property name="geometry">
31- <rect>
32- <x>10</x>
33- <y>20</y>
34- <width>361</width>
35- <height>16</height>
36- </rect>
37- </property>
38- <property name="acceptDrops">
39- <bool>false</bool>
40- </property>
41- <property name="alignment">
42- <set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
43- </property>
44- <property name="readOnly">
45- <bool>false</bool>
46- </property>
47- </widget>
48- <widget class="QLineEdit" name="lineEdit_Version">
49- <property name="geometry">
50- <rect>
51- <x>320</x>
52- <y>50</y>
53- <width>111</width>
54- <height>20</height>
55- </rect>
56- </property>
57- <property name="readOnly">
58- <bool>true</bool>
59- </property>
60- </widget>
61- <widget class="QLabel" name="label1">
62- <property name="geometry">
63- <rect>
64- <x>10</x>
65- <y>0</y>
66- <width>111</width>
67- <height>16</height>
68- </rect>
69- </property>
70- <property name="text">
71- <string>LabVIEW VI Filepath</string>
72- </property>
73- </widget>
74- <widget class="QLabel" name="label">
75- <property name="geometry">
76- <rect>
77- <x>230</x>
78- <y>50</y>
79- <width>91</width>
80- <height>16</height>
81- </rect>
82- </property>
83- <property name="text">
84- <string>LabVIEW Verison</string>
85- </property>
86- </widget>
87- <widget class="QToolButton" name="toolButton">
88- <property name="geometry">
89- <rect>
90- <x>380</x>
91- <y>20</y>
92- <width>61</width>
93- <height>18</height>
94- </rect>
95- </property>
96- <property name="text">
97- <string>Select ...</string>
98- </property>
99- </widget>
100- </widget>
101- <widget class="QMenuBar" name="menuBar">
102- <property name="geometry">
103- <rect>
104- <x>0</x>
105- <y>0</y>
106- <width>450</width>
107- <height>19</height>
108- </rect>
109- </property>
110- </widget>
111- <widget class="QToolBar" name="mainToolBar">
112- <attribute name="toolBarArea">
113- <enum>TopToolBarArea</enum>
114- </attribute>
115- <attribute name="toolBarBreak">
116- <bool>false</bool>
117- </attribute>
118- </widget>
119- </widget>
120- <layoutdefault spacing="6" margin="11"/>
121- <tabstops>
122- <tabstop>lineEdit_FilePath</tabstop>
123- <tabstop>toolButton</tabstop>
124- <tabstop>lineEdit_Version</tabstop>
125- </tabstops>
126- <resources/>
127- <connections/>
128-</ui>
1+<?xml version="1.0" encoding="UTF-8"?>
2+<ui version="4.0">
3+ <class>MainWindow</class>
4+ <widget class="QMainWindow" name="MainWindow">
5+ <property name="geometry">
6+ <rect>
7+ <x>0</x>
8+ <y>0</y>
9+ <width>450</width>
10+ <height>118</height>
11+ </rect>
12+ </property>
13+ <property name="minimumSize">
14+ <size>
15+ <width>450</width>
16+ <height>110</height>
17+ </size>
18+ </property>
19+ <property name="maximumSize">
20+ <size>
21+ <width>450</width>
22+ <height>120</height>
23+ </size>
24+ </property>
25+ <property name="windowTitle">
26+ <string>GetVIVersion</string>
27+ </property>
28+ <widget class="QWidget" name="centralWidget">
29+ <widget class="QLineEdit" name="lineEdit_FilePath">
30+ <property name="geometry">
31+ <rect>
32+ <x>10</x>
33+ <y>20</y>
34+ <width>361</width>
35+ <height>16</height>
36+ </rect>
37+ </property>
38+ <property name="acceptDrops">
39+ <bool>false</bool>
40+ </property>
41+ <property name="alignment">
42+ <set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
43+ </property>
44+ <property name="readOnly">
45+ <bool>false</bool>
46+ </property>
47+ </widget>
48+ <widget class="QLineEdit" name="lineEdit_Version">
49+ <property name="geometry">
50+ <rect>
51+ <x>320</x>
52+ <y>50</y>
53+ <width>111</width>
54+ <height>20</height>
55+ </rect>
56+ </property>
57+ <property name="readOnly">
58+ <bool>true</bool>
59+ </property>
60+ </widget>
61+ <widget class="QLabel" name="label1">
62+ <property name="geometry">
63+ <rect>
64+ <x>10</x>
65+ <y>0</y>
66+ <width>111</width>
67+ <height>16</height>
68+ </rect>
69+ </property>
70+ <property name="text">
71+ <string>LabVIEW VI Filepath</string>
72+ </property>
73+ </widget>
74+ <widget class="QLabel" name="label">
75+ <property name="geometry">
76+ <rect>
77+ <x>230</x>
78+ <y>50</y>
79+ <width>91</width>
80+ <height>16</height>
81+ </rect>
82+ </property>
83+ <property name="text">
84+ <string>LabVIEW Verison</string>
85+ </property>
86+ </widget>
87+ <widget class="QToolButton" name="toolButton">
88+ <property name="geometry">
89+ <rect>
90+ <x>380</x>
91+ <y>20</y>
92+ <width>61</width>
93+ <height>18</height>
94+ </rect>
95+ </property>
96+ <property name="text">
97+ <string>Select ...</string>
98+ </property>
99+ </widget>
100+ </widget>
101+ <widget class="QMenuBar" name="menuBar">
102+ <property name="geometry">
103+ <rect>
104+ <x>0</x>
105+ <y>0</y>
106+ <width>450</width>
107+ <height>19</height>
108+ </rect>
109+ </property>
110+ </widget>
111+ <widget class="QToolBar" name="mainToolBar">
112+ <attribute name="toolBarArea">
113+ <enum>TopToolBarArea</enum>
114+ </attribute>
115+ <attribute name="toolBarBreak">
116+ <bool>false</bool>
117+ </attribute>
118+ </widget>
119+ </widget>
120+ <layoutdefault spacing="6" margin="11"/>
121+ <tabstops>
122+ <tabstop>lineEdit_FilePath</tabstop>
123+ <tabstop>toolButton</tabstop>
124+ <tabstop>lineEdit_Version</tabstop>
125+ </tabstops>
126+ <resources/>
127+ <connections/>
128+</ui>