Put all available libraries into ComboBox.
| 373 | |
| 374 | // Put all available libraries into ComboBox. |
| 375 | void 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"; |
nothing calls this directly
no test coverage detected