texteditor.h
author insilmaril
Fri, 09 Apr 2010 14:16:02 +0000
changeset 845 b98c1793bb8b
parent 842 bec082472471
permissions -rw-r--r--
XHTML export obsoleted by HTML export
     1 #ifndef TEXTEDITOR_H 
     2 #define TEXTEDITOR_H
     3 
     4 #include <QtGui>
     5 
     6 enum EditorState {inactiveEditor,emptyEditor,filledEditor};
     7 
     8 class NoteObj;
     9 
    10 class TextEditor : public QMainWindow {
    11     Q_OBJECT
    12 public:
    13     TextEditor();
    14     ~TextEditor();
    15 
    16 	void reset();
    17 	bool isEmpty();
    18 	void setShowWithMain (bool);
    19 	bool showWithMain ();
    20 	void setFontHint(const QString&);
    21 	QString getFontHint();
    22 	QString getFontHintDefault();
    23 	void setFilename (const QString&);
    24 	QString getFilename ();
    25 	void setFilenameHint (const QString&);
    26 	QString getFilenameHint ();
    27 	QString getText();
    28 	NoteObj getNoteObj();
    29 	void setNote(const NoteObj &note);
    30 
    31 	bool findText(const QString &, const QTextDocument::FindFlags &); 
    32 	bool findText(const QString &, const QTextDocument::FindFlags &,int i); 
    33 	void setTextCursor (const QTextCursor & cursor );
    34 	QTextCursor getTextCursor();
    35 
    36 protected:
    37 	void setupFileActions();
    38 	void setupEditActions();
    39 	void setupFormatActions();
    40 	void setupSettingsActions();
    41     void closeEvent( QCloseEvent* );
    42 	
    43 
    44 public slots:
    45 	void editorChanged();			// received when text() changed
    46 	void setText(const QString &);	// set Text (by MapEditor)
    47 	void setInactive();				// Nothing can be entered
    48 	void editCopyAll();
    49 
    50 signals:
    51 	void textHasChanged();
    52 	void windowClosed();
    53 	void fontFamilyHasChanged();
    54 	void fontSizeHasChanged();
    55 	
    56 private slots:
    57     void textLoad();
    58     void textSaveAs();
    59     void textSave();
    60 	void textExportAsASCII();
    61     void textPrint();
    62 	void textEditUndo();
    63     void toggleFonthint();
    64     void setFixedFont();
    65     void setVarFont();
    66     void textBold();
    67     void textUnderline();
    68     void textItalic();
    69     void textFamily( const QString &f );
    70     void textSize( const QString &p );
    71 	void textColor();
    72 	void textAlign(QAction*);
    73 	void textVAlign();
    74     void fontChanged( const QFont &f );
    75     void colorChanged( const QColor &c );
    76 	void formatChanged (const QTextCharFormat &f);
    77     void alignmentChanged( int a );
    78     void verticalAlignmentChanged(QTextCharFormat::VerticalAlignment);
    79 	void enableActions();
    80 	void disableActions();
    81 	void setState (EditorState);
    82 
    83 private:
    84     QPrinter *printer;
    85     QTextEdit *e;
    86 	QPoint lastPos;			// save last position of window
    87     QString filename;
    88     QString filenameHint;
    89 
    90 	QBrush emptyPaper;		// setting the background color
    91 	QBrush filledPaper;		// depending on the state
    92 	QBrush inactivePaper;	// depending on the state
    93 	EditorState state;
    94 	bool showwithmain;		// same visibility as mainwindow?
    95 	bool blockChangedSignal;
    96 
    97 	QFont varFont;
    98 	QFont fixedFont;
    99     QComboBox *comboFont, *comboSize;
   100 	
   101 	QAction *actionFileLoad,
   102 	*actionFileSave,
   103 	*actionFileSaveAs,
   104 	*actionFilePrint,
   105 	*actionEditUndo,
   106 	*actionEditRedo,
   107 	*actionEditCopy,
   108 	*actionEditCut,
   109 	*actionEditPaste,
   110 	*actionEditDeleteAll,
   111 	*actionFormatUseFixedFont,
   112 	*actionSettingsVarFont,
   113 	*actionSettingsFixedFont,
   114 	*actionSettingsFonthintDefault,
   115     *actionTextBold,
   116 	*actionTextUnderline,
   117 	*actionTextItalic,
   118 	*actionTextColor,
   119 	*actionAlignSubScript,
   120 	*actionAlignSuperScript,
   121 	*actionAlignLeft,
   122 	*actionAlignCenter,
   123 	*actionAlignRight,
   124 	*actionAlignJustify;
   125 };
   126 
   127 #endif