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 all 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
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ if (UNIX)
add_compile_options(-Werror=return-type)
endif()

set(CMAKE_POSITION_INDEPENDENT_CODE ON)

if(APPLE)

Expand Down
9 changes: 4 additions & 5 deletions Common/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ message(STATUS "appinfo.cpp is successfully generated...")
file(GLOB_RECURSE HEADER_FILES "${CMAKE_CURRENT_LIST_DIR}/*.h")
file(GLOB_RECURSE SOURCE_FILES "${CMAKE_CURRENT_LIST_DIR}/*.cpp")

add_library(Common ${SOURCE_FILES} ${HEADER_FILES})
add_library(Common SHARED ${SOURCE_FILES} ${HEADER_FILES})

if(LINUX)
target_link_libraries(Common PUBLIC ${_LIB_RT})
Expand All @@ -34,17 +34,16 @@ target_include_directories(

target_link_libraries(
Common
PUBLIC
PRIVATE
Boost::system
Boost::date_time
Boost::timer
Boost::chrono
$<$<BOOL:${WINDOWS}>:ntdll>
$<$<BOOL:${JASP_USES_QT_HERE}>:Qt::Core>
$<$<BOOL:${WINDOWS}>:ntdll>
)

target_compile_definitions(
Common PUBLIC $<$<BOOL:${JASP_USES_QT_HERE}>:JASP_USES_QT_HERE>
Common PUBLIC
$<$<BOOL:${JASP_TIMER_USED}>:PROFILE_JASP>
JSONCPP_NO_LOCALE_SUPPORT )

Expand Down
2 changes: 1 addition & 1 deletion Common/jaspColumnEncoder
12 changes: 6 additions & 6 deletions Common/log.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,12 @@ class Log
static void redirectStdOut();
static const char * getTimestamp();

static logType _default;
static logType _where;
static std::string _logFilePath;
static logError _logError;
static int _stdoutfd,
_engineNo;
static logType _default;
static logType _where;
static std::string _logFilePath;
static logError _logError;
static int _stdoutfd,
_engineNo;
static std::ostream* _nullStream;
static std::ofstream _logFile;

Expand Down
18 changes: 9 additions & 9 deletions CommonData/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ file(GLOB_RECURSE HEADER_FILES "${CMAKE_CURRENT_LIST_DIR}/*.h")
file(GLOB_RECURSE SOURCE_FILES "${CMAKE_CURRENT_LIST_DIR}/*.cpp")
file(GLOB_RECURSE SQL_FILES "${CMAKE_CURRENT_LIST_DIR}/*.sql")

add_library(CommonData ${SOURCE_FILES} ${HEADER_FILES} ${SQL_FILES})
add_library(CommonData SHARED ${SOURCE_FILES} ${HEADER_FILES} ${SQL_FILES})


if(LINUX)
Expand All @@ -36,16 +36,16 @@ target_include_directories(
)

target_link_libraries(
CommonData
PUBLIC
Common
LibArchive::LibArchive
SQLite::SQLite3
#
$<$<BOOL:${JASP_USES_QT_HERE}>:Qt::Core>)
CommonData
PUBLIC
LibArchive::LibArchive #desktop needs to be able to access it
PRIVATE
Common
SQLite::SQLite3
)

target_compile_definitions(
CommonData PUBLIC $<$<BOOL:${JASP_USES_QT_HERE}>:JASP_USES_QT_HERE>
CommonData PUBLIC
$<$<BOOL:${JASP_TIMER_USED}>:PROFILE_JASP>
JSONCPP_NO_LOCALE_SUPPORT )

Expand Down
21 changes: 11 additions & 10 deletions CommonData/column.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include "dataset.h"
#include "columnutils.h"
#include "databaseinterface.h"
#include <cassert>

bool Column::_autoSortByValuesByDefault = true;

Expand Down Expand Up @@ -435,7 +436,7 @@ stringset Column::mergeOldMissingDataMap(const Json::Value &missingData)
stringset foundEmpty;

std::map<std::string, Label*> displayToLabel; //Keep track of which labels we added because only those could possibly be derived from missingDataMap
for(qsizetype r=0; r<_ints.size(); r++)
for(size_t r=0; r<_ints.size(); r++)
{
const std::string row = std::to_string(r);
if(missingData.isMember(row))
Expand Down Expand Up @@ -940,7 +941,7 @@ int Column::labelsTempCount()
_labelsTemp . push_back(doubleLabel);
_labelsTempDbls . push_back(dbl);
_labelsTempToIndex[doubleLabel] = _labelsTemp.size()-1;
_labelsTempMaxWidth = std::max(_labelsTempMaxWidth, qsizetype(_labelsTemp[_labelsTemp.size()-1].size()));
_labelsTempMaxWidth = std::max(_labelsTempMaxWidth, size_t(_labelsTemp[_labelsTemp.size()-1].size()));
_labelsTempNumerics ++;
}
}
Expand Down Expand Up @@ -983,7 +984,7 @@ stringvec Column::nonFilteredLevels()
levels.insert(label->label());
}
else if(!isEmptyValue(_dbls[r]))
levels.insert(ColumnUtils::doubleToString(_dbls[r]));
levels.insert(ColumnUtils::doubleToString(_dbls[r]));
}

