00001 /* -*- c++ -*- (for Emacs) 00002 * 00003 * gesturequerymodel.h 00004 * Digest 00005 * 00006 * Created by Aidan Lane on Tue Jul 05 2005. 00007 * Copyright (c) 2005-2006 Optimisation and Constraint Solving Group, 00008 * Monash University. All rights reserved. 00009 * 00010 * This program is free software; you can redistribute it and/or modify 00011 * it under the terms of the GNU General Public License as published by 00012 * the Free Software Foundation; either version 2 of the License, or 00013 * (at your option) any later version. 00014 * 00015 * This program is distributed in the hope that it will be useful, 00016 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00017 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00018 * GNU General Public License for more details. 00019 * 00020 * You should have received a copy of the GNU General Public License 00021 * along with this program; if not, write to the Free Software 00022 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00023 */ 00024 00025 #ifndef GESTUREQUERYMODEL_H 00026 #define GESTUREQUERYMODEL_H 00027 00028 00029 #include <QSqlQueryModel> 00030 #include "MvcDigestDb/abstractdigestdbview.h" 00031 00032 #include <QBrush> 00033 #include <QPen> 00034 #include <QPixmap> 00035 #include <QSize> 00036 00037 class DigestDbModel; 00038 00039 00040 class GestureQueryModel : public QSqlQueryModel, public AbstractDigestDbView { 00041 00042 Q_OBJECT 00043 Q_PROPERTY( QSize thumbnailSize READ thumbnailSize WRITE setThumbnailSize ) 00044 00045 00046 public: 00047 GestureQueryModel( QObject* parent = 0 ); 00048 GestureQueryModel( DigestDbController* controller, QObject* parent = 0 ); 00049 00050 virtual Qt::ItemFlags flags( const QModelIndex& index ) const; 00051 virtual QVariant data( const QModelIndex& index, int role = Qt::DisplayRole ) const; 00052 virtual QStringList mimeTypes() const; 00053 virtual QMimeData* mimeData( const QModelIndexList& indexes ) const; 00054 00055 QModelIndex findIndexOfGesture( int gestureId ); 00056 int rowGestureId( int row ) const; 00057 00058 const QSize& thumbnailSize() const; 00059 00060 00061 signals: 00062 void thumbnailSizeChanged( const QSize& size ); 00063 00064 00065 public slots: 00066 virtual void setThumbnailSize( const QSize& size ); 00067 void setThumbnailSize( int w, int h ); 00068 00069 00070 protected: 00071 DEFINE_CUSTOM_VIEWEVENT_HANDLER 00072 virtual void resetEvent( VEvent* ); 00073 virtual void gesturesEvent( VGesturesEvent* ); 00074 00075 virtual QPixmap fetchThumbnail( int gestureId ) const; 00076 virtual QPixmap generateThumbnail( int gestureId ) const; 00077 virtual QPixmap generateThumbnailTile( const QSize& size ) const; 00078 00079 00080 private: 00081 void init(); 00082 00083 QSize m_thumbnailSize; 00084 QPen m_strokesPen; 00085 QPen m_tilePen; 00086 QBrush m_tileBrush; 00087 float m_strokeWidth; 00088 int m_tileMargin; 00089 00090 // Caches: 00091 mutable QPixmap c_thumbnailTile; 00092 }; 00093 00094 00095 #endif // ! GESTUREQUERYMODEL_H
1.5.2