latexeditor.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #ifndef LATEXEDITOR_H
00023 #define LATEXEDITOR_H
00024
00025 #include "ui_latexeditor.h"
00026 #include "scribusapi.h"
00027 #include <QWidget>
00028 #include <QProcess>
00029 #include <QMap>
00030 #include <QPushButton>
00031 #include <QStringList>
00032
00033 class PageItem_LatexFrame;
00034 class LatexHighlighter;
00035 class I18nXmlStreamReader;
00036 class QComboBox;
00037 class QListWidgetItem;
00038 class QFile;
00039 class XmlWidget;
00040
00041 class SCRIBUS_API LatexEditor : public QDialog, Ui::LatexEditor
00042 {
00043 Q_OBJECT
00044 public:
00045 LatexEditor(PageItem_LatexFrame *);
00046 ~LatexEditor();
00047 void startEditor();
00048 void exitEditor();
00049 void revert();
00050 void apply(bool force=false);
00051 void initialize();
00052 static QIcon icon(QString config, QString fn);
00053 static QString iconFile(QString config);
00054 protected:
00055 PageItem_LatexFrame *frame;
00056 LatexHighlighter *highlighter;
00057 void loadSettings();
00058 void createNewSettingsTab(I18nXmlStreamReader *xml);
00059 void createNewItemsTab(I18nXmlStreamReader *xml);
00060 QMap<QString, XmlWidget *> widgetMap;
00061 QString currentConfigFile, currentIconFile;
00062
00063 public slots:
00064 void okClicked();
00065 void cancelClicked();
00066 void updateClicked(bool);
00067 void revertClicked(bool);
00068 void formulaChanged(QString, QString);
00069 void latexFinished();
00070 void stateChanged(QProcess::ProcessState);
00071
00072 void tagButtonClicked(QString);
00073 void insertButtonClicked(QObject *);
00074 void newItemSelected(QListWidgetItem *, QListWidgetItem *);
00075 void itemDoubleClicked(QListWidgetItem *);
00076 void updateConfigFile();
00077 };
00078
00079
00080 class SCRIBUS_API DataPushButton : public QPushButton
00081 {
00082 Q_OBJECT
00083 public:
00084 DataPushButton(QString caption, QObject *data, bool deleteOnDestroy=false):
00085 QPushButton(caption), data(data), del(deleteOnDestroy) {
00086 connect(this, SIGNAL(clicked(bool)), this, SLOT(buttonClicked(bool)));}
00087 ~DataPushButton() {
00088 if (del) delete data;
00089 }
00090 protected:
00091 QObject *data;
00092 bool del;
00093 private slots:
00094 void buttonClicked(bool checked) {
00095 emit clickedWithData(data);
00096 }
00097 signals:
00098 void clickedWithData(QObject *data);
00099 };
00100
00101 class SCRIBUS_API StringPushButton : public QPushButton
00102 {
00103 Q_OBJECT
00104 public:
00105 StringPushButton(QString caption, QString data):
00106 QPushButton(caption), data(data) {
00107 connect(this, SIGNAL(clicked(bool)), this, SLOT(buttonClicked(bool)));}
00108 protected:
00109 QString data;
00110 private slots:
00111 void buttonClicked(bool checked) {
00112 emit clickedWithData(data);
00113 }
00114 signals:
00115 void clickedWithData(QString data);
00116 };
00117
00118 class SCRIBUS_API XmlWidget
00119 {
00120 public:
00121 static XmlWidget *fromXml(I18nXmlStreamReader *xml);
00122 XmlWidget(I18nXmlStreamReader *xml, bool readDescription=true);
00123 virtual ~XmlWidget() {};
00124 QString name() const { return m_name; }
00125 QString description() const { return m_description; }
00126 QString defaultValue() const { return m_defaultValue; }
00127 virtual QString toString() const { return ""; }
00128 virtual void fromString(QString str){};
00129 protected:
00130 QString m_name;
00131 QString m_description;
00132 QString m_defaultValue;
00133 };
00134
00135 class SCRIBUS_API IconBuffer
00136 {
00137 public:
00138 IconBuffer() { len = 0; basePos = 0; file = 0; }
00139 static IconBuffer *instance();
00140 void loadFile(QString filename);
00141 QIcon *icon(QString filename, QString name);
00142 protected:
00143 QFile *file;
00144 QMap<QString, QIcon> icons;
00145 QStringList loadedFiles;
00146 QString readHeader();
00147 QIcon readData();
00148 int len, basePos;
00149 static IconBuffer *_instance;
00150 };
00151
00152 #endif