libpappsomspp
Library for mass spectrometry
Toggle main menu visibility
Loading...
Searching...
No Matches
httpbutton.cpp
Go to the documentation of this file.
1
/**
2
* \file pappsomspp/widget/httpbutton/httpbutton.cpp
3
* \date 20/04/2021
4
* \author Olivier Langella
5
* \brief push button to trigger web browser on URL
6
*/
7
8
9
/*******************************************************************************
10
* Copyright (c) 2021 Olivier Langella
11
*<Olivier.Langella@universite-paris-saclay.fr>.
12
*
13
* This file is part of the PAPPSOms++ library.
14
*
15
* PAPPSOms++ is free software: you can redistribute it and/or modify
16
* it under the terms of the GNU General Public License as published by
17
* the Free Software Foundation, either version 3 of the License, or
18
* (at your option) any later version.
19
*
20
* PAPPSOms++ is distributed in the hope that it will be useful,
21
* but WITHOUT ANY WARRANTY; without even the implied warranty of
22
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23
* GNU General Public License for more details.
24
*
25
* You should have received a copy of the GNU General Public License
26
* along with PAPPSOms++. If not, see <http://www.gnu.org/licenses/>.
27
*
28
******************************************************************************/
29
30
#include "
httpbutton.h
"
31
#include "
pappsomspp/core/utils.h
"
32
33
#include <QDebug>
34
#include <QDesktopServices>
35
36
using namespace
pappso
;
37
38
HttpButton::HttpButton
(QWidget *parent) : QPushButton(parent)
39
{
40
qDebug();
41
}
42
43
pappso::HttpButton::~HttpButton
()
44
{
45
}
46
47
void
48
pappso::HttpButton::mousePressEvent
(QMouseEvent *e)
49
{
50
if
(!text().isEmpty())
51
{
52
if
(text().startsWith(
"MOD:"
))
53
{
54
QDesktopServices::openUrl(
getOlsUrl
(this->text()));
55
// qDebug() << getOlsUrl(this->text());
56
}
57
else
if
(text().startsWith(
"PubMed:"
))
58
{
59
QDesktopServices::openUrl(
getPubMedUrl
(this->text()));
60
// qDebug() << getPubMedUrl(this->text());
61
}
62
else
if
(text().startsWith(
"RESID:"
))
63
{
64
QDesktopServices::openUrl(
getRESIDUrl
(this->text()));
65
// qDebug() << getPubMedUrl(this->text());
66
}
67
else
if
(text().startsWith(
"ChEBI:"
))
68
{
69
QDesktopServices::openUrl(
getChEBIUrl
(this->text()));
70
// qDebug() << getPubMedUrl(this->text());
71
}
72
else
if
(text().startsWith(
"Unimod:"
))
73
{
74
QDesktopServices::openUrl(
getUnimodUrl
(this->text()));
75
// qDebug() << getPubMedUrl(this->text());
76
}
77
else
78
{
79
qDebug() <<
"unknown"
<< this->text();
80
}
81
}
82
QPushButton::mousePressEvent(e);
83
}
84
85
void
86
pappso::HttpButton::setText
(
const
QString &text)
87
{
88
QPushButton::setText(text);
89
}
90
91
92
const
QUrl
93
HttpButton::getOlsUrl
(QString psimod_accession)
94
{
95
96
QString iri(QString(
"http://purl.obolibrary.org/obo/%1"
).arg(psimod_accession.replace(
":"
,
"_"
)));
97
QUrl url(QString(
"http://www.ebi.ac.uk/ols/ontologies/mod/terms?iri=%1"
).arg(iri));
98
return
url;
99
}
100
101
const
QUrl
102
HttpButton::getPubMedUrl
(QString accession)
103
{
104
// https://pubmed.ncbi.nlm.nih.gov/18688235/
105
QUrl url(QString(
"https://pubmed.ncbi.nlm.nih.gov/%1/"
).arg(accession.replace(
"PubMed:"
,
""
)));
106
return
url;
107
}
108
109
110
const
QUrl
111
HttpButton::getRESIDUrl
(QString accession)
112
{
113
// https://annotation.dbi.udel.edu/cgi-bin/resid?id=AA0470
114
QUrl url(QString(
"https://annotation.dbi.udel.edu/cgi-bin/resid?id=%1"
)
115
.arg(accession.replace(
"RESID:"
,
""
)));
116
return
url;
117
}
118
119
120
const
QUrl
121
HttpButton::getChEBIUrl
(QString accession)
122
{
123
// ChEBI:37629
124
// https://www.ebi.ac.uk/chebi/searchId.do?chebiId=37628
125
QUrl url(QString(
"https://www.ebi.ac.uk/chebi/searchId.do?chebiId=%1"
)
126
.arg(accession.replace(
"ChEBI:"
,
""
)));
127
return
url;
128
}
129
130
131
const
QUrl
132
HttpButton::getUnimodUrl
(QString accession)
133
{
134
// Unimod:23
135
// http://www.unimod.org/modifications_view.php?editid1=23
136
QUrl url(QString(
"http://www.unimod.org/modifications_view.php?editid1=%1"
)
137
.arg(accession.replace(
"Unimod:"
,
""
)));
138
return
url;
139
}
pappso::HttpButton::getUnimodUrl
const QUrl getUnimodUrl(QString accession)
Definition
httpbutton.cpp:132
pappso::HttpButton::setText
void setText(const QString &text)
Definition
httpbutton.cpp:86
pappso::HttpButton::mousePressEvent
void mousePressEvent(QMouseEvent *e) override
Definition
httpbutton.cpp:48
pappso::HttpButton::getRESIDUrl
const QUrl getRESIDUrl(QString accession)
Definition
httpbutton.cpp:111
pappso::HttpButton::getChEBIUrl
const QUrl getChEBIUrl(QString accession)
Definition
httpbutton.cpp:121
pappso::HttpButton::HttpButton
HttpButton(QWidget *parent=nullptr)
Definition
httpbutton.cpp:38
pappso::HttpButton::~HttpButton
~HttpButton()
Definition
httpbutton.cpp:43
pappso::HttpButton::getOlsUrl
const QUrl getOlsUrl(QString psimod_accession)
Definition
httpbutton.cpp:93
pappso::HttpButton::getPubMedUrl
const QUrl getPubMedUrl(QString accession)
Definition
httpbutton.cpp:102
httpbutton.h
pappso
tries to keep as much as possible monoisotopes, removing any possible C13 peaks and changes multichar...
Definition
aa.cpp:39
utils.h
pappsomspp
gui
httpbutton
httpbutton.cpp
Generated on
for libpappsomspp by
1.17.0