Skip to content

Commit cc20558

Browse files
committed
Add datafiles report
1 parent 5d75e6f commit cc20558

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+852
-602
lines changed

Desktop/components/JASP/Widgets/MainWindow.qml

Lines changed: 43 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -87,25 +87,58 @@ Window
8787
return (a + n) % n;
8888
}
8989

90-
DropArea
91-
{
92-
id: drop
93-
enabled: true
94-
anchors.fill: parent
95-
onDropped: (drop) => mainWindow.openURLFile(drop.text)
96-
}
97-
9890
Item
9991
{
10092
anchors.fill: parent
10193

10294
Rectangle
10395
{
96+
id: warningRect
10497
z: 1
105-
visible: mainWindow.hadFatalError
106-
color: jaspTheme.red
98+
color: mainWindow.hadFatalError ? jaspTheme.red : "transparent"
10799
opacity: 0.75
108100
anchors.fill: parent
101+
102+
DropArea
103+
{
104+
enabled: true
105+
anchors.fill: parent
106+
onDropped: (drop) =>
107+
{
108+
if (mainWindow.openURLFile(drop.text))
109+
drop.accepted = true
110+
parent.state = ""
111+
}
112+
113+
onExited: parent.state = ""
114+
onEntered: (drag) =>
115+
{
116+
if (drag.hasText)
117+
parent.state = "active"
118+
}
119+
}
120+
121+
states: [
122+
State {
123+
name: "active"
124+
PropertyChanges {
125+
warningRect {
126+
color: jaspTheme.blueLighter
127+
}
128+
}
129+
}
130+
]
131+
132+
transitions: [
133+
Transition {
134+
from: ""
135+
to: "active"
136+
reversible: true
137+
ColorAnimation { properties: "color"; duration: 150; easing.type: Easing.InOutQuad }
138+
}
139+
]
140+
141+
109142
}
110143

111144
Shortcut { onActivated: mainWindow.showEnginesWindow(); sequences: ["Ctrl+Alt+Shift+E"]; context: Qt.ApplicationShortcut; }

Desktop/data/fileevent.cpp

Lines changed: 31 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,10 @@
2323
#include "exporters/dataexporter.h"
2424
#include "exporters/jaspexporter.h"
2525
#include "exporters/resultexporter.h"
26+
#include "widgets/filemenu/filemenu.h"
27+
#include "log.h"
2628

27-
28-
FileEvent::FileEvent(QObject *parent, FileEvent::FileMode fileMode)
29+
FileEvent::FileEvent(FileMenu *parent, FileEvent::FileMode fileMode)
2930
: QObject(parent), _operation(fileMode)
3031
{
3132
switch (_operation)
@@ -36,6 +37,9 @@ FileEvent::FileEvent(QObject *parent, FileEvent::FileMode fileMode)
3637
case FileEvent::FileSave: _exporter = new JASPExporter(); break;
3738
default: _exporter = nullptr; break;
3839
}
40+
41+
connect(this, &FileEvent::started, parent, &FileMenu::dataSetIORequestStarted);
42+
connect(this, &FileEvent::completed, parent, &FileMenu::dataSetIORequestCompleted);
3943
}
4044

4145
FileEvent::~FileEvent()
@@ -93,19 +97,41 @@ bool FileEvent::setPath(const QString & path)
9397

9498
}
9599

100+
void FileEvent::setStarted()
101+
{
102+
_started = true;
103+
104+
emit started();
105+
}
106+
96107
void FileEvent::setComplete(bool success, const QString & message)
97108
{
98109
_completed = true;
99110
_success = success;
100111
_message = message;
101112

102-
emit completed(this);
113+
emit completed();
103114
}
104115

116+
void FileEvent::setFinalized()
117+
{
118+
_finalized = true;
119+
emit finalized();
120+
deleteLater();
121+
}
122+
123+
105124
void FileEvent::chain(FileEvent *event)
106125
{
107-
_chainedTo = event;
108-
connect(event, &FileEvent::completed, this, &FileEvent::chainedComplete);
126+
if (_started)
127+
{
128+
if (_completed)
129+
Log::log() << "Event " << getProgressMsg().toStdString() << " is completed before Event " << event->getProgressMsg().toStdString() << " was completed" << std::endl;
130+
else // The `this` event is already started, but it should be set complete (and start the finalize process) only when `event` is finalized
131+
connect(event, &FileEvent::finalized, this, [this, event]() { setComplete(event->isSuccessful(), event->message()); });
132+
}
133+
else
134+
connect(event, &FileEvent::finalized, this, [this, event]() { if (event->isSuccessful()) emit started(); } );
109135
}
110136

111137
bool FileEvent::isExample() const

Desktop/data/fileevent.h

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@
2525
#include "exporters/exporter.h"
2626
#include "utilenums.h"
2727

28+
class FileMenu;
29+
2830
///
2931
/// This class is used to handle the communication to and from the asynchronous loading/synching/saving file processes.
3032
/// These can be chained to have a Close come after a save once the latter is done.
@@ -35,7 +37,7 @@ class FileEvent : public QObject
3537
public:
3638
enum FileMode { FileSave, FileNew, FileOpen, FileExportResults, FileExportData, FileGenerateData, FileSyncData, FileClose };
3739

38-
FileEvent(QObject *parent = nullptr, FileMode fileMode = FileEvent::FileOpen);
40+
FileEvent(FileMenu *parent, FileMode fileMode = FileEvent::FileOpen);
3941
virtual ~FileEvent();
4042

4143
bool setPath( const QString & path);
@@ -45,14 +47,18 @@ class FileEvent : public QObject
4547
void setFileType( Utils::FileType type) { _type = type; }
4648
void setTmp( bool saveTmp) { _tmp = saveTmp; }
4749

50+
void setStarted();
4851
void setComplete(bool success = true, const QString &message = "");
52+
void setFinalized();
4953
void chain(FileEvent *event);
5054

5155
bool isDatabase() const { return _database != Json::nullValue; }
5256
bool isOnlineNode() const { return _path.startsWith("http"); }
5357
bool isExample() const;
5458
bool isReadOnly() const { return isExample() || isDatabase(); }
59+
bool isStarted() const { return _started; }
5560
bool isCompleted() const { return _completed; }
61+
bool isFinalized() const { return _finalized; }
5662
bool isSuccessful() const { return _success; }
5763
bool isTmp() const { return _tmp; }
5864
static bool autoSaveExists();
@@ -74,10 +80,9 @@ class FileEvent : public QObject
7480
QString getProgressMsg() const;
7581

7682
signals:
77-
void completed(FileEvent *event);
78-
79-
private slots:
80-
void chainedComplete(FileEvent *event) { setComplete(event->isSuccessful(), event->message()); }
83+
void started();
84+
void completed();
85+
void finalized();
8186

8287
private:
8388
FileMode _operation;
@@ -87,10 +92,11 @@ private slots:
8792
_dataFilePath,
8893
_last_error = "Unknown error",
8994
_message;
90-
bool _completed = false,
95+
bool _started = false,
96+
_completed = false,
97+
_finalized = false,
9198
_success = false,
9299
_tmp = false;
93-
FileEvent * _chainedTo = nullptr;
94100
Exporter * _exporter = nullptr;
95101
Json::Value _database = Json::nullValue;
96102
};

0 commit comments

Comments
 (0)