📄 zmultilineedit.h
字号:
//-------------------------------------------------------------------------------------------------//// Header Name: ZMulitLineEdit.h//// General Description: EZX MultiLineEdit widget////-------------------------------------------------------------------------------------------------//// Motorola Confidential Proprietary// Template ID and version: TMP_LFC_50068 Version 1.2// (c) Copyright Motorola 200{x}, All Rights Reserved////-------------------------------------------------------------------------------------------------#ifndef Z_MULTILINE_H#define Z_MULTILINE_H#ifndef __cplusplus#error "This is a C++ header file;it requires C++ to compile."#endif#ifndef QT_H#include "qtableview.h"#include "qstring.h"#include "qlist.h"#include "qregexp.h"#endif // QT_Hstruct ZMultiLineData;class ZMultiLineEditCommand;class QValidator;/** * the ZMainWidget class implements the EZX style's MultiLineEdit: * for example: * 1. support indent * 2. support resize automatically(work with ZScrollView) * 3. support under line * 4. support input text filter * * the ZMultiLineEdit is based on the QMultiLineEdit, so for the most functions please refer to * the doc of the QMultiLineEdit, except for these: * setIndent(), getIndent(), getLineHeight(), setUnderline(), * setFilter(),getFilter(), drawLineText() * * @code * ZScrollView* sv = new ZScrollView( this, "sv" ); * UTIL_MulitLineEdit *ml1, *ml2; * * //add a 6 lines ZMultiLineEdit * ml1 = new ZMultiLineEdit(sv->viewport(),true,6); * * //set filter * QRegExp tmp("[.*]"); * ml1->setFilter(tmp); * sv->addChild(ml1,0,0); * * //set indent * ml1->setIndent(20); * ml2 = new ZMultiLineEdit(sv->viewport()); * * //need to change the widget when ZScrollView's scrollbar is shown/hidden * sv->addChild(ml2,0,30,true); * @endcode */class Q_EXPORT ZMultiLineEdit : public QTableView{ Q_OBJECT Q_ENUMS( EchoMode WordWrap WrapPolicy ) Q_PROPERTY( int numLines READ numLines ) Q_PROPERTY( bool atBeginning READ atBeginning ) Q_PROPERTY( bool atEnd READ atEnd ) Q_PROPERTY( int maxLineWidth READ maxLineWidth ) Q_PROPERTY( Alignment alignment READ alignment WRITE setAlignment ) Q_PROPERTY( bool edited READ edited WRITE setEdited DESIGNABLE false ) Q_PROPERTY( EchoMode echoMode READ echoMode WRITE setEchoMode ) Q_PROPERTY( int maxLength READ maxLength WRITE setMaxLength ) Q_PROPERTY( int maxLines READ maxLines WRITE setMaxLines ) Q_PROPERTY( int hMargin READ hMargin WRITE setHMargin ) Q_PROPERTY( WordWrap wordWrap READ wordWrap WRITE setWordWrap ) Q_PROPERTY( int wrapColumnOrWidth READ wrapColumnOrWidth WRITE setWrapColumnOrWidth ) Q_PROPERTY( WrapPolicy wrapPolicy READ wrapPolicy WRITE setWrapPolicy ) Q_PROPERTY( bool autoUpdate READ autoUpdate WRITE setAutoUpdate DESIGNABLE false ) Q_PROPERTY( bool undoEnabled READ isUndoEnabled WRITE setUndoEnabled ) Q_PROPERTY( int undoDepth READ undoDepth WRITE setUndoDepth ) Q_PROPERTY( bool readOnly READ isReadOnly WRITE setReadOnly ) Q_PROPERTY( bool overWriteMode READ isOverwriteMode WRITE setOverwriteMode ) Q_PROPERTY( QString text READ text WRITE setText ) Q_PROPERTY( int length READ length )public: ZMultiLineEdit( QWidget *parent=0, const char *name=0); /** * Constructor of ZMultiLineEdit * * @param EZXStyle if false, the class is almost the samewith qmultilineedit. * if true ezx-special functions will be suported. * * @param lines the default lines the ZMultiLineEdit has */ ZMultiLineEdit( QWidget *parent,bool EZXStyle,int lines = 1,const char *name=0 ); virtual ~ZMultiLineEdit(); /** * set indent */ void setIndent( int idt ); /** * get indent */ int getIndent(); /** * get the each line's height */ int getLineHeight() const; /** * set the underline flag */ void setUnderline( bool needUnderline = true ); /** * get the underline flag * * @retval if true has underline; if false, does not have underline */ bool getUnderline(); /** * set the filter for the text input * * @param filter the filter * @param match if true the text input need to match the filter * @note if the text is big, maybe the performance will be bad */ void setFilter( const QRegExp& filter, bool match = false ); /** * get the filter */ const QRegExp& getFilter() const; QString textLine( int line ) const; int numLines() const; QSize sizeHint() const; QSize minimumSizeHint() const; QSizePolicy sizePolicy() const; virtual void setFont( const QFont &font ); virtual void insertLine( const QString &s, int line = -1 ); virtual void insertAt( const QString &s, int line, int col, bool mark = FALSE ); virtual void removeLine( int line ); void cursorPosition( int *line, int *col ) const; virtual void setCursorPosition( int line, int col, bool mark = FALSE ); void getCursorPosition( int *line, int *col ) const; bool atBeginning() const; bool atEnd() const; virtual void setFixedVisibleLines( int lines ); int maxLineWidth() const; void setAlignment( int flags ); int alignment() const; virtual void setValidator( const QValidator * ); const QValidator * validator() const; void setEdited( bool ); bool edited() const; void cursorWordForward( bool mark ); void cursorWordBackward( bool mark ); enum EchoMode { Normal, NoEcho, Password }; virtual void setEchoMode( EchoMode ); EchoMode echoMode() const; void setMaxLength(int); int maxLength() const; virtual void setMaxLineLength(int); int maxLineLength() const; virtual void setMaxLines(int); int maxLines() const; virtual void setHMargin(int); int hMargin() const; virtual void setSelection( int row_from, int col_from, int row_to, int col_t ); enum WordWrap { NoWrap, WidgetWidth, FixedPixelWidth, FixedColumnWidth }; void setWordWrap( WordWrap mode ); WordWrap wordWrap() const; void setWrapColumnOrWidth( int ); int wrapColumnOrWidth() const; enum WrapPolicy { AtWhiteSpace, Anywhere }; void setWrapPolicy( WrapPolicy policy ); WrapPolicy wrapPolicy() const; bool autoUpdate() const; virtual void setAutoUpdate( bool ); void setUndoEnabled( bool ); bool isUndoEnabled() const; void setUndoDepth( int ); int undoDepth() const; bool isReadOnly() const; bool isOverwriteMode() const; QString text() const; int length() const; static void setDefaultTabStop( int ex ); static int defaultTabStop(); virtual void show();public slots: /** * change the content size * * @param lines how many lines have be changed * * @param cursorPos cursor position * * @note internal use */ virtual void changeContentSize( int lines,QPoint cursorPos ); virtual void setText( const QString &); virtual void setReadOnly( bool ); virtual void setOverwriteMode( bool ); void clear(); void append( const QString &); void deselect(); void selectAll();#ifndef QT_NO_CLIPBOARD void paste(); void pasteSubType(const QCString& subtype); void copyText() const; void copy() const; void cut(); void deleteText();#endif void insert( const QString& ); void undo(); void redo();signals: void clicked(); void textTrancated();
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -