Kate
abstractexporter.h
Go to the documentation of this file.
00001 00020 #ifndef ABSTRACTEXPORTER_H 00021 #define ABSTRACTEXPORTER_H 00022 00023 #include <QtCore/QTextStream> 00024 00025 #include <ktexteditor/range.h> 00026 #include <ktexteditor/attribute.h> 00027 #include <ktexteditor/document.h> 00028 #include <ktexteditor/view.h> 00029 #include <ktexteditor/configinterface.h> 00030 #include <ktexteditor/highlightinterface.h> 00031 00032 class AbstractExporter 00033 { 00034 public: 00037 AbstractExporter(KTextEditor::View* view, 00038 QTextStream &output, const bool encapsulate = false) 00039 : m_view(view), m_output(output), m_encapsulate(encapsulate), 00040 m_defaultAttribute(0) 00041 { 00042 QColor defaultBackground; 00043 if ( KTextEditor::ConfigInterface* ciface = qobject_cast< KTextEditor::ConfigInterface* >(m_view) ) { 00044 QVariant variant = ciface->configValue("background-color"); 00045 if ( variant.canConvert<QColor>() ) { 00046 defaultBackground = variant.value<QColor>(); 00047 } 00048 } 00049 if ( KTextEditor::HighlightInterface* hiface = qobject_cast< KTextEditor::HighlightInterface* >(m_view->document()) ) { 00050 m_defaultAttribute = hiface->defaultStyle(KTextEditor::HighlightInterface::dsNormal); 00051 m_defaultAttribute->setBackground(QBrush(defaultBackground)); 00052 } 00053 } 00054 00057 virtual ~AbstractExporter() 00058 {} 00059 00061 virtual void openLine() = 0; 00062 00064 virtual void closeLine(const bool lastLine) = 0; 00065 00069 virtual void exportText(const QString& text, const KTextEditor::Attribute::Ptr& attrib) = 0; 00070 00071 protected: 00072 KTextEditor::View* m_view; 00073 QTextStream &m_output; 00074 bool m_encapsulate; 00075 KTextEditor::Attribute::Ptr m_defaultAttribute; 00076 }; 00077 00078 #endif // ABSTRACTEXPORTER_H 00079 00080 // kate: space-indent on; indent-width 2; replace-tabs on;
KDE 4.6 API Reference