Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

R Syntax: Load QML Controls as QML Module #5776

Open
wants to merge 14 commits into
base: development
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Common/jaspColumnEncoder
Submodule jaspColumnEncoder updated 2 files
+19 −0 utils.cpp
+3 −0 utils.h
File renamed without changes.
File renamed without changes.
8 changes: 4 additions & 4 deletions CommonData/column.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -983,7 +983,7 @@ stringvec Column::nonFilteredLevels()
levels.insert(label->label());
}
else if(!isEmptyValue(_dbls[r]))
levels.insert(ColumnUtils::doubleToString(_dbls[r]));
levels.insert(Utils::doubleToString(_dbls[r]));
}

// Use the right label order
Expand Down Expand Up @@ -1164,7 +1164,7 @@ std::string Column::doubleToDisplayString(double dbl, bool fancyEmptyValue, bool
ignoreEmptyValue = ignoreEmptyValue && !std::isnan(dbl);

if (isEmptyValue(dbl) && !ignoreEmptyValue) return fancyEmptyValue ? EmptyValues::displayString() : "";
else return ColumnUtils::doubleToString(dbl);
else return Utils::doubleToString(dbl);
}

std::string Column::operator[](size_t row)
Expand Down Expand Up @@ -1416,7 +1416,7 @@ bool Column::replaceDoubleLabelFromRowWithDouble(size_t row, double dbl)
dblsRef = dbl;

_labelsTempDbls[row] = dbl;
_labelsTemp[row] = ColumnUtils::doubleToString(dbl);
_labelsTemp[row] = Utils::doubleToString(dbl);

return true;
}
Expand Down Expand Up @@ -1580,7 +1580,7 @@ bool Column::setValue(size_t row, const std::string & value, const std::string &

if(justAValue && !newLabel && itsADouble)
{
const std::string valueDbl = ColumnUtils::doubleToString(newDoubleToSet);
const std::string valueDbl = Utils::doubleToString(newDoubleToSet);
newLabel = labelByValue(valueDbl);
newLabel = newLabel ? newLabel : labelByValueAndDisplay(valueDbl, valueDbl);
}
Expand Down
20 changes: 0 additions & 20 deletions CommonData/columnutils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -210,26 +210,6 @@ std::string ColumnUtils::deEuropeaniseForImport(std::string value)
return value;
}

std::string ColumnUtils::doubleToStringMaxPrec(double dbl)
{
constexpr auto max_precision{std::numeric_limits<long double>::digits10 + 1};
return doubleToString(dbl, max_precision);
}

std::string ColumnUtils::doubleToString(double dbl, int precision)
{
JASPTIMER_SCOPE(ColumnUtils::doubleToString);

if (dbl > std::numeric_limits<double>::max()) return "∞";
if (dbl < std::numeric_limits<double>::lowest()) return "-∞";

std::stringstream conv; //Use this instead of std::to_string to make sure there are no trailing zeroes (and to get full precision)
conv << std::setprecision(precision);
conv << dbl;
return conv.str();
}


// hex should be 4 hexadecimals characters
std::string ColumnUtils::_convertEscapedUnicodeToUTF8(std::string hex)
{
Expand Down
3 changes: 0 additions & 3 deletions CommonData/columnutils.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,6 @@ class ColumnUtils

static void convertEscapedUnicodeToUTF8( std::string & inputStr);
static std::string deEuropeaniseForImport( std::string value); //Convert a string to a double with a dot for a separator

static std::string doubleToString( double dbl, int precision = 10);
static std::string doubleToStringMaxPrec( double dbl);

static bool convertVecToInt( const stringvec & values, intvec & intValues, intset & uniqueValues);
static bool convertVecToDouble( const stringvec & values, doublevec & doubleValues);
Expand Down
11 changes: 11 additions & 0 deletions CommonData/filter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
#include "dataset.h"
#include "databaseinterface.h"

std::map<std::string, Filter*> _filterMap;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a terrible Idea, a global really?

Copy link
Contributor Author

@boutinb boutinb Jan 14, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, I have changed this, by creating a new DatabaseInterface that loads the sqlite database. This is indeed much cleaner.


Filter::Filter(DataSet * data)
: DataSetBaseNode(dataSetBaseNodeType::filter, data), _data(data)
{ }
Expand All @@ -15,6 +17,8 @@ Filter::Filter(DataSet * data, const std::string & name, bool createIfMissing)
if(db().filterGetId(_name) > -1) dbLoad();
else if(createIfMissing) dbCreate();
else throw std::runtime_error("Filter by name '" + _name + "' but it doesnt exist and createIfMissing=false!\nAre you sure this filter should exist?");

_filterMap[name] = this;
}

void Filter::dbCreate()
Expand Down Expand Up @@ -136,6 +140,8 @@ void Filter::dbDelete()

