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

Add hide dependencies to result menu #5046

Open
wants to merge 4 commits into
base: stable
Choose a base branch
from
Open
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
13 changes: 11 additions & 2 deletions Desktop/analysis/analyses.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -734,11 +734,20 @@ void Analyses::duplicateAnalysis(size_t id)
analysis->refresh();
}

void Analyses::showDependenciesInAnalysis(size_t analysis_id, QString optionName)
void Analyses::showDependenciesInAnalysis(size_t analysis_id, QString optionName, bool show)
{
if(!get(analysis_id)) return;

get(analysis_id)->showDependenciesOnQMLForObject(optionName);
if(show)
get(analysis_id)->showDependenciesOnQMLForObject(optionName);
else
{
//just hide it for all analysis, probably desired
for (auto& analysis : _analysisMap)
{
analysis.second->hideDependencies();
}
}
}

void Analyses::analysisTitleChangedHandler(string moduleName, string oldTitle, string newTitle)
Expand Down
2 changes: 1 addition & 1 deletion Desktop/analysis/analyses.h
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ public slots:
void setCurrentFormPrevH(double currentFormPrevH);
void move(int fromIndex, int toIndex);
void duplicateAnalysis(size_t id);
void showDependenciesInAnalysis(size_t analysis_id, QString optionName);
void showDependenciesInAnalysis(size_t analysis_id, QString optionName, bool show);
void analysisTitleChangedHandler(std::string moduleName, std::string oldTitle, std::string newTitlesendRScriptHandler);
void prepareForLanguageChange();
void languageChangedHandler();
Expand Down
8 changes: 8 additions & 0 deletions Desktop/analysis/analysis.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -575,6 +575,14 @@ void Analysis::showDependenciesOnQMLForObject(QString uniqueName)
processResultsForDependenciesToBeShown();
}

void Analysis::hideDependencies()
{
_analysisForm->setMustBe({});
_analysisForm->setMustContain({});
_showDepsName = "";
}


