Skip to content

Commit

Permalink
Start
Browse files Browse the repository at this point in the history
  • Loading branch information
boutinb committed Feb 2, 2024
1 parent 77d561f commit 77cff89
Show file tree
Hide file tree
Showing 107 changed files with 240 additions and 150 deletions.
91 changes: 66 additions & 25 deletions Common/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,50 +12,91 @@ configure_file(${CMAKE_CURRENT_LIST_DIR}/appinfo.cpp.in
${CMAKE_CURRENT_LIST_DIR}/appinfo.cpp)
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")
configure_file(${CMAKE_CURRENT_LIST_DIR}/QtUtils/appdirs.h.in
${CMAKE_CURRENT_LIST_DIR}/QtUtils//appdirs.h)
message(STATUS "appdirs.h is successfully generated...")

add_library(Common ${SOURCE_FILES} ${HEADER_FILES})
file(GLOB HEADER_FILES "${CMAKE_CURRENT_LIST_DIR}/*.h" "${CMAKE_CURRENT_LIST_DIR}/json/*.h")
file(GLOB SOURCE_FILES "${CMAKE_CURRENT_LIST_DIR}/*.cpp" "${CMAKE_CURRENT_LIST_DIR}/json/*.cpp")
file(GLOB QT_UTILS_HEADER_FILES "${CMAKE_CURRENT_LIST_DIR}/QtUtils/*.h")
file(GLOB QT_UTILS_SOURCE_FILES "${CMAKE_CURRENT_LIST_DIR}/QtUtils/*.cpp")

add_library(Common SHARED ${SOURCE_FILES} ${HEADER_FILES})
add_library(CommonWithQt SHARED ${SOURCE_FILES} ${HEADER_FILES} ${QT_UTILS_HEADER_FILES} ${QT_UTILS_SOURCE_FILES})

if(LINUX)
target_link_libraries(Common PUBLIC ${_LIB_RT})
target_link_options(Common PUBLIC -lrt)
target_link_libraries(CommonWithQt PUBLIC ${_LIB_RT})
target_link_options(CommonWithQt PUBLIC -lrt)
endif()

target_include_directories(
Common
PUBLIC # JASP
# R
${R_INCLUDE_PATH}
${R_HOME_PATH}/include
${RCPP_PATH}/include
)
Common PUBLIC
# R
${R_INCLUDE_PATH}
${R_HOME_PATH}/include
${RCPP_PATH}/include
)

target_include_directories(
CommonWithQt PUBLIC
# R
${R_INCLUDE_PATH}
${R_HOME_PATH}/include
${RCPP_PATH}/include
)

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

target_link_libraries(
CommonWithQt PUBLIC
Boost::system
Boost::date_time
Boost::timer
Boost::chrono
$<$<BOOL:${WINDOWS}>:ntdll>
Qt::Core
Qt::Qml
Qt::Quick
)

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

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

if(WINDOWS)
target_compile_definitions(
Common
PUBLIC NOMINMAX
WIN32_LEAN_AND_MEAN)
Common PUBLIC
NOMINMAX
WIN32_LEAN_AND_MEAN
)
target_compile_definitions(
CommonWithQt PUBLIC
NOMINMAX
WIN32_LEAN_AND_MEAN
)
endif()

if(IWYU_EXECUTABLE AND RUN_IWYU)
set_target_properties(Common PROPERTIES CXX_INCLUDE_WHAT_YOU_USE ${IWYU_EXECUTABLE})
set_target_properties(CommonWithQt PROPERTIES CXX_INCLUDE_WHAT_YOU_USE ${IWYU_EXECUTABLE})
endif()

list(POP_BACK CMAKE_MESSAGE_CONTEXT)
File renamed without changes.
61 changes: 61 additions & 0 deletions Common/QtUtils/appdirs.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
//
// Copyright (C) 2013-2018 University of Amsterdam
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as
// published by the Free Software Foundation, either version 3 of the
// License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public
// License along with this program. If not, see
// <http://www.gnu.org/licenses/>.


//
// NOTICE:
// `appdirs.h` is generated from `appdirs.h.in` and you should edit
// that file instead if you want your changes to reflect in the app
//

#ifndef APPDIRS_H
#define APPDIRS_H

#include <QString>
#include <QDir>

/// collector class with functions that make the locations of relevannt folders available
/// Uses Qt so can't be used in R-Interface.
class AppDirs
{
public:

static QString examples();
static QString help();
static QString analysisDefaultsDir();
static QString userRLibrary();
static QString userModulesDir();
static QString bundledModulesDir();
static QString documents();
static QString logDir();
static QString appData(bool roaming = true);
static QString rHome();
static QDir programDir();
static QString renvRootLocation();
static QString renvCacheLocations();

private:
static QString processPath(const QString & path);

#ifdef linux
static QString rHomeDir() {
return QString("/Users/brunoboutin/JASP/source/build-jasp-desktop-Qt_6_5_2_for_macOS-Debug/Frameworks/R.framework/Versions/4.3-arm64/Resources");
}
#endif
};

#endif // APPDIRS_H
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#include "appinfo.h"
#include "appdirs.h"
#include "log.h"
#include "utilities/qutils.h"
#include "qutils.h"

#include <fstream>
#include <chrono>
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,9 @@
#include <json/json.h>
#include <string>
#include <set>
#include "stringutils.h"
#include <cmath>
#include "qutils.h"
#include "utils.h"
#include "qutils.h"

/// There are recurring needs when working with Json::Value etc and these are collected here.
/// For instance converting from and to a std::vector<std::string> is useful and might as well be written here.
Expand Down
12 changes: 6 additions & 6 deletions QMLComponents/knownissues.cpp → Common/QtUtils/knownissues.cpp
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#include "knownissues.h"
#include "utilities/messageforwarder.h"
//#include "messageforwarder.h"
#include "appinfo.h"
#include "utilities/jsonutilities.h"
#include "jsonutilities.h"
#include "log.h"
#include "utilities/appdirs.h"
#include "appdirs.h"
#include "utils.h"
#include <fstream>

