X-Git-Url: http://shamusworld.gotdns.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Fwidgets%2Flayerwidget.cpp;h=5dfe475591f5a6eb00e03e803144fb58b334bd77;hb=5adb444f3e523d3fd028617ced72d1ea6661db21;hp=28e5f6ffefb8a59cbd61a007b871ce13112d3a09;hpb=e5a77a32dbe17d9534d3099f1fd3fdacba199516;p=architektonas diff --git a/src/widgets/layerwidget.cpp b/src/widgets/layerwidget.cpp index 28e5f6f..5dfe475 100644 --- a/src/widgets/layerwidget.cpp +++ b/src/widgets/layerwidget.cpp @@ -17,14 +17,14 @@ #include "layerwidget.h" #include "actionhandler.h" -#include "rs_debug.h" -#include "rs_layer.h" -#include "rs_layerlist.h" +#include "debug.h" +#include "layer.h" +#include "layerlist.h" /** * Constructor. */ -QG_LayerWidget::QG_LayerWidget(QG_ActionHandler * ah, QWidget * parent, +LayerWidget::LayerWidget(ActionHandler * ah, QWidget * parent, const char * name, Qt::WindowFlags f): QWidget(parent, f), pxmLayerStatus00(":/res/layerstatus_00.xpm"), @@ -125,11 +125,9 @@ QG_LayerWidget::QG_LayerWidget(QG_ActionHandler * ah, QWidget * parent, /** * Destructor */ -QG_LayerWidget::~QG_LayerWidget() +LayerWidget::~LayerWidget() { delete listBox; - //delete pxmVisible; - //delete pxmHidden; } /** @@ -139,7 +137,7 @@ QG_LayerWidget::~QG_LayerWidget() * it exists. * false: don't show special layer "ByBlock" */ -void QG_LayerWidget::setLayerList(RS_LayerList * layerList, bool showByBlock) +void LayerWidget::setLayerList(LayerList * layerList, bool showByBlock) { this->layerList = layerList; this->showByBlock = showByBlock; @@ -149,117 +147,91 @@ void QG_LayerWidget::setLayerList(RS_LayerList * layerList, bool showByBlock) /** * Updates the layer box from the layers in the graphic. */ -void QG_LayerWidget::update() +void LayerWidget::update() { - RS_DEBUG->print("QG_LayerWidget::update() begin"); + DEBUG->print("LayerWidget::update() begin"); #warning "!!!" // int yPos = listBox->contentsY(); - RS_Layer * activeLayer = NULL; + Layer * activeLayer = NULL; - if (layerList != NULL) + if (layerList) activeLayer = layerList->getActive(); - RS_DEBUG->print("QG_LayerWidget::update() clearing listBox"); - + DEBUG->print("LayerWidget::update() clearing listBox"); listBox->clear(); - if (layerList == NULL) + if (!layerList) { - RS_DEBUG->print("QG_LayerWidget::update() abort"); + DEBUG->print("LayerWidget::update() abort"); return; } - RS_DEBUG->print("QG_LayerWidget::update() filling in layers"); + DEBUG->print("LayerWidget::update() filling in layers"); for(uint i=0; icount(); ++i) { - RS_Layer * layer = layerList->at(i); + Layer * layer = layerList->at(i); // hide layer "ByBlock"? - if (showByBlock || layer->getName()!="ByBlock") + if (showByBlock || layer->getName() != "ByBlock") { QPixmap * pm = NULL; if (!layer->isFrozen()) - { - if (!layer->isLocked()) - { - pm = &pxmLayerStatus10; - } - else - { - pm = &pxmLayerStatus11; - } - } + pm = (!layer->isLocked() ? &pxmLayerStatus10 : &pxmLayerStatus11); else - { - if (!layer->isLocked()) - { - pm = &pxmLayerStatus00; - } - else - { - pm = &pxmLayerStatus01; - } - } - - if (pm != NULL) - { -// listBox->insertItem(*pm, layer->getName()); - listBox->addItem(new QListWidgetItem(*pm, layer->getName())); - } + pm = (!layer->isLocked() ? &pxmLayerStatus00 : &pxmLayerStatus01); + +// listBox->insertItem(*pm, layer->getName()); + listBox->addItem(new QListWidgetItem(*pm, layer->getName())); } } - RS_DEBUG->print("QG_LayerWidget::update() sorting"); - + DEBUG->print("LayerWidget::update() sorting"); // listBox->sort(); listBox->sortItems(Qt::AscendingOrder); + DEBUG->print("LayerWidget::update() reactivating current layer"); - RS_DEBUG->print("QG_LayerWidget::update() reactivating current layer"); - - RS_Layer * l = lastLayer; + Layer * l = lastLayer; highlightLayer(activeLayer); lastLayer = l; #warning "!!!" // listBox->setContentsPos(0, yPos); - - RS_DEBUG->print("QG_LayerWidget::update() end"); + DEBUG->print("LayerWidget::update() end"); } /** * Highlights (activates) the given layer and makes it * the active layer in the layerlist. */ -void QG_LayerWidget::highlightLayer(RS_Layer * layer) +void LayerWidget::highlightLayer(Layer * layer) { - RS_DEBUG->print("QG_LayerWidget::highlightLayer() begin"); + DEBUG->print("LayerWidget::highlightLayer() begin"); - if (layer == NULL || layerList == NULL) + if (!layer || !layerList) { - RS_DEBUG->print("QG_LayerWidget::highlightLayer() abort"); + DEBUG->print("LayerWidget::highlightLayer() abort"); return; } QString name = layer->getName(); highlightLayer(name); - - RS_DEBUG->print("QG_LayerWidget::highlightLayer() end"); + DEBUG->print("LayerWidget::highlightLayer() end"); } /** * Highlights (activates) the given layer and makes it * the active layer in the layerlist. */ -void QG_LayerWidget::highlightLayer(const QString & name) +void LayerWidget::highlightLayer(const QString & name) { - RS_DEBUG->print("QG_LayerWidget::highlightLayer(name) begin"); + DEBUG->print("LayerWidget::highlightLayer(name) begin"); - if (layerList == NULL) + if (!layerList) { - RS_DEBUG->print("QG_LayerWidget::highlightLayer(name) abort"); + DEBUG->print("LayerWidget::highlightLayer(name) abort"); return; } @@ -277,32 +249,32 @@ void QG_LayerWidget::highlightLayer(const QString & name) } } - RS_DEBUG->print("QG_LayerWidget::highlightLayer(name) end"); + DEBUG->print("LayerWidget::highlightLayer(name) end"); } -/*virtual*/ void QG_LayerWidget::layerActivated(RS_Layer * layer) +void LayerWidget::layerActivated(Layer * layer) { highlightLayer(layer); } -/*virtual*/ void QG_LayerWidget::layerAdded(RS_Layer * layer) +void LayerWidget::layerAdded(Layer * layer) { update(); highlightLayer(layer); } -/*virtual*/ void QG_LayerWidget::layerEdited(RS_Layer *) +void LayerWidget::layerEdited(Layer *) { update(); } -/*virtual*/ void QG_LayerWidget::layerRemoved(RS_Layer *) +void LayerWidget::layerRemoved(Layer *) { update(); highlightLayer(layerList->at(0)); } -/*virtual*/ void QG_LayerWidget::layerToggled(RS_Layer *) +void LayerWidget::layerToggled(Layer *) { update(); } @@ -310,13 +282,13 @@ void QG_LayerWidget::highlightLayer(const QString & name) /** * Called when the user activates (highlights) a layer. */ -//void QG_LayerWidget::slotActivated(const QString & layerName) -void QG_LayerWidget::slotActivated(void) +//void LayerWidget::slotActivated(const QString & layerName) +void LayerWidget::slotActivated(void) { QString layerName = listBox->currentItem()->text(); - RS_DEBUG->print("QG_LayerWidget::slotActivated(): %s", layerName.toLatin1().data()); + DEBUG->print("LayerWidget::slotActivated(): %s", layerName.toLatin1().data()); - if (layerList == NULL) + if (!layerList) return; lastLayer = layerList->getActive(); @@ -326,14 +298,16 @@ void QG_LayerWidget::slotActivated(void) /** * Called for every mouse click. */ -//void QG_LayerWidget::slotMouseButtonClicked(int /*button*/, Q3ListBoxItem * item, const QPoint & pos) -void QG_LayerWidget::slotMouseButtonClicked(QListWidgetItem * item) +//void LayerWidget::slotMouseButtonClicked(int /*button*/, Q3ListBoxItem * item, const QPoint & pos) +void LayerWidget::slotMouseButtonClicked(QListWidgetItem * item) { - RS_DEBUG->print("QG_LayerWidget::slotMouseButtonClicked()"); + DEBUG->print("LayerWidget::slotMouseButtonClicked()"); QPoint p = mapFromGlobal(QCursor::pos()); // only change state / no activation - RS_Layer * l = lastLayer; + Layer * l = lastLayer; +#warning "!!! Bad implementation of lock/freeze functionality !!!" +//This is crap. if (p.x() < 23) { actionHandler->slotLayersToggleView(); @@ -346,7 +320,7 @@ void QG_LayerWidget::slotMouseButtonClicked(QListWidgetItem * item) } else { - if (item != NULL && layerList != NULL) + if (item && layerList) lastLayer = layerList->find(item->text()); } } @@ -354,7 +328,7 @@ void QG_LayerWidget::slotMouseButtonClicked(QListWidgetItem * item) /** * Shows a context menu for the layer widget. Launched with a right click. */ -void QG_LayerWidget::contextMenuEvent(QContextMenuEvent * e) +void LayerWidget::contextMenuEvent(QContextMenuEvent * e) { #warning "Needs porting to Qt4... !!! FIX !!!" #if 0 @@ -389,7 +363,7 @@ void QG_LayerWidget::contextMenuEvent(QContextMenuEvent * e) /** * Escape releases focus. */ -void QG_LayerWidget::keyPressEvent(QKeyEvent * e) +void LayerWidget::keyPressEvent(QKeyEvent * e) { switch (e->key()) { @@ -402,4 +376,3 @@ void QG_LayerWidget::keyPressEvent(QKeyEvent * e) break; } } -