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. :-)
20 #include "layerlist.h"
23 * Default Constructor. You must call init manually before using
26 LayerBox::LayerBox(QWidget * parent, const char */*name*/): QComboBox(parent)
29 showUnchanged = false;
42 Layer * LayerBox::getLayer()
48 * Initialisation (called manually only once).
50 * @param layerList Layer list which provides the layer names that are
52 * @param showByBlock true: Show attribute ByBlock.
54 void LayerBox::init(LayerList & layerList, bool showByBlock, bool showUnchanged)
56 this->showByBlock = showByBlock;
57 this->showUnchanged = showUnchanged;
58 this->layerList = &layerList;
61 // insertItem(tr("- Unchanged -"));
62 addItem(tr("- Unchanged -"));
64 for(uint i=0; i<layerList.count(); ++i)
66 Layer * lay = layerList.at(i);
68 if (lay != NULL && (lay->getName() != "ByBlock" || showByBlock))
69 // insertItem(lay->getName());
70 addItem(lay->getName());
73 connect(this, SIGNAL(activated(int)), this, SLOT(slotLayerChanged(int)));
75 slotLayerChanged(currentIndex());
79 * Sets the layer shown in the combobox to the given layer.
81 void LayerBox::setLayer(Layer & layer)
83 currentLayer = &layer;
85 //if (layer.getName()=="ByBlock" && showByBlock) {
89 // setCurrentText(layer.getName());
90 setItemText(currentIndex(), layer.getName());
93 //if (currentItem()!=7+(int)showByBlock*2) {
94 slotLayerChanged(currentIndex());
99 * Sets the layer shown in the combobox to the given layer.
101 void LayerBox::setLayer(QString & layer)
103 //if (layer.getName()=="ByBlock" && showByBlock) {
104 // setCurrentItem(0);
106 // setCurrentText(layer);
107 setItemText(currentIndex(), layer);
110 //if (currentItem()!=7+(int)showByBlock*2) {
111 slotLayerChanged(currentIndex());
115 bool LayerBox::isUnchanged()
121 * Called when the color has changed. This method sets the current color to
122 * the value chosen or even offers a dialog to the user that allows him/her to
123 * choose an individual color.
125 void LayerBox::slotLayerChanged(int index)
127 //currentLayer.resetFlags();
129 if (index == 0 && showUnchanged)
134 // currentLayer = layerList->find(text(index));
135 currentLayer = layerList->find(itemText(index));
137 //printf("Current color is (%d): %s\n",
138 // index, currentLayer.name().latin1());
140 emit layerChanged(currentLayer);