File indexing completed on 2022-09-27 12:24:08

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