MCPcopy Create free account
hub / github.com/Qucs/qucs / fillLibrariesTreeView

Method fillLibrariesTreeView

qucs/qucs.cpp:375–531  ·  view source on GitHub ↗

Put all available libraries into ComboBox.

Source from the content-addressed store, hash-verified

373
374// Put all available libraries into ComboBox.
375void QucsApp::fillLibrariesTreeView ()
376{
377 QStringList LibFiles;
378 QStringList::iterator it;
379 QList<QTreeWidgetItem *> topitems;
380
381 libTreeWidget->clear();
382
383 // make the system libraries section header
384 QTreeWidgetItem* newitem = new QTreeWidgetItem((QTreeWidget*)0, QStringList("System Libraries"));
385 newitem->setChildIndicatorPolicy (QTreeWidgetItem::DontShowIndicator);
386 QFont sectionFont = newitem->font(0);
387 sectionFont.setItalic (true);
388 sectionFont.setBold (true);
389 newitem->setFont (0, sectionFont);
390// newitem->setBackground
391 topitems.append (newitem);
392
393 QDir LibDir(QucsSettings.LibDir);
394 LibFiles = LibDir.entryList(QStringList("*.lib"), QDir::Files, QDir::Name);
395
396 // create top level library items, base on the library names
397 for(it = LibFiles.begin(); it != LibFiles.end(); it++)
398 {
399 QString libPath(*it);
400 libPath.chop(4); // remove extension
401
402 ComponentLibrary parsedlibrary;
403
404 int result = parseComponentLibrary (libPath , parsedlibrary);
405 QStringList nameAndFileName;
406 nameAndFileName.append (parsedlibrary.name);
407 nameAndFileName.append (QucsSettings.LibDir + *it);
408
409 QTreeWidgetItem* newlibitem = new QTreeWidgetItem((QTreeWidget*)0, nameAndFileName);
410
411 switch (result)
412 {
413 case QUCS_COMP_LIB_IO_ERROR:
414 {
415 QString filename = getLibAbsPath(libPath);
416 QMessageBox::critical(0, tr ("Error"), tr("Cannot open \"%1\".").arg (filename));
417 return;
418 }
419 case QUCS_COMP_LIB_CORRUPT:
420 QMessageBox::critical(0, tr("Error"), tr("Library is corrupt."));
421 return;
422 default:
423 break;
424 }
425
426 for (int i = 0; i < parsedlibrary.components.count (); i++)
427 {
428 QStringList compNameAndDefinition;
429
430 compNameAndDefinition.append (parsedlibrary.components[i].name);
431
432 QString s = "<Qucs Schematic " PACKAGE_VERSION ">\n";

Callers

nothing calls this directly

Calls 8

QStringListClass · 0.85
parseComponentLibraryFunction · 0.85
getLibAbsPathFunction · 0.85
QDirClass · 0.85
beginMethod · 0.80
endMethod · 0.80
countMethod · 0.80
clearMethod · 0.45

Tested by

no test coverage detected