2 Qanava - Graph drawing library for QT
3 Copyright (C) 2006 Benoit AUTHEMAN
5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
15 You should have received a copy of the GNU Lesser General Public
16 License along with this library; if not, write to the Free Software
17 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20 //-----------------------------------------------------------------------------
21 // This file is a part of the Qanava software.
23 // \file uiStyleView.h
24 // \author Benoit Autheman (benoit@libqanava.org)
25 // \date 2005 December 23
26 //-----------------------------------------------------------------------------
29 #ifndef uiStyleEditor_h
30 #define uiStyleEditor_h
34 #include "../qanStyle.h"
39 #include <QMainWindow>
40 #include <QAbstractItemModel>
42 #include <QItemDelegate>
48 //-----------------------------------------------------------------------------
49 namespace qan
// ::qan
51 class ColorEditWidget
: public QWidget
57 ColorEditWidget( QWidget
* parent
, QColor color
);
59 QColor
getColor( ) { return _color
; }
61 void setColor( QColor color
);
74 class StringEditWidget
: public QWidget
80 StringEditWidget( QWidget
* parent
, QString s
);
82 QString
getString( ) { return _string
; }
84 void setString( QString s
);
96 void editingFinished( );
99 class StyleDelegate
: public QItemDelegate
103 StyleDelegate( QAbstractItemModel
& model
/*QAbstractItemView& tableView*/ );
105 virtual QWidget
* createEditor ( QWidget
* parent
, const QStyleOptionViewItem
& option
, const QModelIndex
& index
) const;
107 virtual void paint( QPainter
* painter
, const QStyleOptionViewItem
& option
, const QModelIndex
& index
) const;
109 virtual void setEditorData( QWidget
* editor
, const QModelIndex
& index
) const;
111 virtual void setModelData( QWidget
* editor
, QAbstractItemModel
* model
, const QModelIndex
& index
) const;
113 virtual QSize
sizeHint ( const QStyleOptionViewItem
& option
, const QModelIndex
& index
) const;
117 QAbstractItemModel
& _model
;
126 class StyleEditor
: public QMainWindow
132 StyleEditor( QWidget
* parent
= 0, Style
* style
= 0 );
134 virtual ~StyleEditor( ) { }
138 StyleEditor( const StyleEditor
& );
140 StyleEditor
& operator=( const StyleEditor
& );
144 void setStyle( Style
* style
);
146 virtual QSize
sizeHint( ) const { return QSize( 150, 200 ); }
150 void addAttribute( );
152 void removeAttribute( );
158 QTableView
* _tableView
;
163 //-----------------------------------------------------------------------------
166 #endif // uiStyleEditor_h