Skip to content

Commit

Permalink
add hide dependencies to resultmenu
Browse files Browse the repository at this point in the history
  • Loading branch information
RensDofferhoff committed Mar 8, 2023
1 parent 8dfad4e commit f6199cc
Show file tree
Hide file tree
Showing 16 changed files with 48 additions and 7 deletions.
9 changes: 9 additions & 0 deletions Desktop/analysis/analyses.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -741,6 +741,15 @@ void Analyses::showDependenciesInAnalysis(size_t analysis_id, QString optionName
get(analysis_id)->showDependenciesOnQMLForObject(optionName);
}

void Analyses::hideDependenciesInAnalysis(size_t analysis_id, QString optionName)
{
//just hide it for all analysis, probably desired
for (auto& analysis : _analysisMap)
{
analysis.second->hideDependencies();
}
}

void Analyses::analysisTitleChangedHandler(string moduleName, string oldTitle, string newTitle)
{
applyToAll([&](Analysis * a)
Expand Down
1 change: 1 addition & 0 deletions Desktop/analysis/analyses.h
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ public slots:
void move(int fromIndex, int toIndex);
void duplicateAnalysis(size_t id);
void showDependenciesInAnalysis(size_t analysis_id, QString optionName);
void hideDependenciesInAnalysis(size_t analysis_id, QString optionName);
void analysisTitleChangedHandler(std::string moduleName, std::string oldTitle, std::string newTitlesendRScriptHandler);
void prepareForLanguageChange();
void languageChangedHandler();
Expand Down
7 changes: 7 additions & 0 deletions Desktop/analysis/analysis.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -574,6 +574,13 @@ void Analysis::showDependenciesOnQMLForObject(QString uniqueName)
processResultsForDependenciesToBeShown();
}

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


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
3 changes: 2 additions & 1 deletion Desktop/components/JASP/Widgets/MainPage.qml
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,8 @@ 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) { resultsJsInterface.showDependenciesInAnalysis(id, optName); resultMenuModel.setDependenciesShown(true) }
function hideDependenciesInAnalysis(id, optName) { resultsJsInterface.hideDependenciesInAnalysis(id, optName); resultMenuModel.setDependenciesShown(false) }

function showAnalysesMenu(options)
{
Expand Down
2 changes: 1 addition & 1 deletion Desktop/html/js/analysis.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ JASPWidgets.AnalysisView = JASPWidgets.View.extend({
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("HideDependencies:clicked", function (optName) { this.trigger("hideDependencies", this.model.get("id"), optName) }, this);
this.$el.on("changed:userData", this, this.onUserDataChanged);
},

Expand Down
2 changes: 2 additions & 0 deletions Desktop/html/js/collection.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,8 @@ JASPWidgets.collectionView = JASPWidgets.View.extend({
},

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

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
2 changes: 2 additions & 0 deletions Desktop/html/js/image.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ JASPWidgets.imageView = JASPWidgets.objectView.extend({
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")); },
hideDependenciesClicked: function() { this.model.trigger("HideDependencies:clicked", this.model.get("name")); },


menuName: "Plot",
myView: undefined,
Expand Down
1 change: 1 addition & 0 deletions Desktop/html/js/jaspwidgets.js
Original file line number Diff line number Diff line change
Expand Up @@ -967,6 +967,7 @@ JASPWidgets.Toolbar = JASPWidgets.View.extend({
hasRemove: (parent.hasRemove === undefined || parent.hasRemove()) && parent.removeMenuClicked !== undefined,
hasDuplicate: (parent.hasDuplicate === undefined || parent.hasDuplicate()) && parent.duplicateMenuClicked !== undefined,
hasShowDeps: (parent.hasShowDeps === undefined || parent.hasShowDeps()) && parent.showDependenciesClicked !== undefined,
hasHideDeps: true,
hasCollapse: (parent.hasCollapse === undefined || parent.hasCollapse()) && parent.collapseMenuClicked !== undefined,
hasLaTeXCode: (parent.hasLaTeXCode === undefined || parent.hasLaTeXCode()) && parent.latexCodeMenuClicked !== undefined,
hasRemoveAllAnalyses: parent.menuName === 'All',
Expand Down
2 changes: 2 additions & 0 deletions Desktop/html/js/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ $(document).ready(function () {
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.hideDependenciesClicked = function () { window.menuObjectFunctionCaller( window.menuObject.hideDependenciesClicked .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" ); }
Expand Down Expand Up @@ -471,6 +472,7 @@ $(document).ready(function () {
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("hideDependencies", function (id, optName) { jasp.hideDependenciesInAnalysis(id, optName); });
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
1 change: 1 addition & 0 deletions Desktop/html/js/object.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ JASPWidgets.objectConstructor = function (results, params, ignoreEvents) {
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("HideDependencies:clicked", function (options) { this.trigger("HideDependencies:clicked", options) }, 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
1 change: 1 addition & 0 deletions Desktop/html/js/table.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ JASPWidgets.tableView = JASPWidgets.objectView.extend({
},

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

hasLaTeXCode: function () {
var optLaTeXCode = this.model.get("latexCode");
Expand Down
1 change: 1 addition & 0 deletions Desktop/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -327,6 +327,7 @@ void MainWindow::makeConnections()
connect(_resultsJsInterface, &ResultsJsInterface::analysisTitleChangedInResults, _analyses, &Analyses::analysisTitleChangedInResults );
connect(_resultsJsInterface, &ResultsJsInterface::duplicateAnalysis, _analyses, &Analyses::duplicateAnalysis );
connect(_resultsJsInterface, &ResultsJsInterface::showDependenciesInAnalysis, _analyses, &Analyses::showDependenciesInAnalysis );
connect(_resultsJsInterface, &ResultsJsInterface::hideDependenciesInAnalysis, _analyses, &Analyses::hideDependenciesInAnalysis );
connect(_resultsJsInterface, &ResultsJsInterface::showPlotEditor, _plotEditorModel, &PlotEditorModel::showPlotEditor );
connect(_resultsJsInterface, &ResultsJsInterface::resultsMetaChanged, _analyses, &Analyses::resultsMetaChanged );
connect(_resultsJsInterface, &ResultsJsInterface::allUserDataChanged, _analyses, &Analyses::allUserDataChanged );
Expand Down
19 changes: 14 additions & 5 deletions Desktop/results/resultmenumodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,9 @@ 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", "", "") },
{ "hasHideDeps", ResultMenuEntry(tr("Hide Dependencies"), "hasHideDeps", "", "window.hideDependenciesClicked()") }
};
}

QVariant ResultMenuModel::data(const QModelIndex &index, int role) const
Expand Down Expand Up @@ -126,11 +127,19 @@ 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);
if (!_dependenciesShown)
{
entries.push_back(separator);
entries.push_back(entry);
}
else
{
entries.push_back(separator);
entries.push_back(_allResultEntries.find("hasHideDeps")->second);
}
}
}
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
1 change: 1 addition & 0 deletions Desktop/results/resultsjsinterface.h
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ class ResultsJsInterface : public QObject
Q_INVOKABLE void removeAnalysisRequest( int id);
Q_INVOKABLE void duplicateAnalysis( int id);
Q_INVOKABLE void showDependenciesInAnalysis( int id, QString optionName);
Q_INVOKABLE void hideDependenciesInAnalysis( int id, QString optionName);
Q_INVOKABLE void packageModified();
Q_INVOKABLE void refreshAllAnalyses();
Q_INVOKABLE void removeAllAnalyses();
Expand Down

0 comments on commit f6199cc

Please sign in to comment.