Permalink
Browse files

Added QScintilla dependency.

  • Loading branch information...
1 parent 1588c4a commit 92c834bd39969721eb5db66c039e7b7df6d0fc37 sarunas committed Jan 5, 2013
Showing with 45 additions and 39 deletions.
  1. +1 −8 Repleisiukas/Repleisiukas.pro
  2. +39 −25 Repleisiukas/mainwindow.cpp
  3. +5 −1 Repleisiukas/mainwindow.h
  4. +0 −5 Repleisiukas/mainwindow.ui
@@ -36,11 +36,4 @@ OTHER_FILES += \
RESOURCES += \
other/resources.qrc
-
-
-
-
-
-
-
-
+LIBS += -lqscintilla2
@@ -7,9 +7,11 @@
#include <QSettings>
#include <QDebug>
#include <QShortcut>
+
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
- ui(new Ui::MainWindow)
+ ui(new Ui::MainWindow),
+ query(0)
{
contructionInProgress = true;
QCoreApplication::setOrganizationName("SoftDent");
@@ -19,10 +21,10 @@ MainWindow::MainWindow(QWidget *parent) :
fileOperations = new FileLoadSave(this);
queryExecution = new QueryExecution(fileOperations, this);
ui->setupUi(this);
- highlighter = new JSHighlighter(ui->query->document());
+// highlighter = new JSHighlighter(ui->query->document());
- ui->query->addAction(ui->actionExecute);
- ui->query->setPlainText(fileOperations->GetLastQuery());
+// ui->query->addAction(ui->actionExecute);
+// ui->query->setPlainText(fileOperations->GetLastQuery());
UpdateLastUsedMenu();
QSettings settings;
@@ -32,26 +34,38 @@ MainWindow::MainWindow(QWidget *parent) :
bool debugger = settings.value("/settings/debugger").toBool();
ui->actionDebugger->setChecked(debugger);
- QShortcut* shortcut = new QShortcut(QKeySequence(tr("Ctrl+Return")), ui->query);
- connect(shortcut, SIGNAL(activated()), ui->actionExecute, SLOT(trigger()));
-
- connect(fileOperations, SIGNAL(UpdateLastUsed()), this, SLOT(UpdateLastUsedMenu()));
- connect(ui->stringIn, SIGNAL(updateRequest()), this, SLOT(on_pushButton_Go_clicked()));
- connect(ui->query, SIGNAL(textChanged()), this, SLOT(onQueryChanged()));
-
ui->tabs->createNewTab();
tabDocument = ui->tabs->getCurrentDocument();
connect(ui->tabs, SIGNAL(currentChanged(int)), this, SLOT(tabChanged(int)));
ui->tabs->setTrashButton(ui->trashButton);
+ query = new QsciScintilla;
+ ui->splitter->addWidget(query);
+
+ QsciLexerJavaScript* lexer = new QsciLexerJavaScript();
+ lexer->setHighlightTripleQuotedStrings(true);
+ query->setLexer(lexer);
+ query->setAutoIndent(true);
+ query->setBraceMatching(QsciScintilla::SloppyBraceMatch);
+ query->setFolding(QsciScintilla::BoxedTreeFoldStyle);
+ query->setWrapMode(QsciScintilla::WrapWord);
+
+ QShortcut* shortcut = new QShortcut(QKeySequence(tr("Ctrl+Return")), query);
+ connect(shortcut, SIGNAL(activated()), ui->actionExecute, SLOT(trigger()));
+
LoadSession();
+
+ connect(query, SIGNAL(textChanged()), this, SLOT(onQueryChanged()));
+ connect(fileOperations, SIGNAL(UpdateLastUsed()), this, SLOT(UpdateLastUsedMenu()));
+ connect(ui->stringIn, SIGNAL(updateRequest()), this, SLOT(on_pushButton_Go_clicked()));
+
contructionInProgress = false;
}
MainWindow::~MainWindow()
{
- delete highlighter;
+// delete highlighter;
delete ui;
}
@@ -74,15 +88,15 @@ void MainWindow::setCurretTabDocument(QTabDocument * doc){
//tabDocument->setFileName();
// tabDocument->setName();
tabDocument->setInput(ui->stringIn->toPlainText());
- tabDocument->setQuery(ui->query->toPlainText());
+ tabDocument->setQuery(query->text());
tabDocument->setOutput(ui->stringOut->toPlainText());
}
tabDocument = doc;
if(tabDocument != 0)
{
ui->stringIn->setText(tabDocument->input());
- ui->query->setText(tabDocument->query());
+ query->setText(tabDocument->query());
ui->stringOut->setPlainText(tabDocument->output());
}
}
@@ -115,7 +129,7 @@ void MainWindow::on_openFile_clicked()
if(tabDocument != 0)
{
tabDocument->setFileName(file);
- tabDocument->setQuery(ui->query->toPlainText());
+ tabDocument->setQuery(query->text());
tabDocument->setIsModified(false);
}
}
@@ -125,7 +139,7 @@ void MainWindow::LoadQueryToGUI(QString query)
{
if(!query.isNull())
{
- ui->query->setPlainText(query);
+ this->query->setText(query);
QString autoload = fileOperations->GetAutoLoadText(query);
if(!autoload.isNull())
@@ -141,8 +155,8 @@ void MainWindow::on_pushButton_Go_clicked()
qDebug() << contructionInProgress;
if(!contructionInProgress)
{
- fileOperations->SetLastQuery(ui->query->toPlainText());
- QString result = queryExecution->Execute(ui->query->toPlainText(), ui->stringIn->text());
+ fileOperations->SetLastQuery(query->text());
+ QString result = queryExecution->Execute(query->text(), ui->stringIn->text());
ui->stringOut->setPlainText(result);
}
}
@@ -153,8 +167,8 @@ void MainWindow::on_actionSave_triggered()
{
if(!tabDocument->fileName().isEmpty())
{
- fileOperations->SaveToFile(tabDocument->fileName(), ui->query->toPlainText());
- tabDocument->setQuery(ui->query->toPlainText());
+ fileOperations->SaveToFile(tabDocument->fileName(), query->text());
+ tabDocument->setQuery(query->text());
tabDocument->setIsModified(false);
}else
{
@@ -165,13 +179,13 @@ void MainWindow::on_actionSave_triggered()
void MainWindow::on_actionSave_As_triggered()
{
- QString fileName = fileOperations->SaveToFile(ui->query->toPlainText());
+ QString fileName = fileOperations->SaveToFile(query->text());
if(!fileName.isEmpty())
{
if(tabDocument != 0)
{
tabDocument->setFileName(fileName);
- tabDocument->setQuery(ui->query->toPlainText());
+ tabDocument->setQuery(query->text());
tabDocument->setIsModified(false);
}
}
@@ -228,12 +242,12 @@ void MainWindow::on_pushButton_2_clicked()
void MainWindow::on_actionZoom_In_triggered()
{
- ui->query->zoomIn();
+ query->zoomIn();
}
void MainWindow::on_actionZoom_Out_triggered()
{
- ui->query->zoomOut();
+ query->zoomOut();
}
void MainWindow::onClosing()
@@ -253,7 +267,7 @@ void MainWindow::onQueryChanged()
{
if(!contructionInProgress && tabDocument != 0)
{
- tabDocument->setIsModified(ui->query->toPlainText() != tabDocument->query());
+ tabDocument->setIsModified(query->text() != tabDocument->query());
}
}
@@ -7,6 +7,9 @@
#include "presentation/queryexecution.h"
#include "model/qtabdocument.h"
+#include <Qsci/qsciscintilla.h>
+#include <Qsci/qscilexerjavascript.h>
+
namespace Ui {
class MainWindow;
}
@@ -22,11 +25,12 @@ class MainWindow : public QMainWindow
private:
Ui::MainWindow *ui;
- JSHighlighter *highlighter;
+// JSHighlighter *highlighter;
FileLoadSave* fileOperations;
QueryExecution *queryExecution;
QTabDocument * tabDocument;
+ QsciScintilla* query;
bool contructionInProgress;
private:
@@ -58,11 +58,6 @@
<enum>Qt::Vertical</enum>
</property>
<widget class="QAdvancedInputPanel" name="stringIn" native="true"/>
- <widget class="QTextEdit" name="query">
- <property name="tabStopWidth">
- <number>40</number>
- </property>
- </widget>
</widget>
<widget class="QPlainTextEdit" name="stringOut">
<property name="tabStopWidth">

0 comments on commit 92c834b

Please sign in to comment.