0.3.1
[qanava.git] / src / ui / uiStyleView.h
blob612d0a5528138245a2c7553cd16f40115ccefb63
1 /*
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
33 // Qanava headers
34 #include "../qanStyle.h"
37 // QT headers
38 #include <QWidget>
39 #include <QMainWindow>
40 #include <QAbstractItemModel>
41 #include <QTableView>
42 #include <QItemDelegate>
43 #include <QLabel>
44 #include <QLineEdit>
45 #include <QComboBox>
48 //-----------------------------------------------------------------------------
49 namespace qan // ::qan
51 class ColorEditWidget : public QWidget
53 Q_OBJECT
55 public:
57 ColorEditWidget( QWidget* parent, QColor color );
59 QColor getColor( ) { return _color; }
61 void setColor( QColor color );
63 protected:
65 QLabel* _label;
67 QColor _color;
69 private slots:
71 void selectColor( );
74 class StringEditWidget : public QWidget
76 Q_OBJECT
78 public:
80 StringEditWidget( QWidget* parent, QString s );
82 QString getString( ) { return _string; }
84 void setString( QString s );
86 protected:
88 QLineEdit* _edit;
90 QString _string;
92 private slots:
94 void selectString( );
96 void editingFinished( );
99 class StyleDelegate : public QItemDelegate
101 public:
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;
115 protected:
117 QAbstractItemModel& _model;
124 \nosubgrouping
126 class StyleEditor : public QMainWindow
128 Q_OBJECT
130 public:
132 StyleEditor( QWidget* parent = 0, Style* style = 0 );
134 virtual ~StyleEditor( ) { }
136 private:
138 StyleEditor( const StyleEditor& );
140 StyleEditor& operator=( const StyleEditor& );
142 public:
144 void setStyle( Style* style );
146 virtual QSize sizeHint( ) const { return QSize( 150, 200 ); }
148 protected slots:
150 void addAttribute( );
152 void removeAttribute( );
154 protected:
156 Style* _style;
158 QTableView* _tableView;
160 QComboBox* _cbType;
162 } // ::qan
163 //-----------------------------------------------------------------------------
166 #endif // uiStyleEditor_h