1
/****************************************************************************
3
** This file is part of the LibreCAD project, a 2D CAD program
5
** Copyright (C) 2011 Rallaz (rallazz@gmail.com)
6
** Copyright (C) 2010 R. van Twisk (librecad@rvt.dds.nl)
9
** This file is free software; you can redistribute it and/or modify
10
** it under the terms of the GNU General Public License as published by
11
** the Free Software Foundation; either version 2 of the License, or
12
** (at your option) any later version.
14
** This program is distributed in the hope that it will be useful,
15
** but WITHOUT ANY WARRANTY; without even the implied warranty of
16
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17
** GNU General Public License for more details.
19
** You should have received a copy of the GNU General Public License
20
** along with this program; if not, write to the Free Software
21
** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
23
** This copyright notice MUST APPEAR in all copies of the script!
25
**********************************************************************/
27
#ifndef QG_LAYERWIDGET_H
28
#define QG_LAYERWIDGET_H
32
#include <QAbstractTableModel>
34
#include "rs_layerlistlistener.h"
35
#include "rs_layerlist.h"
37
class QG_ActionHandler;
42
* Implementation of a model to use in QG_LayerWidget
44
class QG_LayerModel: public QAbstractTableModel {
53
QG_LayerModel(QObject * parent = 0);
55
Qt::ItemFlags flags ( const QModelIndex & /*index*/ ) const {
56
return Qt::ItemIsSelectable|Qt::ItemIsEnabled;}
57
int columnCount(const QModelIndex &/*parent*/) const {return LAST;}
58
int rowCount ( const QModelIndex & parent = QModelIndex() ) const;
59
QVariant data ( const QModelIndex & index, int role = Qt::DisplayRole ) const;
60
QModelIndex parent ( const QModelIndex & index ) const;
61
QModelIndex index ( int row, int column, const QModelIndex & parent = QModelIndex() ) const;
62
void setLayerList(RS_LayerList* ll);
63
RS_Layer *getLayer( int row );
64
QModelIndex getIndex (RS_Layer * lay);
67
QList<RS_Layer*> listLayer;
77
* This is the Qt implementation of a widget which can view a
78
* layer list and provides a user interface for basic layer actions.
80
class QG_LayerWidget: public QWidget, public RS_LayerListListener {
84
QG_LayerWidget(QG_ActionHandler* ah, QWidget* parent,
85
const char* name=0, Qt::WindowFlags f = 0);
88
void setLayerList(RS_LayerList* layerList, bool showByBlock);
91
void activateLayer(RS_Layer* layer);
93
virtual void layerActivated(RS_Layer* layer) {
96
virtual void layerAdded(RS_Layer* layer) {
100
virtual void layerEdited(RS_Layer*) {
103
virtual void layerRemoved(RS_Layer*) {
105
activateLayer(layerList->at(0));
107
virtual void layerToggled(RS_Layer*) {
110
virtual void layerToggledLock(RS_Layer*) {
113
virtual void layerToggledPrint(RS_Layer*) {
117
QLineEdit* getMatchLayerName() {
118
return matchLayerName;
125
void slotActivated(QModelIndex layerIdx);
126
void slotUpdateLayerList();
129
void contextMenuEvent(QContextMenuEvent *e);
130
virtual void keyPressEvent(QKeyEvent* e);
133
RS_LayerList* layerList;
135
QLineEdit* matchLayerName;
136
QTableView* layerView;
137
QG_LayerModel *layerModel;
139
QG_ActionHandler* actionHandler;