2 This file is part of KJots.
4 Copyright (c) 2008 Stephen Kelly <steveire@gmail.com>
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 "kjotspart.h"
27 #include "aboutdata.h"
32 #include <kactioncollection.h>
33 #include <kcomponentdata.h>
34 #include <kfiledialog.h>
35 #include <kstandardaction.h>
36 #include <kstandarddirs.h>
37 #include <kpluginfactory.h>
39 #include <kstatusbar.h>
41 #include <QtCore/QFile>
42 #include <QtCore/QTextStream>
46 #include "kjotswidget.h"
48 const KAboutData
&createAboutData()
50 static AboutData aboutData
;
54 K_PLUGIN_FACTORY(KJotsPartFactory
, registerPlugin
<KJotsPart
>();)
55 K_EXPORT_PLUGIN(KJotsPartFactory(createAboutData()))
57 KJotsPart::KJotsPart( QWidget
*parentWidget
, QObject
*parent
, const QVariantList
& /*args*/ )
58 : KParts::ReadOnlyPart(parent
)
60 // we need an instance
61 setComponentData( KJotsPartFactory::componentData() );
63 // this should be your custom internal widget
64 mComponent
= new KJotsWidget(parentWidget
, this);
66 mStatusBar
= new KParts::StatusBarExtension(this);
67 // notify the part that this is our internal widget
68 setWidget(mComponent
);
71 // set our XML-UI resource file
72 setXMLFile(KStandardDirs::locate("data", QLatin1String("kjots/kjotspartui.rc")));
74 QTimer::singleShot(0, this, SLOT(delayedInitialization()));
77 KJotsPart::~KJotsPart()
79 mComponent
->queryClose();
82 void KJotsPart::initAction()
84 KAction
*action
= new KAction( KIcon( QLatin1String("configure") ), i18n( "&Configure KJots..." ), this );
85 actionCollection()->addAction( QLatin1String("kjots_configure"), action
);
86 connect( action
, SIGNAL(triggered(bool)), mComponent
,
90 bool KJotsPart::openFile()
95 void KJotsPart::delayedInitialization()
97 connect(mComponent
, SIGNAL(activeAnchorChanged(QString
,QString
)),
98 SLOT(activeAnchorChanged(QString
,QString
)));
101 void KJotsPart::activeAnchorChanged(const QString
&anchorTarget
, const QString
&anchorText
)
103 if (!anchorTarget
.isEmpty())
105 mStatusBar
->statusBar()->showMessage(anchorText
+ QLatin1String(" -> ") + anchorTarget
);
107 mStatusBar
->statusBar()->showMessage(QString());
112 // bool KJotsPart::saveFile()