Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
base fork: ssharunas/repleisiukas
base: b9587a6bdf
...
head fork: ssharunas/repleisiukas
compare: 78afec7051
  • 6 commits
  • 11 files changed
  • 0 commit comments
  • 3 contributors
View
11 Repleisiukas/Repleisiukas.pro
@@ -55,13 +55,4 @@ OTHER_FILES += \
RESOURCES += \
other/resources.qrc
-
-
-
-
-
-
-
-
-
-
+LIBS += -lqscintilla2
View
121 Repleisiukas/mainwindow.cpp
@@ -7,10 +7,13 @@
#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");
QCoreApplication::setOrganizationDomain("softdent.lt");
QCoreApplication::setApplicationName("Repleisiukas");
@@ -18,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;
@@ -31,24 +34,42 @@ 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()));
-
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);
+ query->setUtf8(true);
+
+ QShortcut* shortcut = new QShortcut(QKeySequence(tr("Ctrl+Return")), query);
+ connect(shortcut, SIGNAL(activated()), ui->actionExecute, SLOT(trigger()));
+
+ shortcut = new QShortcut(QKeySequence(tr("Ctrl+Enter")), 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;
}
@@ -71,7 +92,7 @@ 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());
}
@@ -79,7 +100,7 @@ void MainWindow::setCurretTabDocument(QTabDocument * doc){
if(tabDocument != 0)
{
ui->stringIn->setText(tabDocument->input());
- ui->query->setText(tabDocument->query());
+ query->setText(tabDocument->query());
ui->stringOut->setPlainText(tabDocument->output());
}
}
@@ -103,11 +124,18 @@ void MainWindow::on_openFile_clicked()
{
QAction *senderAction = dynamic_cast<QAction*>(sender());
- if(senderAction){
+ if(senderAction)
+ {
QString file = senderAction->data().toString();
qDebug() << "trying to open file" << file;
-
LoadQueryToGUI(fileOperations->LoadFromFile(file));
+
+ if(tabDocument != 0)
+ {
+ tabDocument->setFileName(file);
+ tabDocument->setQuery(query->text());
+ tabDocument->setIsModified(false);
+ }
}
}
@@ -115,7 +143,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())
@@ -128,19 +156,58 @@ void MainWindow::LoadQueryToGUI(QString query)
void MainWindow::on_pushButton_Go_clicked()
{
- fileOperations->SetLastQuery(ui->query->toPlainText());
- QString result = queryExecution->Execute(ui->query->toPlainText(), ui->stringIn->text());
- ui->stringOut->setPlainText(result);
+ qDebug() << contructionInProgress;
+ if(!contructionInProgress)
+ {
+ fileOperations->SetLastQuery(query->text());
+ QString result = queryExecution->Execute(query->text(), ui->stringIn->text());
+ ui->stringOut->setPlainText(result);
+ }
}
void MainWindow::on_actionSave_triggered()
{
- fileOperations->SaveToFile(ui->query->toPlainText());
+ if(tabDocument != 0)
+ {
+ if(!tabDocument->fileName().isEmpty())
+ {
+ fileOperations->SaveToFile(tabDocument->fileName(), query->text());
+ tabDocument->setQuery(query->text());
+ tabDocument->setIsModified(false);
+ }else
+ {
+ on_actionSave_As_triggered();
+ }
+ }
+}
+
+void MainWindow::on_actionSave_As_triggered()
+{
+ QString fileName = fileOperations->SaveToFile(query->text());
+ if(!fileName.isEmpty())
+ {
+ if(tabDocument != 0)
+ {
+ tabDocument->setFileName(fileName);
+ tabDocument->setQuery(query->text());
+ tabDocument->setIsModified(false);
+ }
+ }
}
void MainWindow::on_actionLoad_triggered()
{
- LoadQueryToGUI(fileOperations->LoadFromFile());
+ QString fileName = fileOperations->GetLoadFromFileFilename();
+ if(!fileName.isEmpty())
+ {
+ if(tabDocument != 0)
+ {
+ tabDocument->setFileName(fileName);
+ tabDocument->setIsModified(false);
+ }
+
+ LoadQueryToGUI(fileOperations->LoadFromFile(fileName));
+ }
}
void MainWindow::on_pushButton_clicked()
@@ -179,12 +246,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()
@@ -200,6 +267,14 @@ void MainWindow::onClosing()
fileOperations->saveCurrentSession(documents);
}
+void MainWindow::onQueryChanged()
+{
+ if(!contructionInProgress && tabDocument != 0)
+ {
+ tabDocument->setIsModified(query->text() != tabDocument->query());
+ }
+}
+
void MainWindow::closeEvent(QCloseEvent *ev)
{
onClosing();
View
9 Repleisiukas/mainwindow.h
@@ -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,13 @@ class MainWindow : public QMainWindow
private:
Ui::MainWindow *ui;
- JSHighlighter *highlighter;
+// JSHighlighter *highlighter;
FileLoadSave* fileOperations;
QueryExecution *queryExecution;
QTabDocument * tabDocument;
+ QsciScintilla* query;
+ bool contructionInProgress;
private:
@@ -39,6 +44,7 @@ class MainWindow : public QMainWindow
private slots:
void onClosing();
+ void onQueryChanged();
void tabChanged(int index);
void on_pushButton_2_clicked();
void UpdateLastUsedMenu();
@@ -52,6 +58,7 @@ private slots:
void on_actionZoom_In_triggered();
void on_actionZoom_Out_triggered();
void on_actionDebugger_triggered();
+ void on_actionSave_As_triggered();
};
#endif // MAINWINDOW_H
View
16 Repleisiukas/mainwindow.ui
@@ -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">
@@ -123,6 +118,7 @@
<addaction name="separator"/>
</widget>
<addaction name="actionSave"/>
+ <addaction name="actionSave_As"/>
<addaction name="actionLoad"/>
<addaction name="menuLastUsed"/>
</widget>
@@ -141,7 +137,10 @@
<widget class="QStatusBar" name="statusBar"/>
<action name="actionSave">
<property name="text">
- <string>Save...</string>
+ <string>Save</string>
+ </property>
+ <property name="shortcut">
+ <string>Ctrl+S</string>
</property>
</action>
<action name="actionLoad">
@@ -183,6 +182,11 @@
<string>Debugger</string>
</property>
</action>
+ <action name="actionSave_As">
+ <property name="text">
+ <string>Save As..</string>
+ </property>
+ </action>
</widget>
<layoutdefault spacing="6" margin="11"/>
<customwidgets>
View
47 Repleisiukas/model/qtabdocument.cpp
@@ -1,12 +1,17 @@
#include "qtabdocument.h"
QTabDocument::QTabDocument(QObject *parent) :
- QObject(parent), _index(-1)
+ QObject(parent), _isModified(0)
{
}
QTabDocument::~QTabDocument(){
- qDebug("deteted...");
+ qDebug("Tab was destroyed...");
+}
+
+bool QTabDocument::isModified()
+{
+ return _isModified;
}
QString QTabDocument::uid(){
@@ -24,6 +29,28 @@ QString QTabDocument::name(){
return _name;
}
+QString QTabDocument::tabName()
+{
+ QString tabName = name();
+
+ if(!fileName().isEmpty())
+ {
+ int slash = fileName().lastIndexOf('/');
+
+ if((slash != -1) & (slash + 1 < fileName().length()))
+ {
+ tabName = fileName().mid(slash + 1);
+
+ if(isModified())
+ {
+ tabName += "*";
+ }
+ }
+ }
+
+ return tabName;
+}
+
QString QTabDocument::input(){
return _input;
}
@@ -36,16 +63,22 @@ QString QTabDocument::output(){
return _output;
}
-//int QTabDocument::index(){
-// return _index;
-//}
+void QTabDocument::setIsModified(bool value){
+ _isModified = value;
+
+ emit changed();
+}
void QTabDocument::setFileName(QString filename){
_fileName = filename;
+
+ emit changed();
}
void QTabDocument::setName(QString name){
_name = name;
+
+ emit changed();
}
void QTabDocument::setInput(QString input){
@@ -59,7 +92,3 @@ void QTabDocument::setQuery(QString query){
void QTabDocument::setOutput(QString output){
_output = output;
}
-
-//void QTabDocument::setIndex(int index){
-// _index = index;
-//}
View
11 Repleisiukas/model/qtabdocument.h
@@ -11,24 +11,29 @@ class QTabDocument : public QObject
explicit QTabDocument(QObject *parent = 0);
~QTabDocument();
+ bool isModified();
QString uid();
QString fileName();
QString name();
+ QString tabName();
QString input();
QString query();
QString output();
-// int index();
+ void setIsModified(bool);
void setFileName(QString);
void setName(QString);
void setInput(QString);
void setQuery(QString);
void setOutput(QString);
-// void setIndex(int);
+
+ signals:
+ void changed();
+
private:
- int _index;
+ bool _isModified;
QUuid _uid;
QString _fileName;
QString _name;
View
17 Repleisiukas/presentation/fileloadsave.cpp
@@ -70,7 +70,7 @@ void FileLoadSave::SetLastQuery(QString query)
}
}
-QString FileLoadSave::LoadFromFile()
+QString FileLoadSave::GetLoadFromFileFilename()
{
QSettings settings;
QString path = settings.value("/files/lastSaveDir").toString();
@@ -81,8 +81,8 @@ QString FileLoadSave::LoadFromFile()
{
path = fileName.section('/', 0, -2);
settings.setValue("/files/lastSaveDir", QVariant(path));
- qDebug() << "saved" << path << fileName;
- return LoadFromFile(fileName);
+
+ return fileName;
}
return QString();
@@ -163,22 +163,25 @@ QStringList FileLoadSave::GetLastUsedMenuEntries()
}
-void FileLoadSave::SaveToFile(QString query)
+QString FileLoadSave::SaveToFile(QString query)
{
QSettings settings;
QString path = settings.value("/files/lasLoadDir").toString();
QString fileName = QFileDialog::getSaveFileName(parent(), QString(), path);
+ QString savedTo;
if(!fileName.isEmpty())
{
path = fileName.section('/', 0, -2);
settings.setValue("/files/lasLoadDir", QVariant(path));
- SaveToFile(fileName, query);
+ savedTo = SaveToFile(fileName, query);
}
+
+ return savedTo;
}
-void FileLoadSave::SaveToFile(QString fileName, QString query)
+QString FileLoadSave::SaveToFile(QString fileName, QString query)
{
if(!fileName.isEmpty())
{
@@ -195,6 +198,8 @@ void FileLoadSave::SaveToFile(QString fileName, QString query)
stream << query;
UpdateLastUsedOrder(fileName);
}
+
+ return fileName;
}
QString FileLoadSave::LoadResource(QString path){
View
6 Repleisiukas/presentation/fileloadsave.h
@@ -18,12 +18,12 @@ class FileLoadSave : public QObject
void SetLastQuery(QString query);
QString LoadFromFile(QString filename);
- QString LoadFromFile();
+ QString GetLoadFromFileFilename();
unsigned int MenuItemCount();
void UpdateLastUsedOrder(QString newName);
QStringList GetLastUsedMenuEntries();
- void SaveToFile(QString query);
- void SaveToFile(QString fileName, QString query);
+ QString SaveToFile(QString query);
+ QString SaveToFile(QString fileName, QString query);
QWidget* parent() const;
QString LoadResource(QString path);
View
2  Repleisiukas/presentation/queryexecution.cpp
@@ -109,7 +109,7 @@ QString QueryExecution::Execute(QString query, QString userInput)
qDebug() << extensions;
- QString fullQuery = resources + " ;\n" + extensions + " ;\n " + userInput + " ;\n" + query;
+ QString fullQuery = resources + " ;\n" + extensions + " ;\n " + userInput + " ; \"\" ; \n" + query;
QScriptEngine engine;
View
28 Repleisiukas/qadvancedtabbar.cpp
@@ -51,6 +51,7 @@ QTabDocument* QAdvancedTabBar::createDocument()
{
QTabDocument* doc = new QTabDocument(this);
doc->setName(QString("New %1").arg(tab_document_count++));
+ connect(doc, SIGNAL(changed()), this, SLOT(updateTab()));
documents[doc->uid()] = doc;
@@ -64,6 +65,7 @@ void QAdvancedTabBar::openDocument(QTabDocument* document)
if(!documents.contains(document->uid()))
{
documents[document->uid()] = document;
+ connect(document, SIGNAL(changed()), this, SLOT(updateTab()));
}
int index = -1;
@@ -78,7 +80,7 @@ void QAdvancedTabBar::openDocument(QTabDocument* document)
if(index == -1)
{
- index = addTab(document->name());
+ index = addTab(document->tabName());
setTabData(index, QVariant(document->uid()));
}
@@ -89,7 +91,7 @@ void QAdvancedTabBar::openDocument(QTabDocument* document)
void QAdvancedTabBar::createNewTab()
{
QTabDocument* doc = createDocument();
- int index = addTab(doc->name());
+ int index = addTab(doc->tabName());
setTabData(index, QVariant(doc->uid()));
if(currentIndex() != index){
@@ -199,6 +201,28 @@ void QAdvancedTabBar::restoreTab()
}
}
+void QAdvancedTabBar::updateTab()
+{
+ QTabDocument* doc = qobject_cast<QTabDocument*>(sender());
+ if(doc != 0)
+ {
+ int index = -1;
+ for(int i = 0; i < count(); i++)
+ {
+ if(tabData(i) == doc->uid())
+ {
+ index = i;
+ break;
+ }
+ }
+
+ if(index != -1)
+ {
+ setTabText(index, doc->tabName());
+ }
+ }
+}
+
void QAdvancedTabBar::loadDocuments(QList<QTabDocument*> documents)
{
if(documents.count() > 0)
View
1  Repleisiukas/qadvancedtabbar.h
@@ -42,6 +42,7 @@ class QAdvancedTabBar : public QTabBar
private slots:
void closeTab(int index);
void restoreTab();
+ void updateTab();
};
#endif // QADVANCEDTABBAR_H

No commit comments for this range

Something went wrong with that request. Please try again.