1 /* 2 * wangtemplateview.h 3 * Copyright 2017, Benjamin Trotter <bdtrotte@ucsc.edu> 4 * 5 * This file is part of Tiled. 6 * 7 * This program is free software; you can redistribute it and/or modify it 8 * under the terms of the GNU General Public License as published by the Free 9 * Software Foundation; either version 2 of the License, or (at your option) 10 * any later version. 11 * 12 * This program is distributed in the hope that it will be useful, but WITHOUT 13 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 14 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 15 * more details. 16 * 17 * You should have received a copy of the GNU General Public License along with 18 * this program. If not, see <http://www.gnu.org/licenses/>. 19 */ 20 21 #pragma once 22 23 #include "wangtemplatemodel.h" 24 25 #include <QListView> 26 27 namespace Tiled { 28 29 class WangSet; 30 class WangId; 31 32 class Zoomable; 33 34 class WangTemplateView : public QListView 35 { 36 Q_OBJECT 37 38 public: 39 WangTemplateView(QWidget *parent = nullptr); 40 zoomable()41 Zoomable *zoomable() const { return mZoomable; } 42 43 qreal scale() const; 44 wangTemplateModel()45 WangTemplateModel *wangTemplateModel() const 46 { return static_cast<WangTemplateModel *>(model()); } 47 48 WangSet *wangSet() const; 49 50 bool wangIdIsUsed(WangId wangId) const; 51 52 protected: 53 bool event(QEvent *e) override; 54 void keyPressEvent(QKeyEvent *event) override; 55 void wheelEvent(QWheelEvent *event) override; 56 57 private: 58 void adjustScale(); 59 60 Zoomable *mZoomable; 61 }; 62 63 } // namespace Tiled 64