• Skip to content
  • Skip to link menu
KDE 4.0 API Reference
  • KDE API Reference
  • kdeedu
  • Sitemap
  • Contact Us
 

kalzium

detailinfodlg.cpp

Go to the documentation of this file.
00001 /***************************************************************************
00002     begin                : Tue Apr 8 2003
00003     copyright            : (C) 2003, 2004, 2005, 2006 by Carsten Niehaus
00004     email                : cniehaus@kde.org
00005  ***************************************************************************/
00006 
00007 /***************************************************************************
00008  *                                                                         *
00009  *   This program is free software; you can redistribute it and/or modify  *
00010  *   it under the terms of the GNU General Public License as published by  *
00011  *   the Free Software Foundation; either version 2 of the License, or     *
00012  *   (at your option) any later version.                                   *
00013  *                                                                         *
00014  ***************************************************************************/
00015 
00016 #include "detailinfodlg.h"
00017 #include "isotope.h"
00018 #include "kalziumdataobject.h"
00019 
00020 #include <kdebug.h>
00021 #include <klocale.h>
00022 #include <kicon.h>
00023 #include <khtml_part.h>
00024 #include <dom/html_base.h>
00025 #include <dom/html_document.h>
00026 #include <khtmlview.h>
00027 #include <kstandarddirs.h>
00028 #include <kactioncollection.h>
00029 #include <kcombobox.h>
00030 #include <kstandardaction.h>
00031 #include <kpagewidgetmodel.h>
00032 #include <ktoolinvocation.h>
00033 
00034 #include <QFile>
00035 #include <QLabel>
00036 #include <QImage>
00037 #include <QLayout>
00038 #include <QPushButton>
00039 #include <QStackedWidget>
00040 
00041 #include "element.h"
00042 #include "orbitswidget.h"
00043 #include "detailedgraphicaloverview.h"
00044 //FIXME Readd for KDE 4.1
00045 //X #include "spectrumviewimpl.h"
00046 #include "kalziumutils.h"
00047 #include "kalziumtabletype.h"
00048 
00049 DetailedInfoDlg::DetailedInfoDlg( int el , QWidget *parent )
00050     : KPageDialog( parent ), m_ktt( 0 )
00051 {
00052     setFaceType( List );
00053     setButtons( Help | User1 | User2 | Close );
00054     setDefaultButton( Close );
00055     setButtonGuiItem( User1, KGuiItem( i18nc( "Next element", "Next" ),
00056             ( layoutDirection() == Qt::LeftToRight ) ? "arrow-right" : "arrow-left", i18n( "Goes to the next element" ) ) );
00057     setButtonGuiItem( User2, KGuiItem( i18nc( "Previous element", "Previous" ),
00058             ( layoutDirection() == Qt::LeftToRight ) ? "arrow-left" : "arrow-right", i18n( "Goes to the previous element" ) ) );
00059 
00060     m_baseHtml = KGlobal::dirs()->findResourceDir( "appdata", "data/" ) + "data/htmlview/";
00061     m_baseHtml2 = KGlobal::dirs()->findResourceDir( "appdata", "data/" ) + "data/hazardsymbols/";
00062 
00063 //X     m_picsdir = KGlobal::dirs()->findResourceDir( "appdata", "elempics/" ) + "elempics/";
00064 
00065     //actionButton( Close )->setFocus();
00066 
00067     // creating the tabs but not the contents, as that will be done when
00068     // setting the element
00069     createContent();
00070 
00071     m_actionCollection = new KActionCollection(this);   
00072     KStandardAction::quit(this, SLOT(close()), m_actionCollection);
00073 
00074     connect( this, SIGNAL( user1Clicked() ), this, SLOT( slotUser1() ) );
00075     connect( this, SIGNAL( user2Clicked() ), this, SLOT( slotUser2() ) );
00076     connect( this, SIGNAL( helpClicked() ), this, SLOT( slotHelp() ) );
00077 
00078     // setting the element and updating the whole dialog
00079     setElement( el );
00080 }
00081 
00082 void DetailedInfoDlg::setElement( int el )
00083 {
00084     Element *element = KalziumDataObject::instance()->element( el );
00085     if ( !element ) return;
00086 
00087     m_element = element;
00088     m_elementNumber = el;
00089 
00090         emit elementChanged( m_elementNumber );
00091     
00092     reloadContent();
00093 
00094     enableButton( User1, true );
00095     enableButton( User2, true );
00096     if ( m_elementNumber == 1 )
00097         enableButton( User2, false );
00098     else if ( m_elementNumber == KalziumDataObject::instance()->numberOfElements() )
00099         enableButton( User1, false );
00100 }
00101 
00102 void DetailedInfoDlg::setOverviewBackgroundColor( const QColor &bgColor )
00103 {
00104     dTab->setBackgroundColor( bgColor );
00105 }
00106 
00107 void DetailedInfoDlg::setTableType( KalziumTableType* ktt )
00108 {
00109     m_ktt = ktt;
00110 }
00111 
00112 KHTMLPart* DetailedInfoDlg::addHTMLTab( const QString& title, const QString& icontext, const QString& iconname )
00113 {
00114     QWidget* frame = new QWidget();
00115     KPageWidgetItem *item = addPage( frame, title );
00116     item->setHeader( icontext );
00117     item->setIcon( KIcon( iconname ) );
00118     QVBoxLayout *layout = new QVBoxLayout( frame );
00119     layout->setMargin( 0 );
00120     KHTMLPart *w = new KHTMLPart( frame, frame );
00121     layout->addWidget( w->view() );
00122 
00123     return w;
00124 }
00125 
00126 void DetailedInfoDlg::fillHTMLTab( KHTMLPart* htmlpart, const QString& htmlcode )
00127 {
00128     if ( !htmlpart ) return;
00129 
00130     htmlpart->begin();
00131     htmlpart->write( htmlcode );
00132 
00133     // set the background color of the document to match that of the dialog
00134     DOM::HTMLElement element = htmlpart->htmlDocument().body();
00135     if ( element.tagName() == "body" )
00136     {
00137         const QColor backgroundColor = palette().background().color();
00138         ((DOM::HTMLBodyElement)element).setBgColor( backgroundColor.name() );
00139     }
00140 
00141     htmlpart->end();
00142 }
00143 
00144 QString DetailedInfoDlg::getHtml( DATATYPE type ) const
00145 {
00146     QString html =
00147         "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" \"http://www.w3.org/TR/html4/loose.dtd\">"
00148         "<html><head><title>Chemical data</title>"
00149         "<link rel=\"stylesheet\" type=\"text/css\" href=\"" + m_baseHtml + "style.css\" />"
00150         "<base href=\"" + m_baseHtml + "\"/></head><body>"
00151         "<div class=\"chemdata\"><div><table summary=\"header\">"
00152         "<tr><td>" + m_element->dataAsString( ChemicalDataObject::symbol ) + "<td><td>"
00153         + i18n( "Block: %1", m_element->dataAsString( ChemicalDataObject::periodTableBlock ) ) +
00154         "</td></tr></table></div>"
00155         "<table summary=\"characteristics\" class=\"characterstics\">";
00156 
00157     switch ( type )
00158     {
00159         case CHEMICAL:
00160         {
00161             //Electronic configuration
00162             html.append( "<tr><td><img src=\"structure.png\" alt=\"icon\"/></td><td>" );
00163             //Probably beautify here...
00164             QString config = m_element->dataAsString( ChemicalDataObject::electronicConfiguration );
00165             html.append( i18n( "Electronic configuration: %1", config ) );
00166             html.append( "</td></tr>" );
00167 
00168             //Density
00169             html.append( "<tr><td><img src=\"density.png\" alt=\"icon\"/></td><td>" );
00170             html.append( i18n( "Density: %1", KalziumUtils::prettyUnit( m_element, ChemicalDataObject::density ) ) );
00171             html.append( "</td></tr>" );
00172             // covalent radius
00173             html.append( "<tr><td><img src=\"radius.png\" alt=\"icon\"/></td><td>" );
00174             html.append( i18n( "Covalent Radius: %1", KalziumUtils::prettyUnit( m_element, ChemicalDataObject::radiusCovalent ) ) );
00175             html.append( "</td></tr>" );
00176             // van der Waals radius
00177             html.append( "<tr><td><img src=\"radius.png\" alt=\"icon\"/></td><td>" );
00178             html.append( i18n( "van der Waals Radius: %1", KalziumUtils::prettyUnit( m_element, ChemicalDataObject::radiusVDW ) ) );
00179             html.append( "</td></tr>" );
00180             html.append( "<tr><td stype=\"text-align:center\"><img src=\"mass.png\" alt=\"icon\"/></td><td>" );
00181             html.append( i18n( "Mass: %1", KalziumUtils::prettyUnit( m_element, ChemicalDataObject::mass ) ) );
00182             html.append( "</td></tr>" );
00183             break;
00184         }
00185         case MISC:
00186         {
00187             // discovery date and discoverers
00188             html.append( "<tr><td><img src=\"discovery.png\" alt=\"icon\"/></td><td>" );
00189             html += KalziumUtils::prettyUnit( m_element, ChemicalDataObject::date );
00190             QString discoverers = m_element->dataAsString( ChemicalDataObject::discoverers );
00191             if ( !discoverers.isEmpty() )
00192             {
00193                 discoverers = discoverers.replace( ";", ", " );
00194                 html += "<br />" + i18n( "It was discovered by %1.", discoverers );
00195             }
00196             html.append( "</td></tr>" );
00197             html.append( "<tr><td><img src=\"mass.png\" alt=\"icon\"/></td><td>" );
00198             double mass = m_element->dataAsVariant( ChemicalDataObject::mass ).toDouble();
00199             double neutrons = m_element->dataAsVariant( ChemicalDataObject::atomicNumber ).toInt();
00200             html.append( i18n( "Mean mass: %1 u", mass/neutrons) );
00201             html.append( "</td></tr>" );
00202             // origin of the name
00203             QString nameorigin = m_element->dataAsString( ChemicalDataObject::nameOrigin );
00204             if ( !nameorigin.isEmpty() )
00205             {
00206                 html.append( "<tr><td><img src=\"book.png\" alt=\"icon\"/></td><td>" );
00207                 html.append( i18n( "Origin of the name:<br/>%1", nameorigin ) );
00208                 html.append( "</td></tr>" );
00209             }
00210 //X             if ( m_element->artificial() || m_element->radioactive() )
00211 //X             {
00212 //X                 html.append( "<tr><td><img src=\"structure.png\" alt=\"icon\"/></td><td>" );
00213 //X                 if ( !m_element->radioactive() )
00214 //X                     html.append( i18n( "This element is artificial" ));
00215 //X                 else if ( !m_element->artificial() )
00216 //X                     html.append( i18n( "This element is radioactive" ));
00217 //X                 else
00218 //X                     html.append( i18n( "This element is radioactive and artificial" ));
00219 //X                 html.append( "</td></tr>" );
00220 //X             }
00221             break;
00222         }
00223         case ENERGY:
00224         {
00225             // melting point
00226             html.append( "<tr><td><img src=\"meltingpoint.png\" alt=\"icon\"/></td><td>" );
00227             html.append( i18n( "Melting Point: %1", KalziumUtils::prettyUnit( m_element, ChemicalDataObject::meltingpoint ) ) );
00228             html.append( "</td></tr>" );
00229             // boiling point
00230             html.append( "<tr><td><img src=\"boilingpoint.png\" alt=\"icon\"/></td><td>" );
00231             html.append( i18n( "Boiling Point: %1", KalziumUtils::prettyUnit( m_element, ChemicalDataObject::boilingpoint ) ) );
00232             html.append( "</td></tr>" );
00233             // electro negativity
00234             html.append( "<tr><td><img src=\"structure.png\" alt=\"icon\"/></td><td>" );
00235             html.append( i18n( "Electronegativity: %1", KalziumUtils::prettyUnit( m_element, ChemicalDataObject::electronegativityPauling ) ) );
00236             html.append( "</td></tr>" );
00237             // electro affinity
00238             html.append( "<tr><td><img src=\"electronaffinity.png\" alt=\"icon\"/></td><td>" );
00239             html.append( i18n( "Electron Affinity: %1", KalziumUtils::prettyUnit( m_element, ChemicalDataObject::electronAffinity ) ) );
00240             html.append( "</td></tr>" );
00241             // 1st ionization energy
00242             html.append( "<tr><td><img src=\"ionisation.png\" alt=\"icon\"/></td><td>" );
00243             html.append( i18n( "First Ionization energy: %1", KalziumUtils::prettyUnit( m_element, ChemicalDataObject::ionization ) ) );
00244             html.append( "</td></tr>" );
00245             break;
00246         }
00247         case ISOTOPES:
00248         {
00249                 html.append( "<tr><td>" );
00250                 html.append( isotopeTable() );
00251                 html.append( "</td></tr>" );
00252             break;
00253         }
00254         case DATA:
00255         {
00256             html.append( i18n( "<tr><th colspan=\"2\" align=\"left\">Compound properties</th></tr>" ) );
00257             //Compound Data
00258             // melting point
00259             html.append( "<tr><td><img src=\"meltingpoint.png\" alt=\"icon\"/></td><td>" );
00260             html.append( i18n( "Melting Point: %1", KalziumUtils::prettyUnit( m_element, ChemicalDataObject::meltingpoint ) ) );
00261             html.append( "</td></tr>" );
00262 
00263             // boiling point
00264             html.append( "<tr><td><img src=\"boilingpoint.png\" alt=\"icon\"/></td><td>" );
00265             html.append( i18n( "Boiling Point: %1", KalziumUtils::prettyUnit( m_element, ChemicalDataObject::boilingpoint ) ) );
00266             html.append( "</td></tr>" );
00267             
00268             html.append( "</table>" );
00269             html.append( "<table summary=\"characteristics\" class=\"characterstics\">" );
00270 
00271             //Atomic Data
00272             html.append( i18n( "<tr><th colspan=\"2\" align=\"left\">Atomic properties</th></tr>" ) );
00273             // electro affinity
00274             html.append( "<tr><td><img src=\"electronaffinity.png\" alt=\"icon\"/></td><td>" );
00275             html.append( i18n( "Electron Affinity: %1", KalziumUtils::prettyUnit( m_element, ChemicalDataObject::electronAffinity ) ) );
00276             html.append( "</td></tr>" );
00277             
00278             //Density
00279             html.append( "<tr><td><img src=\"density.png\" alt=\"icon\"/></td><td>" );
00280             html.append( i18n( "Density: %1", KalziumUtils::prettyUnit( m_element, ChemicalDataObject::density ) ) );
00281             html.append( "</td></tr>" );
00282             
00283             //Electronic configuration
00284             html.append( "<tr><td><img src=\"structure.png\" alt=\"icon\"/></td><td>" );
00285                //Probably beautify here...
00286             QString config = m_element->dataAsString( ChemicalDataObject::electronicConfiguration );
00287             html.append( i18n( "Electronic configuration: %1", config ) );
00288             html.append( "</td></tr>" );
00289             
00290             // covalent radius
00291             html.append( "<tr><td><img src=\"radius.png\" alt=\"icon\"/></td><td>" );
00292             html.append( i18n( "Covalent Radius: %1", KalziumUtils::prettyUnit( m_element, ChemicalDataObject::radiusCovalent ) ) );
00293             html.append( "</td></tr>" );
00294             
00295             // van der Waals radius
00296             html.append( "<tr><td><img src=\"radius.png\" alt=\"icon\"/></td><td>" );
00297             html.append( i18n( "van der Waals Radius: %1", KalziumUtils::prettyUnit( m_element, ChemicalDataObject::radiusVDW ) ) );
00298             html.append( "</td></tr>" );
00299             html.append( "<tr><td stype=\"text-align:center\"><img src=\"mass.png\" alt=\"icon\"/></td><td>" );
00300             html.append( i18n( "Mass: %1", KalziumUtils::prettyUnit( m_element, ChemicalDataObject::mass ) ) );
00301             html.append( "</td></tr>" );
00302         }
00303     }
00304 
00305     html += "</table></div></body></html>";
00306     
00307     return html;
00308 }
00309 
00310 QString DetailedInfoDlg::isotopeTable() const
00311 {
00312     QList<Isotope*> list = KalziumDataObject::instance()->isotopes( m_elementNumber );
00313 
00314     QString html;
00315 
00316     html = "<table class=\"isotopes\" cellspacing=\"0\"><tr><td colspan=\"7\">";
00317     html += i18n( "Isotope-Table" );
00318     html += "</tr></td><tr><td><b>";
00319     html += i18n( "Mass" );
00320     html += "</b></td><td><b>";
00321     html += i18n( "Neutrons" );
00322     html += "</b></td><td><b>";
00323     html += i18n( "Percentage" );
00324     html += "</b></td><td><b>";
00325     html += i18n( "Half-life period" );
00326     html += "</b></td><td><b>";
00327     html += i18n( "Energy and Mode of Decay" );
00328     html += "</b></td><td><b>";
00329     html += i18n( "Spin and Parity" );
00330     html += "</b></td><td><b>";
00331     html += i18n( "Magnetic Moment" );
00332     html += "</b></td></tr>";
00333 
00334     foreach( Isotope * isotope , list )
00335     {
00336         html.append( "<tr><td align=\"right\">" ); 
00337         if ( isotope->mass() > 0.0 )
00338             html.append( i18n( "%1 u", isotope->mass() ) );
00339         html.append( "</td><td>" );
00340         html.append( QString::number( (( isotope )->nucleons()-( isotope )->parentElementNumber()) ) );
00341         html.append( "</td><td>" );
00342         //      if ( ( isotope )->abundance() > 0.0 )
00343         if ( !( isotope )->abundance().isEmpty() )
00344             html.append( i18nc( "this can for example be '24%'", "%1%", ( isotope )->abundance() ) );
00345         html.append( "</td><td>" );
00346         //      if ( ( isotope )->halflife() > 0.0 )
00347         //FIXME: There's something (an object) missing...
00348         //          html.append( i18n( "%1 %2", ( isotope )->halflife(), ChemicalDataObject::unitAsString( )) );
00349         html.append( "</td><td>" );
00350         if ( ( isotope )->alphalikeliness() > 0.0){
00351             if ( ( isotope )->alphadecay() > 0.0 )
00352                 html.append( i18n( "%1 MeV", ( isotope )->alphadecay() ));
00353             html.append( i18n( " %1",  QChar( 945 ) ));
00354             if ( ( isotope )->alphalikeliness() < 100.0)
00355                 html.append( i18n( "(%1%)", ( isotope )->alphalikeliness()));
00356             if ( ( isotope )->betaminuslikeliness() > 0.0 || ( isotope )->betapluslikeliness() > 0.0 || ( isotope )->eclikeliness() > 0.0)
00357                 html.append( i18n( ", " ) );
00358         }
00359         if ( ( isotope )->betaminuslikeliness() > 0.0){
00360             if ( ( isotope )->betaminusdecay() > 0.0 )
00361                 html.append( i18n( "%1 MeV", ( isotope )->betaminusdecay() ));
00362             html.append( i18n( " %1<sup>-</sup>", QChar( 946 )  ));
00363             if ( ( isotope )->betaminuslikeliness() < 100.0)
00364                 html.append( i18n( "(%1%)", ( isotope )->betaminuslikeliness() ));
00365 
00366             if ( ( isotope )->betapluslikeliness() > 0.0 || ( isotope )->eclikeliness() > 0.0 )
00367                 html.append( i18n( ", " ) );
00368         }
00369         if ( ( isotope )->betapluslikeliness() > 0.0)   {
00370             if ( ( isotope )->betaplusdecay() > 0.0 )
00371                 html.append( i18n( "%1 MeV", ( isotope )->betaplusdecay() ));
00372             html.append( i18n( " %1<sup>+</sup>", QChar( 946 ) ));
00373             if ( ( isotope )->betapluslikeliness() == ( isotope )->eclikeliness() ) {
00374                 if ( ( isotope )->ecdecay() > 0.0 ) {
00375                     html.append( i18n( "%1 MeV", ( isotope )->ecdecay() )); }
00376                 html.append( i18nc( "Acronym of Electron Capture"," EC" ) ); 
00377             }
00378             if ( ( isotope )->betapluslikeliness() < 100.0) 
00379                 html.append( i18n( "(%1%)", ( isotope )->betapluslikeliness() )); 
00380             html += ' ';
00381         }
00382         if ( ( isotope )->eclikeliness() > 0.0 ){
00383             if ( ( isotope )->ecdecay() > 0.0 )
00384                 html.append( i18n( "%1 MeV", ( isotope )->ecdecay()  ));
00385             html.append( i18nc( "Acronym of Electron Capture"," EC" ) );
00386             if ( ( isotope )->eclikeliness() < 100.0 )
00387                 html.append( i18n( "(%1%)", ( isotope )->eclikeliness() ));
00388         }
00389         html.append( "</td><td>" );
00390         html.append( ( isotope )->spin() );
00391         html.append( "</td><td>" );
00392         if ( !( isotope )->magmoment().isEmpty() )
00393             html.append( i18n( "%1 %2<sub>n</sub>", ( isotope )->magmoment(), QChar( 956 ) ) );
00394         html.append( "</td></tr>" );
00395 
00396     }
00397 
00398     html += "</table>";
00399 
00400     return html;
00401 }
00402 
00403 void DetailedInfoDlg::createContent()
00404 {
00405     KPageWidgetItem *item = 0;
00406 
00407     // overview tab
00408     QWidget *m_pOverviewTab = new QWidget();
00409     item = addPage( m_pOverviewTab, i18n( "Overview" ) );
00410     item->setHeader( i18n( "Overview" ) );
00411     item->setIcon( KIcon( "overview" ) );
00412     QVBoxLayout *overviewLayout = new QVBoxLayout( m_pOverviewTab );
00413     overviewLayout->setMargin( 0 );
00414     dTab = new DetailedGraphicalOverview( m_pOverviewTab );
00415     dTab->setObjectName( "DetailedGraphicalOverview" );
00416     overviewLayout->addWidget( dTab );
00417 
00418 //X     // picture tab
00419 //X     QWidget *m_pPictureTab = new QWidget();
00420 //X     item = addPage( m_pPictureTab, i18n( "Picture" ) );
00421 //X     item->setHeader( i18n( "What does this element look like?" ) );
00422 //X     item->setIcon( KIcon( "elempic" ) );
00423 //X     QVBoxLayout *mainLayout = new QVBoxLayout( m_pPictureTab );
00424 //X     mainLayout->setMargin( 0 );
00425 //X     piclabel = new QLabel( m_pPictureTab );
00426 //X     piclabel->setMinimumSize( 400, 350 );
00427 //X     mainLayout->addWidget( piclabel );
00428 
00429     // atomic model tab
00430     QWidget *m_pModelTab = new QWidget();
00431     item = addPage( m_pModelTab, i18n( "Atom Model" ) );
00432     item->setHeader( i18n( "Atom Model" ) );
00433     item->setIcon( KIcon( "orbits" ) );
00434     QVBoxLayout *modelLayout = new QVBoxLayout( m_pModelTab );
00435     modelLayout->setMargin( 0 );
00436     wOrbits = new OrbitsWidget( m_pModelTab );
00437     modelLayout->addWidget( wOrbits );
00438 
00439     // html tabs
00440 //X m_htmlpages["chemical"] = addHTMLTab( i18n( "Chemical Data" ), i18n( "Chemical Data" ), "chemical" );
00441 //X m_htmlpages["energies"] = addHTMLTab( i18n( "Energies" ), i18n( "Energy Information" ), "energies" );
00442     m_htmlpages["misc"] = addHTMLTab( i18n( "Miscellaneous" ), i18n( "Miscellaneous" ), "misc" );
00443     m_htmlpages["isotopes"] = addHTMLTab( i18n( "Isotopes" ), i18n( "Isotopes" ), "isotopes" );
00444 //X m_htmlpages["warnings"] = addHTMLTab( i18n( "Warnings" ), i18n( "Warnings" ), "warnings" );
00445     m_htmlpages["new"] = addHTMLTab( i18n( "Data Overview" ), i18n( "Data Overview" ), "data" );
00446 
00447     // spectrum widget tab
00448 //X     QWidget *m_pSpectrumTab = new QWidget();
00449 //X     item = addPage( m_pSpectrumTab, i18n( "Spectrum" ) );
00450 //X     item->setHeader( i18n( "Spectrum" ) );
00451 //X     item->setIcon( KIcon( "spectrum" ) );
00452 //X     QVBoxLayout *spectrumLayout = new QVBoxLayout( m_pSpectrumTab );
00453 //X     spectrumLayout->setMargin( 0 );
00454 //X     m_spectrumStack = new QStackedWidget( m_pSpectrumTab );
00455 //X     spectrumLayout->addWidget( m_spectrumStack );
00456 //X     m_spectrumview = new SpectrumViewImpl( m_spectrumStack );
00457 //X     m_spectrumview->setObjectName( "spectrumwidget" );
00458 //X     m_spectrumStack->addWidget( m_spectrumview );
00459 //X     m_spectrumLabel = new QLabel( m_spectrumStack );
00460 //X     m_spectrumStack->addWidget( m_spectrumLabel );
00461 }
00462 
00463 void DetailedInfoDlg::reloadContent()
00464 {
00465     // reading the most common data
00466     const QString element_name = m_element->dataAsString( ChemicalDataObject::name );
00467     const QString element_symbol = m_element->dataAsString( ChemicalDataObject::symbol );
00468 
00469     // updating caption
00470     setCaption( i18nc( "For example Carbon (6)" , "%1 (%2)", element_name, m_elementNumber ) );
00471 
00472     // updating overview tab
00473     dTab->setElement( m_elementNumber );
00474 
00475     //X     // updating picture tab
00476     //X     QString picpath = m_picsdir + element_symbol + ".jpg";
00477     //X     if ( QFile::exists( picpath ) )
00478     //X     {
00479     //X         QImage img( picpath, "JPEG" );
00480     //X         img = img.scaled( 400, 400, Qt::KeepAspectRatio );
00481     //X         piclabel->setPixmap( QPixmap::fromImage( img ) );
00482     //X     }
00483     //X     else 
00484     //X         piclabel->setText( i18n( "No picture of %1 found.", element_name ) );
00485 
00486     // updating atomic model tab
00487     wOrbits->setElementNumber( m_elementNumber );
00488     /*
00489        wOrbits->setWhatsThis(
00490        i18n( "Here you can see the atomic hull of %1. %2 has the configuration %3." )
00491        .arg( m_element->dataAsString( ChemicalDataObject::name ) )
00492        .arg( m_element->dataAsString( ChemicalDataObject::name ) )
00493        .arg( "" ));//m_element->parsedOrbits() ) );
00494        */
00495 
00496     // updating html tabs
00497     //  fillHTMLTab( m_htmlpages["chemical"], getHtml( CHEMICAL ) );
00498     //  fillHTMLTab( m_htmlpages["energies"], getHtml( ENERGY ) );
00499     fillHTMLTab( m_htmlpages["new"], getHtml( DATA ) );
00500     fillHTMLTab( m_htmlpages["misc"], getHtml( MISC ) );
00501     fillHTMLTab( m_htmlpages["isotopes"], getHtml( ISOTOPES ) );
00502 
00503 //X     Spectrum*s = new Spectrum();
00504 //X     s->addPeak( new Spectrum::peak(400,300) );
00505 //X     s->addPeak( new Spectrum::peak(450,500) );
00506 //X     s->addPeak( new Spectrum::peak(455,500) );
00507 //X     s->addPeak( new Spectrum::peak(470,100) );
00508 //X     s->addPeak( new Spectrum::peak(490,50) );
00509 //X     s->addPeak( new Spectrum::peak(500,600) );
00510 //X     s->addPeak( new Spectrum::peak(550,700) );
00511 //X     s->adjustIntensities();
00512 //X 
00513 //X     m_element->setSpectrum( s );
00514 //X 
00515 //X     // updating spectrum widget
00516 //X     if ( m_element->spectrum() )
00517 //X     {
00518 //X         m_spectrumview->setSpectrum( m_element->spectrum() );
00519 //X     }
00520 //X     else
00521 //X     {
00522 //X         m_spectrumLabel->setText( i18n( "No spectrum of %1 found.", element_name ) );
00523 //X         m_spectrumStack->setCurrentWidget( m_spectrumLabel );
00524 //X     }
00525 }
00526 
00527 void DetailedInfoDlg::slotHelp()
00528 {
00529     //TODO fix this stuff...
00530 #if 0
00531     QString chapter = "infodialog_overview";
00532     switch ( activePageIndex() )
00533     {
00534         case 0:
00535             chapter = "infodialog_overview";
00536             break;
00537         case 1:
00538              chapter = "infodialog_orbits";
00539             break;
00540         case 2:
00541              chapter = "infodialog_chemical";
00542             break;
00543         case 3:
00544              chapter = "infodialog_energies";
00545             break;
00546         case 4:
00547              chapter = "infodialog_misc";
00548             break;
00549         case 5:
00550              chapter = "infodialog_spectrum";
00551             break;
00552         case 6:
00553              chapter = "infodialog_warnings";
00554             break;
00555     }
00556 #endif
00557     KToolInvocation::invokeHelp( "infodialog_spectrum", QLatin1String( "kalzium" ) );
00558 }
00559 
00560 void DetailedInfoDlg::slotUser1()
00561 {
00562     setElement( m_ktt->nextOf( m_elementNumber ) );
00563 }
00564 
00565 void DetailedInfoDlg::slotUser2()
00566 {
00567     setElement( m_ktt->previousOf( m_elementNumber ) );
00568 }
00569 
00570 #include "detailinfodlg.moc"

kalzium

Skip menu "kalzium"
  • Main Page
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Namespace Members
  • Class Members
  • Related Pages

kdeedu

Skip menu "kdeedu"
  • kalzium
  • kanagram
  • kig
  • klettres
  • kstars
  • libkdeedu
  •   keduvocdocument
  •   docs
  •   src
  • parley
Generated for kdeedu by doxygen 1.5.4
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal