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
|
/**
* Copyright (C) 2001 the KGhostView authors. See file AUTHORS.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#include <tqlabel.h>
#include <tqlayout.h>
#include <tqtextedit.h>
#include <kdebug.h>
#include <tdelocale.h>
#include <kseparator.h>
#include <kpushbutton.h>
#include <kstdguiitem.h>
#include "kdscerrordialog.h"
#include "kdscerrordialog.moc"
KDSCErrorThreshold::KDSCErrorThreshold( int threshold,
KDSCErrorHandler* errorHandler ) :
_threshold( threshold ),
_errorHandler( errorHandler )
{}
KDSCErrorHandler::Response KDSCErrorThreshold::error( const KDSCError& err )
{
if( _errorHandler != 0 && err.severity() >= _threshold )
return _errorHandler->error( err );
else
// Cancel is the default handling strategy for dsc_error_fn, so
// we keep it. This cancels error handling and *not* document
// parsing!
return Cancel;
}
KDSCErrorDialog::KDSCErrorDialog( TQWidget* parent ) :
KDialog( parent, "dscerrordialog", true ),
_response( Ok )
{
TQVBoxLayout* vbox = new TQVBoxLayout( this, marginHint(), spacingHint() );
_lineNumberLabel = new TQLabel( this );
vbox->addWidget( _lineNumberLabel );
_lineLabel = new TQTextEdit( this );
_lineLabel->setReadOnly( true );
vbox->addWidget( _lineLabel );
_descriptionLabel = new TQLabel( this );
vbox->addWidget( _descriptionLabel );
KSeparator* sep = new KSeparator( KSeparator::HLine, this );
vbox->addWidget( sep );
TQHBoxLayout* hbox = new TQHBoxLayout( vbox );
hbox->addStretch();
_okButton = new KPushButton( KStdGuiItem::ok(), this );
hbox->addWidget( _okButton );
_cancelButton = new KPushButton( KStdGuiItem::cancel(), this );
hbox->addWidget( _cancelButton );
_ignoreAllButton = new TQPushButton( i18n("Ignore All"), this );
hbox->addWidget( _ignoreAllButton );
connect( _okButton, TQT_SIGNAL( clicked() ), this, TQT_SLOT( slotOk() ) );
connect( _cancelButton, TQT_SIGNAL( clicked() ), this, TQT_SLOT( slotCancel() ) );
connect( _ignoreAllButton, TQT_SIGNAL( clicked() ),
this, TQT_SLOT( slotIgnoreAll() ) );
}
KDSCErrorHandler::Response KDSCErrorDialog::error( const KDSCError& err )
{
switch( err.severity() )
{
case KDSCError::Information:
setCaption( i18n( "DSC Information" ) );
break;
case KDSCError::Warning:
setCaption( i18n( "DSC Warning" ) );
break;
case KDSCError::Error:
setCaption( i18n( "DSC Error" ) );
break;
}
_lineNumberLabel->setText( i18n( "On line %1:" ).arg( err.lineNumber() ) );
_lineLabel->setText( err.line() );
_descriptionLabel->setText( description( err.type() ) );
exec();
kdDebug(4500) << "KDSCErrorDialog: returning " << _response << endl;
return _response;
}
TQString KDSCErrorDialog::description( KDSCError::Type type ) const
{
switch( type )
{
case KDSCError::BBox:
return "TODO";
case KDSCError::EarlyTrailer:
return "TODO";
case KDSCError::EarlyEOF:
return "TODO";
case KDSCError::PageInTrailer:
return "TODO";
case KDSCError::PageOrdinal:
return "TODO";
case KDSCError::PagesWrong:
return "TODO";
case KDSCError::EPSNoBBox:
return "TODO";
case KDSCError::EPSPages:
return "TODO";
case KDSCError::NoMedia:
return "TODO";
case KDSCError::AtEnd:
return "TODO";
case KDSCError::DuplicateComment:
return "TODO";
case KDSCError::DuplicateTrailer:
return "TODO";
case KDSCError::BeginEnd:
return "TODO";
case KDSCError::BadSection:
return "TODO";
case KDSCError::LongLine:
return i18n( "Lines in DSC documents must be shorter than 255 "
"characters." );
case KDSCError::IncorrectUsage:
return "TODO";
default: return "TODO";
}
}
void KDSCErrorDialog::slotOk()
{
_response = Ok;
accept();
}
void KDSCErrorDialog::slotCancel()
{
_response = Cancel;
accept();
}
void KDSCErrorDialog::slotIgnoreAll()
{
_response = IgnoreAll;
accept();
}
|