Skip to content

Commit

Permalink
indentation (part X) - finally working
Browse files Browse the repository at this point in the history
  • Loading branch information
ibre5041 committed Jul 27, 2018
1 parent c6dceb4 commit a3d749e
Show file tree
Hide file tree
Showing 20 changed files with 19,882 additions and 18,313 deletions.
3 changes: 3 additions & 0 deletions NEWS
@@ -1,3 +1,6 @@
3.2.132:
2018-07-28: SQL Indentation

3.2.98:
2018-06-09: Qt version 5.11, Query model fixes, Gitub bug fixed #93, Rollback/Commit button fixes

Expand Down
21 changes: 11 additions & 10 deletions src/core/toeditorconfiguration.cpp
Expand Up @@ -140,17 +140,18 @@ QVariant ToConfiguration::Editor::defaultValue(int option) const
return QVariant::fromValue(retval);
}
// 3rd tab
case IndentWidthtInt: return QVariant((int) 120);
case IndentDepthInt: return QVariant((int) 3);
case IndentLineWidthInt: return QVariant((int) 160);
case IndentWidthInt: return QVariant((int) 3);
case ReUseNewlinesBool: return QVariant((bool) true);
case BreakSelectBool: return QVariant((bool) true);
case BreakFromBool: return QVariant((bool) true);
case BreakWhereBool: return QVariant((bool) true);
case BreakGroupBool: return QVariant((bool) true);
case BreakOrderBool: return QVariant((bool) true);
case BreakModelBool: return QVariant((bool) true);
case BreakPivotBool: return QVariant((bool) true);

case BreakOnSelectBool: return QVariant((bool) true);
case BreakOnFromBool: return QVariant((bool) true);
case BreakOnWhereBool: return QVariant((bool) true);
case BreakOnGroupBool: return QVariant((bool) true);
case BreakOnOrderBool: return QVariant((bool) true);
case BreakOnModelBool: return QVariant((bool) true);
case BreakOnPivotBool: return QVariant((bool) true);
case BreakOnLimitBool: return QVariant((bool) true);
case WidthModeBool: return QVariant((bool) true);
default:
Q_ASSERT_X( false, qPrintable(__QHERE__), qPrintable(QString("Context Editor un-registered enum value: %1").arg(option)));
return QVariant();
Expand Down
20 changes: 11 additions & 9 deletions src/core/toeditorconfiguration.h
Expand Up @@ -73,16 +73,18 @@ namespace ToConfiguration
// 2nd tab
, EditStyleMap // #define CONF_EDIT_STYLE
// 3rd tab Indent
, IndentWidthtInt = 3500
, IndentDepthInt
, IndentLineWidthInt = 3500
, IndentWidthInt
, ReUseNewlinesBool
, BreakSelectBool
, BreakFromBool
, BreakWhereBool
, BreakGroupBool
, BreakOrderBool
, BreakModelBool
, BreakPivotBool
, BreakOnSelectBool
, BreakOnFromBool
, BreakOnWhereBool
, BreakOnGroupBool
, BreakOnOrderBool
, BreakOnModelBool
, BreakOnPivotBool
, BreakOnLimitBool
, WidthModeBool
};
virtual QVariant defaultValue(int option) const;

