Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions src/autotest/autotest.pro
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
QT += testlib xml
QT += testlib
CONFIG += c++11 strict_c++
CONFIG(release, debug|release):CONFIG += optimize_full

# For Appveyor because it dumps includes in the project root
APPVEYOR_BUILD_FOLDER=$$(APPVEYOR_BUILD_FOLDER)
!isEmpty(APPVEYOR_BUILD_FOLDER) {
INCLUDEPATH += $$APPVEYOR_BUILD_FOLDER
}

CONFIG += optimize_full c++11
CONFIG += qt console warn_on depend_includepath testcase
CONFIG -= app_bundle

Expand All @@ -20,7 +27,7 @@ DEPENDPATH += $$SOURCE_ROOT/kicad $$SOURCE_ROOT/pdf_extract

SOURCES += tst_pdf_extract.cpp

unix:{
unix {
QMAKE_LFLAGS_RPATH=
QMAKE_LFLAGS += "-Wl,-rpath,\'\$$ORIGIN\'"
}
4 changes: 2 additions & 2 deletions src/autotest/tst_pdf_extract.cpp
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#include <QCoreApplication>
#include <QtTest>

#include "datasheet.h"
#include <datasheet.h>

#include "model/lib.h"
#include <model/lib.h>

class PdfExtract : public QObject
{
Expand Down
22 changes: 12 additions & 10 deletions src/kicad/itemmodel/componentlibitemmodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,18 +22,17 @@
#include <QFont>

ComponentLibItemModel::ComponentLibItemModel(Lib *lib, QObject *parent)
: QAbstractItemModel(parent)
: QAbstractItemModel(parent),
_lib(nullptr),
_activeComponent(nullptr),
_selectedMode(false)
{
if (lib != nullptr)
if (lib == nullptr)
{
_lib = lib;
lib = new Lib();
}
else
{
_lib = new Lib();
}
_selectedMode = false;
_activeComponent = nullptr;

_lib = lib;
}

Lib *ComponentLibItemModel::lib() const
Expand All @@ -47,7 +46,10 @@ void ComponentLibItemModel::setLib(Lib *lib)
_activeComponent = nullptr;
beginResetModel();
resetInternalData();
// delete _lib;
if(lib != nullptr)
{
delete _lib;
}
_lib = lib;
endResetModel();
emit layoutChanged();
Expand Down
2 changes: 1 addition & 1 deletion src/kicad/itemmodel/componentlibitemmodel.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
#include <QAbstractItemModel>
#include <QtCore/qglobal.h>

#include "model/lib.h"
#include <model/lib.h>

class KICAD_EXPORT ComponentLibItemModel : public QAbstractItemModel
{
Expand Down
27 changes: 14 additions & 13 deletions src/kicad/itemmodel/componentlibtreeview.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,19 @@
#include <QMouseEvent>

ComponentLibTreeView::ComponentLibTreeView(Lib *lib, QWidget *parent)
: QTreeView(parent)
: QTreeView(parent),
_model(nullptr),
_sortProxy(nullptr),
_editMode(false),
_removeAction(nullptr)
{
if (lib != nullptr)
if (lib == nullptr)
{
_model = new ComponentLibItemModel(lib);
}
else
{
_model = new ComponentLibItemModel(new Lib());
lib = new Lib();
}

_model = new ComponentLibItemModel(lib);

setSelectionMode(QAbstractItemView::ExtendedSelection);
_editMode = false;

Expand All @@ -55,13 +57,12 @@ Lib *ComponentLibTreeView::lib() const

void ComponentLibTreeView::setLib(Lib *lib)
{
_model->setLib(lib);
if (lib == _model->lib())
if (lib != _model->lib())
{
return;
_model->setLib(lib);
resizeColumnToContents(0);
resizeColumnToContents(1);
}
resizeColumnToContents(0);
resizeColumnToContents(1);
}

void ComponentLibTreeView::setActiveComponent(Component *component)
Expand Down Expand Up @@ -129,7 +130,7 @@ void ComponentLibTreeView::remove()
return;
}
QList<QPersistentModelIndex> pindex;
for (QModelIndex selected : selection)
for (QModelIndex selected : qAsConst(selection))
{
const QModelIndex &indexComponent = _sortProxy->mapToSource(selected);
if (!indexComponent.isValid() || indexComponent.column() != 0)
Expand Down
17 changes: 9 additions & 8 deletions src/kicad/itemmodel/componentpinsitemmodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,12 @@
#include <QDebug>

ComponentPinsItemModel::ComponentPinsItemModel(Component *component, QObject *parent)
: QAbstractItemModel(parent)
: QAbstractItemModel(parent),
_component(nullptr),
_isExpendable(true)
{
setComponent(component);
_isExpendable = true;
_higherPin = QString();
_higherPin.clear();
}

Component *ComponentPinsItemModel::component() const
Expand Down Expand Up @@ -299,7 +300,7 @@ QString ComponentPinsItemModel::toNumeric(const QString &str)
{
QString sortPatern = str;

QRegularExpression numPattern("([^0-9]*)([0-9]+)([^0-9]*)", QRegularExpression::CaseInsensitiveOption);
static QRegularExpression numPattern("([^0-9]*)([0-9]+)([^0-9]*)", QRegularExpression::CaseInsensitiveOption);

QRegularExpressionMatchIterator numMatchIt = numPattern.globalMatch(str);
if (numMatchIt.hasNext())
Expand All @@ -317,11 +318,11 @@ QString ComponentPinsItemModel::toNumeric(const QString &str)

void ComponentPinsItemModel::updateHigherPin()
{
_higherPin = QString();
QString higherNumPin = QString();
QString higherNumPin;
_higherPin.clear();
if (_component != nullptr)
{
for (Pin *pin : _component->pins())
for (Pin *pin : qAsConst(_component->pins()))
{
QString numPin = toNumeric(pin->padName());
if (numPin > higherNumPin)
Expand All @@ -330,7 +331,7 @@ void ComponentPinsItemModel::updateHigherPin()
higherNumPin = numPin;
}
}
QRegularExpression higherNumPinPattern("([A-Z]*0*)([1-9][0-9]*)", QRegularExpression::CaseInsensitiveOption);
static QRegularExpression higherNumPinPattern("([A-Z]*0*)([1-9][0-9]*)", QRegularExpression::CaseInsensitiveOption);
QRegularExpressionMatchIterator higherNumPinMatchIt = higherNumPinPattern.globalMatch(_higherPin);
if (higherNumPinMatchIt.hasNext())
{
Expand Down
2 changes: 1 addition & 1 deletion src/kicad/itemmodel/componentpinsitemmodel.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

#include <QAbstractItemModel>

#include "model/component.h"
#include <model/component.h>

class KICAD_EXPORT ComponentPinsItemModel : public QAbstractItemModel
{
Expand Down
12 changes: 9 additions & 3 deletions src/kicad/itemmodel/componentpinstableview.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,12 @@
#include <QMouseEvent>

ComponentPinsTableView::ComponentPinsTableView(Component *component, QWidget *parent)
: QTableView(parent)
: QTableView(parent),
_model(nullptr),
_delegate(nullptr),
_sortProxy(nullptr),
_removeAction(nullptr),
_copyAction(nullptr)
{
_model = new ComponentPinsItemModel(component);

Expand Down Expand Up @@ -126,7 +131,7 @@ void ComponentPinsTableView::remove()
if (!selection.empty())
{
QList<QPersistentModelIndex> pindex;
for (QModelIndex selected : selection)
for (QModelIndex selected : qAsConst(selection))
{
const QModelIndex &indexComponent = _sortProxy->mapToSource(selected);
if (!indexComponent.isValid())
Expand Down Expand Up @@ -174,7 +179,8 @@ void ComponentPinsTableView::updateSelect(const QItemSelection &selected, const
Q_UNUSED(deselected)

QSet<Pin *> selectedPins;
for (const QModelIndex &index : selectionModel()->selectedIndexes())
const auto& selected_idx = selectionModel()->selectedIndexes();
for (const QModelIndex &index : selected_idx)
{
if (!index.isValid())
{
Expand Down
4 changes: 3 additions & 1 deletion src/kicad/itemmodel/pinlisteditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@
#include <QVBoxLayout>

PinListEditor::PinListEditor(QWidget *parent)
: QWidget(parent)
: QWidget(parent),
_componentPinsTableView(nullptr),
_nameFilterEdit(nullptr)
{
createWidgets();
}
Expand Down
18 changes: 10 additions & 8 deletions src/kicad/kicad.pro
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
#-------------------------------------------------
#
# Project created by QtCreator 2014-08-05T17:49:45
#
#-------------------------------------------------
QT += core gui widgets
QT += printsupport
# printer support is for PDF output

QT += gui printsupport
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
CONFIG += c++11 strict_c++
CONFIG(release, debug|release):CONFIG += optimize_full

CONFIG += optimize_full c++11
# For Appveyor because it dumps includes in the project root
APPVEYOR_BUILD_FOLDER=$$(APPVEYOR_BUILD_FOLDER)
!isEmpty(APPVEYOR_BUILD_FOLDER) {
INCLUDEPATH += $$APPVEYOR_BUILD_FOLDER
}

TARGET = kicad
TEMPLATE = lib
Expand Down
6 changes: 4 additions & 2 deletions src/kicad/ksseditor/ksseditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,10 @@
#include <QPainter>

KssEditor::KssEditor(QWidget *parent)
: QPlainTextEdit(parent)
: QPlainTextEdit(parent),
_syntax(nullptr),
_kssEditorMargin(nullptr),
_lineError(-1)
{
_syntax = new KSSSyntax(this->document());

Expand All @@ -36,7 +39,6 @@ KssEditor::KssEditor(QWidget *parent)
font.setStyleHint(QFont::Monospace);
setFont(font);

_lineError = -1;
updateExtraSelection();
}

Expand Down
6 changes: 3 additions & 3 deletions src/kicad/ksseditor/ksssyntax.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ KSSSyntax::KSSSyntax(QTextDocument *parent)
<< "label"
<< "rect"
<< "priority";
for (const QString &pattern : keywordPatterns)
for (const QString &pattern : qAsConst(keywordPatterns))
{
rule.pattern.setPattern("\\b(" + pattern + ")\\b");
rule.format = keywordFormat;
Expand Down Expand Up @@ -89,7 +89,7 @@ KSSSyntax::KSSSyntax(QTextDocument *parent)
<< "faledge"
<< "nologic";

for (const QString &pattern : enumvaluesPatterns)
for (const QString &pattern : qAsConst(enumvaluesPatterns))
{
rule.pattern.setPattern("\\b(" + pattern + ")\\b");
rule.format = enumvaluesFormat;
Expand Down Expand Up @@ -117,7 +117,7 @@ void KSSSyntax::highlightBlock(const QString &text)
PartToHighlight highlight;

partsToHighlight.clear();
for (const HighlightingRule &rule : highlightingRules)
for (const HighlightingRule &rule : qAsConst(highlightingRules))
{
QRegularExpressionMatch match = rule.pattern.match(text);
if (match.hasMatch())
Expand Down
25 changes: 21 additions & 4 deletions src/kicad/model/component.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,15 @@
* @param name optionally specify the component name at the creation
*/
Component::Component(const QString &name)
: _prefix("U")
: _prefix("U"),
_showPinName(true),
_showPadName(true),
_unitCount(1),
_refText(nullptr),
_nameText(nullptr),
_packageText(nullptr),
_docText(nullptr)
{
_showPinName = true;
_showPadName = true;
_unitCount = 1;
_refText = new DrawText("U");
_nameText = new DrawText();
_packageText = new DrawText();
Expand Down Expand Up @@ -80,15 +84,24 @@ Component::~Component()
for (auto &pin : _pins)
{
delete pin;
pin = nullptr;
}
for (auto &draw : _draws)
{
delete draw;
draw = nullptr;
}
delete _refText;
_refText = nullptr;

delete _nameText;
_nameText = nullptr;

delete _packageText;
_packageText = nullptr;

delete _docText;
_docText = nullptr;
}

/**
Expand Down Expand Up @@ -149,6 +162,7 @@ void Component::removePin(Pin *pin)
if (_pins.removeOne(pin))
{
delete pin;
pin = nullptr;
}
}

Expand All @@ -160,6 +174,7 @@ void Component::clearPins()
for (auto &pin : _pins)
{
delete pin;
pin = nullptr;
}
_pins.clear();
}
Expand Down Expand Up @@ -211,6 +226,7 @@ void Component::removeDraw(Draw *draw)
if (_draws.removeOne(draw))
{
delete draw;
draw = nullptr;
}
}

Expand All @@ -222,6 +238,7 @@ void Component::clearDraws()
for (auto &draw : _draws)
{
delete draw;
draw = nullptr;
}
_draws.clear();
}
Expand Down
3 changes: 3 additions & 0 deletions src/kicad/model/drawarc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@
#include "drawarc.h"

DrawArc::DrawArc()
: _radius(0),
_startAngle(0),
_endAngle(0)
{
}

Expand Down
Loading