-
Notifications
You must be signed in to change notification settings - Fork 0
/
mainwindow.cpp
361 lines (301 loc) · 10.5 KB
/
mainwindow.cpp
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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
#include "mainwindow.h"
#include "ui_mainwindow.h"
#include <QMessageBox>
#include <QtGui>
#include <QtCore>
#include <QMessageBox>
#include <QString>
#include <QDebug>
#include <QClipboard>
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
ui->graphicsView_Drawing->setStyleSheet("background-color:#FFD700");
ui->graphicsView_Pdf->setStyleSheet("background-color:#FFD700");
ui->graphicsView_Dxf->setStyleSheet("background-color:#FFD700");
// statusbar label
statusLabel = new QLabel(this);
statusLabel->setText(" Status");
ui->statusBar->addWidget(statusLabel);
ui->statusBar->setStyleSheet("color:#333");
ui->lineEdit_Sufix->setReadOnly(true);
loadSettings();// call settings
}
MainWindow::~MainWindow()
{
delete ui;
}
void MainWindow::foundIt()
{
QString partNum = " B" + ui->lineEdit_FindPart->text() + ", was successfully found";
ui->statusBar->showMessage(partNum,10000);
}
void MainWindow::foundItLessThan()
{
QString partNum = " B-" + ui->lineEdit_FindPart->text() + ", was successfully found";
ui->statusBar->showMessage(partNum,10000);
}
void MainWindow::notFound()
{
QString partNum = " B" + ui->lineEdit_FindPart->text() + ", was not found";
ui->statusBar->showMessage(partNum,5000);
}
void MainWindow::notFoundLessThan()
{
QString partNum = " B-" + ui->lineEdit_FindPart->text() + ", was not found";
ui->statusBar->showMessage(partNum,5000);
}
void MainWindow::searchingFiles()
{
QString partNum = " Searching for B" + ui->lineEdit_FindPart->text()+ "...";
ui->statusBar->showMessage(partNum);
}
void MainWindow::on_pushButton_Dxf_clicked()
{
QString fileNumber;
fileNumber = ui->lineEdit_FindPart->text();
int partNumber = fileNumber.toInt();
if(fileNumber == "" )
{
QMessageBox::information(this, "Empty", "Enter a number");
}
else if(fileNumber == "0" )
{
QMessageBox::information(this, "Enter a valid number", "Enter a number other than 0");
}
else if (partNumber <= 10000)// IF PART LESS THAN 10000, ADD DASH (-)
{
searchingFiles();
// assigned to a variable to be able to check the status
bool linkToDxf = QDesktopServices::openUrl(QUrl("file:///P:/SW_Track/B-" + fileNumber + ".dxf") );
if(linkToDxf !=true)
{
notFoundLessThan();
QMessageBox::information(this, "Not Found", "The DXF you are looking for was not found in this directory");
}
else
{
foundItLessThan();
}
}
else
{
searchingFiles();
// assigned to a variable to be able to check the status
bool linkToDxf = QDesktopServices::openUrl(QUrl("file:///P:/SW_Track/B" + fileNumber + ".dxf") );
if(linkToDxf !=true)
{
notFound();
QMessageBox::information(this, "Not Found", "The DXF you are looking for was not found in this directory");
}
else
{
foundIt();
}
}
}
void MainWindow::on_pushButton_Pdf_clicked()
{
QString fileNumber;
fileNumber = ui->lineEdit_FindPart->text();
int partNumber = fileNumber.toInt();
if(fileNumber == "" )
{
QMessageBox::information(this, "Empty", "Enter a number");
}
else if(fileNumber == "0" )
{
QMessageBox::information(this, "Enter a valid number", "Enter a number other than 0");
}
else if (partNumber <= 10000) // IF PART LESS THAN 10000, ADD DASH (-)
{
searchingFiles();
// assigned to a variable to be able to check the status
bool linkToPdf = QDesktopServices::openUrl(QUrl("file:///P:/S_Works-Dwgs/B---/B-" + fileNumber + ".pdf") );
if(linkToPdf!= true)
{
notFoundLessThan();
QMessageBox::information(this, "Not Found", "The PDF you are looking for was not found in this directory");
}
else
{
foundItLessThan();
}
}
else
{
searchingFiles();
// assigned to a variable to be able to check the status
bool linkToPdf = QDesktopServices::openUrl(QUrl("file:///P:/S_Works-Dwgs/B---/B" + fileNumber + ".pdf") );
if(linkToPdf!= true)
{
notFound();
QMessageBox::information(this, "Not Found", "The PDF you are looking for was not found in this directory");
}
else
{
foundIt();
}
}
}
void MainWindow::on_pushButton_Drawing_clicked()
{
QString fileNumber;
fileNumber = ui->lineEdit_FindPart->text();
int partNumber = fileNumber.toInt();
int directoryMin = (partNumber /1000)* (1000) + 1;// rounding number
int directoryMax = directoryMin + 999;
if(fileNumber == "0")
{
QMessageBox::information(this, "Enter a valid number", "Enter a number other than 0");
}
else if(fileNumber == "")
{
QMessageBox::information(this, "Empty", "Enter a number");
}
else if (partNumber <= 10000)// if part number is between 1 and 10000 use the static directory AND ADD DASH (-)
{
searchingFiles();
//static directory
QString directoryRange = "B-0001-B10000";
// assigned to a variable to be able to check the status
bool linkToDrawing = QDesktopServices::openUrl(QUrl("file:///N:/SolidWorksDrawing/B---/" + directoryRange + "/B-" + fileNumber + ".slddrw") );
if(linkToDrawing !=true)
{
notFoundLessThan();
QMessageBox::information(this, "Not Found", "The drawing you are looking for was not found in this directory");
}
else
{
foundItLessThan();
}
}
else
{
searchingFiles();
//converting ints to strings and concatinating them
QString directoryRange = "B"+ QString::number(directoryMin)+ "-" + "B" + QString::number(directoryMax);
bool linkToDrawing = QDesktopServices::openUrl(QUrl("file:///N:/SolidWorksDrawing/B---/" + directoryRange + "/b" + fileNumber + ".slddrw") );
if(linkToDrawing !=true)
{
notFound();
QMessageBox::information(this, "Not Found", "The drawing you are looking for was not found in this directory");
}
else
{
foundIt();
}
}
}
void MainWindow::on_pushButton_Check_clicked()
{
QString fileNumber;
fileNumber = ui->lineEdit_FindPart->text();
int partNumber = fileNumber.toInt();
int directoryMin = (partNumber /1000)* (1000) + 1;// rounding number
int directoryMax = directoryMin + 999;
if(fileNumber == "0")
{
QMessageBox::information(this, "Enter a valid number", "Enter a number other than 0");
}
else if(fileNumber == "")
{
QMessageBox::information(this, "Empty", "Enter a number");
}
else if (partNumber <= 10000)// if part number is between 1 and 10000 use the static directory AND ADD DASH (-)
{
//SHOW PART NUMBER
ui->label_LastChecked->setText("B-"+fileNumber);
//static directory
QString directoryRange = "B-0001-B10000";
QFile drawing("N:/SolidWorksDrawing/B---/" + directoryRange + "/B-" + fileNumber + ".slddrw");
QFile pdf("P:/S_Works-Dwgs/B---/B-" + fileNumber + ".pdf");
QFile dxf("P:/SW_Track/B-" + fileNumber + ".dxf");
if(drawing.exists())
{
ui->graphicsView_Drawing->setStyleSheet("background-color:#00ff00");
}
else
{
ui->graphicsView_Drawing->setStyleSheet("background-color:#ff0000");
}
// PDF
if(pdf.exists())
{
ui->graphicsView_Pdf->setStyleSheet("background-color:#00ff00");
}
else
{
ui->graphicsView_Pdf->setStyleSheet("background-color:#ff0000");
}
// DXF
if(dxf.exists())
{
ui->graphicsView_Dxf->setStyleSheet("background-color:#00ff00");
}
else
{
ui->graphicsView_Dxf->setStyleSheet("background-color:#ff0000");
}
}
else
{
//SHOW PART NUMBER
ui->label_LastChecked->setText("B"+fileNumber);
//converting ints to strings and concatinating them
QString directoryRange = "B"+ QString::number(directoryMin)+ "-" + "B" + QString::number(directoryMax);
QFile drawing("N:/SolidWorksDrawing/B---/" + directoryRange + "/B" + fileNumber + ".slddrw");
QFile pdf("P:/S_Works-Dwgs/B---/B" + fileNumber + ".pdf");
QFile dxf("P:/SW_Track/B" + fileNumber + ".dxf");
if(drawing.exists())
{
ui->graphicsView_Drawing->setStyleSheet("background-color:#00ff00");
}
else
{
ui->graphicsView_Drawing->setStyleSheet("background-color:#ff0000");
}
// PDF
if(pdf.exists())
{
ui->graphicsView_Pdf->setStyleSheet("background-color:#00ff00");
}
else
{
ui->graphicsView_Pdf->setStyleSheet("background-color:#ff0000");
}
// DXF
if(dxf.exists())
{
ui->graphicsView_Dxf->setStyleSheet("background-color:#00ff00");
}
else
{
ui->graphicsView_Dxf->setStyleSheet("background-color:#ff0000");
}
}
}//CHECK ENDS HERE
void MainWindow::on_actionSave_Location_triggered()
{
ui->statusBar->showMessage(" Saving layout...", 400);
QSettings settings("tuDesign", "FindR");
settings.setValue("geometry", saveGeometry());
QMessageBox::information(this,"Save Layout","Layout has been saved");
}
void MainWindow::loadSettings()
{
QSettings settings("tuDesign", "FindR");
restoreGeometry(settings.value("geometry").toByteArray());
}
void MainWindow::on_actionAbout_Finder_triggered()
{
QMessageBox::about(this, tr("About FindR"),
tr( "<img src=':/icons/images/FindRLogo-80x256.png'/>"
"<h2>FindR</h2>"
"<p>Version 1.0</p>"
"<p>Copyright © 2012 tuDesign. All Rights Reserved.</p>"
"<p>FindR was exclusively designed for the engineers at Kenall Manufacturing!"
));
}