Expand Down
82 changes: 82 additions & 0 deletions src/editor/complex.sql
@@ -0,0 +1,82 @@
select
T1.INC_ID "ID",
T2.RCT_NAME "Status",
T1.INC_DESCRIPTION "Description",
T4.WOG_SEARCHCODE "Workgroup",
T5.PER_SEARCHCODE "Person",
T1.INC_SOLUTION "Solution",
T6.CDL_NAME "Closure Code",
T7.CDL_NAME "Closure Code Parent",
T9.CDL_NAME "Reason Caused Code Parent",
T10.CIT_SEARCHCODE "CI",
T11.CDL_NAME "Severity",
T12.RCT_NAME "Category",
T13.CDL_NAME "Business Impact",
T16.CDL_NAME "Priority",
TO_CHAR(T1."REG_CREATED", 'DD-MM-YY HH24:MI:SS') "Registered",
TO_CHAR(T1."INC_DEADLINE", 'DD-MM-YY HH24:MI:SS') "Deadline",
TO_CHAR(T1."INC_ACTUALFINISH", 'DD-MM-YY HH24:MI:SS') "Finish",
T3.ICF_INCSHORTTEXT3 "Message Group",
T3.ICF_INCSHORTTEXT4 "Application",
T3.ICF_INCSHORTTEXT2 "Msg ID",
T99.RCT_NAME "Folder",
c.firstwg "FirstWG",
f.firstreswg "FirstRes"
from
SERVICEDESKREPO.REP_CODES_TEXT T2,
SERVICEDESK.INC_CUSTOM_FIELDS T3,
SERVICEDESK.WORKGROUPS T4,
SERVICEDESK.CODES_LOCALE T11,
SERVICEDESKREPO.REP_CODES_TEXT T12,
SERVICEDESK.CODES_LOCALE T13,
SERVICEDESKREPO.REP_CODES_TEXT T99,
SERVICEDESK.CODES_LOCALE T16,
(select
a.hin_subject as firstwg,
a.hin_inc_oid as firstwgoid,
to_char(a.reg_created, 'YYYY-MM-DD HH24:MI:SS') as firstwgcreated
from
itsm_historylines_incident a,
itsm_incidents b
where a.hin_inc_oid= b.inc_oid
and a.hin_subject like 'To Workgroup set to%'
-- order by firstwgcreated desc
) c,
(
(
(
(
(
(
(
(SERVICEDESK.INCIDENTS T1 LEFT OUTER JOIN SERVICEDESK.PERSONS T5 on T1.INC_ASSIGN_PERSON_TO=T5.PER_OID)
LEFT OUTER JOIN SERVICEDESK.CODES T14 on T1.INC_CLO_OID=T14.COD_OID)
LEFT OUTER JOIN SERVICEDESK.CODES_LOCALE T6 on T14.COD_OID=T6.CDL_COD_OID)
LEFT OUTER JOIN SERVICEDESK.CODES_LOCALE T7 on T14.COD_COD_OID=T7.CDL_COD_OID)
LEFT OUTER JOIN SERVICEDESK.CODES T15 on T1.INC_CLA_OID=T15.COD_OID)
LEFT OUTER JOIN SERVICEDESK.CODES_LOCALE T8 on T15.COD_OID=T8.CDL_COD_OID)
LEFT OUTER JOIN SERVICEDESK.CODES_LOCALE T9 on T15.COD_COD_OID=T9.CDL_COD_OID)
LEFT OUTER JOIN SERVICEDESK.CONFIGURATION_ITEMS T10 on T1.INC_CIT_OID=T10.CIT_OID)
LEFT OUTER JOIN (select d.hin_subject as firstreswg, d.hin_inc_oid as firstresoid, to_char(d.reg_created, 'YYYY-MM-DD HH24:MI:SS') as firstrescreated
from itsm_historylines_incident d,
itsm_incidents e
where d.hin_inc_oid= e.inc_oid
and ( d.hin_subject like 'To Workgroup from%' and d.hin_subject not like 'To Workgroup to%' )
order by
firstrescreated desc
)
f on f.firstresoid=T1.INC_OID
where
T1.INC_STA_OID=T2.RCT_RCD_OID and
T1.INC_OID=T3.ICF_INC_OID and
T1.INC_ASSIGN_WORKGROUP=T4.WOG_OID and
T1.INC_SEV_OID=T11.CDL_COD_OID and
T1.INC_CAT_OID=T12.RCT_RCD_OID and
T13.CDL_COD_OID=T1.INC_IMP_OID and
T1.INC_POO_OID=T99.RCT_RCD_OID and
T1.INC_PRI_OID=T16.CDL_COD_OID
and TO_DATE(T1."REG_CREATED", 'YYYY-MM-DD HH24:MI:SS') >= SYSDATE -1
and TO_DATE(T1."REG_CREATED", 'YYYY-MM-DD HH24:MI:SS') <= SYSDATE
and c.firstwgoid=T1.INC_OID


60 changes: 60 additions & 0 deletions src/main/tosyntaxsetup.cpp
Expand Up @@ -44,6 +44,7 @@
#include "core/tosyntaxanalyzer.h"
#include "editor/tosyntaxanalyzernl.h"
#include "editor/tosyntaxanalyzeroracle.h"
#include "parsing/toindent.h"
#include "core/toeditorconfiguration.h"

#include <QFontDialog>
Expand Down Expand Up @@ -138,6 +139,65 @@ toSyntaxSetup::toSyntaxSetup(QWidget *parent, const char *name, toWFlags fl)
ListFontName = Utils::toFontToString(font);
ResultExampleFont->setFont(font);
}

// 3rd TAB Indent
toIndent indentInst;
if (SyntaxHighlightingInt->currentText() == "QsciSQL")
IndentExample->setHighlighter(toSqlText::QsciSql);
else
IndentExample->setHighlighter(toSqlText::Oracle);
QFile f(":/editor/complex.sql");
f.open(QFile::ReadOnly);
QString SqlExample = QString::fromUtf8(f.readAll());
IndentExample->setText(indentInst.indent(SqlExample));

