Skip to content

Commit

Permalink
the event can just be aware of when it ought to be readonly
Browse files Browse the repository at this point in the history
  • Loading branch information
JorisGoosen committed Jan 3, 2024
1 parent b97fc67 commit ca40346
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 12 deletions.
2 changes: 1 addition & 1 deletion Desktop/analysis/analysis.h
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ class Analysis : public AnalysisBase
void requestComputedColumnDestruction( const std::string & columnName);

void refreshTableViewModels();
Q_INVOKABLE void expandAnalysis();
void expandAnalysis();
void emptyQMLCache();

void createFormWhenYouHaveAMoment(QQuickItem* parent = nullptr);
Expand Down
10 changes: 6 additions & 4 deletions Desktop/data/fileevent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@
#include "exporters/jaspexporter.h"

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

FileEvent::FileEvent(QObject *parent, FileEvent::FileMode fileMode)
: QObject(parent), _operation(fileMode)
Expand Down Expand Up @@ -51,8 +50,6 @@ void FileEvent::setDataFilePath(const QString & path)

void FileEvent::setDatabase(const Json::Value & dbInfo)
{
setReadOnly();

_database = dbInfo;
}

Expand Down Expand Up @@ -110,6 +107,11 @@ void FileEvent::chain(FileEvent *event)
connect(event, &FileEvent::completed, this, &FileEvent::chainedComplete);
}

bool FileEvent::isExample() const
{
return path().startsWith(AppDirs::examples());
}

const std::string FileEvent::databaseStr() const
{
return _database.toStyledString();
Expand Down
8 changes: 3 additions & 5 deletions Desktop/data/fileevent.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,10 @@ class FileEvent : public QObject
void setComplete(bool success = true, const QString &message = "");
void chain(FileEvent *event);

void setReadOnly() { _readOnly = true; }

bool isDatabase() const { return _database != Json::nullValue; }
bool isOnlineNode() const { return _path.startsWith("http"); }
bool isReadOnly() const { return _readOnly; }
bool isExample() const;
bool isReadOnly() const { return isExample() || isDatabase(); }
bool isCompleted() const { return _completed; }
bool isSuccessful() const { return _success; }

Expand Down Expand Up @@ -83,8 +82,7 @@ private slots:
_dataFilePath,
_last_error = "Unknown error",
_message;
bool _readOnly = false,
_completed = false,
bool _completed = false,
_success = false;
FileEvent * _chainedTo = nullptr;
Exporter * _exporter = nullptr;
Expand Down
1 change: 0 additions & 1 deletion Desktop/widgets/filemenu/datalibrarylistmodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ void DataLibraryListModel::openFile(const QString &path)
{
FileEvent *event = new FileEvent(this->parent(), FileEvent::FileOpen);
event->setPath(path);
event->setReadOnly(); // A file from the Data Library should be read only, also csv file so that its path is not added in the recent list

emit openFileEvent(event);

Expand Down
2 changes: 1 addition & 1 deletion Desktop/widgets/filemenu/filemenu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ void FileMenu::dataSetIOCompleted(FileEvent *event)
if (!event->isDatabase())
{
_recentFiles->pushRecentFilePath(event->path());
if (!event->path().startsWith(AppDirs::examples()))
if (!event->isExample())
_computer->addRecentFolder(event->path());
}

Expand Down

0 comments on commit ca40346

Please sign in to comment.