Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Recent files should contain example #5317

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading