Commit 83430ff8 authored by Robert Lancaster's avatar Robert Lancaster Committed by Jasem Mutlaq

Here are some more improvements to the Whats Interesting panel.

This will download wikipedia info text box in addition to the description.
It can dynamically display the content in a tabbed pane or right next to each other depending on the width of the page. Both the descriptions and the info text are now saved after loaded the first time for easier loading later.
I also captured the wikipedia image from the info text box and added that to the list of images available in the thumbnail picker.  I also improved some of the layouts in whats interesting
parent 9c6c0c85
......@@ -73,9 +73,9 @@ QVariant SkyObjItem::data(int role)
case DispNameRole:
return getLongName();
case DispImageRole:
return getImageURL();
return getImageURL(true);
case DispSummaryRole:
return getSummary();
return getSummary(true);
case CategoryRole:
return getType();
case CategoryNameRole:
......@@ -110,14 +110,23 @@ void SkyObjItem::setPosition(SkyObject * so)
m_Position = xi18n("Now visible: About %1 degrees above the %2 horizon", rounded_altitude, KSUtils::toDirectionString( sp.az() ) );
}
QString SkyObjItem::getImageURL() const
QString SkyObjItem::getImageURL(bool preferThumb) const
{
if ( m_Type==Star )
{
return "";
}
QString thumbName = KSPaths::locate(QStandardPaths::GenericDataLocation, "thumb-" + m_So->name().toLower().remove( ' ' ) + ".png" ) ;
QString fullSizeName = KSPaths::locate(QStandardPaths::GenericDataLocation, "Image_" + m_So->name().toLower().remove( ' ' ) + ".png" ) ;
QString fname = KSPaths::locate(QStandardPaths::GenericDataLocation, "image_" + m_So->name().toLower().remove( ' ' ) + ".png" ) ;
//First try to return the preferred file
if(thumbName!=""&&preferThumb)
return thumbName;
if(fullSizeName!=""&&(!preferThumb))
return fullSizeName;
//If that fails, try to return the large image first, then the thumb and then if it is a planet, the xplanet image.
QString fname = KSPaths::locate(QStandardPaths::GenericDataLocation, "Image_" + m_So->name().toLower().remove( ' ' ) + ".png" ) ;
if(fname=="")
fname = KSPaths::locate(QStandardPaths::GenericDataLocation, "thumb-" + m_So->name().toLower().remove( ' ' ) + ".png" ) ;
if(fname=="" && m_Type==Planet){
......@@ -128,9 +137,12 @@ QString SkyObjItem::getImageURL() const
}
QString SkyObjItem::getSummary() const
QString SkyObjItem::getSummary(bool includeDescription) const
{
return m_So->typeName()+"\n"+getRADE()+"\n"+getAltAz()+"\n";
if(includeDescription)
return m_So->typeName() + "<BR>" + getRADE() + "<BR>" + getAltAz()+"<BR><BR>" + loadObjectDescription();
else
return m_So->typeName() + "<BR>" + getRADE() + "<BR>" + getAltAz();
}
QString SkyObjItem::getDesc() const
......@@ -222,3 +234,22 @@ QString SkyObjItem::getSize() const
return QString(" --");
}
}
inline QString SkyObjItem::loadObjectDescription() const{
QFile file;
QString fname = "description-" + getName().toLower().remove( ' ' ) + ".html";
file.setFileName( KSPaths::writableLocation(QStandardPaths::GenericDataLocation) + "descriptions/" + fname ) ; //determine filename in local user KDE directory tree.
if(file.exists())
{
if(file.open(QIODevice::ReadOnly))
{
QTextStream in(&file);
QString line;
line = in.readAll();
file.close();
return line;
}
}
return "";
}
......@@ -114,7 +114,7 @@ class SkyObjItem
*/
inline QString getRADE() const
{
return "RA: "+ m_So->ra().toHMSString() + "\nDE: " + m_So->ra().toDMSString();
return "RA: "+ m_So->ra().toHMSString() + "<BR>DE: " + m_So->ra().toDMSString();
}
/**
......@@ -135,14 +135,16 @@ class SkyObjItem
return m_So;
}
QString getImageURL() const;
QString getImageURL(bool preferThumb) const;
inline QString loadObjectDescription() const;
/**
* \brief Get Summary Description for the SkyObjItem.
* \return Summary Description for the SkyObjItem as a QString.
*/
QString getSummary() const;
QString getSummary(bool includeDescription) const;
/**
......@@ -194,6 +196,7 @@ class SkyObjItem
Type m_Type; ///Category of sky-object of type SkyObjItem::Type
SkyObject * m_So; ///Pointer to SkyObject represented by SkyObjItem
SkyObjDescription * skd; /// pointer to SkyObjDescription
};
#endif
This diff is collapsed.
......@@ -120,7 +120,13 @@ class WIView : public QWidget
*/
void onReloadIconClicked();
void tryToLoadFromWikipedia(QObject * descTextObj, QObject *descSrcTextObj, SkyObjItem * soitem);
void tryToLoadDescFromWikipedia(QObject * descTextObj, QObject *descSrcTextObj, SkyObjItem * soitem);
void loadObjectDescription(QObject * descTextObj, QObject *descSrcTextObj, SkyObjItem * soitem);
void tryToLoadInfoBoxFromWikipedia(QObject * infoBoxText, SkyObjItem * soitem);
void loadObjectInfoBox(QObject * infoBoxText, SkyObjItem * soitem);
void saveImageURL(SkyObjItem * soitem, QString imageURL);
void saveObjectText(SkyObjItem * soitem, QString type, QString infoText);
void downloadWikipediaImage(SkyObjItem * soitem, QString imageURL);
private:
......
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