MCPcopy Create free account
hub / github.com/TeXworks/texworks / treeSelectionChanged

Method treeSelectionChanged

src/ScriptManagerWidget.cpp:175–217  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

173}
174
175void ScriptManagerWidget::treeSelectionChanged()
176{
177 details->setPlainText(QString());
178
179 QTreeWidget * tree = scriptTabs->currentWidget() == standaloneTab ? standaloneTree : hookTree;
180 QList<QTreeWidgetItem*> selection = tree->selectedItems();
181 if (selection.size() != 1)
182 return;
183
184 if (selection[0]->type() != kScriptType)
185 return;
186
187 Tw::Scripting::ScriptObject * so = static_cast<Tw::Scripting::ScriptObject*>(selection[0]->data(0, Qt::UserRole).value<void*>());
188 if (!so)
189 return;
190
191 QString rows;
192 addDetailsRow(rows, tr("Name: "), so->getTitle());
193 addDetailsRow(rows, tr("Context: "), so->getContext());
194 addDetailsRow(rows, tr("Description: "), so->getDescription());
195 addDetailsRow(rows, tr("Author: "), so->getAuthor());
196 addDetailsRow(rows, tr("Version: "), so->getVersion());
197 addDetailsRow(rows, tr("Shortcut: "), so->getKeySequence().toString());
198 addDetailsRow(rows, tr("File: "), QFileInfo(so->getFilename()).fileName());
199
200#if QT_VERSION < QT_VERSION_CHECK(6, 3, 0)
201 const Tw::Scripting::ScriptLanguageInterface * sli = qobject_cast<Tw::Scripting::ScriptLanguageInterface*>(so->getScriptLanguagePlugin());
202#else
203 const Tw::Scripting::ScriptLanguageInterface * sli = qobject_cast<const Tw::Scripting::ScriptLanguageInterface*>(so->getScriptLanguagePlugin());
204#endif
205 if(sli) {
206 QString url = sli->scriptLanguageURL();
207 QString str = sli->scriptLanguageName();
208 if (!url.isEmpty())
209 str = QString::fromLatin1("<a href=\"%1\">%2</a>").arg(url, str);
210 addDetailsRow(rows, tr("Language: "), str);
211 }
212
213 if (so->getType() == Tw::Scripting::Script::ScriptHook)
214 addDetailsRow(rows, tr("Hook: "), so->getHook());
215
216 details->setHtml(QString::fromLatin1("<table>%1</table").arg(rows));
217}
218
219void ScriptManagerWidget::addDetailsRow(QString& html, const QString & label, const QString & value)
220{

Callers

nothing calls this directly

Calls 15

getTitleMethod · 0.80
getContextMethod · 0.80
getDescriptionMethod · 0.80
getAuthorMethod · 0.80
getKeySequenceMethod · 0.80
getHookMethod · 0.80
typeMethod · 0.45
dataMethod · 0.45
getVersionMethod · 0.45
fileNameMethod · 0.45
getFilenameMethod · 0.45

Tested by

no test coverage detected