![]() |
XML Mill
1.0.0
A GUI based XML editor with a memory.
|
00001 /* Copyright (c) 2012 - 2013 by William Hallatt. 00002 * 00003 * This file forms part of "XML Mill". 00004 * 00005 * The official website for this project is <http://www.goblincoding.com> and, 00006 * although not compulsory, it would be appreciated if all works of whatever 00007 * nature using this source code (in whole or in part) include a reference to 00008 * this site. 00009 * 00010 * Should you wish to contact me for whatever reason, please do so via: 00011 * 00012 * <http://www.goblincoding.com/contact> 00013 * 00014 * This program is free software: you can redistribute it and/or modify it under 00015 * the terms of the GNU General Public License as published by the Free Software 00016 * Foundation, either version 3 of the License, or (at your option) any later 00017 * version. 00018 * 00019 * This program is distributed in the hope that it will be useful, but WITHOUT 00020 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 00021 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. 00022 * 00023 * You should have received a copy of the GNU General Public License along with 00024 * this program (GNUGPL.txt). If not, see 00025 * 00026 * <http://www.gnu.org/licenses/> 00027 */ 00028 00029 #ifndef GCPLAINTEXTEDIT_H 00030 #define GCPLAINTEXTEDIT_H 00031 00032 #include <QPlainTextEdit> 00033 #include <QTextBlock> 00034 00036 00043 class GCPlainTextEdit : public QPlainTextEdit 00044 { 00045 Q_OBJECT 00046 public: 00047 explicit GCPlainTextEdit( QWidget* parent = 0 ); 00048 00051 void setContent( const QString& text ); 00052 00056 void findTextRelativeToDuplicates( const QString& text, int relativePos ); 00057 00059 void clearAndReset(); 00060 00061 public slots: 00063 void wrapText( bool wrap ); 00064 00065 signals: 00070 void selectedIndex( int index ); 00071 00074 void commentOut( const QList< int >&, const QString& ); 00075 00078 void manualEditAccepted(); 00079 00080 protected: 00082 void keyPressEvent( QKeyEvent* e ); 00083 00085 void mouseMoveEvent( QMouseEvent* e ); 00086 00088 void mouseReleaseEvent( QMouseEvent* e ); 00089 00090 private slots: 00094 void emitSelectedIndex(); 00095 00097 void setCursorPositionChanged(); 00098 00104 void showContextMenu( const QPoint& point ); 00105 00109 void commentOutSelection(); 00110 00113 void uncommentSelection(); 00114 00117 void deleteSelection(); 00118 00121 void insertEmptyRow(); 00122 00125 void deleteEmptyRow(); 00126 00128 bool confirmDomNotBroken( int undoCount ); 00129 00132 int findIndexMatchingBlockNumber( QTextBlock block ); 00133 00134 private: 00135 QBrush m_savedBackground; 00136 QBrush m_savedForeground; 00137 QAction* m_comment; 00138 QAction* m_uncomment; 00139 QAction* m_deleteSelection; 00140 QAction* m_deleteEmptyRow; 00141 QAction* m_insertEmptyRow; 00142 bool m_cursorPositionChanging; 00143 bool m_cursorPositionChanged; 00144 bool m_mouseDragEntered; 00145 bool m_textEditClicked; 00146 }; 00147 00148 #endif // GCPLAINTEXTEDIT_H