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"
20 #include "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 * Initialization (called manually and only once).
41 void PatternBox::init()
45 for(Pattern * f=PATTERNLIST->firstPattern(); f!=NULL; f=PATTERNLIST->nextPattern())
46 patterns.append(f->getFileName());
49 std::cout << "patterns size = " << patterns.size() << std::endl;
51 for(int i=0; i<patterns.size(); i++)
52 std::cout << patterns.at(i).toLocal8Bit().constData() << std::endl;
59 connect(this, SIGNAL(activated(int)), this, SLOT(slotPatternChanged(int)));
62 slotPatternChanged(currentIndex());
65 Pattern * PatternBox::getPattern()
67 return currentPattern;
71 * Sets the currently selected width item to the given width.
73 void PatternBox::setPattern(const QString & pName)
75 DEBUG->print("PatternBox::setPattern %s\n", pName.toAscii().data());
76 setItemText(currentIndex(), pName);
77 slotPatternChanged(currentIndex());
81 * Called when the pattern has changed. This method
82 * sets the current pattern to the value chosen.
84 void PatternBox::slotPatternChanged(int index)
86 DEBUG->print("PatternBox::slotPatternChanged %d\n", index);
87 currentPattern = PATTERNLIST->requestPattern(currentText());
90 DEBUG->print("Current pattern is (%d): %s\n", index, currentPattern->getFileName().toAscii().data());
92 emit patternChanged(currentPattern);