-
-
Notifications
You must be signed in to change notification settings - Fork 622
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add CSV table preview and CSV highlighting (#680)
* Add CSV table preview and CSV highlighting * add toggles for enabling CSV table view and syntax highlighting
- Loading branch information
1 parent
ac15b7c
commit 146d744
Showing
7 changed files
with
230 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
#pragma once | ||
|
||
#include <internal/QCSVHighlighter.hpp> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
#pragma once | ||
|
||
// QCodeEditor | ||
#include <QStyleSyntaxHighlighter> // Required for inheritance | ||
#include <QHighlightRule> | ||
#include <QHighlightBlockRule> | ||
|
||
// Qt | ||
#include <QRegularExpression> | ||
#include <QVector> | ||
#include <QMap> | ||
#include <QChar> | ||
|
||
class QSyntaxStyle; | ||
|
||
/** | ||
* @brief Class, that describes C++ code | ||
* highlighter. | ||
*/ | ||
class QCSVHighlighter : public QStyleSyntaxHighlighter | ||
{ | ||
Q_OBJECT | ||
public: | ||
|
||
/** | ||
* @brief Constructor. | ||
* @param document Pointer to document. | ||
*/ | ||
explicit QCSVHighlighter(QTextDocument* document=nullptr); | ||
|
||
QChar delimiter = QChar(','); | ||
|
||
protected: | ||
void highlightBlock(const QString& text) override; | ||
|
||
private: | ||
QRegularExpression m_delimiter; | ||
|
||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
// QCodeEditor | ||
#include <QCSVHighlighter> | ||
#include <QSyntaxStyle> | ||
#include <QLanguage> | ||
|
||
// Qt | ||
#include <QFile> | ||
|
||
|
||
QCSVHighlighter::QCSVHighlighter(QTextDocument* document) : | ||
QStyleSyntaxHighlighter(document), | ||
m_delimiter(QRegularExpression(",")) | ||
{ | ||
Q_INIT_RESOURCE(qcodeeditor_resources); | ||
|
||
} | ||
|
||
void QCSVHighlighter::highlightBlock(const QString& text) | ||
{ | ||
{ // Checking for require | ||
QRegularExpression m_delimiter; | ||
//m_delimiter = QRegularExpression(delimiter); | ||
m_delimiter.setPattern(delimiter); | ||
auto matchIterator = m_delimiter.globalMatch(text); | ||
|
||
while (matchIterator.hasNext()) | ||
{ | ||
auto match = matchIterator.next(); | ||
|
||
setFormat( | ||
match.capturedStart(), | ||
match.capturedLength(), | ||
syntaxStyle()->getFormat("VisualWhitespace") | ||
); | ||
|
||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters