| 1 | /* This file is part of Mapnik (c++ mapping toolkit) |
|---|
| 2 | * Copyright (C) 2007 Artem Pavlenko |
|---|
| 3 | * |
|---|
| 4 | * Mapnik is free software; you can redistribute it and/or |
|---|
| 5 | * modify it under the terms of the GNU General Public License |
|---|
| 6 | * as published by the Free Software Foundation; either version 2 |
|---|
| 7 | * of the License, or any later version. |
|---|
| 8 | * |
|---|
| 9 | * This program is distributed in the hope that it will be useful, |
|---|
| 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|---|
| 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|---|
| 12 | * GNU General Public License for more details. |
|---|
| 13 | * |
|---|
| 14 | * You should have received a copy of the GNU General Public License |
|---|
| 15 | * along with this program; if not, write to the Free Software |
|---|
| 16 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
|---|
| 17 | */ |
|---|
| 18 | |
|---|
| 19 | //$Id$ |
|---|
| 20 | |
|---|
| 21 | #include "layerwidget.hpp" |
|---|
| 22 | #include <qabstractitemdelegate.h> |
|---|
| 23 | #include <qapplication.h> |
|---|
| 24 | #include <qpainter.h> |
|---|
| 25 | #include <qbitmap.h> |
|---|
| 26 | #include <qvector.h> |
|---|
| 27 | #include <qstyle.h> |
|---|
| 28 | #include <qevent.h> |
|---|
| 29 | #include <qscrollbar.h> |
|---|
| 30 | #include <qrubberband.h> |
|---|
| 31 | #include <qdebug.h> |
|---|
| 32 | #include <iostream> |
|---|
| 33 | #include "layerlistmodel.hpp" |
|---|
| 34 | #include "layer_info_dialog.hpp" |
|---|
| 35 | |
|---|
| 36 | using namespace std; |
|---|
| 37 | |
|---|
| 38 | LayerTab::LayerTab(QWidget* parent) |
|---|
| 39 | : QListView(parent) {} |
|---|
| 40 | |
|---|
| 41 | |
|---|
| 42 | void LayerTab::paintEvent(QPaintEvent *e) |
|---|
| 43 | { |
|---|
| 44 | QListView::paintEvent(e); |
|---|
| 45 | } |
|---|
| 46 | |
|---|
| 47 | void LayerTab::dataChanged(const QModelIndex &topLeft, |
|---|
| 48 | const QModelIndex &bottomRight) |
|---|
| 49 | { |
|---|
| 50 | QListView::dataChanged(topLeft, bottomRight); |
|---|
| 51 | qDebug("FIXME : update map view!"); |
|---|
| 52 | emit update_mapwidget(); |
|---|
| 53 | } |
|---|
| 54 | |
|---|
| 55 | void LayerTab::selectionChanged(const QItemSelection & selected, const QItemSelection &) |
|---|
| 56 | { |
|---|
| 57 | QModelIndexList list = selected.indexes(); |
|---|
| 58 | if (list.size() != 0) |
|---|
| 59 | { |
|---|
| 60 | std::cout << "SELECTED LAYER ->" << list[0].row() << "\n"; |
|---|
| 61 | emit layerSelected(list[0].row()); |
|---|
| 62 | } |
|---|
| 63 | } |
|---|
| 64 | |
|---|
| 65 | void LayerTab::layerInfo() |
|---|
| 66 | { |
|---|
| 67 | qDebug("Layer info"); |
|---|
| 68 | QModelIndexList indexes = selectedIndexes(); |
|---|
| 69 | if (indexes.size() > 0) |
|---|
| 70 | { |
|---|
| 71 | qDebug("id = %d",indexes[0].row()); |
|---|
| 72 | |
|---|
| 73 | } |
|---|
| 74 | } |
|---|
| 75 | |
|---|
| 76 | void LayerTab::layerInfo2(QModelIndex const& index) |
|---|
| 77 | { |
|---|
| 78 | qDebug("LayerInfo id = %d",index.row()); |
|---|
| 79 | QVector<QPair<QString,QString> > params; |
|---|
| 80 | QVector<QString> style_names; |
|---|
| 81 | unsigned i = index.row(); |
|---|
| 82 | LayerListModel * model = static_cast<LayerListModel*>(this->model()); |
|---|
| 83 | boost::optional<mapnik::layer&> layer = model->map_layer(i); |
|---|
| 84 | |
|---|
| 85 | if (layer) |
|---|
| 86 | { |
|---|
| 87 | layer_info_dialog dlg(*layer,this); |
|---|
| 88 | dlg.exec(); |
|---|
| 89 | } |
|---|
| 90 | } |
|---|
| 91 | |
|---|
| 92 | StyleTab::StyleTab(QWidget*) |
|---|
| 93 | { |
|---|
| 94 | |
|---|
| 95 | } |
|---|
| 96 | |
|---|
| 97 | void StyleTab::contextMenuEvent(QContextMenuEvent * event ) |
|---|
| 98 | { |
|---|
| 99 | qDebug("test"); |
|---|
| 100 | } |
|---|