File indexing completed on 2024-04-21 03:41:41

0001 /*
0002     SPDX-FileCopyrightText: 2003, 2004, 2005, 2006 Carsten Niehaus <cniehaus@kde.org>
0003     SPDX-License-Identifier: GPL-2.0-or-later
0004 */
0005 
0006 #ifndef DETAILINFODLG_H
0007 #define DETAILINFODLG_H
0008 
0009 #include <QMap>
0010 
0011 #include <KPageDialog>
0012 
0013 class DetailedGraphicalOverview;
0014 class Element;
0015 class OrbitsWidget;
0016 class SpectrumViewImpl;
0017 
0018 class KActionCollection;
0019 class QLabel;
0020 class QStackedWidget;
0021 class QTextBrowser;
0022 class KHTMLPart;
0023 
0024 /**
0025  * @brief The dialog which shows all available information of an element
0026  * @author Carsten Niehaus
0027  */
0028 class DetailedInfoDlg : public KPageDialog
0029 {
0030     Q_OBJECT
0031 
0032 public:
0033     explicit DetailedInfoDlg(int el, QWidget *parent = nullptr);
0034     ~DetailedInfoDlg() override;
0035 
0036     void setElement(int el);
0037 
0038     //     void setOverviewBackgroundColor(const QColor &bgColor);
0039 
0040     void setTableType(int ktt);
0041 
0042     /**
0043      * add <sup></sup> to the numbers
0044      @return the beatified string
0045      */
0046     QString beautifyOrbitalString(const QString &orbits);
0047 
0048 private:
0049     enum DATATYPE {
0050         MISC = 0,
0051         ISOTOPES,
0052         DATA, /** <the overview about atomic and compound data */
0053         EXTRA /** Links to wikipedia and other sites where useful information can be found*/
0054     };
0055 
0056     Element *m_element;
0057     int m_elementNumber;
0058 
0059     KActionCollection *m_actionCollection;
0060 
0061     SpectrumViewImpl *m_spectrumview;
0062     QStackedWidget *m_spectrumStack;
0063     QLabel *m_spectrumLabel;
0064 
0065     QString isotopeTable() const;
0066 
0067     DetailedGraphicalOverview *dTab;
0068     // X         QLabel *piclabel;
0069     OrbitsWidget *wOrbits;
0070     QMap<QString, QTextBrowser *> m_htmlpages;
0071 
0072     int m_tableTyp;
0073 
0074     /**
0075      * Create the initial set of tabs. Used it *ONLY* once in the
0076      * constructor.
0077      */
0078     void createContent();
0079     void reloadContent();
0080 
0081     QString getHtml(DATATYPE);
0082 
0083     QString m_baseHtml;
0084     QString m_baseHtml2;
0085     // X         QString m_picsdir;
0086 
0087     /**
0088      * Add a new HTML page to the dialog.
0089      *
0090      * @param title The title of the tab, appears above the htmlview
0091      * @param icontext The name of the tab, appears belov or instead
0092      * of the icon
0093      * @param iconname The name of the icon
0094      * @returns the pointer to the resulting KHTMLPart, needed for
0095      * writing HTML code on it
0096      */
0097     QTextBrowser *addHTMLTab(const QString &title, const QString &icontext, const QString &iconname);
0098     /**
0099      * Change the HTML code in an HTML page.
0100      *
0101      * @param browser the QTextBrowser to edit
0102      * @param htmlcode the HTML code to display
0103      */
0104     void fillHTMLTab(QTextBrowser *browser, const QString &htmlcode);
0105 
0106     /**
0107      * Creates a localized link to Wikipedia.
0108      * https://en.wikipedia.org/wiki/link"
0109      * @param link the link inside wikipedia
0110      * @param displayString the displayed string to click on.
0111      */
0112     QString createWikiLink(QString link, QString displayString);
0113 
0114     /// overloaded function to add link as the displayed String
0115     QString createWikiLink(QString link);
0116 
0117 private Q_SLOTS:
0118     void showNextElement();
0119     void showPreviousElement();
0120     /**
0121      * invoke the help of the correct chapter
0122      */
0123     virtual void slotHelp();
0124 
0125 Q_SIGNALS:
0126     void elementChanged(int);
0127 };
0128 
0129 #endif // DETAILINFODLG_H