3 // Part of the Architektonas Project
4 // Originally part of QCad Community Edition by Andrew Mustun
5 // Extensively rewritten and refactored by James L. Hammons
6 // Portions copyright (C) 2001-2003 RibbonSoft
7 // Copyright (C) 2010 Underground Software
8 // See the README and GPLv2 files for licensing and warranty information
10 // JLH = James L. Hammons <jlhamm@acm.org>
13 // --- ---------- -----------------------------------------------------------
14 // JLH 05/11/2010 Added this text. :-)
17 #include "patternbox.h"
19 #include "rs_pattern.h"
20 #include "rs_patternlist.h"
24 * Default Constructor. You must call init manually if you choose
25 * to use this constructor.
27 PatternBox::PatternBox(QWidget * parent, const char */*name*/): QComboBox(parent)
34 PatternBox::~PatternBox()
39 * Initialisation (called manually and only once).
41 void PatternBox::init()
45 for(RS_Pattern * f=RS_PATTERNLIST->firstPattern(); f!=NULL; f=RS_PATTERNLIST->nextPattern())
46 patterns.append(f->getFileName());
49 // insertStringList(patterns);
52 connect(this, SIGNAL(activated(int)), this, SLOT(slotPatternChanged(int)));
55 slotPatternChanged(currentIndex());
58 RS_Pattern * PatternBox::getPattern()
60 return currentPattern;
64 * Sets the currently selected width item to the given width.
66 void PatternBox::setPattern(const QString & pName)
68 RS_DEBUG->print("PatternBox::setPattern %s\n", pName.toLatin1().data());
69 // setCurrentText(pName);
70 setItemText(currentIndex(), pName);
71 slotPatternChanged(currentIndex());
75 * Called when the pattern has changed. This method
76 * sets the current pattern to the value chosen.
78 void PatternBox::slotPatternChanged(int index)
80 RS_DEBUG->print("PatternBox::slotPatternChanged %d\n", index);
81 currentPattern = RS_PATTERNLIST->requestPattern(currentText());
83 if (currentPattern!=NULL)
84 RS_DEBUG->print("Current pattern is (%d): %s\n", index, currentPattern->getFileName().toLatin1().data());
86 emit patternChanged(currentPattern);