Fix no newlines warnings. Patch by Peter Oberndorfer
[kdevelopdvcssupport.git] / kross / krossdocument.cpp
blob984bbbe2ec5383e2441fdab80d199df7abdb0b90
1 /***************************************************************************
2 * Copyright 2008 Harald Fernengel <harry@kdevelop.org> *
3 * *
4 * This program is free software; you can redistribute it and/or modify *
5 * it under the terms of the GNU Library General Public License as *
6 * published by the Free Software Foundation; either version 2 of the *
7 * License, or (at your option) any later version. *
8 * *
9 * This program 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 *
12 * GNU General Public License for more details. *
13 * *
14 * You should have received a copy of the GNU Library General Public *
15 * License along with this program; if not, write to the *
16 * Free Software Foundation, Inc., *
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
18 ***************************************************************************/
20 #include "idocument.h"
22 #include <QObject>
23 #include <kross/core/manager.h>
24 #include <kross/core/wrapperinterface.h>
25 namespace KDevelop
28 /* This is a scripting wrapper for IDocument - since it's not a QObject,
29 we need to pass this wrapper whenever IDocument* is passed into a script.
30 This class is not exported - only accessible through scripting backend
33 class KrossDocument : public QObject, public Kross::WrapperInterface
35 Q_OBJECT
36 Q_ENUMS(DocumentSaveMode)
38 public:
39 enum DocumentSaveMode
41 Default = KDevelop::IDocument::Default,
42 Silent = KDevelop::IDocument::Silent
45 void* wrappedObject() const { return doc; }
47 KrossDocument(KDevelop::IDocument *document, QObject *parent = 0)
48 : QObject(parent), doc(document)
50 Q_ASSERT(document);
53 /* These are forwarded to the IDocument methods */
54 Q_SCRIPTABLE inline KUrl url() const
56 return doc->url();
59 Q_SCRIPTABLE inline bool save(DocumentSaveMode mode = Default)
61 return doc->save(KDevelop::IDocument::DocumentSaveMode(mode));
64 Q_SCRIPTABLE inline void reload()
66 doc->reload();
69 Q_SCRIPTABLE inline void close()
71 doc->close();
74 Q_SCRIPTABLE inline bool isActive() const
76 return doc->isActive();
79 /* ### TODO - add the rest of IDocument here */
81 private:
82 KDevelop::IDocument *doc;
85 QVariant documentHandler(void* type)
87 if(!type) return QVariant();
88 IDocument* t=static_cast<IDocument*>(type);
89 qDebug() << "handling";
90 return qVariantFromValue((QObject*) new KrossDocument(t, 0));
93 int a=Kross::Manager::self().registerMetaTypeHandler("KDevelop::IDocument*", documentHandler);
97 #include "krossdocument.moc"