2 This file is part of KNode.
3 Copyright (c) 2003 Laurent Montel <montel@kde.org>,
4 Based on the work of Cornelius Schumacher <schumacher@kde.org>
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20 As a special exception, permission is given to link this program
21 with any edition of Qt, and distribute the resulting executable,
22 without including the source code for Qt in the source distribution.
25 #include "knode_part.h"
27 #include "knglobals.h"
28 #include "knmainwidget.h"
29 #include "aboutdata.h"
30 #include "kncollectionview.h"
31 #include "utils/startup.h"
34 #include <kpluginfactory.h>
35 #include <kparts/statusbarextension.h>
36 #include <kiconloader.h>
38 #include <kstatusbar.h>
39 #include <ksqueezedtextlabel.h>
41 #include <QVBoxLayout>
44 K_PLUGIN_FACTORY(KNodeFactory
, registerPlugin
<KNodePart
>();)
45 K_EXPORT_PLUGIN(KNodeFactory(KNode::AboutData()))
47 KNodePart::KNodePart( QWidget
*parentWidget
, QObject
*parent
, const QVariantList
&)
48 : KParts::ReadOnlyPart( parent
),
49 mParentWidget( parentWidget
)
51 kDebug(5003) <<"KNodePart()";
52 kDebug(5003) <<" InstanceName:" << KGlobal::mainComponent().componentName();
54 setComponentData( KNodeFactory::componentData() );
56 kDebug(5003) <<"KNodePart()...";
57 kDebug(5003) <<" InstanceName:" << KGlobal::mainComponent().componentName();
60 KNode::Utilities::Startup s
;
61 s
.loadLibrariesIconsAndTranslations();
62 s
.updateDataAndConfiguration();
67 // kapp->dcopClient()->suspend(); // Don't handle DCOP requests yet
69 knGlobals
.setComponentData( KNodeFactory::componentData() );
71 // create a canvas to insert our widget
72 QWidget
*canvas
= new QWidget(parentWidget
);
73 canvas
->setFocusPolicy( Qt::ClickFocus
);
76 mainWidget
= new KNMainWidget( this, canvas
);
77 QVBoxLayout
*topLayout
= new QVBoxLayout( canvas
);
78 topLayout
->setContentsMargins( 0, 0, 0, 0 );
79 topLayout
->addWidget(mainWidget
);
80 mainWidget
->setFocusPolicy( Qt::ClickFocus
);
85 // kapp->dcopClient()->resume(); // Ok. We are ready for DCOP requests.
87 KParts::StatusBarExtension
* statusBar
= new KParts::StatusBarExtension(this);
88 statusBar
->addStatusBarItem(mainWidget
->statusBarLabelFilter(), 10, false);
89 statusBar
->addStatusBarItem(mainWidget
->statusBarLabelGroup(), 15, false);
91 setXMLFile( "knodeui.rc" );
94 KNodePart::~KNodePart()
96 mainWidget
->prepareShutdown();
99 KAboutData
*KNodePart::createAboutData()
101 return new KNode::AboutData();
104 bool KNodePart::openFile()
106 kDebug(5003) <<"KNodePart:openFile()";
112 void KNodePart::guiActivateEvent(KParts::GUIActivateEvent
*e
)
114 kDebug(5003) <<"KNodePart::guiActivateEvent";
115 KParts::ReadOnlyPart::guiActivateEvent(e
);
119 QWidget
* KNodePart::parentWidget() const
121 return mParentWidget
;