Commit ea518c3f authored by Vijay Dhameliya's avatar Vijay Dhameliya

REVIEW: 115705

Made keyword wikipedia in "What's interesting..." clickable so Wikipedia link opens in browser when clicked
parent b494a7dc
......@@ -551,6 +551,7 @@ Rectangle {
wrapMode: Text.WrapAtWordBoundaryOrAnywhere
width: parent.width
font.pixelSize: 13
onLinkActivated: Qt.openUrlExternally(link)
}
}
}
......
......@@ -29,19 +29,28 @@ void SkyObjDescription::fileDownloaded(QNetworkReply* reply)
if(m_DownloadedData != ""){
QString data(m_DownloadedData);
if(data.contains("description", Qt::CaseInsensitive))
const QString descOpeing( "<Description xml:space=\"preserve\">" );
const QString descClosing( "</Description>" );
// retrieving description from recieved data
if(data.contains( "description", Qt::CaseInsensitive ) )
{
int startIndex = data.lastIndexOf( descOpeing ) + descOpeing.length();
int endIndex = data.lastIndexOf( descClosing );
m_description = data.mid( startIndex, endIndex-startIndex );
}
const QString urlOpening( "<Url xml:space=\"preserve\">" );
const QString urlClosing( "</Url>" );
// retrieving link of wikipedia page from received data
if( data.contains( urlOpening, Qt::CaseInsensitive ) )
{
int startIndex = data.lastIndexOf("<Description xml:space=\"preserve\">") + 34;
int endIndex = data.lastIndexOf("</Description>");
m_description = data.mid(startIndex, endIndex-startIndex);
int startIndex = data.lastIndexOf( urlOpening ) + urlOpening.length();
int endIndex = data.lastIndexOf( urlClosing );
m_url = data.mid( startIndex, endIndex-startIndex );
}
}
reply->deleteLater();
emit downloaded();
}
QString SkyObjDescription::downloadedData() const
{
return m_description;
}
......@@ -50,7 +50,12 @@ public:
/**
* @return returns description if it was available on wikipedia else returns empty string
*/
QString downloadedData() const;
QString downloadedData() const {return m_description;}
/**
* @return returns wikipedia link for skyobject
*/
QString url() const { return m_url;}
signals:
void downloaded();
......@@ -63,7 +68,7 @@ private slots:
void fileDownloaded(QNetworkReply* reply);
private:
QString soName, soType, m_description;
QString soName, soType, m_description, m_url;
QNetworkAccessManager* manager;
QByteArray m_DownloadedData;
......
......@@ -146,8 +146,8 @@ QString SkyObjItem::getDescSource()
if(skd)
{
if(skd->downloadedData() != "")
return i18n("(Source: Wikipedia)");
if(!skd->downloadedData().isEmpty() && !skd->url().isEmpty())
return "(Source: <a href=\"" + skd->url() + "\">Wikipedia</a>)";
}
return i18n("(Source: N/A)");
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment