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

0001 /*
0002     SPDX-FileCopyrightText: 2006, 2008 Carsten Niehaus <cniehaus@kde.org>
0003 
0004     SPDX-License-Identifier: GPL-2.0-or-later
0005 */
0006 
0007 #include "rsdialog.h"
0008 
0009 #include <QDialogButtonBox>
0010 #include <QPushButton>
0011 #include <QRegularExpression>
0012 #include <QVBoxLayout>
0013 
0014 #include "kalziumdataobject.h"
0015 #include "kalziumutils.h"
0016 
0017 #include <KConfigGroup>
0018 #include <KHelpClient>
0019 #include <KLocalizedString>
0020 #include <KMessageBox>
0021 
0022 RSDialog::RSDialog(QWidget *parent)
0023     : QDialog(parent)
0024 {
0025     setWindowTitle(i18nc("@title:window", "Risks/Security Phrases"));
0026     auto buttonBox = new QDialogButtonBox(QDialogButtonBox::Help | QDialogButtonBox::Close, this);
0027     auto mainWidget = new QWidget(this);
0028     auto mainLayout = new QVBoxLayout(this);
0029     mainLayout->addWidget(mainWidget);
0030     connect(buttonBox, &QDialogButtonBox::rejected, this, &RSDialog::reject);
0031     mainLayout->addWidget(buttonBox);
0032 
0033     createRPhrases();
0034     createSPhrases();
0035 
0036     ui.setupUi(mainWidget);
0037 
0038     connect(ui.filterButton, &QAbstractButton::clicked, this, &RSDialog::filter);
0039     connect(buttonBox, &QDialogButtonBox::helpRequested, this, &RSDialog::slotHelp);
0040 
0041     filter();
0042 }
0043 
0044 void RSDialog::filter()
0045 {
0046     // if the RS sentence starts or ends with a - invalidate it.
0047     // It is probably an user error
0048     if (ui.r_le->text().startsWith('-') || ui.r_le->text().endsWith('-') || ui.s_le->text().startsWith('-') || ui.s_le->text().endsWith('-')) {
0049         invalidPhaseString();
0050         return;
0051     }
0052 
0053     QList<int> r;
0054     QList<int> s;
0055 
0056     // for now only separation by a - is allowed
0057     if (!ui.r_le->text().isEmpty()) {
0058         const QStringList rSplit = ui.r_le->text().split('-');
0059         for (const QString &st : rSplit) {
0060             r << st.toInt();
0061         }
0062     }
0063 
0064     // for now only separation by a - is allowed
0065     if (!ui.s_le->text().isEmpty()) {
0066         const QStringList sSplit = ui.s_le->text().split('-');
0067         for (const QString &st : sSplit) {
0068             s << st.toInt();
0069         }
0070     }
0071 
0072     filterRS(r, s);
0073 }
0074 
0075 void RSDialog::filterRS(const QList<int> &r, const QList<int> &s)
0076 {
0077     QString string(QStringLiteral("<qt>"));
0078 
0079     if (!r.isEmpty()) {
0080         string.append("<h2>" + i18n("R-Phrases:") + "</h2>");
0081         for (int i : r) {
0082             QString phrase("<b>" + QString::number(i) + " - ");
0083             phrase.append(rphrase(i) + "</b>");
0084             string.append(phrase + "<br>");
0085         }
0086     }
0087     if (!s.isEmpty()) {
0088         string.append("<h2>" + i18n("S-Phrases:") + "</h2>");
0089         for (int i : s) {
0090             QString phrase("<b>" + QString::number(i) + " -  ");
0091             phrase.append(sphrase(i) + "</b>");
0092             string.append(phrase + "<br>");
0093         }
0094     }
0095     if (s.isEmpty() && r.isEmpty())
0096         string.append("<h2>" + i18n("You asked for no R/S-Phrases.") + "</h2>");
0097 
0098     string.append("</qt>");
0099 
0100     ui.text->setHtml(string);
0101 }
0102 
0103 QString RSDialog::rphrase(int number)
0104 {
0105     QString p;
0106 
0107     QMap<int, QString>::const_iterator i = rphrases_map.constBegin();
0108     while (i != rphrases_map.constEnd()) {
0109         if (i.key() == number) {
0110             return i.value();
0111         }
0112 
0113         ++i;
0114     }
0115 
0116     return p;
0117 }
0118 
0119 QString RSDialog::sphrase(int number)
0120 {
0121     QString p;
0122 
0123     QMap<int, QString>::const_iterator i = sphrases_map.constBegin();
0124     while (i != sphrases_map.constEnd()) {
0125         if (i.key() == number) {
0126             return i.value();
0127         }
0128 
0129         ++i;
0130     }
0131 
0132     return p;
0133 }
0134 
0135 void RSDialog::createSPhrases()
0136 {
0137     QStringList sphrases;
0138     sphrases << i18nc(
0139         "Please take the official translations! You find them here: https://eur-lex.europa.eu/LexUriServ/LexUriServ.do?uri=CELEX:32001L0059:EN:HTML",
0140         "S1: Keep locked up");
0141     sphrases << i18nc(
0142         "Please take the official translations! You find them here: https://eur-lex.europa.eu/LexUriServ/LexUriServ.do?uri=CELEX:32001L0059:EN:HTML",
0143         "S2: Keep out of the reach of children");
0144     sphrases << i18nc(
0145         "Please take the official translations! You find them here: https://eur-lex.europa.eu/LexUriServ/LexUriServ.do?uri=CELEX:32001L0059:EN:HTML",
0146         "S3: Keep in a cool place");
0147     sphrases << i18nc(
0148         "Please take the official translations! You find them here: https://eur-lex.europa.eu/LexUriServ/LexUriServ.do?uri=CELEX:32001L0059:EN:HTML",
0149         "S4: Keep away from living quarters");
0150     sphrases << i18nc(
0151         "Please take the official translations! You find them here: https://eur-lex.europa.eu/LexUriServ/LexUriServ.do?uri=CELEX:32001L0059:EN:HTML",
0152         "S5: Keep contents under ... ( appropriate liquid to be specified by the manufacturer )");
0153     sphrases << i18nc(
0154         "Please take the official translations! You find them here: https://eur-lex.europa.eu/LexUriServ/LexUriServ.do?uri=CELEX:32001L0059:EN:HTML",
0155         "S6: Keep under ... ( inert gas to be specified by the manufacturer )");
0156     sphrases << i18nc(
0157         "Please take the official translations! You find them here: https://eur-lex.europa.eu/LexUriServ/LexUriServ.do?uri=CELEX:32001L0059:EN:HTML",
0158         "S7: Keep container tightly closed");
0159     sphrases << i18nc(
0160         "Please take the official translations! You find them here: https://eur-lex.europa.eu/LexUriServ/LexUriServ.do?uri=CELEX:32001L0059:EN:HTML",
0161         "S8: Keep container dry");
0162     sphrases << i18nc(
0163         "Please take the official translations! You find them here: https://eur-lex.europa.eu/LexUriServ/LexUriServ.do?uri=CELEX:32001L0059:EN:HTML",
0164         "S9: Keep container in a well-ventilated place");
0165     sphrases << i18nc(
0166         "Please take the official translations! You find them here: https://eur-lex.europa.eu/LexUriServ/LexUriServ.do?uri=CELEX:32001L0059:EN:HTML",
0167         "S12: Do not keep the container sealed");
0168     sphrases << i18nc(
0169         "Please take the official translations! You find them here: https://eur-lex.europa.eu/LexUriServ/LexUriServ.do?uri=CELEX:32001L0059:EN:HTML",
0170         "S13: Keep away from food, drink and animal feedingstuffs");
0171     sphrases << i18nc(
0172         "Please take the official translations! You find them here: https://eur-lex.europa.eu/LexUriServ/LexUriServ.do?uri=CELEX:32001L0059:EN:HTML",
0173         "S14: Keep away from ... ( incompatible materials to be indicated by the manufacturer )");
0174     sphrases << i18nc(
0175         "Please take the official translations! You find them here: https://eur-lex.europa.eu/LexUriServ/LexUriServ.do?uri=CELEX:32001L0059:EN:HTML",
0176         "S15: Keep away from heat");
0177     sphrases << i18nc(
0178         "Please take the official translations! You find them here: https://eur-lex.europa.eu/LexUriServ/LexUriServ.do?uri=CELEX:32001L0059:EN:HTML",
0179         "S16: Keep away from sources of ignition - No smoking");
0180     sphrases << i18nc(
0181         "Please take the official translations! You find them here: https://eur-lex.europa.eu/LexUriServ/LexUriServ.do?uri=CELEX:32001L0059:EN:HTML",
0182         "S17: Keep away from combustible material");
0183     sphrases << i18nc(
0184         "Please take the official translations! You find them here: https://eur-lex.europa.eu/LexUriServ/LexUriServ.do?uri=CELEX:32001L0059:EN:HTML",
0185         "S18: Handle and open container with care");
0186     sphrases << i18nc(
0187         "Please take the official translations! You find them here: https://eur-lex.europa.eu/LexUriServ/LexUriServ.do?uri=CELEX:32001L0059:EN:HTML",
0188         "S20: When using do not eat or drink");
0189     sphrases << i18nc(
0190         "Please take the official translations! You find them here: https://eur-lex.europa.eu/LexUriServ/LexUriServ.do?uri=CELEX:32001L0059:EN:HTML",
0191         "S21: When using do not smoke");
0192     sphrases << i18nc(
0193         "Please take the official translations! You find them here: https://eur-lex.europa.eu/LexUriServ/LexUriServ.do?uri=CELEX:32001L0059:EN:HTML",
0194         "S22: Do not breathe dust");
0195     sphrases << i18nc(
0196         "Please take the official translations! You find them here: https://eur-lex.europa.eu/LexUriServ/LexUriServ.do?uri=CELEX:32001L0059:EN:HTML",
0197         "S23: Do not breathe gas/fumes/vapour/spray ( appropriate wording to be specified by the manufacturer )");
0198     sphrases << i18nc(
0199         "Please take the official translations! You find them here: https://eur-lex.europa.eu/LexUriServ/LexUriServ.do?uri=CELEX:32001L0059:EN:HTML",
0200         "S24: Avoid contact with skin");
0201     sphrases << i18nc(
0202         "Please take the official translations! You find them here: https://eur-lex.europa.eu/LexUriServ/LexUriServ.do?uri=CELEX:32001L0059:EN:HTML",
0203         "S25: Avoid contact with eyes");
0204     sphrases << i18nc(
0205         "Please take the official translations! You find them here: https://eur-lex.europa.eu/LexUriServ/LexUriServ.do?uri=CELEX:32001L0059:EN:HTML",
0206         "S26: In case of contact with eyes, rinse immediately with plenty of water and seek medical advice");
0207     sphrases << i18nc(
0208         "Please take the official translations! You find them here: https://eur-lex.europa.eu/LexUriServ/LexUriServ.do?uri=CELEX:32001L0059:EN:HTML",
0209         "S27: Take off immediately all contaminated clothing");
0210     sphrases << i18nc(
0211         "Please take the official translations! You find them here: https://eur-lex.europa.eu/LexUriServ/LexUriServ.do?uri=CELEX:32001L0059:EN:HTML",
0212         "S28: After contact with skin, wash immediately with plenty of ... ( to be specified by the manufacturer )");
0213     sphrases << i18nc(
0214         "Please take the official translations! You find them here: https://eur-lex.europa.eu/LexUriServ/LexUriServ.do?uri=CELEX:32001L0059:EN:HTML",
0215         "S29: Do not empty into drains");
0216     sphrases << i18nc(
0217         "Please take the official translations! You find them here: https://eur-lex.europa.eu/LexUriServ/LexUriServ.do?uri=CELEX:32001L0059:EN:HTML",
0218         "S30: Never add water to this product");
0219     sphrases << i18nc(
0220         "Please take the official translations! You find them here: https://eur-lex.europa.eu/LexUriServ/LexUriServ.do?uri=CELEX:32001L0059:EN:HTML",
0221         "S33: Take precautionary measures against static discharges");
0222     sphrases << i18nc(
0223         "Please take the official translations! You find them here: https://eur-lex.europa.eu/LexUriServ/LexUriServ.do?uri=CELEX:32001L0059:EN:HTML",
0224         "S35: This material and its container must be disposed of in a safe way");
0225     sphrases << i18nc(
0226         "Please take the official translations! You find them here: https://eur-lex.europa.eu/LexUriServ/LexUriServ.do?uri=CELEX:32001L0059:EN:HTML",
0227         "S36: Wear suitable protective clothing");
0228     sphrases << i18nc(
0229         "Please take the official translations! You find them here: https://eur-lex.europa.eu/LexUriServ/LexUriServ.do?uri=CELEX:32001L0059:EN:HTML",
0230         "S37: Wear suitable gloves");
0231     sphrases << i18nc(
0232         "Please take the official translations! You find them here: https://eur-lex.europa.eu/LexUriServ/LexUriServ.do?uri=CELEX:32001L0059:EN:HTML",
0233         "S38: In case of insufficient ventilation wear suitable respiratory equipment");
0234     sphrases << i18nc(
0235         "Please take the official translations! You find them here: https://eur-lex.europa.eu/LexUriServ/LexUriServ.do?uri=CELEX:32001L0059:EN:HTML",
0236         "S39: Wear eye/face protection");
0237     sphrases << i18nc(
0238         "Please take the official translations! You find them here: https://eur-lex.europa.eu/LexUriServ/LexUriServ.do?uri=CELEX:32001L0059:EN:HTML",
0239         "S40: To clean the floor and all objects contaminated by this material use ... ( to be specified by the manufacturer )");
0240     sphrases << i18nc(
0241         "Please take the official translations! You find them here: https://eur-lex.europa.eu/LexUriServ/LexUriServ.do?uri=CELEX:32001L0059:EN:HTML",
0242         "S41: In case of fire and/or explosion do not breathe fumes");
0243     sphrases << i18nc(
0244         "Please take the official translations! You find them here: https://eur-lex.europa.eu/LexUriServ/LexUriServ.do?uri=CELEX:32001L0059:EN:HTML",
0245         "S42: During fumigation/spraying wear suitable respiratory equipment ( appropriate wording to be specified by the manufacturer )");
0246     sphrases << i18nc(
0247         "Please take the official translations! You find them here: https://eur-lex.europa.eu/LexUriServ/LexUriServ.do?uri=CELEX:32001L0059:EN:HTML",
0248         "S43: In case of fire use ... ( indicate in the space the precise type of fire-fighting equipment. If water increases the risk add - Never use water "
0249         ")");
0250     sphrases << i18nc(
0251         "Please take the official translations! You find them here: https://eur-lex.europa.eu/LexUriServ/LexUriServ.do?uri=CELEX:32001L0059:EN:HTML",
0252         "S45: In case of accident or if you feel unwell seek medical advice immediately ( show the label where possible )");
0253     sphrases << i18nc(
0254         "Please take the official translations! You find them here: https://eur-lex.europa.eu/LexUriServ/LexUriServ.do?uri=CELEX:32001L0059:EN:HTML",
0255         "S46: If swallowed, seek medical advice immediately and show this container or label");
0256     sphrases << i18nc(
0257         "Please take the official translations! You find them here: https://eur-lex.europa.eu/LexUriServ/LexUriServ.do?uri=CELEX:32001L0059:EN:HTML",
0258         "S47: Keep at temperature not exceeding ... °C ( to be specified by the manufacturer )");
0259     sphrases << i18nc(
0260         "Please take the official translations! You find them here: https://eur-lex.europa.eu/LexUriServ/LexUriServ.do?uri=CELEX:32001L0059:EN:HTML",
0261         "S48: Keep wet with ... ( appropriate material to be specified by the manufacturer )");
0262     sphrases << i18nc(
0263         "Please take the official translations! You find them here: https://eur-lex.europa.eu/LexUriServ/LexUriServ.do?uri=CELEX:32001L0059:EN:HTML",
0264         "S49: Keep only in the original container");
0265     sphrases << i18nc(
0266         "Please take the official translations! You find them here: https://eur-lex.europa.eu/LexUriServ/LexUriServ.do?uri=CELEX:32001L0059:EN:HTML",
0267         "S50: Do not mix with ... ( to be specified by the manufacturer )");
0268     sphrases << i18nc(
0269         "Please take the official translations! You find them here: https://eur-lex.europa.eu/LexUriServ/LexUriServ.do?uri=CELEX:32001L0059:EN:HTML",
0270         "S51: Use only in well-ventilated areas");
0271     sphrases << i18nc(
0272         "Please take the official translations! You find them here: https://eur-lex.europa.eu/LexUriServ/LexUriServ.do?uri=CELEX:32001L0059:EN:HTML",
0273         "S52: Not recommended for interior use on large surface areas");
0274     sphrases << i18nc(
0275         "Please take the official translations! You find them here: https://eur-lex.europa.eu/LexUriServ/LexUriServ.do?uri=CELEX:32001L0059:EN:HTML",
0276         "S53: Avoid exposure - obtain special instructions before use");
0277     sphrases << i18nc(
0278         "Please take the official translations! You find them here: https://eur-lex.europa.eu/LexUriServ/LexUriServ.do?uri=CELEX:32001L0059:EN:HTML",
0279         "S56: Dispose of this material and its container at hazardous or special waste collection point");
0280     sphrases << i18nc(
0281         "Please take the official translations! You find them here: https://eur-lex.europa.eu/LexUriServ/LexUriServ.do?uri=CELEX:32001L0059:EN:HTML",
0282         "S57: Use appropriate containment to avoid environmental contamination");
0283     sphrases << i18nc(
0284         "Please take the official translations! You find them here: https://eur-lex.europa.eu/LexUriServ/LexUriServ.do?uri=CELEX:32001L0059:EN:HTML",
0285         "S59: Refer to manufacturer/supplier for information on recovery/recycling");
0286     sphrases << i18nc(
0287         "Please take the official translations! You find them here: https://eur-lex.europa.eu/LexUriServ/LexUriServ.do?uri=CELEX:32001L0059:EN:HTML",
0288         "S60: This material and its container must be disposed of as hazardous waste");
0289     sphrases << i18nc(
0290         "Please take the official translations! You find them here: https://eur-lex.europa.eu/LexUriServ/LexUriServ.do?uri=CELEX:32001L0059:EN:HTML",
0291         "S61: Avoid release to the environment. Refer to special instructions/safety data sheet");
0292     sphrases << i18nc(
0293         "Please take the official translations! You find them here: https://eur-lex.europa.eu/LexUriServ/LexUriServ.do?uri=CELEX:32001L0059:EN:HTML",
0294         "S62: If swallowed, do not induce vomiting: seek medical advice immediately and show this container or label");
0295     sphrases << i18nc(
0296         "Please take the official translations! You find them here: https://eur-lex.europa.eu/LexUriServ/LexUriServ.do?uri=CELEX:32001L0059:EN:HTML",
0297         "S63: In case of accident by inhalation: remove casualty to fresh air and keep at rest");
0298     sphrases << i18nc(
0299         "Please take the official translations! You find them here: https://eur-lex.europa.eu/LexUriServ/LexUriServ.do?uri=CELEX:32001L0059:EN:HTML",
0300         "S64: If swallowed, rinse mouth with water ( only if the person is conscious )");
0301 
0302     QRegularExpression reg("(R|S)(\\d+): (.*)");
0303 
0304     for (const QString &p : std::as_const(sphrases)) {
0305         int number = 0;
0306         QString phrase(QLatin1String(""));
0307         QRegularExpressionMatch match = reg.match(p);
0308 
0309         if (match.hasMatch()) {
0310             const QString part1 = match.captured(2);
0311             const QString part2 = match.captured(3);
0312 
0313             phrase = part2;
0314             number = part1.toInt();
0315         }
0316 
0317         sphrases_map.insert(number, phrase);
0318     }
0319 }
0320 
0321 void RSDialog::createRPhrases()
0322 {
0323     QStringList rphrases;
0324     rphrases << i18nc(
0325         "Please take the official translations! You find them here: https://eur-lex.europa.eu/LexUriServ/LexUriServ.do?uri=CELEX:32001L0059:EN:HTML",
0326         "R1: Explosive when dry");
0327     rphrases << i18nc(
0328         "Please take the official translations! You find them here: https://eur-lex.europa.eu/LexUriServ/LexUriServ.do?uri=CELEX:32001L0059:EN:HTML",
0329         "R2: Risk of explosion by shock, friction, fire or other sources of ignition");
0330     rphrases << i18nc(
0331         "Please take the official translations! You find them here: https://eur-lex.europa.eu/LexUriServ/LexUriServ.do?uri=CELEX:32001L0059:EN:HTML",
0332         "R3: Extreme risk of explosion by shock, friction, fire or other sources of ignition");
0333     rphrases << i18nc(
0334         "Please take the official translations! You find them here: https://eur-lex.europa.eu/LexUriServ/LexUriServ.do?uri=CELEX:32001L0059:EN:HTML",
0335         "R4: Forms very sensitive explosive metallic compounds");
0336     rphrases << i18nc(
0337         "Please take the official translations! You find them here: https://eur-lex.europa.eu/LexUriServ/LexUriServ.do?uri=CELEX:32001L0059:EN:HTML",
0338         "R5: Heating may cause an explosion");
0339     rphrases << i18nc(
0340         "Please take the official translations! You find them here: https://eur-lex.europa.eu/LexUriServ/LexUriServ.do?uri=CELEX:32001L0059:EN:HTML",
0341         "R6: Explosive with or without contact with air");
0342     rphrases << i18nc(
0343         "Please take the official translations! You find them here: https://eur-lex.europa.eu/LexUriServ/LexUriServ.do?uri=CELEX:32001L0059:EN:HTML",
0344         "R7: May cause fire");
0345     rphrases << i18nc(
0346         "Please take the official translations! You find them here: https://eur-lex.europa.eu/LexUriServ/LexUriServ.do?uri=CELEX:32001L0059:EN:HTML",
0347         "R8: Contact with combustible material may cause fire");
0348     rphrases << i18nc(
0349         "Please take the official translations! You find them here: https://eur-lex.europa.eu/LexUriServ/LexUriServ.do?uri=CELEX:32001L0059:EN:HTML",
0350         "R9: Explosive when mixed with combustible material");
0351     rphrases << i18nc(
0352         "Please take the official translations! You find them here: https://eur-lex.europa.eu/LexUriServ/LexUriServ.do?uri=CELEX:32001L0059:EN:HTML",
0353         "R10: Flammable");
0354     rphrases << i18nc(
0355         "Please take the official translations! You find them here: https://eur-lex.europa.eu/LexUriServ/LexUriServ.do?uri=CELEX:32001L0059:EN:HTML",
0356         "R11: Highly flammable");
0357     rphrases << i18nc(
0358         "Please take the official translations! You find them here: https://eur-lex.europa.eu/LexUriServ/LexUriServ.do?uri=CELEX:32001L0059:EN:HTML",
0359         "R12: Extremely flammable");
0360     rphrases << i18nc(
0361         "Please take the official translations! You find them here: https://eur-lex.europa.eu/LexUriServ/LexUriServ.do?uri=CELEX:32001L0059:EN:HTML",
0362         "R14: Reacts violently with water");
0363     rphrases << i18nc(
0364         "Please take the official translations! You find them here: https://eur-lex.europa.eu/LexUriServ/LexUriServ.do?uri=CELEX:32001L0059:EN:HTML",
0365         "R15: Contact with water liberates extremely flammable gases");
0366     rphrases << i18nc(
0367         "Please take the official translations! You find them here: https://eur-lex.europa.eu/LexUriServ/LexUriServ.do?uri=CELEX:32001L0059:EN:HTML",
0368         "R16: Explosive when mixed with oxidising substances");
0369     rphrases << i18nc(
0370         "Please take the official translations! You find them here: https://eur-lex.europa.eu/LexUriServ/LexUriServ.do?uri=CELEX:32001L0059:EN:HTML",
0371         "R17: Spontaneously flammable in air");
0372     rphrases << i18nc(
0373         "Please take the official translations! You find them here: https://eur-lex.europa.eu/LexUriServ/LexUriServ.do?uri=CELEX:32001L0059:EN:HTML",
0374         "R18: In use, may form flammable/explosive vapour-air mixture");
0375     rphrases << i18nc(
0376         "Please take the official translations! You find them here: https://eur-lex.europa.eu/LexUriServ/LexUriServ.do?uri=CELEX:32001L0059:EN:HTML",
0377         "R19: May form explosive peroxides");
0378     rphrases << i18nc(
0379         "Please take the official translations! You find them here: https://eur-lex.europa.eu/LexUriServ/LexUriServ.do?uri=CELEX:32001L0059:EN:HTML",
0380         "R20: Harmful by inhalation");
0381     rphrases << i18nc(
0382         "Please take the official translations! You find them here: https://eur-lex.europa.eu/LexUriServ/LexUriServ.do?uri=CELEX:32001L0059:EN:HTML",
0383         "R21: Harmful in contact with skin");
0384     rphrases << i18nc(
0385         "Please take the official translations! You find them here: https://eur-lex.europa.eu/LexUriServ/LexUriServ.do?uri=CELEX:32001L0059:EN:HTML",
0386         "R22: Harmful if swallowed");
0387     rphrases << i18nc(
0388         "Please take the official translations! You find them here: https://eur-lex.europa.eu/LexUriServ/LexUriServ.do?uri=CELEX:32001L0059:EN:HTML",
0389         "R23: Toxic by inhalation");
0390     rphrases << i18nc(
0391         "Please take the official translations! You find them here: https://eur-lex.europa.eu/LexUriServ/LexUriServ.do?uri=CELEX:32001L0059:EN:HTML",
0392         "R24: Toxic in contact with skin");
0393     rphrases << i18nc(
0394         "Please take the official translations! You find them here: https://eur-lex.europa.eu/LexUriServ/LexUriServ.do?uri=CELEX:32001L0059:EN:HTML",
0395         "R25: Toxic if swallowed");
0396     rphrases << i18nc(
0397         "Please take the official translations! You find them here: https://eur-lex.europa.eu/LexUriServ/LexUriServ.do?uri=CELEX:32001L0059:EN:HTML",
0398         "R26: Very toxic by inhalation");
0399     rphrases << i18nc(
0400         "Please take the official translations! You find them here: https://eur-lex.europa.eu/LexUriServ/LexUriServ.do?uri=CELEX:32001L0059:EN:HTML",
0401         "R27: Very toxic in contact with skin");
0402     rphrases << i18nc(
0403         "Please take the official translations! You find them here: https://eur-lex.europa.eu/LexUriServ/LexUriServ.do?uri=CELEX:32001L0059:EN:HTML",
0404         "R28: Very toxic if swallowed");
0405     rphrases << i18nc(
0406         "Please take the official translations! You find them here: https://eur-lex.europa.eu/LexUriServ/LexUriServ.do?uri=CELEX:32001L0059:EN:HTML",
0407         "R29: Contact with water liberates toxic gas.");
0408     rphrases << i18nc(
0409         "Please take the official translations! You find them here: https://eur-lex.europa.eu/LexUriServ/LexUriServ.do?uri=CELEX:32001L0059:EN:HTML",
0410         "R30: Can become highly flammable in use");
0411     rphrases << i18nc(
0412         "Please take the official translations! You find them here: https://eur-lex.europa.eu/LexUriServ/LexUriServ.do?uri=CELEX:32001L0059:EN:HTML",
0413         "R31: Contact with acids liberates toxic gas");
0414     rphrases << i18nc(
0415         "Please take the official translations! You find them here: https://eur-lex.europa.eu/LexUriServ/LexUriServ.do?uri=CELEX:32001L0059:EN:HTML",
0416         "R32: Contact with acids liberates very toxic gas");
0417     rphrases << i18nc(
0418         "Please take the official translations! You find them here: https://eur-lex.europa.eu/LexUriServ/LexUriServ.do?uri=CELEX:32001L0059:EN:HTML",
0419         "R33: Danger of cumulative effects");
0420     rphrases << i18nc(
0421         "Please take the official translations! You find them here: https://eur-lex.europa.eu/LexUriServ/LexUriServ.do?uri=CELEX:32001L0059:EN:HTML",
0422         "R34: Causes burns");
0423     rphrases << i18nc(
0424         "Please take the official translations! You find them here: https://eur-lex.europa.eu/LexUriServ/LexUriServ.do?uri=CELEX:32001L0059:EN:HTML",
0425         "R35: Causes severe burns");
0426     rphrases << i18nc(
0427         "Please take the official translations! You find them here: https://eur-lex.europa.eu/LexUriServ/LexUriServ.do?uri=CELEX:32001L0059:EN:HTML",
0428         "R36: Irritating to eyes");
0429     rphrases << i18nc(
0430         "Please take the official translations! You find them here: https://eur-lex.europa.eu/LexUriServ/LexUriServ.do?uri=CELEX:32001L0059:EN:HTML",
0431         "R37: Irritating to respiratory system");
0432     rphrases << i18nc(
0433         "Please take the official translations! You find them here: https://eur-lex.europa.eu/LexUriServ/LexUriServ.do?uri=CELEX:32001L0059:EN:HTML",
0434         "R38: Irritating to skin");
0435     rphrases << i18nc(
0436         "Please take the official translations! You find them here: https://eur-lex.europa.eu/LexUriServ/LexUriServ.do?uri=CELEX:32001L0059:EN:HTML",
0437         "R39: Danger of very serious irreversible effects");
0438     rphrases << i18nc(
0439         "Please take the official translations! You find them here: https://eur-lex.europa.eu/LexUriServ/LexUriServ.do?uri=CELEX:32001L0059:EN:HTML",
0440         "R40: Limited evidence of a carcinogenic effect");
0441     rphrases << i18nc(
0442         "Please take the official translations! You find them here: https://eur-lex.europa.eu/LexUriServ/LexUriServ.do?uri=CELEX:32001L0059:EN:HTML",
0443         "R41: Risk of serious damage to eyes");
0444     rphrases << i18nc(
0445         "Please take the official translations! You find them here: https://eur-lex.europa.eu/LexUriServ/LexUriServ.do?uri=CELEX:32001L0059:EN:HTML",
0446         "R42: May cause sensitisation by inhalation");
0447     rphrases << i18nc(
0448         "Please take the official translations! You find them here: https://eur-lex.europa.eu/LexUriServ/LexUriServ.do?uri=CELEX:32001L0059:EN:HTML",
0449         "R43: May cause sensitisation by skin contact");
0450     rphrases << i18nc(
0451         "Please take the official translations! You find them here: https://eur-lex.europa.eu/LexUriServ/LexUriServ.do?uri=CELEX:32001L0059:EN:HTML",
0452         "R44: Risk of explosion if heated under confinement");
0453     rphrases << i18nc(
0454         "Please take the official translations! You find them here: https://eur-lex.europa.eu/LexUriServ/LexUriServ.do?uri=CELEX:32001L0059:EN:HTML",
0455         "R45: May cause cancer");
0456     rphrases << i18nc(
0457         "Please take the official translations! You find them here: https://eur-lex.europa.eu/LexUriServ/LexUriServ.do?uri=CELEX:32001L0059:EN:HTML",
0458         "R46: May cause heritable genetic damage");
0459     rphrases << i18nc(
0460         "Please take the official translations! You find them here: https://eur-lex.europa.eu/LexUriServ/LexUriServ.do?uri=CELEX:32001L0059:EN:HTML",
0461         "R48: Danger of serious damage to health by prolonged exposure");
0462     rphrases << i18nc(
0463         "Please take the official translations! You find them here: https://eur-lex.europa.eu/LexUriServ/LexUriServ.do?uri=CELEX:32001L0059:EN:HTML",
0464         "R49: May cause cancer by inhalation");
0465     rphrases << i18nc(
0466         "Please take the official translations! You find them here: https://eur-lex.europa.eu/LexUriServ/LexUriServ.do?uri=CELEX:32001L0059:EN:HTML",
0467         "R50: Very toxic to aquatic organisms");
0468     rphrases << i18nc(
0469         "Please take the official translations! You find them here: https://eur-lex.europa.eu/LexUriServ/LexUriServ.do?uri=CELEX:32001L0059:EN:HTML",
0470         "R51: Toxic to aquatic organisms");
0471     rphrases << i18nc(
0472         "Please take the official translations! You find them here: https://eur-lex.europa.eu/LexUriServ/LexUriServ.do?uri=CELEX:32001L0059:EN:HTML",
0473         "R52: Harmful to aquatic organisms");
0474     rphrases << i18nc(
0475         "Please take the official translations! You find them here: https://eur-lex.europa.eu/LexUriServ/LexUriServ.do?uri=CELEX:32001L0059:EN:HTML",
0476         "R53: May cause long-term adverse effects in the aquatic environment");
0477     rphrases << i18nc(
0478         "Please take the official translations! You find them here: https://eur-lex.europa.eu/LexUriServ/LexUriServ.do?uri=CELEX:32001L0059:EN:HTML",
0479         "R54: Toxic to flora");
0480     rphrases << i18nc(
0481         "Please take the official translations! You find them here: https://eur-lex.europa.eu/LexUriServ/LexUriServ.do?uri=CELEX:32001L0059:EN:HTML",
0482         "R55: Toxic to fauna");
0483     rphrases << i18nc(
0484         "Please take the official translations! You find them here: https://eur-lex.europa.eu/LexUriServ/LexUriServ.do?uri=CELEX:32001L0059:EN:HTML",
0485         "R56: Toxic to soil organisms");
0486     rphrases << i18nc(
0487         "Please take the official translations! You find them here: https://eur-lex.europa.eu/LexUriServ/LexUriServ.do?uri=CELEX:32001L0059:EN:HTML",
0488         "R57: Toxic to bees");
0489     rphrases << i18nc(
0490         "Please take the official translations! You find them here: https://eur-lex.europa.eu/LexUriServ/LexUriServ.do?uri=CELEX:32001L0059:EN:HTML",
0491         "R58: May cause long-term adverse effects in the environment");
0492     rphrases << i18nc(
0493         "Please take the official translations! You find them here: https://eur-lex.europa.eu/LexUriServ/LexUriServ.do?uri=CELEX:32001L0059:EN:HTML",
0494         "R59: Dangerous for the ozone layer");
0495     rphrases << i18nc(
0496         "Please take the official translations! You find them here: https://eur-lex.europa.eu/LexUriServ/LexUriServ.do?uri=CELEX:32001L0059:EN:HTML",
0497         "R60: May impair fertility");
0498     rphrases << i18nc(
0499         "Please take the official translations! You find them here: https://eur-lex.europa.eu/LexUriServ/LexUriServ.do?uri=CELEX:32001L0059:EN:HTML",
0500         "R61: May cause harm to the unborn child");
0501     rphrases << i18nc(
0502         "Please take the official translations! You find them here: https://eur-lex.europa.eu/LexUriServ/LexUriServ.do?uri=CELEX:32001L0059:EN:HTML",
0503         "R62: Possible risk of impaired fertility");
0504     rphrases << i18nc(
0505         "Please take the official translations! You find them here: https://eur-lex.europa.eu/LexUriServ/LexUriServ.do?uri=CELEX:32001L0059:EN:HTML",
0506         "R63: Possible risk of harm to the unborn child");
0507     rphrases << i18nc(
0508         "Please take the official translations! You find them here: https://eur-lex.europa.eu/LexUriServ/LexUriServ.do?uri=CELEX:32001L0059:EN:HTML",
0509         "R64: May cause harm to breast-fed babies");
0510     rphrases << i18nc(
0511         "Please take the official translations! You find them here: https://eur-lex.europa.eu/LexUriServ/LexUriServ.do?uri=CELEX:32001L0059:EN:HTML",
0512         "R65: Harmful: may cause lung damage if swallowed");
0513     rphrases << i18nc(
0514         "Please take the official translations! You find them here: https://eur-lex.europa.eu/LexUriServ/LexUriServ.do?uri=CELEX:32001L0059:EN:HTML",
0515         "R66: Repeated exposure may cause skin dryness or cracking");
0516     rphrases << i18nc(
0517         "Please take the official translations! You find them here: https://eur-lex.europa.eu/LexUriServ/LexUriServ.do?uri=CELEX:32001L0059:EN:HTML",
0518         "R67: Vapours may cause drowsiness and dizziness");
0519     rphrases << i18nc(
0520         "Please take the official translations! You find them here: https://eur-lex.europa.eu/LexUriServ/LexUriServ.do?uri=CELEX:32001L0059:EN:HTML",
0521         "R68: Possible risk of irreversible effects");
0522 
0523     QRegularExpression reg("(R|S)(\\d+): (.*)");
0524 
0525     for (const QString &p : std::as_const(rphrases)) {
0526         int number = 0;
0527         QString phrase(QLatin1String(""));
0528         QRegularExpressionMatch match = reg.match(p);
0529 
0530         if (match.hasMatch()) {
0531             const QString part1 = match.captured(2);
0532             const QString part2 = match.captured(3);
0533 
0534             phrase = part2;
0535             number = part1.toInt();
0536         }
0537 
0538         rphrases_map.insert(number, phrase);
0539     }
0540 }
0541 
0542 void RSDialog::slotHelp()
0543 {
0544     KHelpClient::invokeHelp(QStringLiteral("tools.html#rs_phrases"), QStringLiteral("kalzium"));
0545 }
0546 
0547 void RSDialog::invalidPhaseString()
0548 {
0549     KMessageBox::error(nullptr, i18n("At least one of the specified phrases is invalid."));
0550 }