Skip to content

Commit c9e5084

Browse files
committed
Recent files should remember also Data library files
1 parent dcd073b commit c9e5084

File tree

4 files changed

+13
-4
lines changed

4 files changed

+13
-4
lines changed

Desktop/components/JASP/Widgets/FileMenu/ListItem.qml

+1-1
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ FocusScope
214214
anchors.left: rectTitleAndDataFile.left
215215
anchors.right: parent.right
216216
anchors.leftMargin: (10 * preferencesModel.uiScale) + associatedDatafileImage.width
217-
text: model.dirpath
217+
text: model.displayedpath
218218
color: jaspTheme.textEnabled
219219
horizontalAlignment: Text.AlignLeft
220220
verticalAlignment: Text.AlignVCenter

Desktop/widgets/filemenu/filemenu.cpp

+5-3
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
#include "log.h"
2525
#include "data/datasetpackage.h"
2626
#include "mainwindow.h"
27+
#include "utilities/appdirs.h"
2728

2829
FileMenu::FileMenu(QObject *parent) : QObject(parent)
2930
{
@@ -255,11 +256,12 @@ void FileMenu::dataSetIOCompleted(FileEvent *event)
255256
{
256257
if (event->isSuccessful())
257258
{
258-
// don't add examples to the recent list
259-
if (!event->isReadOnly())
259+
// don't add database to the recent list
260+
if (!event->isDatabase())
260261
{
261262
_recentFiles->pushRecentFilePath(event->path());
262-
_computer->addRecentFolder(event->path());
263+
if (!event->path().startsWith(AppDirs::examples()))
264+
_computer->addRecentFolder(event->path());
263265
}
264266

265267
if(event->operation() == FileEvent::FileSave || (event->operation() == FileEvent::FileOpen && !event->isReadOnly()))

Desktop/widgets/filemenu/filemenubasiclistmodel.cpp

+5
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
#include <QTimer>
55
#include "log.h"
66
#include "jasptheme.h"
7+
#include "utilities/appdirs.h"
78

89
FileMenuBasicListModel::FileMenuBasicListModel(QObject *parent, FileSystem * model) : QAbstractListModel(parent), _model(model)
910
{
@@ -41,12 +42,15 @@ QVariant FileMenuBasicListModel::data(const QModelIndex &index, int role) const
4142
case IconSourceRole: return JaspTheme::currentIconPath() + FileSystemEntry::sourcesIcons()[item.entryType];
4243
case DataIconSourceRole: return JaspTheme::currentIconPath() + FileSystemEntry::sourcesIcons()[FileSystemEntry::CSV];
4344
case DirRole:
45+
case DisplayedPathRole:
4446
{
4547
if (QFileInfo(item.path).path().toLower().startsWith("http:") || QFileInfo(item.path).path().toLower().startsWith("https:"))
4648
return QFileInfo (item.path).path();
4749
else
4850
{
4951
QString location = QDir::toNativeSeparators(QFileInfo (item.path).path()) ;
52+
if (role == DisplayedPathRole && location.startsWith(AppDirs::examples()))
53+
location = location.mid(AppDirs::examples().length() + 1);
5054
while (location.endsWith(QDir::separator())) location.chop(1);
5155
return location + QDir::separator();
5256
}
@@ -76,6 +80,7 @@ bool FileMenuBasicListModel::setData(const QModelIndex &index, const QVariant &v
7680
case AssociatedDataFileRole: item.associatedDataFile = value.toString(); break;
7781
case IconSourceRole: //Do nothing
7882
case DataIconSourceRole:
83+
case DisplayedPathRole:
7984
case DirRole: break;
8085
}
8186

Desktop/widgets/filemenu/filemenulistitem.h

+2
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ enum FileMenuListItemType {
1313
IconSourceRole,
1414
DataIconSourceRole,
1515
DirRole,
16+
DisplayedPathRole,
1617
ActionRole
1718
};
1819

@@ -25,6 +26,7 @@ const QHash<int, QByteArray> FileMenuListItemTypeRoleNames = {
2526
{ IconSourceRole, "iconsource" },
2627
{ DataIconSourceRole, "dataiconsource" },
2728
{ DirRole, "dirpath" },
29+
{ DisplayedPathRole, "displayedpath" },
2830
{ ActionRole, "action" }
2931
};
3032

0 commit comments

Comments
 (0)