french -> French
[kdepim.git] / kjots / kjotspart.cpp
blob9905dbaf362642aa7a14e20383afd9ac0d25bcbc
1 /*
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"
29 #include <kdebug.h>
31 #include <kaction.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>
38 #include <klocale.h>
39 #include <kstatusbar.h>
41 #include <QtCore/QFile>
42 #include <QtCore/QTextStream>
43 #include <QTimer>
44 #include <QTextEdit>
45 #include <QLabel>
46 #include "kjotswidget.h"
48 const KAboutData &createAboutData()
50 static AboutData aboutData;
51 return 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);
69 initAction();
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,
87 SLOT(configure()) );
90 bool KJotsPart::openFile()
92 return false;
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);
106 } else {
107 mStatusBar->statusBar()->showMessage(QString());
112 // bool KJotsPart::saveFile()
113 // {
114 // return false;
115 // }