forked from qt-creator/qt-creator
Move the plugin examples to subdir of pluginhowto.
This commit is contained in:
11
doc/pluginhowto/examples/htmleditor/HTMLEditor.pluginspec
Normal file
11
doc/pluginhowto/examples/htmleditor/HTMLEditor.pluginspec
Normal file
@@ -0,0 +1,11 @@
|
||||
<plugin name="HTMLEditor" version="0.0.1">
|
||||
<vendor>FooCompanyInc Pvt. Ltd</vendor>
|
||||
<copyright>(C) 2009-2010 FooCompanyInc Pvt. Ltd.</copyright>
|
||||
<license></license>
|
||||
<description>{{PLUGIN_DESCRIPTION}}</description>
|
||||
<url>http://www.FooCompanyInc.com</url>
|
||||
<dependencyList>
|
||||
<dependency name="Core"/>
|
||||
</dependencyList>
|
||||
</plugin>
|
||||
|
||||
129
doc/pluginhowto/examples/htmleditor/htmleditor.cpp
Normal file
129
doc/pluginhowto/examples/htmleditor/htmleditor.cpp
Normal file
@@ -0,0 +1,129 @@
|
||||
#include "htmlfile.h"
|
||||
#include "htmleditor.h"
|
||||
#include "htmleditorwidget.h"
|
||||
|
||||
#include "coreplugin/uniqueidmanager.h"
|
||||
|
||||
struct HTMLEditorData
|
||||
{
|
||||
HTMLEditorData() : editorWidget(0), file(0) { }
|
||||
|
||||
HTMLEditorWidget* editorWidget;
|
||||
QString displayName;
|
||||
HTMLFile* file;
|
||||
QList<int> context;
|
||||
};
|
||||
|
||||
namespace HTMLEditorConstants
|
||||
{
|
||||
const char* const C_HTMLEDITOR_MIMETYPE = "text/html";
|
||||
const char* const C_HTMLEDITOR = "HTML Editor";
|
||||
}
|
||||
|
||||
HTMLEditor::HTMLEditor(HTMLEditorWidget* editorWidget)
|
||||
:Core::IEditor(editorWidget)
|
||||
{
|
||||
d = new HTMLEditorData;
|
||||
d->editorWidget = editorWidget;
|
||||
d->file = new HTMLFile(this, editorWidget);
|
||||
|
||||
Core::UniqueIDManager* uidm = Core::UniqueIDManager::instance();
|
||||
d->context << uidm->uniqueIdentifier(HTMLEditorConstants::C_HTMLEDITOR);
|
||||
|
||||
connect(d->editorWidget, SIGNAL(contentModified()),
|
||||
d->file, SLOT(modified()));
|
||||
connect(d->editorWidget, SIGNAL(titleChanged(QString)),
|
||||
this, SLOT(slotTitleChanged(QString)));
|
||||
connect(d->editorWidget, SIGNAL(contentModified()),
|
||||
this, SIGNAL(changed()));
|
||||
}
|
||||
|
||||
HTMLEditor::~HTMLEditor()
|
||||
{
|
||||
delete d;
|
||||
}
|
||||
|
||||
QWidget* HTMLEditor::widget()
|
||||
{
|
||||
return d->editorWidget;
|
||||
}
|
||||
|
||||
QList<int> HTMLEditor::context() const
|
||||
{
|
||||
return d->context;
|
||||
}
|
||||
|
||||
Core::IFile* HTMLEditor::file()
|
||||
{
|
||||
return d->file;
|
||||
}
|
||||
|
||||
bool HTMLEditor::createNew(const QString& contents)
|
||||
{
|
||||
Q_UNUSED(contents);
|
||||
|
||||
d->editorWidget->setContent(QByteArray());
|
||||
d->file->setFilename(QString());
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool HTMLEditor::open(const QString &fileName)
|
||||
{
|
||||
return d->file->open(fileName);
|
||||
}
|
||||
|
||||
const char* HTMLEditor::kind() const
|
||||
{
|
||||
return HTMLEditorConstants::C_HTMLEDITOR;
|
||||
}
|
||||
|
||||
QString HTMLEditor::displayName() const
|
||||
{
|
||||
return d->displayName;
|
||||
}
|
||||
|
||||
void HTMLEditor::setDisplayName(const QString& title)
|
||||
{
|
||||
if(d->displayName == title)
|
||||
return;
|
||||
|
||||
d->displayName = title;
|
||||
emit changed();
|
||||
}
|
||||
|
||||
bool HTMLEditor::duplicateSupported() const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
Core::IEditor* HTMLEditor::duplicate(QWidget* parent)
|
||||
{
|
||||
Q_UNUSED(parent);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
QByteArray HTMLEditor::saveState() const
|
||||
{
|
||||
return QByteArray();
|
||||
}
|
||||
|
||||
bool HTMLEditor::restoreState(const QByteArray& state)
|
||||
{
|
||||
Q_UNUSED(state);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
QToolBar* HTMLEditor::toolBar()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool HTMLEditor::isTemporary() const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
44
doc/pluginhowto/examples/htmleditor/htmleditor.h
Normal file
44
doc/pluginhowto/examples/htmleditor/htmleditor.h
Normal file
@@ -0,0 +1,44 @@
|
||||
#ifndef HTMLEDITOR_H
|
||||
#define HTMLEDITOR_H
|
||||
|
||||
#include "coreplugin/editormanager/ieditor.h"
|
||||
|
||||
#include <QToolBar>
|
||||
|
||||
class HTMLEditorWidget;
|
||||
|
||||
struct HTMLEditorData;
|
||||
class HTMLEditor : public Core::IEditor
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
HTMLEditor(HTMLEditorWidget* editorWidget);
|
||||
~HTMLEditor();
|
||||
|
||||
bool createNew(const QString& contents = QString());
|
||||
QString displayName() const;
|
||||
IEditor* duplicate(QWidget* parent);
|
||||
bool duplicateSupported() const;
|
||||
Core::IFile* file();
|
||||
bool isTemporary() const;
|
||||
const char* kind() const;
|
||||
bool open(const QString& fileName = QString()) ;
|
||||
bool restoreState(const QByteArray& state);
|
||||
QByteArray saveState() const;
|
||||
void setDisplayName(const QString &title);
|
||||
QToolBar* toolBar();
|
||||
|
||||
// From Core::IContext
|
||||
QWidget* widget();
|
||||
QList<int> context() const;
|
||||
|
||||
protected slots:
|
||||
void slotTitleChanged(const QString& title)
|
||||
{ setDisplayName(title); }
|
||||
|
||||
private:
|
||||
HTMLEditorData* d;
|
||||
};
|
||||
|
||||
#endif // HTMLEDITOR_H
|
||||
61
doc/pluginhowto/examples/htmleditor/htmleditorfactory.cpp
Normal file
61
doc/pluginhowto/examples/htmleditor/htmleditorfactory.cpp
Normal file
@@ -0,0 +1,61 @@
|
||||
#include "coreplugin/editormanager/editormanager.h"
|
||||
#include "htmleditorfactory.h"
|
||||
#include "htmleditorwidget.h"
|
||||
#include "htmleditorplugin.h"
|
||||
#include "htmleditor.h"
|
||||
|
||||
namespace HTMLEditorConstants
|
||||
{
|
||||
const char* const C_HTMLEDITOR_MIMETYPE = "text/html";
|
||||
const char* const C_HTMLEDITOR = "HTML Editor";
|
||||
}
|
||||
|
||||
struct HTMLEditorFactoryData
|
||||
{
|
||||
HTMLEditorFactoryData() : kind(HTMLEditorConstants::C_HTMLEDITOR)
|
||||
{
|
||||
mimeTypes << QString(HTMLEditorConstants::C_HTMLEDITOR_MIMETYPE);
|
||||
}
|
||||
|
||||
QString kind;
|
||||
QStringList mimeTypes;
|
||||
};
|
||||
|
||||
|
||||
HTMLEditorFactory::HTMLEditorFactory(HTMLEditorPlugin* owner)
|
||||
:Core::IEditorFactory(owner)
|
||||
{
|
||||
d = new HTMLEditorFactoryData;
|
||||
}
|
||||
|
||||
HTMLEditorFactory::~HTMLEditorFactory()
|
||||
{
|
||||
delete d;
|
||||
}
|
||||
|
||||
QStringList HTMLEditorFactory::mimeTypes() const
|
||||
{
|
||||
return d->mimeTypes;
|
||||
}
|
||||
|
||||
QString HTMLEditorFactory::kind() const
|
||||
{
|
||||
return d->kind;
|
||||
}
|
||||
|
||||
Core::IFile* HTMLEditorFactory::open(const QString& fileName)
|
||||
{
|
||||
Core::EditorManager* em = Core::EditorManager::instance();
|
||||
Core::IEditor* iface = em->openEditor(fileName, d->kind);
|
||||
|
||||
return iface ? iface->file() : 0;
|
||||
}
|
||||
|
||||
Core::IEditor* HTMLEditorFactory::createEditor(QWidget* parent)
|
||||
{
|
||||
HTMLEditorWidget* editorWidget = new HTMLEditorWidget(parent);
|
||||
|
||||
return new HTMLEditor(editorWidget);
|
||||
}
|
||||
|
||||
|
||||
27
doc/pluginhowto/examples/htmleditor/htmleditorfactory.h
Normal file
27
doc/pluginhowto/examples/htmleditor/htmleditorfactory.h
Normal file
@@ -0,0 +1,27 @@
|
||||
#ifndef HTMLEDITORFACTORY_H
|
||||
#define HTMLEDITORFACTORY_H
|
||||
|
||||
#include "coreplugin/editormanager/ieditorfactory.h"
|
||||
|
||||
class HTMLEditorPlugin;
|
||||
|
||||
struct HTMLEditorFactoryData;
|
||||
class HTMLEditorFactory : public Core::IEditorFactory
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
HTMLEditorFactory(HTMLEditorPlugin* owner);
|
||||
~HTMLEditorFactory();
|
||||
|
||||
QStringList mimeTypes() const;
|
||||
QString kind() const;
|
||||
|
||||
Core::IEditor* createEditor(QWidget* parent);
|
||||
Core::IFile* open(const QString &fileName);
|
||||
|
||||
private:
|
||||
HTMLEditorFactoryData* d;
|
||||
};
|
||||
|
||||
#endif // HTMLEDITORFACTORY_H
|
||||
57
doc/pluginhowto/examples/htmleditor/htmleditorplugin.cpp
Normal file
57
doc/pluginhowto/examples/htmleditor/htmleditorplugin.cpp
Normal file
@@ -0,0 +1,57 @@
|
||||
#include "htmleditorplugin.h"
|
||||
#include "htmleditorfactory.h"
|
||||
#include <coreplugin/actionmanager/actionmanager.h>
|
||||
#include <coreplugin/actionmanager/command.h>
|
||||
#include <coreplugin/coreconstants.h>
|
||||
#include <coreplugin/mimedatabase.h>
|
||||
#include <coreplugin/icore.h>
|
||||
#include <QtPlugin>
|
||||
#include <QString>
|
||||
#include <QMessageBox>
|
||||
#include <QFontDialog>
|
||||
|
||||
HTMLEditorPlugin::HTMLEditorPlugin()
|
||||
{
|
||||
// Do nothing
|
||||
}
|
||||
|
||||
HTMLEditorPlugin::~HTMLEditorPlugin()
|
||||
{
|
||||
// Do notning
|
||||
}
|
||||
|
||||
void HTMLEditorPlugin::extensionsInitialized()
|
||||
{
|
||||
// Do nothing
|
||||
}
|
||||
|
||||
bool HTMLEditorPlugin::initialize(const QStringList& args, QString *errMsg)
|
||||
{
|
||||
Q_UNUSED(args);
|
||||
|
||||
Core::ActionManager* am = Core::ICore::instance()->actionManager();
|
||||
Core::ActionContainer* ac = am->actionContainer(Core::Constants::M_EDIT);
|
||||
QAction* Font = ac->menu()->addAction("Font");
|
||||
|
||||
// Create a command for "Font".
|
||||
Core::Command* cmd = am->registerAction(new QAction(this),"HTMLEditorPlugin.Font",QList<int>() << 0);
|
||||
cmd->action()->setText("Font");
|
||||
|
||||
Core::ICore* core = Core::ICore::instance();
|
||||
Core::MimeDatabase* mdb = core->mimeDatabase();
|
||||
|
||||
if(!mdb->addMimeTypes("text-html-mimetype.xml", errMsg))
|
||||
return false;
|
||||
|
||||
QMessageBox::information(0, "Msg", *errMsg);
|
||||
|
||||
addAutoReleasedObject(new HTMLEditorFactory(this));
|
||||
return true;
|
||||
}
|
||||
|
||||
void HTMLEditorPlugin::shutdown()
|
||||
{
|
||||
// Do nothing
|
||||
}
|
||||
|
||||
Q_EXPORT_PLUGIN(HTMLEditorPlugin)
|
||||
21
doc/pluginhowto/examples/htmleditor/htmleditorplugin.h
Normal file
21
doc/pluginhowto/examples/htmleditor/htmleditorplugin.h
Normal file
@@ -0,0 +1,21 @@
|
||||
#ifndef HTMLEDITOR_PLUGIN_H
|
||||
#define HTMLEDITOR_PLUGIN_H
|
||||
|
||||
#include "extensionsystem/iplugin.h"
|
||||
#include "coreplugin/uniqueidmanager.h"
|
||||
|
||||
class HTMLEditorPlugin : public ExtensionSystem::IPlugin
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
HTMLEditorPlugin();
|
||||
~HTMLEditorPlugin();
|
||||
|
||||
void extensionsInitialized();
|
||||
bool initialize(const QStringList & arguments, QString * errorString);
|
||||
void shutdown();
|
||||
};
|
||||
|
||||
#endif // HTMLEDITOR_PLUGIN_H
|
||||
|
||||
31
doc/pluginhowto/examples/htmleditor/htmleditorplugin.pro
Normal file
31
doc/pluginhowto/examples/htmleditor/htmleditorplugin.pro
Normal file
@@ -0,0 +1,31 @@
|
||||
QTC_SOURCE = C:/Work/QtCreator
|
||||
QTC_BUILD = C:/Work/QtCreator/build
|
||||
|
||||
TEMPLATE = lib
|
||||
TARGET = HTMLEditor
|
||||
IDE_SOURCE_TREE = $$QTC_SOURCE
|
||||
IDE_BUILD_TREE = $$QTC_BUILD
|
||||
PROVIDER = FooCompanyInc
|
||||
|
||||
QT += webkit
|
||||
|
||||
PROVIDER = FooCompanyInc
|
||||
|
||||
include($$QTC_SOURCE/src/qtcreatorplugin.pri)
|
||||
include($$QTC_SOURCE/src/plugins/coreplugin/coreplugin.pri)
|
||||
LIBS += -L$$IDE_PLUGIN_PATH/Nokia
|
||||
|
||||
HEADERS = htmleditorplugin.h \
|
||||
htmleditorwidget.h \
|
||||
htmlfile.h \
|
||||
htmleditor.h \
|
||||
htmleditorfactory.h
|
||||
|
||||
SOURCES = htmleditorplugin.cpp \
|
||||
htmleditorwidget.cpp \
|
||||
htmlfile.cpp \
|
||||
htmleditor.cpp \
|
||||
htmleditorfactory.cpp
|
||||
|
||||
OTHER_FILES = HTMLEditor.pluginspec \
|
||||
text-html-mimetype.xml
|
||||
82
doc/pluginhowto/examples/htmleditor/htmleditorwidget.cpp
Normal file
82
doc/pluginhowto/examples/htmleditor/htmleditorwidget.cpp
Normal file
@@ -0,0 +1,82 @@
|
||||
#include "htmleditorwidget.h"
|
||||
|
||||
#include <QTextEdit>
|
||||
#include <QPlainTextEdit>
|
||||
#include <QtWebKit>
|
||||
#include <QDebug>
|
||||
|
||||
struct HTMLEditorWidgetData
|
||||
{
|
||||
QWebView* webView;
|
||||
QPlainTextEdit* textEdit;
|
||||
bool modified;
|
||||
QString path;
|
||||
};
|
||||
|
||||
HTMLEditorWidget::HTMLEditorWidget(QWidget* parent):QTabWidget(parent)
|
||||
{
|
||||
d = new HTMLEditorWidgetData;
|
||||
|
||||
d->webView = new QWebView;
|
||||
d->textEdit = new QPlainTextEdit;
|
||||
|
||||
addTab(d->webView, "Preview");
|
||||
addTab(d->textEdit, "Source");
|
||||
setTabPosition(QTabWidget::South);
|
||||
setTabShape(QTabWidget::Triangular);
|
||||
|
||||
d->textEdit->setFont( QFont("Courier", 12) );
|
||||
|
||||
connect(this, SIGNAL(currentChanged(int)),
|
||||
this, SLOT(slotCurrentTabChanged(int)));
|
||||
|
||||
connect(d->textEdit, SIGNAL(textChanged()),
|
||||
this, SLOT(slotContentModified()));
|
||||
|
||||
connect(d->webView, SIGNAL(titleChanged(QString)),
|
||||
this, SIGNAL(titleChanged(QString)));
|
||||
|
||||
d->modified = false;
|
||||
}
|
||||
|
||||
|
||||
HTMLEditorWidget::~HTMLEditorWidget()
|
||||
{
|
||||
delete d;
|
||||
}
|
||||
|
||||
void HTMLEditorWidget::setContent(const QByteArray& ba, const QString& path)
|
||||
{
|
||||
if(path.isEmpty())
|
||||
d->webView->setHtml(ba);
|
||||
else
|
||||
d->webView->setHtml(ba, "file:///" + path);
|
||||
d->textEdit->setPlainText(ba);
|
||||
d->modified = false;
|
||||
d->path = path;
|
||||
}
|
||||
|
||||
QByteArray HTMLEditorWidget::content() const
|
||||
{
|
||||
QString HTMLText = d->textEdit->toPlainText();
|
||||
return HTMLText.toAscii();
|
||||
}
|
||||
|
||||
QString HTMLEditorWidget::title() const
|
||||
{
|
||||
return d->webView->title();
|
||||
}
|
||||
|
||||
void HTMLEditorWidget::slotCurrentTabChanged(int tab)
|
||||
{
|
||||
if(tab == 0 && d->modified)
|
||||
setContent( content(), d->path );
|
||||
}
|
||||
|
||||
void HTMLEditorWidget::slotContentModified()
|
||||
{
|
||||
d->modified = true;
|
||||
emit contentModified();
|
||||
}
|
||||
|
||||
|
||||
32
doc/pluginhowto/examples/htmleditor/htmleditorwidget.h
Normal file
32
doc/pluginhowto/examples/htmleditor/htmleditorwidget.h
Normal file
@@ -0,0 +1,32 @@
|
||||
#ifndef RTEDITORWIDGET_H
|
||||
#define RTEDITORWIDGET_H
|
||||
|
||||
#include<QTabWidget>
|
||||
|
||||
struct HTMLEditorWidgetData;
|
||||
class HTMLEditorWidget:public QTabWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
HTMLEditorWidget(QWidget* parent = 0);
|
||||
~HTMLEditorWidget();
|
||||
|
||||
void setContent(const QByteArray& ba, const QString& path=QString());
|
||||
QByteArray content() const;
|
||||
|
||||
QString title() const;
|
||||
|
||||
protected slots:
|
||||
void slotCurrentTabChanged(int tab);
|
||||
void slotContentModified();
|
||||
|
||||
signals:
|
||||
void contentModified();
|
||||
void titleChanged(const QString&);
|
||||
|
||||
private:
|
||||
HTMLEditorWidgetData* d;
|
||||
};
|
||||
|
||||
#endif // RTEDITORWIDGET_H
|
||||
130
doc/pluginhowto/examples/htmleditor/htmlfile.cpp
Normal file
130
doc/pluginhowto/examples/htmleditor/htmlfile.cpp
Normal file
@@ -0,0 +1,130 @@
|
||||
#include "htmlfile.h"
|
||||
#include<QFile>
|
||||
#include<QFileInfo>
|
||||
|
||||
namespace HTMLEditorConstants
|
||||
{
|
||||
const char* const C_HTMLEDITOR_MIMETYPE = "text/html";
|
||||
const char* const C_HTMLEDITOR = "HTML Editor";
|
||||
}
|
||||
struct HTMLFileData
|
||||
{
|
||||
HTMLFileData(): mimeType(HTMLEditorConstants::C_HTMLEDITOR),
|
||||
editorWidget(0), editor(0), modified(false) { }
|
||||
const QString mimeType;
|
||||
HTMLEditorWidget* editorWidget;
|
||||
HTMLEditor* editor;
|
||||
QString fileName;
|
||||
bool modified;
|
||||
};
|
||||
|
||||
HTMLFile::HTMLFile(HTMLEditor* editor, HTMLEditorWidget* editorWidget)
|
||||
: Core::IFile(editor)
|
||||
{
|
||||
d = new HTMLFileData;
|
||||
d->editor = editor;
|
||||
d->editorWidget = editorWidget;
|
||||
}
|
||||
|
||||
|
||||
HTMLFile::~HTMLFile()
|
||||
{
|
||||
delete d;
|
||||
}
|
||||
|
||||
void HTMLFile::setModified(bool val)
|
||||
{
|
||||
if(d->modified == val)
|
||||
return;
|
||||
|
||||
d->modified = val;
|
||||
emit changed();
|
||||
}
|
||||
|
||||
bool HTMLFile::isModified() const
|
||||
{
|
||||
return d->modified;
|
||||
}
|
||||
|
||||
QString HTMLFile::mimeType() const
|
||||
{
|
||||
return d->mimeType;
|
||||
}
|
||||
|
||||
bool HTMLFile::save(const QString &fileName)
|
||||
{
|
||||
QFile file(fileName);
|
||||
|
||||
if(file.open(QFile::WriteOnly))
|
||||
{
|
||||
d->fileName = fileName;
|
||||
|
||||
QByteArray content = d->editorWidget->content();
|
||||
file.write(content);
|
||||
|
||||
setModified(false);
|
||||
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool HTMLFile::open(const QString &fileName)
|
||||
{
|
||||
QFile file(fileName);
|
||||
|
||||
if(file.open(QFile::ReadOnly))
|
||||
{
|
||||
d->fileName = fileName;
|
||||
|
||||
QString path = QFileInfo(fileName).absolutePath();
|
||||
d->editorWidget->setContent(file.readAll(), path);
|
||||
d->editor->setDisplayName(d->editorWidget->title());
|
||||
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void HTMLFile::setFilename(const QString& filename)
|
||||
{
|
||||
d->fileName = filename;
|
||||
}
|
||||
|
||||
QString HTMLFile::fileName() const
|
||||
{
|
||||
return d->fileName;
|
||||
}
|
||||
QString HTMLFile::defaultPath() const
|
||||
{
|
||||
return QString();
|
||||
}
|
||||
|
||||
QString HTMLFile::suggestedFileName() const
|
||||
{
|
||||
return QString();
|
||||
}
|
||||
|
||||
QString HTMLFile::fileFilter() const
|
||||
{
|
||||
return QString();
|
||||
}
|
||||
|
||||
QString HTMLFile::fileExtension() const
|
||||
{
|
||||
return QString();
|
||||
}
|
||||
|
||||
bool HTMLFile::isReadOnly() const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
bool HTMLFile::isSaveAsAllowed() const
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
void HTMLFile::modified(ReloadBehavior* behavior)
|
||||
{
|
||||
Q_UNUSED(behavior);
|
||||
}
|
||||
38
doc/pluginhowto/examples/htmleditor/htmlfile.h
Normal file
38
doc/pluginhowto/examples/htmleditor/htmlfile.h
Normal file
@@ -0,0 +1,38 @@
|
||||
#ifndef HTMLFILE_H
|
||||
#define HTMLFILE_H
|
||||
#include "coreplugin/ifile.h"
|
||||
#include "htmleditorwidget.h"
|
||||
#include "htmleditor.h"
|
||||
|
||||
struct HTMLFileData;
|
||||
class HTMLFile : public Core::IFile
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
HTMLFile(HTMLEditor* editor, HTMLEditorWidget* editorWidget);
|
||||
~HTMLFile();
|
||||
|
||||
void setModified(bool val=true);
|
||||
bool isModified() const ;
|
||||
|
||||
bool save(const QString &filename);
|
||||
bool open(const QString &filename);
|
||||
void setFilename(const QString &filename);
|
||||
QString mimiType(void) const ;
|
||||
QString fileName() const;
|
||||
QString defaultPath() const ;
|
||||
QString mimeType() const;
|
||||
QString suggestedFileName() const;
|
||||
QString fileFilter() const;
|
||||
QString fileExtension() const;
|
||||
bool isReadOnly() const;
|
||||
bool isSaveAsAllowed() const;
|
||||
void modified(ReloadBehavior* behavior);
|
||||
|
||||
protected slots:
|
||||
void modified() { setModified(true); }
|
||||
private:
|
||||
HTMLFileData* d;
|
||||
};
|
||||
#endif // HTMLFILE_H
|
||||
@@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<mime-info xmlns='http://www.freedesktop.org/standards/shared-mime-info'>
|
||||
<mime-type type="text/html">
|
||||
<sub-class-of type="text/plain"/>
|
||||
<comment>HTML File</comment>
|
||||
<glob pattern="*.html"/>
|
||||
</mime-type>
|
||||
</mime-info>
|
||||
Reference in New Issue
Block a user