Skip to content

Commit

Permalink
Feature layer list filter by reg-expression is completed
Browse files Browse the repository at this point in the history
Now the layer list is always updated after
  changing reg-expression
  adding a new layer
  editing a layer
  removing a layer
  
New for adding layer:

New layer name is the last selected layer with an additional number
If there was only layer "0" the new layer is initialized to "noname"
Every new layer name is now selected, because of it's very easy to enter
a complete different name or editing the submitted name.
  • Loading branch information
epagel committed May 2, 2012
1 parent 1b7af53 commit 3a57136
Show file tree
Hide file tree
Showing 11 changed files with 46 additions and 5 deletions.
1 change: 0 additions & 1 deletion gitmodules/libredwg
Submodule libredwg deleted from d0b62c
2 changes: 2 additions & 0 deletions librecad/src/actions/rs_actionlayersadd.cpp
Expand Up @@ -29,6 +29,7 @@
#include <QAction>
#include "rs_dialogfactory.h"
#include "rs_graphic.h"
#include "qg_layerwidget.h"



Expand All @@ -53,6 +54,7 @@ void RS_ActionLayersAdd::trigger() {
graphic->getLayerList());
if (layer!=NULL)
graphic->addLayer(layer);
graphic->getLayerList()->getLayerWitget()->slotUpdateLayerList();
}
}
finish(false);
Expand Down
3 changes: 3 additions & 0 deletions librecad/src/actions/rs_actionlayersedit.cpp
Expand Up @@ -31,6 +31,7 @@
#include "rs_graphicview.h"
#include "rs_graphic.h"
#include "rs_layer.h"
#include "qg_layerwidget.h"



Expand Down Expand Up @@ -73,6 +74,8 @@ void RS_ActionLayersEdit::trigger() {
}
finish(false);

graphic->getLayerList()->getLayerWitget()->slotUpdateLayerList();

graphicView->redraw(RS2::RedrawDrawing);

}
Expand Down
2 changes: 2 additions & 0 deletions librecad/src/actions/rs_actionlayersremove.cpp
Expand Up @@ -29,6 +29,7 @@
#include <QAction>
#include "rs_dialogfactory.h"
#include "rs_graphic.h"
#include "qg_layerwidget.h"



Expand Down Expand Up @@ -76,6 +77,7 @@ void RS_ActionLayersRemove::trigger() {

// Now remove the layer from the layer list:
graphic->removeLayer(layer);
graphic->getLayerList()->getLayerWitget()->slotUpdateLayerList();
}
finish(false);
RS_DIALOGFACTORY->updateSelectionWidget(container->countSelected(),container->totalSelectedLength());
Expand Down
1 change: 1 addition & 0 deletions librecad/src/lib/engine/rs_graphic.h
Expand Up @@ -36,6 +36,7 @@
#include "rs_units.h"

class RS_VariableDict;
class QG_LayerWidget;

/**
* A graphic document which can contain entities layers and blocks.
Expand Down
11 changes: 11 additions & 0 deletions librecad/src/lib/engine/rs_layerlist.h
Expand Up @@ -32,6 +32,7 @@

class RS_Layer;
class RS_LayerListListener;
class QG_LayerWidget;

/**
* A list of layers.
Expand Down Expand Up @@ -75,6 +76,15 @@ class RS_LayerList {
void toggle(RS_Layer* layer);
void toggleLock(RS_Layer* layer);
void freezeAll(bool freeze);

//! sets the layerWidget pointer in RS_LayerListClass
void setLayerWitget(QG_LayerWidget * lw) {
layerWidget=lw;
}
//! @return the layerWidget pointer inside the RS_LayerListClass
QG_LayerWidget* getLayerWitget() {
return layerWidget;
}
//! @return First layer of the list.
//RS_Layer* firstLayer() {
// return layers.first();
Expand Down Expand Up @@ -111,6 +121,7 @@ class RS_LayerList {
QList<RS_Layer*> layers;
//! List of registered LayerListListeners
QList<RS_LayerListListener*> layerListListeners;
QG_LayerWidget* layerWidget;
//! Currently active layer
RS_Layer* activeLayer;
/** Flag set if the layer list was modified and not yet saved. */
Expand Down
6 changes: 6 additions & 0 deletions librecad/src/ui/forms/qg_layerdialog.cpp
Expand Up @@ -117,3 +117,9 @@ void QG_LayerDialog::init(){
void QG_LayerDialog::setEditLayer( bool el ){
editLayer = el;
}


//! @return a reference to the QLineEdit object.
QLineEdit* QG_LayerDialog::getQLineEdit () {
return leName;
}
2 changes: 2 additions & 0 deletions librecad/src/ui/forms/qg_layerdialog.h
Expand Up @@ -45,6 +45,8 @@ public slots:
virtual void validate();
virtual void setLayerList( RS_LayerList * ll );
virtual void setEditLayer( bool el );
//! @return a reference to the QLineEdit object.
virtual QLineEdit* getQLineEdit ();

protected:
RS_Layer* layer;
Expand Down
16 changes: 12 additions & 4 deletions librecad/src/ui/qg_dialogfactory.cpp
Expand Up @@ -32,6 +32,7 @@
//Added by qt3to4:
//#include <Q3StrList>
#include <QImageReader>
#include <QString>

#include "rs_patternlist.h"
#include "rs_settings.h"
Expand Down Expand Up @@ -191,20 +192,27 @@ RS_Layer* QG_DialogFactory::requestNewLayerDialog(RS_LayerList* layerList) {

RS_Layer* layer = NULL;

QString layer_name = "noname";
QString layer_name = "", newLayerName = "";
int i = 2;

if (layerList!=NULL) {
while (layerList->find(layer_name) > 0)
layer_name.sprintf("noname%d", i++);
layer_name = QString(layerList->getActive()->getName());
if (layer_name.isEmpty() || !layer_name.compare("0", Qt::CaseInsensitive) ) {
layer_name = "noname";
}
newLayerName = QString(layer_name);
while(layerList->find(newLayerName) > 0) {
newLayerName = QString("%1%2").arg(layer_name).arg(i);
}
}

// Layer for parameter livery
layer = new RS_Layer(layer_name);
layer = new RS_Layer(newLayerName);

QG_LayerDialog dlg(parent, "Layer Dialog");
dlg.setLayer(layer);
dlg.setLayerList(layerList);
dlg.getQLineEdit()->selectAll();
if (dlg.exec()) {
dlg.updateLayer();
} else {
Expand Down
3 changes: 3 additions & 0 deletions librecad/src/ui/qg_layerwidget.cpp
Expand Up @@ -241,6 +241,9 @@ QG_LayerWidget::~QG_LayerWidget() {
void QG_LayerWidget::setLayerList(RS_LayerList* layerList, bool showByBlock) {
this->layerList = layerList;
this->showByBlock = showByBlock;
if (layerList != NULL) {
this->layerList->setLayerWitget(this);
}
update();
}

Expand Down
4 changes: 4 additions & 0 deletions librecad/src/ui/qg_layerwidget.h
Expand Up @@ -108,6 +108,10 @@ class QG_LayerWidget: public QWidget, public RS_LayerListListener {
update();
}

QLineEdit* getMatchLayerName() {
return matchLayerName;
}

signals:
void escape();

Expand Down

0 comments on commit 3a57136

Please sign in to comment.