Permalink
Browse files

Add manage button in line pattern selector

  • Loading branch information...
feragon committed Aug 9, 2016
1 parent 943242e commit f60aea18d30ac6cda75800b606634b7eef7f6a0d
@@ -6,7 +6,7 @@ LinePatternPainter::LinePatternPainter(QPaintDevice *device, lc::DxfLinePattern_
_width(width) {
}
LinePatternPainter::LinePatternPainter(QPaintDevice *device, int width, lc::DxfLinePattern_CSPtr linePattern) :
LinePatternPainter::LinePatternPainter(QPaintDevice *device, double width, lc::DxfLinePattern_CSPtr linePattern) :
_device(device),
_linePattern(linePattern),
_width(width) {
@@ -7,7 +7,7 @@
class LinePatternPainter {
public:
LinePatternPainter(QPaintDevice* device, lc::DxfLinePattern_CSPtr linePattern, int width = 1);
LinePatternPainter(QPaintDevice* device, int width, lc::DxfLinePattern_CSPtr linePattern = nullptr);
LinePatternPainter(QPaintDevice* device, double width, lc::DxfLinePattern_CSPtr linePattern = nullptr);
void drawLinePattern();
private:
@@ -63,21 +63,26 @@ void LinePatternSelect::onActivated(const QString& text) {
auto dialog = new AddLinePatternDialog(_document, this);
dialog->show();
}
else if(text == MANAGE_LP) {
auto dialog = new LinePatternManager(_document, this);
dialog->show();
}
}
void LinePatternSelect::createEntries() {
clear();
if(_document != nullptr) {
if(_showByBlock) {
insertItem(0, BY_BLOCK);
}
addItem(NEW_LP);
addItem(MANAGE_LP);
insertSeparator(2);
if(_showByLayer) {
insertItem(0, BY_LAYER);
addItem(BY_LAYER);
}
if(_showByBlock) {
addItem(BY_BLOCK);
}
insertItem(0, NEW_LP);
auto linePatterns = _document->linePatterns();
for (auto linePattern : linePatterns) {
@@ -5,11 +5,13 @@
#include <cad/meta/dxflinepattern.h>
#include <widgets/linepatternpainter.h>
#include <dialogs/addlinepatterndialog.h>
#include <dialogs/linepatternmanager.h>
#include <cad/document/document.h>
#define BY_BLOCK "ByBlock"
#define BY_LAYER "ByLayer"
#define NEW_LP "New line pattern"
#define MANAGE_LP "Manage line patterns"
class LinePatternSelect : public QComboBox {
Q_OBJECT
@@ -68,11 +68,11 @@ TEST(LinePatternTest, Selection) {
auto document = createDocument();
auto linePatternSelect = new LinePatternSelect(document);
EXPECT_EQ(1, linePatternSelect->count()) << "Select should contains New";
EXPECT_EQ(3, linePatternSelect->count()) << "Select should contains New/Manage/Separator";
delete linePatternSelect;
linePatternSelect = new LinePatternSelect(document, 0, true, true);
EXPECT_EQ(3, linePatternSelect->count()) << "Select should contains New/ByBlock/ByLayer";
EXPECT_EQ(5, linePatternSelect->count()) << "Select should contains New/Manage/Separator/ByBlock/ByLayer";
auto linePattern1 = std::make_shared<const lc::DxfLinePattern>("LP", "Line Pattern", std::vector<double>{1, -1, 0, -1}, 3);
auto linePattern2 = std::make_shared<const lc::DxfLinePattern>("NLP", "New Line Pattern", std::vector<double>{0, -1, 1, -1}, 3);
@@ -82,7 +82,7 @@ TEST(LinePatternTest, Selection) {
operation = std::make_shared<lc::operation::AddLinePattern>(document, linePattern2);
operation->execute();
EXPECT_EQ(5, linePatternSelect->count()) << "Layers were not added to line pattern select";
EXPECT_EQ(7, linePatternSelect->count()) << "Line patterns were not added to select";
linePatternSelect->setCurrentText(linePattern1->name().c_str());
EXPECT_EQ(linePattern1, linePatternSelect->linePattern()) << "Selected line pattern wasn't returned";

0 comments on commit f60aea1

Please sign in to comment.