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
|
/*
**************************************************************************
description
--------------------
copyright : (C) 2000-2001 by Andreas Zehender
email : [email protected]
**************************************************************************
**************************************************************************
* *
* 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. *
* *
**************************************************************************/
#include "pmerrordialog.h"
#include "pmerrorflags.h"
#include <tdelocale.h>
#include <tqlabel.h>
#include <tqtextedit.h>
#include <tdeconfig.h>
TQSize PMErrorDialog::s_size = TQSize( 150, 200 );
PMErrorDialog::PMErrorDialog( const PMMessageList& messages, int errorFlags,
TQWidget* parent, const char* name )
: KDialogBase( parent, name, true, i18n( "Messages" ),
Ok | Cancel, Cancel )
{
TQVBox* page = makeVBoxMainWidget( );
TQLabel* text = new TQLabel( TQString( "" ), ( TQWidget* )page );
m_pTextView = new TQTextEdit( ( TQWidget* )page );
m_pTextView->setReadOnly( true );
m_messageDict.setAutoDelete( true );
m_messages.setAutoDelete( true );
PMMessageList::ConstIterator it;
for( it = messages.begin( ); it != messages.end( ); ++it )
m_messages.append( new PMMessage( *it ) );
TQPtrListIterator<PMMessage> pit( m_messages );
for( ; pit.current( ); ++pit )
{
PMObject* obj = pit.current( )->linkedObject( );
for( ; obj; obj = obj->parent( ) )
{
TQPtrList<PMMessage>* pList = m_messageDict.find( obj );
if( !pList )
{
pList = new TQPtrList<PMMessage>;
m_messageDict.insert( obj, pList );
}
pList->append( pit.current( ) );
if( !obj->parent( ) )
{
if( obj->type( ) != "scene" )
{
kdError( PMArea ) << "A message contains an object that is not inserted in the scene" << endl;
pit.current( )->setLinkedObject( 0 );
}
}
}
}
displayMessages( );
if( errorFlags & PMEWarning )
{
if( ( errorFlags & PMEError ) || ( errorFlags & PMEFatal ) )
text->setText( i18n( "There were warnings and errors:" ) );
else
text->setText( i18n( "There were warnings:" ) );
}
else
text->setText( i18n( "There were errors:" ) );
KGuiItem ok = KStdGuiItem::ok();
ok.setToolTip( i18n( "Proceed" ) );
ok.setWhatsThis( i18n( "When clicking <b>Proceed</b>, the program\n"
"will try to proceed with the current action." ) );
setButtonOK( ok );
KGuiItem cancel = KStdGuiItem::cancel();
ok.setToolTip( i18n( "&Cancel" ) );
ok.setWhatsThis( i18n( "When clicking <b>Cancel<b>, the program\n"
"will cancel the current action." ) );
setButtonCancel( cancel );
if( errorFlags & PMEFatal )
showButtonOK( false );
else
new TQLabel( i18n( "Still try to proceed?" ), ( TQWidget* )page );
resize( s_size );
}
void PMErrorDialog::displayMessages( )
{
TQPtrListIterator<PMMessage> pit( m_messages );
TQString text;
text = "<qt>\n";
for( ; pit.current( ); ++pit )
text += "<p>" + pit.current( )->text( ) + "</p>\n";
text += "</qt>";
m_pTextView->setText( text );
}
void PMErrorDialog::saveConfig( TDEConfig* cfg )
{
cfg->setGroup( "Appearance" );
cfg->writeEntry( "ErrorDialogSize", s_size );
}
void PMErrorDialog::restoreConfig( TDEConfig* cfg )
{
cfg->setGroup( "Appearance" );
TQSize defaultSize( 150, 200 );
s_size = cfg->readSizeEntry( "ErrorDialogSize", &defaultSize );
}
void PMErrorDialog::resizeEvent( TQResizeEvent* ev )
{
s_size = ev->size( );
}
#include "pmerrordialog.moc"
|