Skip to content

Commit

Permalink
Merge pull request #580 from guitorri/rebase-PR556
Browse files Browse the repository at this point in the history
Fix for issues #550 and #553
  • Loading branch information
guitorri authored Nov 4, 2016
2 parents 7552363 + c08a6b7 commit 7278ccf
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 8 deletions.
2 changes: 1 addition & 1 deletion qucs-core/src/logging.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
# include <config.h>
#endif

#include <stdio.h>

#include <stdlib.h>
#include <stdarg.h>

Expand Down
2 changes: 1 addition & 1 deletion qucs-core/src/logging.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@

#define LOG_ERROR 0
#define LOG_STATUS 1

#include <stdio.h>
__BEGIN_DECLS

void logprint (int, const char *, ...);
Expand Down
12 changes: 6 additions & 6 deletions qucs/qucs-lib/qucslib.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@
#include "displaydialog.h"
#include "symbolwidget.h"


/* Constructor setups the GUI. */
QucsLib::QucsLib()
{
Expand Down Expand Up @@ -112,6 +111,7 @@ QucsLib::QucsLib()
CompList = new QListWidget();
connect(CompList, SIGNAL(itemActivated(QListWidgetItem*)), SLOT(slotShowComponent(QListWidgetItem*)));
connect(CompList,SIGNAL(currentItemChanged(QListWidgetItem*,QListWidgetItem*)),SLOT(slotShowComponent(QListWidgetItem*)));
connect(CompList, SIGNAL(itemClicked(QListWidgetItem*)), SLOT(slotShowComponent(QListWidgetItem*)));

CompSearch = new QLineEdit(this);
CompSearch->setPlaceholderText(tr("Search Lib Components"));
Expand Down Expand Up @@ -458,7 +458,6 @@ void QucsLib::slotSearchClear()
// ----------------------------------------------------
void QucsLib::slotShowComponent(QListWidgetItem *Item)
{

if(!Item) return;

//QString CompString = LibraryComps.at(CompList->index(Item));
Expand All @@ -468,6 +467,7 @@ void QucsLib::slotShowComponent(QListWidgetItem *Item)
CompDescr->append("Library: " + LibName);
CompDescr->append("----------------------------");


// FIXME: here we assume that LibName is the same as the actual filename...
int i = Library->findText(LibName);

Expand Down Expand Up @@ -510,11 +510,11 @@ void QucsLib::slotShowComponent(QListWidgetItem *Item)
QMessageBox::critical(this, tr("Error"), tr("Library is corrupt."));
return;
}
if(!content.isEmpty())
Symbol->setSymbol(content, LibName, Item->text());
else if(!DefaultSymbol.isEmpty()) // has library a default symbol ?
Symbol->setSymbol(DefaultSymbol, LibName, Item->text());


Symbol->setSymbol(content, LibName, Item->text());


// change currently selected category, so the user will
// learn where the component comes from
Library->setCurrentIndex(i);
Expand Down
23 changes: 23 additions & 0 deletions qucs/qucs-lib/symbolwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -360,6 +360,29 @@ int SymbolWidget::createSymbol(const QString& Lib_, const QString& Comp_)
int SymbolWidget::setSymbol( QString& SymbolString,
const QString& Lib_, const QString& Comp_)
{
if (SymbolString.isEmpty())//Whenever SymbolString is empty, it tries to load the default symbol
{
//Load the default symbol for the current Qucs library
ComponentLibrary parsedlib;
QString libpath = QucsSettings.LibDir + Lib_ + ".lib";
int result = parseComponentLibrary (libpath, parsedlib);

switch (result)//Check if the library was properly loaded
{
case QUCS_COMP_LIB_IO_ERROR:
QMessageBox::critical(0, tr ("Error"), tr("Cannot open \"%1\".").arg (libpath));
return -1;
case QUCS_COMP_LIB_CORRUPT:
QMessageBox::critical(0, tr("Error"), tr("Library is corrupt."));
return -1;
default:
break;
}

// copy the contents of default symbol section to a string
SymbolString = parsedlib.defaultSymbol;
}

Arcs.clear();
Lines.clear();
Rects.clear();
Expand Down
1 change: 1 addition & 0 deletions qucs/qucs-lib/symbolwidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
#include <QList>
#include <QMouseEvent>
#include <QPaintEvent>
#include <QMessageBox>

#include "element.h"

Expand Down

0 comments on commit 7278ccf

Please sign in to comment.