mirror of
https://github.com/overte-org/overte.git
synced 2025-08-09 14:08:51 +02:00
complete Group Functionality i.e Group,GroupCollapsed,GroupEnd
This commit is contained in:
parent
c5d8268007
commit
2bd2804d0b
2 changed files with 140 additions and 126 deletions
|
@ -26,6 +26,10 @@ void ConsoleScriptingInterface::log(QString message) {
|
|||
/*if (!listgrp.isEmpty()){
|
||||
listgrp.append(qMakePair(currentGroupSelection, message));
|
||||
}*/
|
||||
/*_listOfGroupData.append(qMakePair(_selectedGroup, message));
|
||||
if (!_listOfGroupData.isEmpty()) {
|
||||
showdata(_selectedGroup, message);
|
||||
}*/
|
||||
if (ScriptEngine* scriptEngine = qobject_cast<ScriptEngine*>(engine())) {
|
||||
scriptEngine->scriptPrintedMessage(message);
|
||||
}
|
||||
|
@ -86,7 +90,8 @@ void ConsoleScriptingInterface::timeEnd(QString labelName) {
|
|||
if (_dateTimeOfLabel.toString(TIME_FORMAT) == _currentDateTimeValue.toString(TIME_FORMAT)) {
|
||||
millisecondsDiff = _dateTimeOfLabel.msecsTo(_currentDateTimeValue);
|
||||
message = QString::number(millisecondsDiff) + " ms";
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
message = secondsToString(_dateTimeOfLabel.secsTo(_currentDateTimeValue));
|
||||
}
|
||||
|
||||
|
@ -109,10 +114,12 @@ void ConsoleScriptingInterface::asserts(bool condition, QString message) {
|
|||
QString assertFailed = "Assertion failed";
|
||||
if (message.isEmpty()) {
|
||||
message = assertFailed;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
if (typeid(message) != typeid(QString)) {
|
||||
message = assertFailed;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
message = assertFailed + " " + message;
|
||||
}
|
||||
}
|
||||
|
@ -135,60 +142,62 @@ void ConsoleScriptingInterface::clear() {
|
|||
}
|
||||
|
||||
void ConsoleScriptingInterface::group(QString groupName) {
|
||||
listgrp.append(qMakePair(defaultGroupName, groupName));
|
||||
currentGroupSelection = groupName;
|
||||
_listOfGroupData.append(qMakePair(GROUP, groupName));
|
||||
_selectedGroup = groupName;
|
||||
showdata(GROUP, groupName);
|
||||
}
|
||||
|
||||
void ConsoleScriptingInterface::groupCollapsed(QString groupName) {
|
||||
listgrp.append(qMakePair(defaultGroupCollapseName, groupName));
|
||||
currentGroupSelection = groupName;
|
||||
_listOfGroupData.append(qMakePair(GROUPCOLLAPSED, groupName));
|
||||
_selectedGroup = groupName;
|
||||
showdata(GROUPCOLLAPSED, groupName);
|
||||
}
|
||||
|
||||
void ConsoleScriptingInterface::consoleLog(QString groupName) {
|
||||
if (!listgrp.isEmpty()){
|
||||
listgrp.append(qMakePair(currentGroupSelection, groupName));
|
||||
void ConsoleScriptingInterface::consoleLog(QString message) {
|
||||
_listOfGroupData.append(qMakePair(_selectedGroup, message));
|
||||
if (!_listOfGroupData.isEmpty()) {
|
||||
showdata(_selectedGroup, message);
|
||||
}
|
||||
}
|
||||
|
||||
int collapseCount = 0;
|
||||
QString addSpace = " ";
|
||||
void ConsoleScriptingInterface::groupEnd() {
|
||||
QString endGroup= "endGroup";
|
||||
listgrp.append(qMakePair(currentGroupSelection, endGroup));
|
||||
//currentGroupSelection = groupName;
|
||||
_listOfGroupData.append(qMakePair(_selectedGroup, GROUPEND));
|
||||
showdata(_selectedGroup, GROUPEND);
|
||||
}
|
||||
|
||||
void show(){
|
||||
QString tmp;
|
||||
QPair<QString, QString> pair;
|
||||
for (int i = 0; i<listgrp.count(); i++) {
|
||||
pair = listgrp.at(i);
|
||||
if (pair.first == "group") {
|
||||
tmp = pair.second;
|
||||
addSpace = "";
|
||||
debug(pair.second);
|
||||
void ConsoleScriptingInterface::showdata(QString currentGroup, QString groupName) {
|
||||
QPair<QString, QString> groupData;
|
||||
QString firstGroupData;
|
||||
|
||||
for (int index = 0; index<_listOfGroupData.count(); index++) {
|
||||
groupData = _listOfGroupData.at(index);
|
||||
firstGroupData = groupData.first;
|
||||
if (groupData.first == GROUP || groupData.first == GROUPCOLLAPSED) {
|
||||
firstGroupData = groupData.second;
|
||||
if (_isSameLevel) {
|
||||
_addSpace = _addSpace.mid(0, _addSpace.length() - 3);
|
||||
}
|
||||
else if (pair.first == "groupCollapse") {
|
||||
tmp = pair.second;
|
||||
int count = 0;
|
||||
addSpace = collapseCount == 0 ? "\t" : " ";
|
||||
while (count<collapseCount) {
|
||||
addSpace += '\t\t';
|
||||
count++;
|
||||
_addSpace += " "; //add inner groupcollapsed
|
||||
|
||||
if (groupData.first == GROUPCOLLAPSED) {
|
||||
QString space = _addSpace.mid(0, _addSpace.length() - 1);
|
||||
debug(space + groupData.second);
|
||||
} else {
|
||||
debug(_addSpace + groupData.second);
|
||||
}
|
||||
collapseCount++;
|
||||
pair.second = addSpace + pair.second;
|
||||
debug(pair.second);
|
||||
_isSameLevel = false;
|
||||
} else if (groupData.second == GROUPEND) {
|
||||
_addSpace = _addSpace.mid(0, _addSpace.length() - 3);
|
||||
} else {
|
||||
if (groupData.first == firstGroupData && groupData.first != GROUPCOLLAPSED && groupData.first != GROUP && groupData.second != GROUPEND) {
|
||||
if (!_isSameLevel) {
|
||||
_addSpace += " "; //2 space inner element
|
||||
_isSameLevel = true; //same level log entry
|
||||
}
|
||||
else {
|
||||
if (pair.first == tmp) {
|
||||
pair.second = addSpace + pair.second;
|
||||
debug(pair.second);
|
||||
debug(_addSpace + groupData.second);
|
||||
}
|
||||
}
|
||||
}
|
||||
addSpace = "";
|
||||
tmp = "";
|
||||
collapseCount = 0;
|
||||
listgrp.clear();
|
||||
_listOfGroupData.removeOne(qMakePair(currentGroup, groupName));
|
||||
|
||||
}
|
|
@ -22,6 +22,7 @@
|
|||
#include <QtCore/QString>
|
||||
#include <QtScript/QScriptable>
|
||||
#include <QHash>
|
||||
#include <QList>
|
||||
|
||||
|
||||
/// Scriptable interface of console object. Used exclusively in the JavaScript API
|
||||
|
@ -41,8 +42,9 @@ public slots:
|
|||
void clear();
|
||||
void group(QString groupName);
|
||||
void groupCollapsed(QString groupName);
|
||||
void consoleLog(QString groupName);
|
||||
void groupEnd();
|
||||
void consoleLog(QString message);
|
||||
void showdata(QString currentGroup, QString groupName);
|
||||
public:
|
||||
QString secondsToString(qint64 seconds);
|
||||
bool isInteger(const std::string & s);
|
||||
|
@ -50,10 +52,13 @@ private:
|
|||
QHash<QString, QDateTime> _listOfTimeValues;
|
||||
const qint64 DAY = 86400;
|
||||
const QString TIME_FORMAT = "yyyy-MM-dd HH:mm";
|
||||
QString currentGroupSelection;
|
||||
QString defaultGroupName = "group";
|
||||
QString defaultGroupCollapseName = "groupCollapse";
|
||||
QList<QPair<QString, QString> > listgrp;
|
||||
QString _selectedGroup;
|
||||
const QString GROUP = "group";
|
||||
const QString GROUPCOLLAPSED = "groupCollapse";
|
||||
const QString GROUPEND = "groupEnd";
|
||||
bool _isSameLevel = false;
|
||||
QString _addSpace = "";
|
||||
QList<QPair<QString, QString> > _listOfGroupData;
|
||||
};
|
||||
|
||||
#endif // hifi_ConsoleScriptingInterface_h
|
||||
|
|
Loading…
Reference in a new issue