File: latexeditor.h

package info (click to toggle)
scribus 1.4.4%2Bdfsg1-2
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 246,704 kB
  • ctags: 25,243
  • sloc: cpp: 272,543; xml: 15,558; ansic: 3,438; python: 3,427; makefile: 1,160; perl: 94; sh: 41
file content (172 lines) | stat: -rw-r--r-- 5,097 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
/*
For general Scribus (>=1.3.2) copyright and licensing information please refer
to the COPYING file provided with the program. Following this notice may exist
a copyright and/or license notice that predates the release of Scribus 1.3.2
for which a new license (GPL+exception) is in place.
*/
/***************************************************************************
						latexeditor.h  -  description
						-------------------
copyright            : Scribus Team
***************************************************************************/

/***************************************************************************
*                                                                         *
*   This program is free software; you can redistribute it and/or modify  *
*   it under the terms of the GNU General Public License as published by  *
*   the Free Software Foundation; either version 2 of the License, or     *
*   (at your option) any later version.                                   *
*                                                                         *
***************************************************************************/

#ifndef LATEXEDITOR_H
#define LATEXEDITOR_H

#include "ui_latexeditor.h"
#include "scribusapi.h"
#include <QWidget>
#include <QProcess>
#include <QMap>
#include <QPushButton>
#include <QStringList>

class PageItem_LatexFrame;
class LatexHighlighter;
class I18nXmlStreamReader;
class QComboBox;
class QListWidgetItem;
class QFile;
class XmlWidget;
class FileWatcher;

class SCRIBUS_API LatexEditor : public QDialog, Ui::LatexEditor
{
		Q_OBJECT
	public:
		LatexEditor ( PageItem_LatexFrame * );
		~LatexEditor();
		virtual void changeEvent ( QEvent *e );
		void startEditor();
		void exitEditor();
		void revert();
		void apply ( bool force=false );
		void initialize();
		static QIcon icon ( QString config, QString fn );
		static QString iconFile ( QString config );
	protected:
		PageItem_LatexFrame *frame;
		LatexHighlighter *highlighter;
		void loadSettings();
		void createNewSettingsTab ( I18nXmlStreamReader *xml );
		void createNewItemsTab ( I18nXmlStreamReader *xml );
		QMap<QString, XmlWidget *> widgetMap;
		QString currentConfigFile, currentIconFile;
		/*External Editor*/
		QString extEditorFile;
		void loadExternalEditorFile();
		void writeExternalEditorFile();
		QProcess *extEditor;
		FileWatcher *fileWatcher;
	protected slots:
		void extEditorFinished ( int exitCode, QProcess::ExitStatus exitStatus );
		void extEditorFileChanged ( QString filename );
		void extEditorError ( QProcess::ProcessError error );
	public slots:
		void okClicked();
		void cancelClicked();
		void updateClicked ( bool );
		void revertClicked ( bool );
		void formulaChanged ( QString, QString );
		void applicationChanged();
		void latexFinished();
		void stateChanged ( QProcess::ProcessState );
		//Slots for the dynamic interface
		void tagButtonClicked ( QString );
		void insertButtonClicked ( QObject * );
		void newItemSelected ( QListWidgetItem *, QListWidgetItem * );
		void itemDoubleClicked ( QListWidgetItem * );
		void updateConfigFile();
		void extEditorClicked();
};


class SCRIBUS_API DataPushButton : public QPushButton
{
		Q_OBJECT
	public:
		DataPushButton ( QString caption, QObject *data, bool deleteOnDestroy=false ) :
				QPushButton ( caption ), data ( data ), del ( deleteOnDestroy )
		{
			connect ( this, SIGNAL ( clicked ( bool ) ), this, SLOT ( buttonClicked ( bool ) ) );
		}
		~DataPushButton()
		{
			if ( del ) delete data;
		}
	protected:
		QObject *data;
		bool del;
	private slots:
		void buttonClicked ( bool checked )
		{
			emit clickedWithData ( data );
		}
	signals:
		void clickedWithData ( QObject *data );
};

class SCRIBUS_API StringPushButton : public QPushButton
{
		Q_OBJECT
	public:
		StringPushButton ( QString caption, QString data ) :
				QPushButton ( caption ), data ( data )
		{
			connect ( this, SIGNAL ( clicked ( bool ) ), this, SLOT ( buttonClicked ( bool ) ) );
		}
	protected:
		QString data;
	private slots:
		void buttonClicked ( bool checked )
		{
			emit clickedWithData ( data );
		}
	signals:
		void clickedWithData ( QString data );
};

class SCRIBUS_API XmlWidget
{
	public:
		static XmlWidget *fromXml ( I18nXmlStreamReader *xml );
		XmlWidget ( I18nXmlStreamReader *xml, bool readDescription=true );
		virtual ~XmlWidget() {};
		QString name() const { return m_name; }
		QString description() const { return m_description; }
		QString defaultValue() const { return m_defaultValue; }
		virtual QString toString() const { return ""; }
		virtual void fromString ( QString str ) {};
	protected:
		QString m_name;
		QString m_description;
		QString m_defaultValue;
};

class SCRIBUS_API IconBuffer
{
	public:
		IconBuffer() { len = 0; basePos = 0; file = 0; }
		static IconBuffer *instance();
		void loadFile ( QString filename );
		QIcon *icon ( QString filename, QString name );
	protected:
		QFile *file;
		QMap<QString, QIcon> icons;
		QStringList loadedFiles;
		QString readHeader();
		QIcon readData();
		int len, basePos;
		static IconBuffer *_instance;
};

#endif