// Use the right label order
Expand Down Expand Up @@ -1777,15 +1778,15 @@ bool Column::labelsRemoveOrphans()
return idsNotUsed.size();
}

std::set<size_t> Column::labelsMoveRows(std::vector<qsizetype> rows, bool up)
std::set<size_t> Column::labelsMoveRows(std::vector<size_t> rows, bool up)
{
JASPTIMER_SCOPE(Column::labelsMoveRows);

int mod = up ? -1 : 1;

std::sort(rows.begin(), rows.end(), [&](const auto & l, const auto & r) { return up ? l < r : r < l; });

replaceDoublesTillLabelsRowWithLabels(std::min(qsizetype(labelsTempCount()), rows.back() + 1));
replaceDoublesTillLabelsRowWithLabels(std::min(size_t(labelsTempCount()), rows.back() + 1));

std::vector<Label*> new_labels(_labels.begin(), _labels.end());

Expand Down Expand Up @@ -2020,7 +2021,7 @@ void Column::upgradeExtractDoublesIntsFromLabels()
{
_dbls.resize(_ints.size());

for(qsizetype r=0; r<_dbls.size(); r++)
for(size_t r=0; r<_dbls.size(); r++)
{
Label * label = labelByIntsId(_ints[r]);

Expand Down Expand Up @@ -2318,7 +2319,7 @@ bool Column::isEmptyValue(const double val) const
return _emptyValues->isEmptyValue(val);
}

qsizetype Column::getMaximumWidthInCharactersIncludingShadow()
size_t Column::getMaximumWidthInCharactersIncludingShadow()
{
bool thereIsAShadow = false;

Expand All @@ -2337,9 +2338,9 @@ qsizetype Column::getMaximumWidthInCharactersIncludingShadow()
}


qsizetype Column::getMaximumWidthInCharacters(bool fancyEmptyValue, bool valuesPlease, qsizetype extraPad)
size_t Column::getMaximumWidthInCharacters(bool fancyEmptyValue, bool valuesPlease, size_t extraPad)
{
qsizetype maxWidth = 0;
size_t maxWidth = 0;
std::string takeWidth;

//Call labelsTempCount() to both find out how many there are and generate them if necessary
Expand All @@ -2349,7 +2350,7 @@ qsizetype Column::getMaximumWidthInCharacters(bool fancyEmptyValue, bool valuesP
for(Label * label : labels())
{
takeWidth = !valuesPlease ? label->label() : label->originalValueAsString(fancyEmptyValue);
maxWidth = std::max(maxWidth, qsizetype(stringUtils::approximateVisualLength(takeWidth)));
maxWidth = std::max(maxWidth, size_t(stringUtils::approximateVisualLength(takeWidth)));
}


Expand Down
10 changes: 5 additions & 5 deletions CommonData/column.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#include "utils.h"
#include <list>
#include "emptyvalues.h"

#include <cmath>
class DataSet;
class Analysis;

Expand Down Expand Up @@ -133,7 +133,7 @@ class Column : public DataSetBaseNode
stringvec nonFilteredLevels();
void nonFilteredCountersReset();

std::set<size_t> labelsMoveRows(std::vector<qsizetype> rows, bool up);
std::set<size_t> labelsMoveRows(std::vector<size_t> rows, bool up);
void labelsReverse();
void valuesReverse();
void labelsOrderByValue(bool doDbUpdateEtc=true);
Expand Down Expand Up @@ -226,8 +226,8 @@ class Column : public DataSetBaseNode
bool isEmptyValue( const std::string & val) const;
bool isEmptyValue( const double val) const;

qsizetype getMaximumWidthInCharactersIncludingShadow();
qsizetype getMaximumWidthInCharacters(bool shortenAndFancyEmptyValue, bool valuesPlease, qsizetype extraPad = 4); ///< Tries to take into consideration that utf-8 can have more characters than codepoints and compensates for it
size_t getMaximumWidthInCharactersIncludingShadow();
size_t getMaximumWidthInCharacters(bool shortenAndFancyEmptyValue, bool valuesPlease, size_t extraPad = 4); ///< Tries to take into consideration that utf-8 can have more characters than codepoints and compensates for it
columnType resetValues(int thresholdScale); ///< "Reimport" the values it already has with a possibly different threshold of values
stringset mergeOldMissingDataMap(const Json::Value & missingData); ///< <0.19 JASP collected the removed empty values values in a map in a json object... We need to be able to read at least 0.18.3 so here this function that absorbs such a map and adds any required labels. It does not add the empty values itself though!

Expand Down Expand Up @@ -258,7 +258,7 @@ class Column : public DataSetBaseNode
_labelsTempRevision = -1, ///< When were the "temporary labels" created?
_labelsTempNumerics = 0, ///< Use the labelsTemp step to calculate the amount of numeric labels
_highestIntsId = -1;
qsizetype _labelsTempMaxWidth = 0;
size_t _labelsTempMaxWidth = 0;
stringvec _labelsTemp; ///< Contains displaystring for labels. Used to allow people to edit "double" labels. Initialized when necessary
doublevec _labelsTempDbls;
strintmap _labelsTempToIndex;
Expand Down
3 changes: 0 additions & 3 deletions CommonData/columnutils.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@
#define COLUMNUTILS_H

#include <string>
#include <vector>
#include <set>
#include <map>
#include "utils.h"

class ColumnUtils
Expand Down
11 changes: 11 additions & 0 deletions CommonData/databaseinterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1367,6 +1367,17 @@ std::string DatabaseInterface::dbFile(bool onlyName) const
return onlyName ? fileName : Utils::osPath(TempFiles::sessionDirName() + "/" + fileName).string();
}

DatabaseInterface *DatabaseInterface::singleton()
{
if(!_singleton)
{
Log::log() << "No DatabaseInterface::singleton available here yet, creating an interface for internal.sqlite without recreating the dbstructure" << std::endl;
_singleton = new DatabaseInterface(false);
}

return _singleton;
}

void DatabaseInterface::runQuery(const std::string & query, std::function<void(sqlite3_stmt *stmt)> bindParameters, std::function<void(size_t row, sqlite3_stmt *stmt)> processRow)
{
JASPTIMER_SCOPE(DatabaseInterface::runQuery);
Expand Down
5 changes: 3 additions & 2 deletions CommonData/databaseinterface.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
#include "utils.h"
#include <json/json.h>
#include "version.h"

#include <functional>
#include <cassert>

class DataSet;
class Column;
Expand Down Expand Up @@ -60,7 +61,7 @@ class DatabaseInterface
~DatabaseInterface();
std::string dbFile(bool onlyPostfix = false) const; ///< Convenience function for getting the filename where sqlite db should be

static DatabaseInterface * singleton() { return _singleton; } ///< There can be only one! https://www.youtube.com/watch?v=sqcLjcSloXs
static DatabaseInterface * singleton(); ///< There can be only one! https://www.youtube.com/watch?v=sqcLjcSloXs

bool hasConnection() { return _db; }
void upgradeDBFromVersion(Version originalVersion); ///< Ensures that the database has all the fields configured as required for the current JASP version, useful when loading older sqlite-containing jasp-files
Expand Down
2 changes: 1 addition & 1 deletion CommonData/dataset.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ Column * DataSet::newColumn(const std::string &name)
return col;
}

qsizetype DataSet::getMaximumColumnWidthInCharacters(size_t columnIndex) const
size_t DataSet::getMaximumColumnWidthInCharacters(size_t columnIndex) const
{
if(columnIndex >= columnCount())
return 0;
Expand Down
2 changes: 1 addition & 1 deletion CommonData/dataset.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ class DataSet : public DataSetBaseNode

bool allColumnsPassFilter() const;

qsizetype getMaximumColumnWidthInCharacters(size_t columnIndex) const;
size_t getMaximumColumnWidthInCharacters(size_t columnIndex) const;
stringvec getColumnNames();

void setDataFile( const std::string & dataFilePath, long timestamp) { _dataFilePath = dataFilePath; _dataFileTimestamp = timestamp; dbUpdate(); }
Expand Down
1 change: 1 addition & 0 deletions CommonData/datasetbasenode.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#define DATASETBASENODE_H

#include "enumutilities.h"
#include <functional>

DECLARE_ENUM(dataSetBaseNodeType, unknown, dataSet, data, filters, filter, column, label);

Expand Down
12 changes: 6 additions & 6 deletions Desktop/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ target_include_directories(
PUBLIC
${CMAKE_CURRENT_LIST_DIR}
${PROJECT_SOURCE_DIR}/Common
${PROJECT_SOURCE_DIR}/Common/jaspColumnEncoder
${PROJECT_SOURCE_DIR}/Common/jaspColumnEncoder
${PROJECT_SOURCE_DIR}/CommonData
${PROJECT_SOURCE_DIR}/QMLComponents
# ReadStat
Expand All @@ -110,7 +110,7 @@ target_include_directories(

target_link_libraries(
JASP
PUBLIC
PRIVATE
Common
CommonData
QMLComponents
Expand Down Expand Up @@ -165,9 +165,9 @@ if(NOT WINDOWS)

target_link_libraries(
JASP
PUBLIC
# When using Conan, we need to provide the static libraries directly, for some reason!
${Iconv_LIBRARY_LIST})
PRIVATE
# When using Conan, we need to provide the static libraries directly, for some reason!
${Iconv_LIBRARY_LIST})
endif()

if(LINUX)
Expand Down 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
Loading
Loading