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

Method setModel

src/frontend/datasources/ImportDialog.cpp:72–123  ·  view source on GitHub ↗

! creates widgets for the frame "Import-To" and sets the current model in the "Add to"-combobox. */

Source from the content-addressed store, hash-verified

70 creates widgets for the frame "Import-To" and sets the current model in the "Add to"-combobox.
71 */
72void ImportDialog::setModel() {
73 // Frame for the "Import To"-Stuff
74 frameAddTo = new QGroupBox(this);
75 frameAddTo->setTitle(i18n("Import to"));
76
77 auto* label = new QLabel(i18n("Data container:"));
78 label->setToolTip(i18n("Data container where the data has to be imported into"));
79
80 auto* grid = new QGridLayout(frameAddTo);
81 grid->addWidget(label, 0, 0);
82
83 cbAddTo = new TreeViewComboBox(this);
84 cbAddTo->setToolTip(i18n("Data container where the data has to be imported into"));
85 cbAddTo->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
86 grid->addWidget(cbAddTo, 0, 1);
87
88 QList<AspectType> list{AspectType::Folder, AspectType::Spreadsheet, AspectType::Matrix, AspectType::Workbook};
89 cbAddTo->setTopLevelClasses(list);
90
91 list.removeFirst(); // do not allow selection of Folders
92 m_aspectTreeModel->setSelectableAspects(list);
93
94 cbAddTo->setModel(m_aspectTreeModel);
95
96 tbNewDataContainer = new QToolButton(frameAddTo);
97 tbNewDataContainer->setText(i18n("New"));
98 tbNewDataContainer->setIcon(QIcon::fromTheme(QStringLiteral("list-add")));
99 tbNewDataContainer->setToolButtonStyle(Qt::ToolButtonTextBesideIcon);
100 tbNewDataContainer->setToolTip(i18n("Add new data container to the project"));
101 grid->addWidget(tbNewDataContainer, 0, 2);
102
103 lPosition = new QLabel(i18n("Position:"), frameAddTo);
104 lPosition->setEnabled(false);
105 grid->addWidget(lPosition, 1, 0);
106
107 cbPosition = new QComboBox(frameAddTo);
108 cbPosition->setEnabled(false);
109 cbPosition->addItem(i18n("Append"));
110 cbPosition->addItem(i18n("Prepend"));
111 cbPosition->addItem(i18n("Replace"));
112 KConfigGroup conf = Settings::group(QStringLiteral("ImportDialog"));
113 cbPosition->setCurrentIndex(conf.readEntry("Position", 0));
114
115 cbPosition->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed);
116 grid->addWidget(cbPosition, 1, 1);
117
118 // add the "Import to"-frame to the layout after the first main widget
119 vLayout->insertWidget(1, frameAddTo);
120
121 connect(tbNewDataContainer, &QToolButton::clicked, this, &ImportDialog::newDataContainerMenu);
122 connect(cbAddTo, &TreeViewComboBox::currentModelIndexChanged, this, &ImportDialog::currentModelIndexChanged);
123}
124
125void ImportDialog::setCurrentIndex(const QModelIndex& index) {
126 QDEBUG(Q_FUNC_INFO << ", index =" << index);

Callers 5

applyFilterSettingsMethod · 0.45
ImportProjectDialogMethod · 0.45
refreshPreviewMethod · 0.45
fileNameChangedMethod · 0.45
initOptionsWidgetMethod · 0.45

Calls 12

groupFunction · 0.85
setTitleMethod · 0.80
setToolTipMethod · 0.80
setTopLevelClassesMethod · 0.80
removeFirstMethod · 0.80
setSelectableAspectsMethod · 0.80
setToolButtonStyleMethod · 0.80
setTextMethod · 0.45
setIconMethod · 0.45
setEnabledMethod · 0.45
setCurrentIndexMethod · 0.45
insertWidgetMethod · 0.45

Tested by

no test coverage detected