Skip to content

Commit

Permalink
Recent files should remember also Data library files
Browse files Browse the repository at this point in the history
  • Loading branch information
boutinb committed Nov 11, 2023
1 parent 6cd1f00 commit 76d71d9
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 4 deletions.
2 changes: 1 addition & 1 deletion Desktop/components/JASP/Widgets/FileMenu/ListItem.qml
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ FocusScope
anchors.left: rectTitleAndDataFile.left
anchors.right: parent.right
anchors.leftMargin: (10 * preferencesModel.uiScale) + associatedDatafileImage.width
text: model.dirpath
text: model.displayedpath
color: jaspTheme.textEnabled
horizontalAlignment: Text.AlignLeft
verticalAlignment: Text.AlignVCenter
Expand Down
8 changes: 5 additions & 3 deletions Desktop/widgets/filemenu/filemenu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
#include "log.h"
#include "data/datasetpackage.h"
#include "mainwindow.h"
#include "utilities/appdirs.h"

FileMenu::FileMenu(QObject *parent) : QObject(parent)
{
Expand Down Expand Up @@ -255,11 +256,12 @@ void FileMenu::dataSetIOCompleted(FileEvent *event)
{
if (event->isSuccessful())
{
// don't add examples to the recent list
if (!event->isReadOnly())
// don't add database to the recent list
if (!event->isDatabase())
{
_recentFiles->pushRecentFilePath(event->path());
_computer->addRecentFolder(event->path());
if (!event->path().startsWith(AppDirs::examples()))
_computer->addRecentFolder(event->path());
}

if(event->operation() == FileEvent::FileSave || (event->operation() == FileEvent::FileOpen && !event->isReadOnly()))
Expand Down
5 changes: 5 additions & 0 deletions Desktop/widgets/filemenu/filemenubasiclistmodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include <QTimer>
#include "log.h"
#include "jasptheme.h"
#include "utilities/appdirs.h"

FileMenuBasicListModel::FileMenuBasicListModel(QObject *parent, FileSystem * model) : QAbstractListModel(parent), _model(model)
{
Expand Down Expand Up @@ -41,12 +42,15 @@ QVariant FileMenuBasicListModel::data(const QModelIndex &index, int role) const
case IconSourceRole: return JaspTheme::currentIconPath() + FileSystemEntry::sourcesIcons()[item.entryType];
case DataIconSourceRole: return JaspTheme::currentIconPath() + FileSystemEntry::sourcesIcons()[FileSystemEntry::CSV];
case DirRole:
case DisplayedPathRole:
{
if (QFileInfo(item.path).path().toLower().startsWith("http:") || QFileInfo(item.path).path().toLower().startsWith("https:"))
return QFileInfo (item.path).path();
else
{
QString location = QDir::toNativeSeparators(QFileInfo (item.path).path()) ;
if (role == DisplayedPathRole && location.startsWith(AppDirs::examples()))
location = location.mid(AppDirs::examples().length() + 1);
while (location.endsWith(QDir::separator())) location.chop(1);
return location + QDir::separator();
}
Expand Down Expand Up @@ -76,6 +80,7 @@ bool FileMenuBasicListModel::setData(const QModelIndex &index, const QVariant &v
case AssociatedDataFileRole: item.associatedDataFile = value.toString(); break;
case IconSourceRole: //Do nothing
case DataIconSourceRole:
case DisplayedPathRole:
case DirRole: break;
}

Expand Down
2 changes: 2 additions & 0 deletions Desktop/widgets/filemenu/filemenulistitem.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ enum FileMenuListItemType {
IconSourceRole,
DataIconSourceRole,
DirRole,
DisplayedPathRole,
ActionRole
};

Expand All @@ -25,6 +26,7 @@ const QHash<int, QByteArray> FileMenuListItemTypeRoleNames = {
{ IconSourceRole, "iconsource" },
{ DataIconSourceRole, "dataiconsource" },
{ DirRole, "dirpath" },
{ DisplayedPathRole, "displayedpath" },
{ ActionRole, "action" }
};

Expand Down

0 comments on commit 76d71d9

Please sign in to comment.