db().filterDelete(_id);
_id = -1;

_filterMap.erase(_name);
}

void Filter::incRevision()
Expand Down Expand Up @@ -175,6 +181,11 @@ bool Filter::filterNameIsFree(const std::string &filterName)
return -1 == DatabaseInterface::singleton()->filterGetId(filterName);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Which is also where it was...

}

Filter* Filter::getFilterFromName(const std::string & filterName)
{
return _filterMap[filterName];
}

void Filter::reset()
{
if(!_data->writeBatchedToDB())
Expand Down
23 changes: 12 additions & 11 deletions CommonData/filter.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,16 @@ class Filter : public DataSetBaseNode
Filter(DataSet * data);
Filter(DataSet * data, const std::string & name, bool createIfMissing = true);

DataSet * data() const { return _data; }
int id() const { return _id; }
const std::string & name() const { return _name; }
const std::string & rFilter() const { return _rFilter; }
const std::string & generatedFilter() const { return _generatedFilter; }
const std::string & constructorJson() const { return _constructorJson; }
const std::string & constructorR() const { return _constructorR; }
const std::string & errorMsg() const { return _errorMsg; }
const std::vector<bool> & filtered() const { return _filtered; }
int filteredRowCount() const { return _filteredRowCount; }
DataSet * data() const { return _data; }
int id() const { return _id; }
const std::string & name() const { return _name; }
const std::string & rFilter() const { return _rFilter; }
const std::string & generatedFilter() const { return _generatedFilter; }
const std::string & constructorJson() const { return _constructorJson; }
const std::string & constructorR() const { return _constructorR; }
const std::string & errorMsg() const { return _errorMsg; }
const std::vector<bool> & filtered() const { return _filtered; }
int filteredRowCount() const { return _filteredRowCount; }

void setRFilter( const std::string & rFilter) { _rFilter = rFilter; dbUpdate(); }
void setGeneratedFilter( const std::string & generatedFilter) { _generatedFilter = generatedFilter; dbUpdate(); }
Expand All @@ -52,10 +52,11 @@ class Filter : public DataSetBaseNode
void dbLoad();
bool dbLoadResultAndError(); ///< Loads (updated) filtervalues from database and the (possible) error msg, returns true if an error is set
void dbDelete();
void incRevision() override;
void incRevision() override;
bool checkForUpdates();

static bool filterNameIsFree(const std::string & filterName);
static Filter* getFilterFromName(const std::string & filterName);

void reset();

Expand Down
2 changes: 1 addition & 1 deletion Desktop/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ qt_add_resources(
file(GLOB_RECURSE QML_RESOURCE_FILES "${CMAKE_CURRENT_LIST_DIR}/components/*")
qt_add_resources(
JASP
"widgets"
"widgetsandtheme"
PREFIX
"/"
BASE
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@
//


import QtQuick 2.12
import QtQuick.Controls 2.12
import JASP 1.0
import QtQuick
import QtQuick.Controls
import JASP

JaspTheme
{
Expand Down
6 changes: 3 additions & 3 deletions Desktop/components/JASP/Widgets/AnalysisFormExpander.qml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import QtQuick 2.11
import QtQuick.Controls 2.4
import JASP.Controls 1.0
import QtQuick
import QtQuick.Controls
import JASP.Controls
import Qt5Compat.GraphicalEffects

DropArea
Expand Down
5 changes: 2 additions & 3 deletions Desktop/components/JASP/Widgets/AnalysisForms.qml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import QtQuick 2.11
import QtQuick.Controls 2.4
import QtQuick
import JASP
import JASP.Controls 1.0
import JASP.Controls


FocusScope
Expand Down
10 changes: 5 additions & 5 deletions Desktop/components/JASP/Widgets/ComputeColumnWindow.qml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import QtQuick 2.7
import QtQuick.Controls 2.12
import QtQuick.Layouts 1.3
import JASP.Controls 1.0 as JaspControls
import QtQuick
import QtQuick.Controls
import QtQuick.Layouts
import JASP.Controls as JaspControls
import JASP

import "FilterConstructor"
Expand Down Expand Up @@ -105,7 +105,7 @@ FocusScope
{
id: computeColumnEdit

RSyntaxHighlighterQuick
JaspControls.RSyntaxHighlighterQuick
{
textDocument: computeColumnEdit.textDocument
}
Expand Down
4 changes: 2 additions & 2 deletions Desktop/components/JASP/Widgets/CreateComputeColumnDialog.qml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import QtQuick 2.9
import QtQuick.Controls 2.2
import QtQuick
import QtQuick.Controls
import JASP.Controls as JaspControls


Expand Down
6 changes: 3 additions & 3 deletions Desktop/components/JASP/Widgets/CustomMenu.qml
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@
// <http://www.gnu.org/licenses/>.
//

import QtQuick 2.15
import QtQuick.Controls 2.4
import JASP.Controls 1.0 as JASPControl
import QtQuick
import QtQuick.Controls
import JASP.Controls as JASPControl
import Qt5Compat.GraphicalEffects

FocusScope
Expand Down
6 changes: 3 additions & 3 deletions Desktop/components/JASP/Widgets/DataPanel.qml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import QtQuick.Controls 6.0
import QtQuick.Layouts 1.0
import QtQuick 2.15
import QtQuick.Controls
import QtQuick.Layouts
import QtQuick


Rectangle
Expand Down
10 changes: 5 additions & 5 deletions Desktop/components/JASP/Widgets/EnginesWindow.qml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import QtQuick 2.12
import QtQuick.Window 2.12
import QtWebEngine 1.8
import JASP.Widgets 1.0
import JASP.Controls 1.0
import QtQuick
import QtQuick.Window
import QtWebEngine
import JASP.Widgets
import JASP.Controls

Window
{
Expand Down
11 changes: 5 additions & 6 deletions Desktop/components/JASP/Widgets/FileMenu/BreadCrumbs.qml
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import QtQuick 2.11
import QtQuick.Layouts 1.3
import QtQuick.Controls 2.4

import JASP.Widgets 1.0
import JASP.Controls 1.0
import QtQuick
import QtQuick.Layouts
import QtQuick.Controls
import JASP.Widgets
import JASP.Controls

ListView
{
Expand Down
11 changes: 5 additions & 6 deletions Desktop/components/JASP/Widgets/FileMenu/Computer.qml
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import QtQuick 2.9
import QtQuick.Controls 2.2
import QtQuick.Layouts 1.3

import JASP.Controls 1.0
import JASP.Widgets 1.0
import QtQuick
import QtQuick.Controls
import QtQuick.Layouts
import JASP.Controls
import JASP.Widgets

Item
{
Expand Down
4 changes: 2 additions & 2 deletions Desktop/components/JASP/Widgets/FileMenu/CurrentFile.qml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import QtQuick 2.9
import QtQuick.Controls 2.2
import QtQuick
import QtQuick.Controls


Item
Expand Down
6 changes: 3 additions & 3 deletions Desktop/components/JASP/Widgets/FileMenu/DataLibrary.qml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import QtQuick 2.9
import QtQuick.Controls 2.2
import QtQuick.Layouts 1.3
import QtQuick
import QtQuick.Controls
import QtQuick.Layouts


Item
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import QtQuick 2.0
import QtQuick.Layouts 1.3
import QtQuick.Controls 2.2
import JASP.Theme 1.0
import QtQuick
import QtQuick.Layouts
import QtQuick.Controls
import JASP.Theme

ListView
{
Expand Down
8 changes: 4 additions & 4 deletions Desktop/components/JASP/Widgets/FileMenu/FileList.qml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import QtQuick 2.11
import QtQuick.Controls 2.4
import JASP.Controls 1.0
import QtQuick
import QtQuick.Controls
import JASP.Controls as JC


ListView
Expand Down Expand Up @@ -81,7 +81,7 @@ ListView
hasBreadCrumbs: listView.breadCrumbs !== null
}

JASPScrollBar
JC.JASPScrollBar
{
id: rightscrollbar
flickable: parent
Expand Down
10 changes: 5 additions & 5 deletions Desktop/components/JASP/Widgets/FileMenu/FileMenu.qml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import QtQuick 2.11
import QtQuick.Controls 2.2
import QtQuick.Layouts 1.3
import QtQuick
import QtQuick.Controls
import QtQuick.Layouts

import JASP.Controls 1.0
import JASP.Controls
import JASP
import FileOperation 1.0
import FileOperation

FocusScope
{
Expand Down
6 changes: 2 additions & 4 deletions Desktop/components/JASP/Widgets/FileMenu/ListItem.qml
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import QtQuick 2.11
import QtQuick.Controls 2.4
import JASP.Controls 1.0

import QtQuick
import QtQuick.Controls

FocusScope
{
Expand Down
13 changes: 6 additions & 7 deletions Desktop/components/JASP/Widgets/FileMenu/MenuHeader.qml
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import QtQuick 2.9
import QtQuick.Controls 2.2
import QtQuick.Layouts 1.3

import JASP.Widgets 1.0
import JASP.Controls 1.0
import QtQuick
import QtQuick.Controls as QtC
import QtQuick.Layouts
import JASP.Widgets
import JASP.Controls

Item
{
Expand Down Expand Up @@ -63,7 +62,7 @@ Item
}
}

ToolSeparator
QtC.ToolSeparator
{
id: firstSeparator

Expand Down
Loading
Loading