Expand Down Expand Up @@ -36,7 +36,7 @@ void KnownIssues::loadJson(const std::string & jsonTxt, bool saveIt)
{
Log::log() << "## " << tr("Problem loading known issues") << "\n" << tr("JASP ran into a problem downloading the known issues for this version, it probably could not connect to the server. Don't worry, JASP will work fine it just might not tell you about a few small known issues.") << std::endl;
#if JASP_DEBUG
MessageForwarder::showWarning("Known issues from server was empty!");
// MessageForwarder::showWarning("Known issues from server was empty!");
#endif
return;
}
Expand All @@ -48,7 +48,7 @@ void KnownIssues::loadJson(const std::string & jsonTxt, bool saveIt)
{
Log::log() << "## " << tr("Problem loading known issues") << "\n" << tr("JASP ran into a problem loading the known issues for this version, this isn't necessarily a problem but if it keeps occuring you could contact the JASP team for assistance.") << std::endl;
#if JASP_DEBUG
MessageForwarder::showWarning("Known issues could not be parsed!");
// MessageForwarder::showWarning("Known issues could not be parsed!");
#endif
}
}
Expand Down Expand Up @@ -80,7 +80,7 @@ void KnownIssues::loadJson(const Json::Value & json, bool saveIt)
{
Log::log() << "## " << tr("Problem loading known issues") << "\n" << tr("JASP ran into a problem ('%1') loading the known issues for this version, this isn't necessarily a problem but if it keeps occuring you could contact the JASP team for assistance.").arg(e.what()) << std::endl;
#if JASP_DEBUG
MessageForwarder::showWarning(QString("Loading known issues had exception: '%1'!").arg(e.what()));
// MessageForwarder::showWarning(QString("Loading known issues had exception: '%1'!").arg(e.what()));
#endif
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

#include <QObject>
#include <json/json.h>
#include "utilities/qutils.h"
#include "qutils.h"
#include "stringutils.h"

///
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
4 changes: 4 additions & 0 deletions Common/utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@
#include <iomanip>
#include <chrono>

#ifndef JASP_USES_QT_HERE
#include <cmath>
#endif

using namespace std;

Utils::FileType Utils::getTypeFromFileName(const std::string &path)
Expand Down
2 changes: 1 addition & 1 deletion Desktop/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ configure_file(${CMAKE_CURRENT_LIST_DIR}/gui/preferencesmodel.cpp.in
${CMAKE_CURRENT_LIST_DIR}/gui/preferencesmodel.cpp)
message(STATUS "preferencesmodel.cpp is successfully generated...")


file(GLOB_RECURSE HEADER_FILES "${CMAKE_CURRENT_LIST_DIR}/*.h")
file(GLOB_RECURSE SOURCE_FILES "${CMAKE_CURRENT_LIST_DIR}/*.cpp")

Expand Down Expand Up @@ -94,6 +93,7 @@ target_include_directories(
PUBLIC
${CMAKE_CURRENT_LIST_DIR}
${PROJECT_SOURCE_DIR}/Common
${PROJECT_SOURCE_DIR}/Common/QtUtils
${PROJECT_SOURCE_DIR}/CommonData
${PROJECT_SOURCE_DIR}/QMLComponents
# ReadStat
Expand Down
2 changes: 1 addition & 1 deletion Desktop/analysis/analyses.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
//

#include "analyses.h"
#include "utilities/appdirs.h"
#include "appdirs.h"
#include "utilities/settings.h"
#include "processinfo.h"
#include "modules/ribbonmodel.h"
Expand Down
2 changes: 1 addition & 1 deletion Desktop/analysis/analysis.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
#include "dirs.h"
#include "analyses.h"
#include "analysisform.h"
#include "utilities/qutils.h"
#include "qutils.h"
#include "log.h"
#include "utils.h"
#include "utilities/settings.h"
Expand Down
2 changes: 1 addition & 1 deletion Desktop/analysis/analysis.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
#include "analysisbase.h"
#include "modules/dynamicmodules.h"
#include "data/datasetpackage.h"
#include "utilities/qutils.h"
#include "qutils.h"
#include "modules/upgrader/upgradechange.h"
#include <QFileSystemWatcher>
#include <QQuickItem>
Expand Down
2 changes: 1 addition & 1 deletion Desktop/data/asyncloader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@

#include <boost/bind.hpp>

#include "utilities/qutils.h"
#include "qutils.h"
#include "utils.h"
#include "osf/onlinedatamanager.h"
#include "log.h"
Expand Down
2 changes: 1 addition & 1 deletion Desktop/data/columnmodel.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include "columnmodel.h"
#include "jasptheme.h"
#include "utilities/qutils.h"
#include "qutils.h"
#include "datasettablemodel.h"
#include "computedcolumnsmodel.h"

Expand Down
2 changes: 1 addition & 1 deletion Desktop/data/columnsmodel.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include "columnsmodel.h"
#include "log.h"
#include "utilities/qutils.h"
#include "qutils.h"
#include "mainwindow.h"

ColumnsModel * ColumnsModel::_singleton = nullptr;
Expand Down
4 changes: 2 additions & 2 deletions Desktop/data/computedcolumnsmodel.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include "computedcolumnsmodel.h"
#include "utilities/jsonutilities.h"
#include "utilities/qutils.h"
#include "jsonutilities.h"
#include "qutils.h"
#include "columnencoder.h"
#include "log.h"

Expand Down
2 changes: 1 addition & 1 deletion Desktop/data/databaseconnectioninfo.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include "databaseconnectioninfo.h"
#include "utilities/qutils.h"
#include "qutils.h"
#include <QSqlDatabase>
#include <QSqlError>
#include "log.h"
Expand Down
4 changes: 2 additions & 2 deletions Desktop/data/datasetpackage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@

#include "datasetpackage.h"
#include "log.h"
#include "utilities/qutils.h"
#include "qutils.h"
#include <QThread>
#include "engine/enginesync.h"
#include "jasptheme.h"
#include "columnencoder.h"
#include "timers.h"
#include "utilities/appdirs.h"
#include "appdirs.h"
#include "utils.h"
#include "columnutils.h"
#include "utilities/messageforwarder.h"
Expand Down
2 changes: 1 addition & 1 deletion Desktop/data/datasettablemodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
//

#include "datasettablemodel.h"
#include "utilities/qutils.h"
#include "qutils.h"
#include "log.h"

DataSetTableModel::DataSetTableModel(bool showInactive)
Expand Down
2 changes: 1 addition & 1 deletion Desktop/data/exporters/jaspexporter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
#include "tempfiles.h"
#include "log.h"
#include "utilenums.h"
#include "utilities/qutils.h"
#include "qutils.h"
#include <fstream>
#include "appinfo.h"

Expand Down
2 changes: 1 addition & 1 deletion Desktop/data/fileevent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
#include "exporters/jaspexporter.h"

#include <QTimer>
#include "utilities/appdirs.h"
#include "appdirs.h"

FileEvent::FileEvent(QObject *parent, FileEvent::FileMode fileMode)
: QObject(parent), _operation(fileMode)
Expand Down
2 changes: 1 addition & 1 deletion Desktop/data/filtermodel.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include "filtermodel.h"
#include "utilities/jsonutilities.h"
#include "jsonutilities.h"
#include "columnencoder.h"

FilterModel::FilterModel(labelFilterGenerator * labelFilterGenerator)
Expand Down
Loading

0 comments on commit 77cff89

Please sign in to comment.