1 /***************************************************************************
2 * Copyright (C) 2003 by Petri Damsten *
3 * petri.damsten@iki.fi *
4 * *
5 * This program is free software; you can redistribute it and/or modify *
6 * it under the terms of the GNU General Public License as published by *
7 * the Free Software Foundation; either version 2 of the License, or *
8 * (at your option) any later version. *
9 * *
10 * This program is distributed in the hope that it will be useful, *
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13 * GNU General Public License for more details. *
14 * *
15 * You should have received a copy of the GNU General Public License *
16 * along with this program; if not, write to the *
17 * Free Software Foundation, Inc., *
18 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
19 ***************************************************************************/
20
21 #include "basket_part.h"
22
23 #include <KParts/StatusBarExtension>
24
25 #include "aboutdata.h"
26 #include "basketstatusbar.h"
27 #include "bnpview.h"
28
K_PLUGIN_FACTORY_DEFINITION(BasketFactory,registerPlugin<BasketPart> ();)29 K_PLUGIN_FACTORY_DEFINITION(BasketFactory,
30 registerPlugin<BasketPart>();
31 )
32
33 BasketPart::BasketPart(QWidget *parentWidget, QObject *parent, const QList<QVariant> &)
34 : KParts::ReadWritePart(parent)
35 {
36 // we need an instance
37 //setInstance( BasketFactory::instance() );
38
39 BasketStatusBar* bar = new BasketStatusBar(new KParts::StatusBarExtension(this));
40 // this should be your custom internal widget
41 m_view = new BNPView(parentWidget, "BNPViewPart", this, actionCollection(), bar);
42 connect(m_view, SIGNAL(setWindowCaption(const QString &)), this, SLOT(setWindowTitle(const QString &)));
43 connect(m_view, SIGNAL(showPart()), this, SIGNAL(showPart()));
44 m_view->setFocusPolicy(Qt::ClickFocus);
45
46 // notify the part that this is our internal widget
47 setWidget(m_view);
48
49 setComponentName(AboutData::componentName(), AboutData::displayName());
50
51 // set our XML-UI resource file
52 setXMLFile("basket_part.rc", true);
53
54 // we are read-write by default
55 setReadWrite(true);
56
57 // we are not modified since we haven't done anything yet
58 setModified(false);
59 }
60
~BasketPart()61 BasketPart::~BasketPart()
62 {}
63
setReadWrite(bool rw)64 void BasketPart::setReadWrite(bool rw)
65 {
66 // TODO: notify your internal widget of the read-write state
67 ReadWritePart::setReadWrite(rw);
68 }
69
setModified(bool modified)70 void BasketPart::setModified(bool modified)
71 {
72 // in any event, we want our parent to do it's thing
73 ReadWritePart::setModified(modified);
74 }
75
openFile()76 bool BasketPart::openFile()
77 {
78 // TODO
79 return false;
80 }
81
saveFile()82 bool BasketPart::saveFile()
83 {
84 //TODO
85 return false;
86 }
87
createAboutData()88 KAboutData *BasketPart::createAboutData()
89 {
90 return new AboutData();
91 }
92
setWindowTitle(const QString & caption)93 void BasketPart::setWindowTitle(const QString &caption)
94 {
95 emit setWindowCaption(caption);
96 }
97