summaryrefslogtreecommitdiff
path: root/cad/plugins/NanoVision-1/src/ErrorDialog.cpp
blob: 133ef9cd957c510620f648f0f3e38867dddb6fe7 (plain)
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
// Copyright 2008 Nanorex, Inc.  See LICENSE file for details.

#include "ErrorDialog.h"


/* CONSTRUCTORS */
ErrorDialog::ErrorDialog(const QString& shortMessage,
						 NXCommandResult* commandResult,
						 QWidget *parent)
		: QDialog(parent), Ui_ErrorDialog() {
		
	setupUi(this);
	errorImageLabel->setPixmap(QPixmap(":/Icons/error.png"));
	
	QString longMessage;
	if (commandResult)
		longMessage = GetNV1ResultCodeString(commandResult);
	else
		longMessage = shortMessage;
		
	setMessage(shortMessage, longMessage);
}
ErrorDialog::ErrorDialog(const QString& shortMessage,
						 const QString& longMessage,
						 QWidget *parent)
		: QDialog(parent), Ui_ErrorDialog() {
		
	setupUi(this);
	errorImageLabel->setPixmap(QPixmap(":/Icons/error.png"));
				  
	setMessage(shortMessage, longMessage);
}


/* DESTRUCTOR */
ErrorDialog::~ErrorDialog() {
}


/* FUNCTION: setMessage */
void ErrorDialog::setMessage(const QString& shortMessage,
							 const QString& longMessage) {
	
	QString logMessage = shortMessage;
	if (shortMessage != longMessage)
		logMessage.append(": ").append(longMessage);
	NXLOG_SEVERE("", qPrintable(logMessage));
	
	errorLabel->setText(shortMessage);
	textEdit->setText(longMessage);
}