MCPcopy Create free account
hub / github.com/KDE/labplot / fitsTreeWidgetSelectionChanged

Method fitsTreeWidgetSelectionChanged

src/frontend/datasources/FITSOptionsWidget.cpp:57–121  ·  view source on GitHub ↗

! updates the selected var name of a FITS file when the tree widget item is selected */ TODO

Source from the content-addressed store, hash-verified

55*/
56// TODO
57void FITSOptionsWidget::fitsTreeWidgetSelectionChanged() {
58 QDEBUG(Q_FUNC_INFO << ", SELECTED ITEMS =" << ui.twExtensions->selectedItems());
59
60 if (ui.twExtensions->selectedItems().isEmpty())
61 return;
62
63 QTreeWidgetItem* item = ui.twExtensions->selectedItems().first();
64 int column = ui.twExtensions->currentColumn();
65
66 WAIT_CURSOR;
67 const QString& itemText = item->text(column);
68 QString selectedExtension;
69 // TODO: same as extensionName() ?
70 int extType = 0;
71 if (itemText.contains(QLatin1String("IMAGE #")) || itemText.contains(QLatin1String("ASCII_TBL #")) || itemText.contains(QLatin1String("BINARY_TBL #")))
72 extType = 1;
73 else if (!itemText.compare(i18n("Primary header")))
74 extType = 2;
75 if (extType == 0) {
76 if (item->parent() != nullptr) {
77 if (item->parent()->parent() != nullptr)
78 selectedExtension = item->parent()->parent()->text(0) + QStringLiteral("[") + item->text(column) + QStringLiteral("]");
79 }
80 } else if (extType == 1) {
81 if (item->parent() != nullptr) {
82 if (item->parent()->parent() != nullptr) {
83 bool ok;
84 int hduNum = itemText.right(1).toInt(&ok);
85 selectedExtension = item->parent()->parent()->text(0) + QStringLiteral("[") + QString::number(hduNum - 1) + QStringLiteral("]");
86 }
87 }
88 } else {
89 if (item->parent()->parent() != nullptr)
90 selectedExtension = item->parent()->parent()->text(column);
91 }
92
93 if (!selectedExtension.isEmpty()) {
94 auto filter = static_cast<FITSFilter*>(m_fileWidget->currentFileFilter());
95 bool readFitsTableToMatrix;
96 const QVector<QStringList> importedStrings = filter->readChdu(selectedExtension, &readFitsTableToMatrix, ui.sbPreviewLines->value());
97 Q_EMIT m_fileWidget->enableImportToMatrix(readFitsTableToMatrix);
98
99 const int rows = importedStrings.size();
100 ui.twPreview->clear();
101
102 ui.twPreview->setRowCount(rows);
103 const int maxColumns = 300;
104 for (int i = 0; i < rows; ++i) {
105 QStringList lineString = importedStrings[i];
106 int colCount;
107 if (i == 0) {
108 colCount = lineString.size() > maxColumns ? maxColumns : lineString.size();
109 ui.twPreview->setColumnCount(colCount);
110 }
111 colCount = lineString.size() > maxColumns ? maxColumns : lineString.size();
112
113 for (int j = 0; j < colCount; ++j) {
114 auto* item = new QTableWidgetItem(lineString[j]);

Callers

nothing calls this directly

Calls 12

selectedItemsMethod · 0.80
currentFileFilterMethod · 0.80
readChduMethod · 0.80
isEmptyMethod · 0.45
textMethod · 0.45
containsMethod · 0.45
parentMethod · 0.45
valueMethod · 0.45
sizeMethod · 0.45
clearMethod · 0.45
setRowCountMethod · 0.45
setColumnCountMethod · 0.45

Tested by

no test coverage detected