00001 /* 00002 This file is part of the Opie Project 00003 00004 Copyright (c) 2002 Robert Griebl <sandman@handhelds.org> 00005 =. 00006 .=l. 00007 .>+-= 00008 _;:, .> :=|. This program is free software; you can 00009 .> <`_, > . <= redistribute it and/or modify it under 00010 :`=1 )Y*s>-.-- : the terms of the GNU Library General Public 00011 .="- .-=="i, .._ License as published by the Free Software 00012 - . .-<_> .<> Foundation; either version 2 of the License, 00013 ._= =} : or (at your option) any later version. 00014 .%`+i> _;_. 00015 .i_,=:_. -<s. This program is distributed in the hope that 00016 + . -:. = it will be useful, but WITHOUT ANY WARRANTY; 00017 : .. .:, . . . without even the implied warranty of 00018 =_ + =;=|` MERCHANTABILITY or FITNESS FOR A 00019 _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU 00020 ..}^=.= = ; Library General Public License for more 00021 ++= -. .` .: details. 00022 : = ...= . :.=- 00023 -. .:....=;==+<; You should have received a copy of the GNU 00024 -_. . . )=. = Library General Public License along with 00025 -- :-=` this library; see the file COPYING.LIB. 00026 If not, write to the Free Software Foundation, 00027 Inc., 59 Temple Place - Suite 330, 00028 Boston, MA 02111-1307, USA. 00029 */ 00030 00031 #ifndef STYLELISTITEM_H 00032 #define STYLELISTITEM_H 00033 00034 /* OPIE */ 00035 #include <opie2/oresource.h> 00036 00037 #include <qpe/styleinterface.h> 00038 #include <qpe/qlibrary.h> 00039 00040 /* QT */ 00041 #include <qlistbox.h> 00042 #include <qfileinfo.h> 00043 00044 #include <stdio.h> 00045 00046 class StyleListItem : public QListBoxText { 00047 public: 00048 StyleListItem ( const QString &t, QStyle *sty ) : QListBoxText ( t ) 00049 { 00050 m_lib = 0; 00051 m_style_if = 0; 00052 m_settings_if = 0; 00053 m_style = sty; 00054 } 00055 00056 StyleListItem ( QLibrary *lib, StyleInterface *iface ) : QListBoxText ( iface-> name ( )) 00057 { 00058 m_lib = lib; 00059 m_style_if = iface; 00060 m_settings_if = 0; 00061 m_style = iface-> style ( ); 00062 00063 iface-> queryInterface ( IID_StyleExtended, (QUnknownInterface **) &m_settings_if ); 00064 } 00065 00066 virtual ~StyleListItem ( ) 00067 { 00068 delete m_style; 00069 00070 if ( m_settings_if ) 00071 m_settings_if-> release ( ); 00072 if ( m_style_if ) 00073 m_style_if-> release ( ); 00074 delete m_lib; 00075 } 00076 00077 bool hasSettings ( ) const 00078 { 00079 return m_settings_if ? m_settings_if-> hasSettings ( ) : false; 00080 } 00081 00082 QWidget *settings ( QWidget *parent ) 00083 { 00084 return m_settings_if ? m_settings_if-> create ( parent ) : 0; 00085 } 00086 00087 bool setSettings ( bool accepted ) 00088 { 00089 if ( !m_settings_if ) 00090 return false; 00091 00092 if ( accepted ) 00093 return m_settings_if-> accept ( ); 00094 else { 00095 m_settings_if-> reject ( ); 00096 return false; 00097 } 00098 } 00099 00100 QString key ( ) 00101 { 00102 if ( m_lib ) 00103 return QFileInfo ( m_lib-> library ( )). fileName ( ); 00104 else 00105 return text ( ); 00106 } 00107 00108 QStyle *style ( ) 00109 { 00110 return m_style; 00111 } 00112 00113 private: 00114 QLibrary *m_lib; 00115 QStyle *m_style; 00116 StyleInterface *m_style_if; 00117 StyleExtendedInterface *m_settings_if; 00118 00119 }; 00120 00121 00122 #endif
1.4.2