Implemented blacklisting libraries

Libraires may contain components that are default-simulator incompatible.
For example RF-componenents library is SPICE-incompatible. And XSPICE
devices libary is Qucs-incompatible. Blacklisting allows to hide
undesired libraries in QucsLib library manager.
This commit is contained in:
Vadim Kuznetzov 2016-05-05 19:28:56 +03:00
parent 541f5c5d93
commit a24152d92e
7 changed files with 51 additions and 2 deletions

View File

@ -19,6 +19,11 @@ SpiceOpamp.lib
Xanalogue.lib
)
INSTALL( FILES ${COMPLIBS} DESTINATION share/qucs/library )
SET(BLACKLIST
qucs.blacklist
spice.blacklist
)
INSTALL( FILES ${COMPLIBS} ${BLACKLIST} DESTINATION share/qucs/library )
ADD_SUBDIRECTORY( AnalogueCM )

View File

@ -28,7 +28,7 @@ SUBDIRS = AnalogueCM
COMPLIBS = Transistors.lib Substrates.lib Diodes.lib MOSFETs.lib OpAmps.lib \
Bridges.lib LEDs.lib JFETs.lib Z-Diodes.lib NMOSFETs.lib \
PMOSFETs.lib Ideal.lib Regulators.lib Varistors.lib Cores.lib Transformers.lib \
AnalogueCM.lib Xanalogue.lib
AnalogueCM.lib Xanalogue.lib qucs.blacklist spice.blacklist

View File

@ -0,0 +1,5 @@
AnalogueCM.lib
Cores.lib
Transformers.lib
Xanalogue.lib

View File

@ -0,0 +1,2 @@
Substrates.lib

View File

@ -56,6 +56,9 @@ bool loadSettings()
if(settings.contains("font"))QucsSettings.font.fromString(settings.value("font").toString());
if(settings.contains("Language"))QucsSettings.Language=settings.value("Language").toString();
if(settings.contains("DefaultSimulator"))
QucsSettings.DefaultSimulator = settings.value("DefaultSimulator").toInt();
else QucsSettings.DefaultSimulator = spicecompat::simNotSpecified;
return true;
}

View File

@ -48,6 +48,8 @@
#include "displaydialog.h"
#include "symbolwidget.h"
#include "../qucs/extsimkernels/spicecompat.h"
/* Constructor setups the GUI. */
QucsLib::QucsLib()
@ -189,6 +191,10 @@ void QucsLib::putLibrariesIntoCombobox()
{
//LibFiles = UserLibDir.entryList("*.lib", QDir::Files, QDir::Name);
LibFiles = UserLibDir.entryList(QStringList("*.lib"), QDir::Files, QDir::Name);
QStringList blacklist = getBlacklistedLibraries(UserLibDir.absolutePath());
foreach(QString ss, blacklist) { // exclude blacklisted files
LibFiles.removeAll(ss);
}
UserLibCount = LibFiles.count();
@ -205,6 +211,10 @@ void QucsLib::putLibrariesIntoCombobox()
QDir LibDir(QucsSettings.LibDir);
LibFiles = LibDir.entryList(QStringList("*.lib"), QDir::Files, QDir::Name);
QStringList blacklist = getBlacklistedLibraries(QucsSettings.LibDir);
foreach(QString ss, blacklist) { // exclude blacklisted files
LibFiles.removeAll(ss);
}
for(it = LibFiles.begin(); it != LibFiles.end(); it++)
Library->addItem(QPixmap(":/bitmaps/big.qucs.xpm"), (*it).left((*it).length()-4));
@ -524,3 +534,22 @@ void QucsLib::slotShowComponent(QListWidgetItem *Item)
}
QStringList QucsLib::getBlacklistedLibraries(QString dir)
{
QString filename;
QStringList blacklisted_libs;
blacklisted_libs.clear();
if (QucsSettings.DefaultSimulator==spicecompat::simQucsator)
filename = dir + QDir::separator()+ "qucs.blacklist";
else filename = dir + QDir::separator() + "spice.blacklist";
QFile f_blist(filename);
if (!f_blist.open(QIODevice::ReadOnly)) return blacklisted_libs;
QTextStream ts(&f_blist);
while (!ts.atEnd()) {
QString lib = ts.readLine();
if (!lib.isEmpty()) blacklisted_libs.append(lib);
}
f_blist.close();
return blacklisted_libs;
}

View File

@ -31,9 +31,12 @@
#include "symbolwidget.h"
#include "../qucs/extsimkernels/spicecompat.h"
// Application settings.
struct tQucsSettings {
int DefaultSimulator;
int x, y, dx, dy; // position and size of main window
QFont font; // font
QString LangDir; // translation directory
@ -82,6 +85,8 @@ private:
QTextEdit *CompDescr;
QVBoxLayout *all;
QLineEdit *CompSearch;
QStringList getBlacklistedLibraries(QString dir);
};
#endif /* QUCSLIB_H */