bool Analysis::processResultsForDependenciesToBeShownMetaTraverser(const Json::Value & array)
{
if(!array.isArray())
Expand Down
1 change: 1 addition & 0 deletions Desktop/analysis/analysis.h
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,7 @@ public slots:
void setDynamicModule( Modules::DynamicModule * module);
void emitDuplicationSignals();
void showDependenciesOnQMLForObject(QString uniqueName); //uniqueName is basically "name" in meta in results.
void hideDependencies();
void boundValueChangedHandler() override;
void requestComputedColumnCreationHandler( const std::string & columnName) override;
void requestColumnCreationHandler( const std::string & columnName, columnType colType) override { emit requestColumnCreation(columnName, this, colType); }
Expand Down
5 changes: 4 additions & 1 deletion Desktop/components/JASP/Widgets/MainPage.qml
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,10 @@ Item
function setAllUserDataFromJavascript(json) { resultsJsInterface.setAllUserDataFromJavascript(json) }
function setResultsMetaFromJavascript(json) { resultsJsInterface.setResultsMetaFromJavascript(json) }
function duplicateAnalysis(id) { resultsJsInterface.duplicateAnalysis(id) }
function showDependenciesInAnalysis(id, optName) { resultsJsInterface.showDependenciesInAnalysis(id, optName) }

function showDependenciesInAnalysis(id, optName, show) {
resultsJsInterface.showDependenciesInAnalysis(id, optName, show);
resultMenuModel.setDependenciesShown(show); }

function showAnalysesMenu(options)
{
Expand Down
3 changes: 1 addition & 2 deletions Desktop/html/js/analysis.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,7 @@ JASPWidgets.AnalysisView = JASPWidgets.View.extend({
this.model.on("CustomOptions:changed", function (options) { this.trigger("optionschanged", this.model.get("id"), options) }, this);
this.model.on("SaveImage:clicked", function (options) { this.trigger("saveimage", this.model.get("id"), options) }, this);
this.model.on("EditImage:clicked", function (image, options) { this.imageBeingEdited = image; this.trigger("editimage", this.model.get("id"), options) }, this);
this.model.on("ShowDependencies:clicked", function (optName) { this.trigger("showDependencies", this.model.get("id"), optName) }, this);

this.model.on("ShowDependencies:clicked", function (optName, show) { this.trigger("showDependencies", this.model.get("id"), optName, show) }, this);
this.$el.on("changed:userData", this, this.onUserDataChanged);
},

Expand Down
2 changes: 1 addition & 1 deletion Desktop/html/js/collection.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ JASPWidgets.collectionView = JASPWidgets.View.extend({
return true;
},

showDependenciesClicked: function() { this.model.trigger("ShowDependencies:clicked", this.model.get("name")); },
showDependenciesClicked: function(show) { this.model.trigger("ShowDependencies:clicked", this.model.get("name"), show); },
collapseMenuClicked: function() { this.setCollapsedState(!this.model.get('collapsed')); },
noteOptions: function() { return [ { key: this.noteBoxKey, visible: this.noteBox.visible } ]; },
hasNotes: function() { return this.model.get('name') !== null; },
Expand Down
3 changes: 2 additions & 1 deletion Desktop/html/js/image.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ JASPWidgets.imageView = JASPWidgets.objectView.extend({
hasCollapse: function() { return this.$el.hasClass('jasp-collection-item') === false; },
saveImageClicked: function() { this.model.trigger("SaveImage:clicked", { data: this.model.get("data"), width: this.model.get("width"), height: this.model.get("height"), name: this.model.get("name") }); },
editImageClicked: function() { this.model.trigger("EditImage:clicked", this.myView, { data: this.model.get("data"), width: this.model.get("width"), height: this.model.get("height"), name: this.model.get("name"), title: this.model.get("title"), type: "interactive" }); },
showDependenciesClicked: function() { this.model.trigger("ShowDependencies:clicked", this.model.get("name")); },
showDependenciesClicked: function(show) { this.model.trigger("ShowDependencies:clicked", this.model.get("name"), show); },


menuName: "Plot",
myView: undefined,
Expand Down
5 changes: 3 additions & 2 deletions Desktop/html/js/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -145,12 +145,13 @@ $(document).ready(function () {
window.editImageClicked = function () { window.menuObjectFunctionCaller( window.menuObject.editImageClicked .bind(window.menuObject) ); }
window.editTitleMenuClicked = function () { window.menuObjectFunctionCaller( window.menuObject.editTitleClicked .bind(window.menuObject) ); }
window.collapseMenuClicked = function () { window.menuObjectFunctionCaller( window.menuObject.collapseMenuClicked .bind(window.menuObject) ); }
window.showDependenciesClicked = function () { window.menuObjectFunctionCaller( window.menuObject.showDependenciesClicked .bind(window.menuObject) ); }
window.duplicateMenuClicked = function () { window.menuObjectFunctionCaller( window.menuObject.duplicateMenuClicked .bind(window.menuObject) ); }
window.removeMenuClicked = function () { window.menuObjectFunctionCaller( window.menuObject.removeMenuClicked .bind(window.menuObject) ); }
window.citeMenuClicked = function () { window.menuObjectFunctionCaller( window.menuObject.citeMenuClicked .bind(window.menuObject), "Citations copied to clipboard" ); }
window.latexCodeMenuClicked = function () { window.menuObjectFunctionCaller( window.menuObject.latexCodeMenuClicked .bind(window.menuObject), "LaTeX code copied to clipboard"); }

window.showDependenciesClicked = function (show) { window.menuObject.showDependenciesClicked(show); }

window.notesMenuClicked = function (noteType, visibility) {
if (window.menuObject.notesMenuClicked && window.menuObject.notesMenuClicked(noteType, visibility))
window.menuObject.toolbar.displayMessage();
Expand Down Expand Up @@ -470,7 +471,7 @@ $(document).ready(function () {
jaspWidget.on("optionschanged", function (id, options) { jasp.analysisChangedDownstream(id, JSON.stringify(options)) });
jaspWidget.on("saveimage", function (id, options) { jasp.analysisSaveImage(id, JSON.stringify(options)) });
jaspWidget.on("editimage", function (id, options) { jasp.analysisEditImage(id, JSON.stringify(options)) });
jaspWidget.on("showDependencies", function (id, optName) { jasp.showDependenciesInAnalysis(id, optName); });
jaspWidget.on("showDependencies", function (id, optName, show) { jasp.showDependenciesInAnalysis(id, optName, show); });
jaspWidget.on("analysis:remove", function (id) { jasp.removeAnalysisRequest(id); });
jaspWidget.on("analysis:duplicate", function (id) { jasp.duplicateAnalysis(id); });
jaspWidget.on("analysis:userDataChanged", function () { window.getAllUserData(); });
Expand Down
2 changes: 1 addition & 1 deletion Desktop/html/js/object.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ JASPWidgets.objectConstructor = function (results, params, ignoreEvents) {
itemModel.on("CustomOptions:changed", function (options) { this.trigger("CustomOptions:changed", options) }, this.model);
itemModel.on("SaveImage:clicked", function (options) { this.trigger("SaveImage:clicked", options) }, this.model);
itemModel.on("EditImage:clicked", function (image, options) { this.trigger("EditImage:clicked", image, options) }, this.model);
itemModel.on("ShowDependencies:clicked", function (options) { this.trigger("ShowDependencies:clicked", options) }, this.model);
itemModel.on("ShowDependencies:clicked", function (options, show) { this.trigger("ShowDependencies:clicked", options, show) }, this.model);
itemModel.on("analysis:resizeStarted", function (image) { this.trigger("analysis:resizeStarted", image) }, this.model);

if (!ignoreEvents) { this.listenTo(itemView, "toolbar:showMenu", function (obj, options) { this.trigger("toolbar:showMenu", obj, options); }); }
Expand Down
2 changes: 1 addition & 1 deletion Desktop/html/js/table.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ JASPWidgets.tableView = JASPWidgets.objectView.extend({
return true;
},

showDependenciesClicked: function() { this.model.trigger("ShowDependencies:clicked", this.model.get("name")); },
showDependenciesClicked: function(show) { this.model.trigger("ShowDependencies:clicked", this.model.get("name"), show); },

hasLaTeXCode: function () {
var optLaTeXCode = this.model.get("latexCode");
Expand Down
13 changes: 7 additions & 6 deletions Desktop/results/resultmenumodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ void ResultMenuModel::_generateCorrectlyTranslatedResultEntries()
{ "hasRemoveAllAnalyses", ResultMenuEntry(tr("Remove All"), "hasRemoveAllAnalyses", "close-button.png", "") },
{ "hasRefreshAllAnalyses", ResultMenuEntry(tr("Refresh All"), "hasRefreshAllAnalyses", "", "") },
{ "hasShowDeps", ResultMenuEntry(tr("Show Dependencies"), "hasShowDeps", "", "window.showDependenciesClicked()") },
{ "hasExportResults", ResultMenuEntry(tr("Export Results"), "hasExportResults", "", "") }
};
{ "hasExportResults", ResultMenuEntry(tr("Export Results"), "hasExportResults", "", "") },
};
}

QVariant ResultMenuModel::data(const QModelIndex &index, int role) const
Expand Down Expand Up @@ -126,11 +126,12 @@ void ResultMenuModel::setOptions(QString options, QStringList selected)
}
else if (key == "hasShowDeps")
{
if(Settings::value(Settings::DEVELOPER_MODE).toBool())
if (Settings::value(Settings::DEVELOPER_MODE).toBool())
{
//It's developerMode time!
entries.push_back(separator);
entries.push_back(entry);
entry.setDisplayText(_dependenciesShown ? "Hide Dependencies" : "Show Dependencies");
entry.setJSFunction(QString("window.showDependenciesClicked(%1)").arg(_dependenciesShown ? "false" : "true"));
entries.push_back(separator);
entries.push_back(entry);
}
}
else
Expand Down
2 changes: 2 additions & 0 deletions Desktop/results/resultmenumodel.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ class ResultMenuModel : public QAbstractListModel
Q_INVOKABLE void setOptions(QString, QStringList);
Q_INVOKABLE QString getJSFunction(int index) const { return _resultMenuEntries.at(index).jsFunction(); }
Q_INVOKABLE QString getName(int index) const { return _resultMenuEntries.at(index).name(); }
Q_INVOKABLE void setDependenciesShown(bool value) { _dependenciesShown = value; }

private slots:
void _generateCorrectlyTranslatedResultEntries();
Expand All @@ -59,6 +60,7 @@ private slots:
std::vector<ResultMenuEntry> _resultMenuEntries;
std::map<QString, ResultMenuEntry> _allResultEntries;
QStringList _entriesOrder;
bool _dependenciesShown = false;

};

Expand Down
3 changes: 2 additions & 1 deletion Desktop/results/resultsjsinterface.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,8 @@ class ResultsJsInterface : public QObject
Q_INVOKABLE void analysisTitleChangedInResults( int id, QString title);
Q_INVOKABLE void removeAnalysisRequest( int id);
Q_INVOKABLE void duplicateAnalysis( int id);
Q_INVOKABLE void showDependenciesInAnalysis( int id, QString optionName);
Q_INVOKABLE void showDependenciesInAnalysis( int id, QString optionName, bool show);
Q_INVOKABLE void hideDependenciesInAnalysis( int id, QString optionName);
Q_INVOKABLE void packageModified();
Q_INVOKABLE void refreshAllAnalyses();
Q_INVOKABLE void removeAllAnalyses();
Expand Down