code format
This commit is contained in:
@@ -1,33 +1,34 @@
|
||||
/*
|
||||
QAD - Qt ADvanced
|
||||
QAD - Qt ADvanced
|
||||
|
||||
Ivan Pelipenko peri4ko@yandex.ru, Andrey Bychkov work.a.b@yandex.ru
|
||||
Ivan Pelipenko peri4ko@yandex.ru, Andrey Bychkov work.a.b@yandex.ru
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Lesser General Public License for more details.
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef QCODEEDIT_H
|
||||
#define QCODEEDIT_H
|
||||
|
||||
#include "qad_widgets_export.h"
|
||||
|
||||
#include <QIcon>
|
||||
#include <QTextEdit>
|
||||
#include <QUrl>
|
||||
#include <QIcon>
|
||||
|
||||
|
||||
namespace Ui {
|
||||
class QCodeEdit;
|
||||
class QCodeEdit;
|
||||
}
|
||||
|
||||
class QPlainTextEdit;
|
||||
@@ -36,8 +37,7 @@ class IconedLabel;
|
||||
class _QCE_Viewport;
|
||||
|
||||
|
||||
class QAD_WIDGETS_EXPORT QCodeEdit: public QWidget
|
||||
{
|
||||
class QAD_WIDGETS_EXPORT QCodeEdit: public QWidget {
|
||||
Q_OBJECT
|
||||
Q_PROPERTY(QString text READ text WRITE setText)
|
||||
Q_PROPERTY(bool showSpaces READ showSpaces WRITE setShowSpaces)
|
||||
@@ -47,24 +47,34 @@ class QAD_WIDGETS_EXPORT QCodeEdit: public QWidget
|
||||
|
||||
friend class QCodeEditCompleter;
|
||||
friend class _QCE_Viewport;
|
||||
|
||||
|
||||
public:
|
||||
QCodeEdit(QWidget * parent = nullptr);
|
||||
~QCodeEdit() override;
|
||||
|
||||
|
||||
enum ACClassType {
|
||||
Keyword,
|
||||
Function,
|
||||
Namespace
|
||||
};
|
||||
struct QAD_WIDGETS_EXPORT ACEntry {
|
||||
ACEntry(const QString & t = QString(), const QString & n = QString(), const QString & h = QString()):
|
||||
type(t), name(n), hint(h) {declaration_pos = -1;}
|
||||
bool isNull() const {return type.isEmpty() && name.isEmpty();}
|
||||
ACEntry(const QString & t = QString(), const QString & n = QString(), const QString & h = QString()): type(t), name(n), hint(h) {
|
||||
declaration_pos = -1;
|
||||
}
|
||||
bool isNull() const { return type.isEmpty() && name.isEmpty(); }
|
||||
QString declaration() const;
|
||||
ACEntry & addHint(QString h) {hint = h; return *this;}
|
||||
ACEntry & addHelpHRef(QUrl h) {help_href = h; return *this;}
|
||||
ACEntry & addCustomData(QVariant d) {custom_data = d; return *this;}
|
||||
ACEntry & addHint(QString h) {
|
||||
hint = h;
|
||||
return *this;
|
||||
}
|
||||
ACEntry & addHelpHRef(QUrl h) {
|
||||
help_href = h;
|
||||
return *this;
|
||||
}
|
||||
ACEntry & addCustomData(QVariant d) {
|
||||
custom_data = d;
|
||||
return *this;
|
||||
}
|
||||
QString type;
|
||||
QString name;
|
||||
QString hint;
|
||||
@@ -86,7 +96,7 @@ public:
|
||||
QRect cursorRect(const QTextCursor & cursor) const;
|
||||
QString text() const;
|
||||
QStringList cursorScope() const;
|
||||
bool showSpaces() const {return spaces_;}
|
||||
bool showSpaces() const { return spaces_; }
|
||||
bool showLineNumbers() const;
|
||||
void setHelpHintVisible(bool on);
|
||||
bool isHelpHintVisible() const;
|
||||
@@ -95,23 +105,23 @@ public:
|
||||
|
||||
void setEditorFont(QFont f);
|
||||
QFont editorFont() const;
|
||||
|
||||
|
||||
QPlainTextEdit * textEdit() const;
|
||||
|
||||
|
||||
void registerAutoCompletitionClass(int id, ACClassType ac_class, const QString & name, const QIcon & icon = QIcon());
|
||||
bool wordCompletitionEnabled() const {return word_complete;}
|
||||
bool wordCompletitionEnabled() const { return word_complete; }
|
||||
|
||||
protected:
|
||||
typedef QPair<QString, QString> StringsPair;
|
||||
typedef QPair<int, QList<ACEntry> > ACSection; // section, ACClass.id -> list of entries
|
||||
typedef QList<ACSection> ACList; // list of sections
|
||||
|
||||
virtual ACList autoCompletitionList(const QStringList & scope, const QString & written) const {return ACList();}
|
||||
typedef QPair<int, QList<ACEntry>> ACSection; // section, ACClass.id -> list of entries
|
||||
typedef QList<ACSection> ACList; // list of sections
|
||||
|
||||
virtual ACList autoCompletitionList(const QStringList & scope, const QString & written) const { return ACList(); }
|
||||
virtual void parse() {}
|
||||
virtual void documentUnset() {}
|
||||
virtual void documentChanged(QTextDocument * d) {}
|
||||
virtual void linkClicked(ACEntry entry) {}
|
||||
virtual bool linkValidate(ACEntry e) {return true;}
|
||||
virtual bool linkValidate(ACEntry e) { return true; }
|
||||
|
||||
QString selectArg(QString s, int arg);
|
||||
void raiseHelp(QTextCursor tc, int arg = -1);
|
||||
@@ -124,7 +134,7 @@ protected:
|
||||
static QChar pairChar(QChar c);
|
||||
|
||||
private slots:
|
||||
void _activateLink(QCodeEdit::ACEntry e) {linkClicked(e);}
|
||||
void _activateLink(QCodeEdit::ACEntry e) { linkClicked(e); }
|
||||
void gotoHelpHRef(QCodeEdit::ACEntry e);
|
||||
void resizeOverlay();
|
||||
void syncScrolls();
|
||||
@@ -166,18 +176,22 @@ public slots:
|
||||
void setShowLineNumbers(bool yes);
|
||||
void search(const QString & t);
|
||||
void searchNext(bool next);
|
||||
void searchNext() {searchNext(true);}
|
||||
void searchNext() { searchNext(true); }
|
||||
void searchPrevious();
|
||||
void hideSearch();
|
||||
void setWordCompletitionEnabled(bool on) {word_complete = on;}
|
||||
void setWordCompletitionEnabled(bool on) { word_complete = on; }
|
||||
|
||||
signals:
|
||||
void textChanged();
|
||||
void parseRequest();
|
||||
|
||||
|
||||
private:
|
||||
struct QAD_WIDGETS_EXPORT ACClass {
|
||||
ACClass(int i = -2, ACClassType c = QCodeEdit::Keyword, const QString & n = QString(), const QIcon & ic = QIcon()): id(i), class_(c), name(n), icon(ic) {}
|
||||
ACClass(int i = -2, ACClassType c = QCodeEdit::Keyword, const QString & n = QString(), const QIcon & ic = QIcon())
|
||||
: id(i)
|
||||
, class_(c)
|
||||
, name(n)
|
||||
, icon(ic) {}
|
||||
int id;
|
||||
ACClassType class_;
|
||||
QString name;
|
||||
@@ -191,9 +205,9 @@ private:
|
||||
};
|
||||
|
||||
bool eventFilter(QObject * o, QEvent * e) override;
|
||||
void showEvent(QShowEvent * ) override;
|
||||
void timerEvent(QTimerEvent * ) override;
|
||||
void leaveEvent(QEvent * ) override;
|
||||
void showEvent(QShowEvent *) override;
|
||||
void timerEvent(QTimerEvent *) override;
|
||||
void leaveEvent(QEvent *) override;
|
||||
void changeEvent(QEvent * e) override;
|
||||
bool codeKeyEvent(QKeyEvent * ke);
|
||||
void toggleComment();
|
||||
|
||||
Reference in New Issue
Block a user