Navigation Menu

Skip to content

Commit

Permalink
CellMLAnnotation view: refactoring of some static methods.
Browse files Browse the repository at this point in the history
  • Loading branch information
agarny committed Jul 7, 2017
1 parent 9a664e8 commit 82ed497
Show file tree
Hide file tree
Showing 8 changed files with 113 additions and 35 deletions.
1 change: 1 addition & 0 deletions src/plugins/editing/CellMLAnnotationView/CMakeLists.txt
Expand Up @@ -12,6 +12,7 @@ ADD_PLUGIN(CellMLAnnotationView
../../pluginmanager.cpp
../../viewinterface.cpp

src/cellmlannotationview.cpp
src/cellmlannotationviewcellmllistwidget.cpp
src/cellmlannotationvieweditingwidget.cpp
src/cellmlannotationviewmetadatadetailswidget.cpp
Expand Down
@@ -0,0 +1,56 @@
/*******************************************************************************
Copyright (C) The University of Auckland
OpenCOR is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenCOR is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*******************************************************************************/

//==============================================================================
// CellML Annotation view
//==============================================================================

#include "cellmlannotationview.h"

//==============================================================================

namespace OpenCOR {
namespace CellMLAnnotationView {

//==============================================================================

QString resourceUrl(const QString &pResource)
{
// Return the URL for the given resource

return "http://identifiers.org/"+pResource+"/?redirect=true";
}

//==============================================================================

QString idUrl(const QString &pResource, const QString &pId)
{
// Return the URL for the given resource

return "http://identifiers.org/"+pResource+"/"+pId+"/?profile=most_reliable&redirect=true";
}

//==============================================================================

} // namespace CellMLAnnotationView
} // namespace OpenCOR

//==============================================================================
// End of file
//==============================================================================
@@ -0,0 +1,47 @@
/*******************************************************************************
Copyright (C) The University of Auckland
OpenCOR is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenCOR is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*******************************************************************************/

//==============================================================================
// CellML Annotation view
//==============================================================================

#pragma once

//==============================================================================

#include <QString>

//==============================================================================

namespace OpenCOR {
namespace CellMLAnnotationView {

//==============================================================================

QString resourceUrl(const QString &pResource);
QString idUrl(const QString &pResource, const QString &pId);

//==============================================================================

} // namespace CellMLAnnotationView
} // namespace OpenCOR

//==============================================================================
// End of file
//==============================================================================
Expand Up @@ -22,13 +22,13 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
//==============================================================================

#include "borderedwidget.h"
#include "cellmlannotationview.h"
#include "cellmlannotationviewcellmllistwidget.h"
#include "cellmlannotationvieweditingwidget.h"
#include "cellmlannotationviewmetadatanormalviewdetailswidget.h"
#include "cellmlannotationviewmetadatadetailswidget.h"
#include "cellmlannotationviewmetadataeditdetailswidget.h"
#include "cellmlannotationviewplugin.h"
#include "cellmlannotationviewwidget.h"
#include "cellmlfilemanager.h"
#include "corecliutils.h"
#include "treeviewwidget.h"
Expand Down Expand Up @@ -295,7 +295,7 @@ void CellmlAnnotationViewEditingWidget::updateWebViewerWithResourceDetails(WebVi
// The user requested a resource to be looked up, so retrieve it using
// identifiers.org

pWebViewer->webView()->load(CellmlAnnotationViewWidget::resourceUrl(pResource));
pWebViewer->webView()->load(resourceUrl(pResource));
}

//==============================================================================
Expand All @@ -307,7 +307,7 @@ void CellmlAnnotationViewEditingWidget::updateWebViewerWithIdDetails(WebViewerWi
// The user requested a resource id to be looked up, so retrieve it using
// identifiers.org

pWebViewer->webView()->load(CellmlAnnotationViewWidget::idUrl(pResource, pId));
pWebViewer->webView()->load(idUrl(pResource, pId));
}

//==============================================================================
Expand Down
Expand Up @@ -21,6 +21,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
// CellML Annotation view metadata edit details widget
//==============================================================================

#include "cellmlannotationview.h"
#include "cellmlannotationviewcellmllistwidget.h"
#include "cellmlannotationvieweditingwidget.h"
#include "cellmlannotationviewmetadatadetailswidget.h"
Expand Down Expand Up @@ -565,13 +566,11 @@ void CellmlAnnotationViewMetadataEditDetailsWidget::updateItemsGui(const CellmlA

QString itemInformation = item.resource()+"|"+item.id();
QString itemInformationSha1 = Core::sha1(itemInformation);
QString resourceUrl = CellmlAnnotationViewWidget::resourceUrl(item.resource());
QString idUrl = CellmlAnnotationViewWidget::idUrl(item.resource(), item.id());

if (!mUrls.contains(item.resource()))
mUrls.insert(item.resource(), resourceUrl);
mUrls.insert(item.resource(), resourceUrl(item.resource()));

mUrls.insert(itemInformation, idUrl);
mUrls.insert(itemInformation, idUrl(item.resource(), item.id()));

mItemInformationSha1s << itemInformationSha1;

Expand Down
Expand Up @@ -21,7 +21,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
// CellML Annotation view metadata normal view details widget
//==============================================================================

#include "cellmlannotationviewwidget.h"
#include "cellmlannotationview.h"
#include "cellmlannotationvieweditingwidget.h"
#include "cellmlannotationviewmetadatanormalviewdetailswidget.h"
#include "corecliutils.h"
Expand Down Expand Up @@ -308,13 +308,10 @@ void CellmlAnnotationViewMetadataNormalViewDetailsWidget::addRdfTriple(CellMLSup

// Keep track of some information

QString resourceUrl = CellmlAnnotationViewWidget::resourceUrl(pRdfTriple->resource());
QString idUrl = CellmlAnnotationViewWidget::idUrl(pRdfTriple->resource(), pRdfTriple->id());

if (!mUrls.contains(pRdfTriple->resource()))
mUrls.insert(pRdfTriple->resource(), resourceUrl);
mUrls.insert(pRdfTriple->resource(), resourceUrl(pRdfTriple->resource()));

mUrls.insert(rdfTripleInformation, idUrl);
mUrls.insert(rdfTripleInformation, idUrl(pRdfTriple->resource(), pRdfTriple->id()));

mRdfTripleInformationSha1s << rdfTripleInformationSha1;

Expand Down
Expand Up @@ -239,25 +239,6 @@ bool CellmlAnnotationViewWidget::saveFile(const QString &pOldFileName,

//==============================================================================

QString CellmlAnnotationViewWidget::resourceUrl(const QString &pResource)
{
// Return the URL for the given resource

return "http://identifiers.org/"+pResource+"/?redirect=true";
}

//==============================================================================

QString CellmlAnnotationViewWidget::idUrl(const QString &pResource,
const QString &pId)
{
// Return the URL for the given resource

return "http://identifiers.org/"+pResource+"/"+pId+"/?profile=most_reliable&redirect=true";
}

//==============================================================================

void CellmlAnnotationViewWidget::editingWidgetSplitterMoved(const QIntList &pSizes)
{
// The splitter of our editing widget has moved, so keep track of its new
Expand Down
Expand Up @@ -70,9 +70,6 @@ class CellmlAnnotationViewWidget : public Core::ViewWidget

bool saveFile(const QString &pOldFileName, const QString &pNewFileName);

static QString resourceUrl(const QString &pResource);
static QString idUrl(const QString &pResource, const QString &pId);

private:
CellMLAnnotationViewPlugin *mPlugin;

Expand Down

0 comments on commit 82ed497

Please sign in to comment.