Warning, file /education/kalzium/src/tablesdialog.cpp was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

0001 /*
0002     SPDX-FileCopyrightText: 2006 Carsten Niehaus <cniehaus@kde.org>
0003     SPDX-FileCopyrightText: 2007 Ian Monroe <ian@monroe.nu>
0004     SPDX-License-Identifier: GPL-2.0-or-later
0005 */
0006 
0007 #include "tablesdialog.h"
0008 
0009 #include <QApplication>
0010 #include <QClipboard>
0011 #include <QContextMenuEvent>
0012 #include <QHeaderView>
0013 #include <QIcon>
0014 #include <QMenu>
0015 #include <QVBoxLayout>
0016 
0017 #include <KLocalizedString>
0018 
0019 TablesDialog::TablesDialog(QWidget *parent)
0020     : KPageDialog(parent)
0021 {
0022     setFaceType(List);
0023 
0024     // setButtons(Help | Close);
0025     // setDefaultButton(Close);
0026 
0027     createGreekSymbolTable();
0028     createNumbersTable();
0029 }
0030 
0031 void TablesDialog::createGreekSymbolTable()
0032 {
0033     auto frame = new QWidget();
0034     KPageWidgetItem *item = addPage(frame, i18n("Greek alphabet"));
0035     item->setHeader(i18n("Greek alphabet"));
0036     item->setIcon(QIcon::fromTheme(QStringLiteral("numbers")));
0037     auto layout = new QVBoxLayout(frame);
0038     layout->setContentsMargins(0, 0, 0, 0);
0039 
0040     QTableWidget *table = new MyTableWidget(frame);
0041     table->verticalHeader()->hide();
0042 
0043     table->setColumnCount(3);
0044     table->setRowCount(24);
0045     table->setHorizontalHeaderLabels(
0046         QStringList() << i18n("Uppercase") << i18n("Lowercase")
0047                       << i18nc("The name of the greek letter in your language. For example 'Alpha' for the first letter. ", "Name"));
0048 
0049     layout->addWidget(table);
0050     table->setItem(0, 0, new MyWidgetItem(QString(QChar(913)))); // capital Alpha
0051     table->setItem(1, 0, new MyWidgetItem(QString(QChar(914))));
0052     table->setItem(2, 0, new MyWidgetItem(QString(QChar(915))));
0053     table->setItem(3, 0, new MyWidgetItem(QString(QChar(916))));
0054     table->setItem(4, 0, new MyWidgetItem(QString(QChar(917))));
0055     table->setItem(5, 0, new MyWidgetItem(QString(QChar(918))));
0056     table->setItem(6, 0, new MyWidgetItem(QString(QChar(919))));
0057     table->setItem(7, 0, new MyWidgetItem(QString(QChar(920))));
0058     table->setItem(8, 0, new MyWidgetItem(QString(QChar(921))));
0059     table->setItem(9, 0, new MyWidgetItem(QString(QChar(922))));
0060     table->setItem(10, 0, new MyWidgetItem(QString(QChar(923))));
0061     table->setItem(11, 0, new MyWidgetItem(QString(QChar(924))));
0062     table->setItem(12, 0, new MyWidgetItem(QString(QChar(925))));
0063     table->setItem(13, 0, new MyWidgetItem(QString(QChar(926))));
0064     table->setItem(14, 0, new MyWidgetItem(QString(QChar(927))));
0065     table->setItem(15, 0, new MyWidgetItem(QString(QChar(928))));
0066     table->setItem(16, 0, new MyWidgetItem(QString(QChar(929))));
0067     table->setItem(17, 0, new MyWidgetItem(QString(QChar(931))));
0068     table->setItem(18, 0, new MyWidgetItem(QString(QChar(932))));
0069     table->setItem(19, 0, new MyWidgetItem(QString(QChar(933))));
0070     table->setItem(20, 0, new MyWidgetItem(QString(QChar(934))));
0071     table->setItem(21, 0, new MyWidgetItem(QString(QChar(935))));
0072     table->setItem(22, 0, new MyWidgetItem(QString(QChar(936))));
0073     table->setItem(23, 0, new MyWidgetItem(QString(QChar(937))));
0074 
0075     // small letters
0076     table->setItem(0, 1, new MyWidgetItem(QString(QChar(945)))); // small alpha
0077     table->setItem(1, 1, new MyWidgetItem(QString(QChar(946))));
0078     table->setItem(2, 1, new MyWidgetItem(QString(QChar(947))));
0079     table->setItem(3, 1, new MyWidgetItem(QString(QChar(948))));
0080     table->setItem(4, 1, new MyWidgetItem(QString(QChar(949))));
0081     table->setItem(5, 1, new MyWidgetItem(QString(QChar(950))));
0082     table->setItem(6, 1, new MyWidgetItem(QString(QChar(951))));
0083     table->setItem(7, 1, new MyWidgetItem(QString(QChar(952))));
0084     table->setItem(8, 1, new MyWidgetItem(QString(QChar(953))));
0085     table->setItem(9, 1, new MyWidgetItem(QString(QChar(954))));
0086     table->setItem(10, 1, new MyWidgetItem(QString(QChar(955))));
0087     table->setItem(11, 1, new MyWidgetItem(QString(QChar(956))));
0088     table->setItem(12, 1, new MyWidgetItem(QString(QChar(957))));
0089     table->setItem(13, 1, new MyWidgetItem(QString(QChar(958))));
0090     table->setItem(14, 1, new MyWidgetItem(QString(QChar(959))));
0091     table->setItem(15, 1, new MyWidgetItem(QString(QChar(960))));
0092     table->setItem(16, 1, new MyWidgetItem(QString(QChar(961))));
0093     // there are two greek letters for sigma
0094     table->setItem(17, 1, new MyWidgetItem(QString(QChar(962)) + ", " + QString(QChar(963))));
0095     table->setItem(18, 1, new MyWidgetItem(QString(QChar(964))));
0096     table->setItem(19, 1, new MyWidgetItem(QString(QChar(965))));
0097     table->setItem(20, 1, new MyWidgetItem(QString(QChar(966))));
0098     table->setItem(21, 1, new MyWidgetItem(QString(QChar(967))));
0099     table->setItem(22, 1, new MyWidgetItem(QString(QChar(968))));
0100     table->setItem(23, 1, new MyWidgetItem(QString(QChar(969))));
0101 
0102     // english names
0103     table->setItem(0, 2, new MyWidgetItem(i18n("alpha")));
0104     table->setItem(1, 2, new MyWidgetItem(i18n("beta")));
0105     table->setItem(2, 2, new MyWidgetItem(i18n("gamma")));
0106     table->setItem(3, 2, new MyWidgetItem(i18n("delta")));
0107     table->setItem(4, 2, new MyWidgetItem(i18n("epsilon")));
0108     table->setItem(5, 2, new MyWidgetItem(i18n("zeta")));
0109     table->setItem(6, 2, new MyWidgetItem(i18n("eta")));
0110     table->setItem(7, 2, new MyWidgetItem(i18n("theta")));
0111     table->setItem(8, 2, new MyWidgetItem(i18n("iota")));
0112     table->setItem(9, 2, new MyWidgetItem(i18n("kappa")));
0113     table->setItem(10, 2, new MyWidgetItem(i18n("lambda")));
0114     table->setItem(11, 2, new MyWidgetItem(i18n("mu")));
0115     table->setItem(12, 2, new MyWidgetItem(i18n("nu")));
0116     table->setItem(13, 2, new MyWidgetItem(i18n("xi")));
0117     table->setItem(14, 2, new MyWidgetItem(i18n("omicron")));
0118     table->setItem(15, 2, new MyWidgetItem(i18n("pi")));
0119     table->setItem(16, 2, new MyWidgetItem(i18n("rho")));
0120     table->setItem(17, 2, new MyWidgetItem(i18n("sigma")));
0121     table->setItem(18, 2, new MyWidgetItem(i18n("tau")));
0122     table->setItem(19, 2, new MyWidgetItem(i18n("upsilon")));
0123     table->setItem(20, 2, new MyWidgetItem(i18n("phi")));
0124     table->setItem(21, 2, new MyWidgetItem(i18n("chi")));
0125     table->setItem(22, 2, new MyWidgetItem(i18n("psi")));
0126     table->setItem(23, 2, new MyWidgetItem(i18n("omega")));
0127 
0128     table->resizeColumnsToContents();
0129     frame->setMinimumWidth(qMax(table->columnWidth(0) + table->columnWidth(1) + table->columnWidth(2), table->horizontalHeader()->sizeHint().width()) + 25);
0130 }
0131 
0132 void TablesDialog::createNumbersTable()
0133 {
0134     auto frame = new QWidget();
0135     KPageWidgetItem *item = addPage(frame, i18n("Numbers"));
0136     item->setHeader(i18n("Numeric Prefixes and Roman Numerals"));
0137     item->setIcon(QIcon::fromTheme(QStringLiteral("numbers")));
0138     auto layout = new QVBoxLayout(frame);
0139     layout->setContentsMargins(0, 0, 0, 0);
0140 
0141     QTableWidget *table = new MyTableWidget(frame);
0142     table->verticalHeader()->hide();
0143 
0144     table->setColumnCount(3);
0145     table->setRowCount(28);
0146     table->setHorizontalHeaderLabels(QStringList() << i18n("Number") << i18nc("For example 'Mono' for 1 and 'Tri' for 3", "Prefix") << i18n("Roman Numerals"));
0147 
0148     layout->addWidget(table);
0149 
0150     table->setItem(0, 0, new MyWidgetItem(i18n("0.5")));
0151     table->setItem(1, 0, new MyWidgetItem(i18n("1")));
0152     table->setItem(2, 0, new MyWidgetItem(i18n("1.5")));
0153     table->setItem(3, 0, new MyWidgetItem(i18n("2")));
0154     table->setItem(4, 0, new MyWidgetItem(i18n("2.5")));
0155     table->setItem(5, 0, new MyWidgetItem(i18n("3")));
0156     table->setItem(6, 0, new MyWidgetItem(i18n("4")));
0157     table->setItem(7, 0, new MyWidgetItem(i18n("5")));
0158     table->setItem(8, 0, new MyWidgetItem(i18n("6")));
0159     table->setItem(9, 0, new MyWidgetItem(i18n("7")));
0160     table->setItem(10, 0, new MyWidgetItem(i18n("8")));
0161     table->setItem(11, 0, new MyWidgetItem(i18n("9")));
0162     table->setItem(12, 0, new MyWidgetItem(i18n("10")));
0163     table->setItem(13, 0, new MyWidgetItem(i18n("11")));
0164     table->setItem(14, 0, new MyWidgetItem(i18n("12")));
0165     table->setItem(15, 0, new MyWidgetItem(i18n("13")));
0166     table->setItem(16, 0, new MyWidgetItem(i18n("14")));
0167     table->setItem(17, 0, new MyWidgetItem(i18n("15")));
0168     table->setItem(18, 0, new MyWidgetItem(i18n("16")));
0169     table->setItem(19, 0, new MyWidgetItem(i18n("17")));
0170     table->setItem(20, 0, new MyWidgetItem(i18n("18")));
0171     table->setItem(21, 0, new MyWidgetItem(i18n("19")));
0172     table->setItem(22, 0, new MyWidgetItem(i18n("20")));
0173     table->setItem(23, 0, new MyWidgetItem(i18n("40")));
0174     table->setItem(24, 0, new MyWidgetItem(i18n("50")));
0175     table->setItem(25, 0, new MyWidgetItem(i18n("60")));
0176     table->setItem(26, 0, new MyWidgetItem(i18n("90")));
0177     table->setItem(27, 0, new MyWidgetItem(i18n("100")));
0178 
0179     // greek names of the numbers
0180     table->setItem(0, 1, new MyWidgetItem(QStringLiteral("hemi")));
0181     table->setItem(1, 1, new MyWidgetItem(QStringLiteral("mono")));
0182     table->setItem(2, 1, new MyWidgetItem(QStringLiteral("sesqui")));
0183     table->setItem(3, 1, new MyWidgetItem(QStringLiteral("di, bi")));
0184     table->setItem(4, 1, new MyWidgetItem(QStringLiteral("hemipenta")));
0185     table->setItem(5, 1, new MyWidgetItem(QStringLiteral("tri")));
0186     table->setItem(6, 1, new MyWidgetItem(QStringLiteral("tetra")));
0187     table->setItem(7, 1, new MyWidgetItem(QStringLiteral("penta")));
0188     table->setItem(8, 1, new MyWidgetItem(QStringLiteral("hexa")));
0189     table->setItem(9, 1, new MyWidgetItem(QStringLiteral("hepta")));
0190     table->setItem(10, 1, new MyWidgetItem(QStringLiteral("octa")));
0191     table->setItem(11, 1, new MyWidgetItem(QStringLiteral("nona, ennea")));
0192     table->setItem(12, 1, new MyWidgetItem(QStringLiteral("deca")));
0193     table->setItem(13, 1, new MyWidgetItem(QStringLiteral("hendeca, undeca")));
0194     table->setItem(14, 1, new MyWidgetItem(QStringLiteral("dodeca")));
0195     table->setItem(15, 1, new MyWidgetItem(QStringLiteral("trideca")));
0196     table->setItem(16, 1, new MyWidgetItem(QStringLiteral("tetradeca")));
0197     table->setItem(17, 1, new MyWidgetItem(QStringLiteral("pentadeca")));
0198     table->setItem(18, 1, new MyWidgetItem(QStringLiteral("hexadeca")));
0199     table->setItem(19, 1, new MyWidgetItem(QStringLiteral("heptadeca")));
0200     table->setItem(20, 1, new MyWidgetItem(QStringLiteral("octadeca")));
0201     table->setItem(21, 1, new MyWidgetItem(QStringLiteral("nonadeca")));
0202     table->setItem(22, 1, new MyWidgetItem(QStringLiteral("eicosa")));
0203     table->setItem(23, 1, new MyWidgetItem(QStringLiteral("tetraconta")));
0204     table->setItem(24, 1, new MyWidgetItem(QStringLiteral("pentaconta")));
0205     table->setItem(25, 1, new MyWidgetItem(QStringLiteral("hexaconta")));
0206     table->setItem(26, 1, new MyWidgetItem(QStringLiteral("nonaconta")));
0207     table->setItem(27, 1, new MyWidgetItem(QStringLiteral("hecta")));
0208 
0209     // roman symbols
0210     table->setItem(1, 2, new MyWidgetItem(QStringLiteral("I")));
0211     table->setItem(3, 2, new MyWidgetItem(QStringLiteral("II")));
0212     table->setItem(5, 2, new MyWidgetItem(QStringLiteral("III")));
0213     table->setItem(6, 2, new MyWidgetItem(QStringLiteral("IV")));
0214     table->setItem(7, 2, new MyWidgetItem(QStringLiteral("V")));
0215     table->setItem(8, 2, new MyWidgetItem(QStringLiteral("VI")));
0216     table->setItem(9, 2, new MyWidgetItem(QStringLiteral("VII")));
0217     table->setItem(10, 2, new MyWidgetItem(QStringLiteral("VIII")));
0218     table->setItem(11, 2, new MyWidgetItem(QStringLiteral("IX")));
0219     table->setItem(12, 2, new MyWidgetItem(QStringLiteral("X")));
0220     table->setItem(13, 2, new MyWidgetItem(QStringLiteral("XI")));
0221     table->setItem(14, 2, new MyWidgetItem(QStringLiteral("XII")));
0222     table->setItem(15, 2, new MyWidgetItem(QStringLiteral("XIII")));
0223     table->setItem(16, 2, new MyWidgetItem(QStringLiteral("XIV")));
0224     table->setItem(17, 2, new MyWidgetItem(QStringLiteral("XV")));
0225     table->setItem(18, 2, new MyWidgetItem(QStringLiteral("XVI")));
0226     table->setItem(19, 2, new MyWidgetItem(QStringLiteral("XVII")));
0227     table->setItem(20, 2, new MyWidgetItem(QStringLiteral("XVIII")));
0228     table->setItem(21, 2, new MyWidgetItem(QStringLiteral("XIV")));
0229     table->setItem(22, 2, new MyWidgetItem(QStringLiteral("XX")));
0230     table->setItem(23, 2, new MyWidgetItem(QStringLiteral("XL")));
0231     table->setItem(24, 2, new MyWidgetItem(QStringLiteral("L")));
0232     table->setItem(25, 2, new MyWidgetItem(QStringLiteral("LX")));
0233     table->setItem(26, 2, new MyWidgetItem(QStringLiteral("XC")));
0234     table->setItem(27, 2, new MyWidgetItem(QStringLiteral("C")));
0235 
0236     table->resizeColumnsToContents();
0237     frame->setMinimumWidth(qMax(table->columnWidth(0) + table->columnWidth(1) + table->columnWidth(2), table->horizontalHeader()->sizeHint().width()) + 25);
0238 }
0239 
0240 TablesDialog::~TablesDialog() = default;
0241 
0242 MyTableWidget::MyTableWidget(QWidget *parent)
0243     : QTableWidget(parent)
0244 {
0245 }
0246 
0247 void MyTableWidget::contextMenuEvent(QContextMenuEvent *event)
0248 {
0249     auto menu = QMenu((QWidget *)sender());
0250     menu.addAction(i18n("&Copy"), this, &MyTableWidget::copyToClipboard, QKeySequence(Qt::Key_C | Qt::CTRL));
0251     menu.exec(event->globalPos());
0252 }
0253 
0254 void MyTableWidget::copyToClipboard()
0255 {
0256     QApplication::clipboard()->setText(currentItem()->data(QTableWidgetItem::Type).toString());
0257 }