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

Method ImportDatasetWidget

src/frontend/datasources/ImportDatasetWidget.cpp:37–87  ·  view source on GitHub ↗

! \class ImportDatasetWidget \brief Widget for importing data from a dataset. \ingroup frontend */

Source from the content-addressed store, hash-verified

35 \ingroup frontend
36 */
37ImportDatasetWidget::ImportDatasetWidget(QWidget* parent)
38 : QWidget(parent)
39 , m_networkManager(new QNetworkAccessManager(this)) {
40 ui.setupUi(this);
41
42 m_jsonDir = QStandardPaths::locate(QStandardPaths::AppDataLocation, QStringLiteral("datasets"), QStandardPaths::LocateDirectory);
43 loadCategories();
44
45 ui.lwDatasets->setSelectionMode(QAbstractItemView::SingleSelection);
46 ui.twCategories->setSelectionMode(QAbstractItemView::SingleSelection);
47
48 const int size = ui.leSearch->height();
49 ui.lSearch->setPixmap(QIcon::fromTheme(QStringLiteral("edit-find")).pixmap(size, size));
50
51 QString info = i18n("Enter the keyword you want to search for");
52 ui.lSearch->setToolTip(info);
53 ui.leSearch->setToolTip(info);
54 ui.leSearch->setPlaceholderText(i18n("Search..."));
55 ui.leSearch->setFocus();
56
57 connect(ui.cbCollections, QOverload<int>::of(&QComboBox::currentIndexChanged), this, &ImportDatasetWidget::collectionChanged);
58 connect(ui.twCategories, &QTreeWidget::itemDoubleClicked, this, &ImportDatasetWidget::updateDatasets);
59 connect(ui.twCategories, &QTreeWidget::itemSelectionChanged, [this] {
60 if (!m_initializing)
61 updateDatasets(ui.twCategories->selectedItems().first());
62 });
63
64 connect(ui.leSearch, &TimedLineEdit::textChanged, this, &ImportDatasetWidget::updateCategories);
65 connect(ui.lwDatasets, &QListWidget::itemSelectionChanged, [this]() {
66 if (!m_initializing)
67 datasetChanged();
68 });
69 connect(ui.lwDatasets, &QListWidget::doubleClicked, [this]() {
70 Q_EMIT datasetDoubleClicked();
71 });
72 connect(m_networkManager, &QNetworkAccessManager::finished, this, &ImportDatasetWidget::downloadFinished);
73
74 // select the last used collection
75 KConfigGroup conf = Settings::group(QStringLiteral("ImportDatasetWidget"));
76 const QString& collection = conf.readEntry("Collection", QString());
77 if (collection.isEmpty())
78 ui.cbCollections->setCurrentIndex(0);
79 else {
80 for (int i = 0; i < ui.cbCollections->count(); ++i) {
81 if (ui.cbCollections->itemData(i).toString() == collection) {
82 ui.cbCollections->setCurrentIndex(i);
83 break;
84 }
85 }
86 }
87}
88
89ImportDatasetWidget::~ImportDatasetWidget() {
90 delete m_model;

Callers

nothing calls this directly

Calls 12

groupFunction · 0.85
heightMethod · 0.80
setToolTipMethod · 0.80
setPlaceholderTextMethod · 0.80
selectedItemsMethod · 0.80
QStringClass · 0.50
pixmapMethod · 0.45
setFocusMethod · 0.45
isEmptyMethod · 0.45
setCurrentIndexMethod · 0.45
countMethod · 0.45
toStringMethod · 0.45

Tested by

no test coverage detected