1
/* This file is part of the KDE project
2
Copyright (C) 2001 David Faure <david@mandrakesoft.com>
4
This library is free software; you can redistribute it and/or
5
modify it under the terms of the GNU Library General Public
6
License as published by the Free Software Foundation; either
7
version 2 of the License, or (at your option) any later version.
9
This library is distributed in the hope that it will be useful,
10
but WITHOUT ANY WARRANTY; without even the implied warranty of
11
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12
Library General Public License for more details.
14
You should have received a copy of the GNU Library General Public License
15
along with this library; see the file COPYING.LIB. If not, write to
16
the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17
Boston, MA 02111-1307, USA.
20
#include "kounavail.h"
25
#include <kinstance.h>
26
#include <kstdaction.h>
28
#include <kaboutdata.h>
30
#include <kglobalsettings.h>
31
#include <qapplication.h>
33
KoUnavailPart::KoUnavailPart( QWidget *parentWidget, const char *widgetName, QObject* parent, const char* name )
34
: KoDocument( parentWidget, widgetName, parent, name, false /*singleViewMode*/ )
36
setReadWrite( false );
39
KoView* KoUnavailPart::createViewInstance( QWidget* parent, const char* name )
41
return new KoUnavailView( this, parent, name );
44
bool KoUnavailPart::loadXML( QIODevice *, const QDomDocument &doc )
46
// Simply keep a copy of the whole document ;)
51
bool KoUnavailPart::saveFile()
53
kdDebug() << "KoUnavailPart::saveFile m_url=" << m_url.prettyURL() << endl;
54
// This is called if the part points to an external file
55
// In that case we have nothing to save, the file was unavailable !
59
QDomDocument KoUnavailPart::saveXML()
61
kdDebug() << "KoUnavailPart::saveXML" << endl;
65
void KoUnavailPart::setMimeType( const QCString& mime )
67
kdDebug() << "KoUnavailPart::setMimeType " << mime << endl;
71
void KoUnavailPart::paintContent( QPainter& painter, const QRect& rect, bool /*transparent*/,
72
double /*zoomX*/, double /*zoomY*/ )
75
painter.setPen( QApplication::palette().color( QPalette::Active, QColorGroup::Text ) );
76
// Need to draw only the document rectangle described in the parameter rect.
77
int left = rect.left() / 20;
78
int right = rect.right() / 20 + 1;
79
int top = rect.top() / 20;
80
int bottom = rect.bottom() / 20 + 1;
82
for( int x = left; x < right; ++x )
83
painter.drawLine( x * 20, top * 20, x * 20, bottom * 20 );
84
for( int y = left; y < right; ++y )
85
painter.drawLine( left * 20, y * 20, right * 20, y * 20 );
87
QFont defaultFont = KGlobalSettings::generalFont();
88
defaultFont.setPointSize( 16 ); // ###
89
painter.setFont( defaultFont );
90
//painter.drawText( 20, 20, m_reason );
91
painter.drawText( rect, Qt::AlignCenter | Qt::WordBreak, m_reason );
95
KoUnavailView::KoUnavailView( KoUnavailPart* part, QWidget* parent, const char* name )
96
: KoView( part, parent, name )
98
setInstance( KoUnavailFactory::global() );
99
//setXMLFile( "kounavail.rc" );
102
void KoUnavailView::paintEvent( QPaintEvent* ev )
105
painter.begin( this );
109
// Let the document do the drawing
110
koDocument()->paintEverything( painter, ev->rect(), FALSE, this );
117
void* init_libkounavailpart()
119
return new KoUnavailFactory;
123
KInstance* KoUnavailFactory::s_global = 0L;
124
KAboutData* KoUnavailFactory::s_aboutData = 0L;
126
KoUnavailFactory::KoUnavailFactory( QObject* parent, const char* name )
127
: KoFactory( parent, name )
132
KoUnavailFactory::~KoUnavailFactory()
140
KParts::Part* KoUnavailFactory::createPartObject( QWidget *parentWidget, const char *widgetName, QObject* parent, const char* name, const char*, const QStringList & )
142
return new KoUnavailPart( parentWidget, widgetName, parent, name );
145
KAboutData* KoUnavailFactory::aboutData()
149
static const char* description=I18N_NOOP("KoUnavail KOffice Program");
150
static const char* version="0.1";
151
s_aboutData=new KAboutData( "kounavail", I18N_NOOP("KoUnavail"),
152
version, description, KAboutData::License_LGPL,
153
"(c) 2001, David Faure");
154
s_aboutData->addAuthor("David Faure",0, "david@mandrakesoft.com");
159
KInstance* KoUnavailFactory::global()
163
s_global = new KInstance( aboutData() );
164
// Tell the iconloader about share/apps/koffice/icons
165
//s_global->iconLoader()->addAppDir("koffice");
170
#include "kounavail.moc"