connect(IndentLineWidthInt, SIGNAL(valueChanged(int)), this, SLOT(setIndentLineWidth(int)));
connect(IndentWidthInt, SIGNAL(valueChanged(int)), this, SLOT(setIndentWidth(int)));
connect(ReUseNewlinesBool, SIGNAL(stateChanged(int)), this, SLOT(setReUseNewlines(int)));
// connect(BreakSelectBool,
// connect(BreakFromBool,
// connect(BreakWhereBoo,
// connect(BreakGroupBool,
// connect(BreakOrderBool,
// connect(BreakModelBool,
// connect(BreakPivotBool,
// connect(WidthModeBool,
}

void toSyntaxSetup::setIndentLineWidth(int i)
{
Utils::toBusy busy;
indentParams.insert("IndentLineWidthInt", i);
toIndent indentInst(indentParams);
QString oldSQL = IndentExample->text();
QString newSQL = indentInst.indent(oldSQL);
IndentExample->beginUndoAction();
IndentExample->setText(newSQL);
IndentExample->endUndoAction();
}

void toSyntaxSetup::setIndentWidth(int i)
{
Utils::toBusy busy;
indentParams.insert("IndentWidthInt", i);
toIndent indentInst(indentParams);
QString oldSQL = IndentExample->text();
QString newSQL = indentInst.indent(oldSQL);
IndentExample->beginUndoAction();
IndentExample->setText(newSQL);
IndentExample->endUndoAction();
}

void toSyntaxSetup::setReUseNewlines(int i)
{
Utils::toBusy busy;
indentParams.insert("ReUseNewlinesBool", i != 0);
toIndent indentInst(indentParams);
QString oldSQL = IndentExample->text();
QString newSQL = indentInst.indent(oldSQL);
IndentExample->beginUndoAction();
IndentExample->setText(newSQL);
IndentExample->endUndoAction();
}

void toSyntaxSetup::checkFixedWidth(const QFont &fnt)
Expand Down
7 changes: 7 additions & 0 deletions src/main/tosyntaxsetup.h
Expand Up @@ -39,6 +39,7 @@
#include "core/utils.h"

#include <QtCore/QString>
#include <QtCore/QVariant>
#include <QtCore/QMetaEnum>
#include "core/tostyle.h"
#include "core/toeditorconfiguration.h"
Expand Down Expand Up @@ -84,7 +85,13 @@ class toSyntaxSetup

void setCaretAlpha();

void setIndentLineWidth(int);
void setIndentWidth(int);
void setReUseNewlines(int);

private:
QMap<QString, QVariant> indentParams;

int wordClass() const; // returns enum toSyntaxAnalyzer::wordClass
void checkFixedWidth(const QFont &fnt);
};
35 changes: 31 additions & 4 deletions src/main/tosyntaxsetupui.ui
Expand Up @@ -47,7 +47,7 @@
<item>
<widget class="QTabWidget" name="tabWidget">
<property name="currentIndex">
<number>2</number>
<number>0</number>
</property>
<widget class="QWidget" name="OptionsTab">
<attribute name="title">
Expand Down Expand Up @@ -611,13 +611,16 @@
</widget>
</item>
<item>
<widget class="QSpinBox" name="IndentWidthtInt">
<widget class="QSpinBox" name="IndentLineWidthInt">
<property name="minimum">
<number>60</number>
</property>
<property name="maximum">
<number>300</number>
</property>
<property name="value">
<number>180</number>
</property>
</widget>
</item>
</layout>
Expand All @@ -632,7 +635,7 @@
</widget>
</item>
<item>
<widget class="QSpinBox" name="IndentDepthInt">
<widget class="QSpinBox" name="IndentWidthInt">
<property name="maximum">
<number>10</number>
</property>
Expand All @@ -643,6 +646,13 @@
</item>
</layout>
</item>
<item>
<widget class="Line" name="line">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="ReUseNewlinesBool">
<property name="text">
Expand All @@ -656,7 +666,7 @@
<item>
<widget class="QLabel" name="LinebreakLabel">
<property name="text">
<string>Linebreak for:</string>
<string>Line break for:</string>
</property>
</widget>
</item>
Expand Down Expand Up @@ -733,6 +743,23 @@
</property>
</widget>
</item>
<item>
<widget class="Line" name="line_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="WidthModeBool">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string>Width mode</string>
</property>
</widget>
</item>
<item>
<spacer name="verticalSpacer_2">
<property name="orientation">
Expand Down

0 comments on commit a3d749e

Please sign in to comment.