[Jahshaka-cvs] jah/jahwidgets/src/qt3/python icon_view.cpp, NONE, 1.1 list_view.cpp, NONE, 1.1 py.c
Status: Beta
Brought to you by:
jahshaka
From: John B. <ok_...@us...> - 2007-01-16 10:51:35
|
Update of /cvsroot/jahshaka/jah/jahwidgets/src/qt3/python In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv4811/jahwidgets/src/qt3/python Modified Files: py.cpp python.pro python_vc71.vcproj Added Files: icon_view.cpp list_view.cpp Log Message: Adding listview and iconview --- NEW FILE: list_view.cpp --- // Copyright (C) 2006 VM Inc. // Released under the LGPL. // For more information, see http://www.jahshaka.org. // Boost #include "python.hpp" namespace py = boost::python; // Code to be wrapped #include <wrapper/list_view.hpp> #include "utils/string_utils.hpp" namespace opl = olib::openpluginlib; namespace qt3 = jahwidgets::qt3; namespace jahwidgets { namespace qt3 { // Create the delegate wrapper to properly support virtual functions... class list_view_delegate : public ListViewDelegate, public py::wrapper< ListViewDelegate > { public: list_view_delegate( ) : ListViewDelegate() { } list_view_delegate( const ListViewDelegate& other ) : ListViewDelegate( other ) { } list_view_delegate( const list_view_delegate& other ) : ListViewDelegate( other ), py::wrapper< ListViewDelegate >( other ) { } virtual ~list_view_delegate( ) { } // ListViewDelegate pure-virtual methods - most of which forward onto our 'wstring' python compatible versions int childCountOfItem( const QString& id ) const { return child_count_of_item( QStringToWString::convert( id ) ); } QString identifierForItem( int index, const QString& parentId ) const { return WStringToQString::convert( identifier_for_item( index, QStringToWString::convert( parentId ) ) ); } QString labelForItem( int index, const QString& parentId ) const { return WStringToQString::convert( label_for_item( index, QStringToWString::convert( parentId ) ) ); } bool itemIsBranch( int index, const QString& parentId ) const { return item_is_branch( index, QStringToWString::convert( parentId ) ); } int columns() const { return get_override( "columns" )(); } QString columnLabel( int col ) const { return WStringToQString::convert( column_label( col ) ); } // wstring versions which are actually exposed to python virtual int child_count_of_item( const opl::wstring& id ) const { return get_override( "child_count_of_item" )( id ); } virtual opl::wstring identifier_for_item( int index, const opl::wstring& parentId ) const { return get_override( "identifier_for_item" )( index, parentId ); } virtual opl::wstring label_for_item( int index, const opl::wstring& parentId ) const { return get_override( "label_for_item" )( index, parentId ); } virtual bool item_is_branch( int index, const opl::wstring& parentId ) const { return get_override( "item_is_branch" )( index, parentId ); } virtual opl::wstring column_label( int col ) const { return get_override( "column_label" )( col ); } }; } } void register_list_view( ) { // The control py::scope scope = py::class_< qt3::listview, boost::noncopyable >( "list_view", py::init< qt3::widget_handle* >( ) ) .def( "valid", &qt3::listview::valid ) .def( "update", &qt3::listview::update ) .def( "handle", &qt3::listview::handle ) .def( "register_delegate", &qt3::listview::setDelegate ) ; // The delegate - scoped by list_view py::class_< qt3::list_view_delegate >( "delegate", py::init< >( ) ) .def( "child_count_of_item", &qt3::list_view_delegate::child_count_of_item ) .def( "identifier_for_item", &qt3::list_view_delegate::identifier_for_item ) .def( "label_for_item", &qt3::list_view_delegate::label_for_item ) .def( "columns", &qt3::list_view_delegate::columns ) .def( "column_label", &qt3::list_view_delegate::column_label ) ; } Index: py.cpp =================================================================== RCS file: /cvsroot/jahshaka/jah/jahwidgets/src/qt3/python/py.cpp,v retrieving revision 1.13 retrieving revision 1.14 diff -u -d -r1.13 -r1.14 --- py.cpp 12 Dec 2006 11:29:11 -0000 1.13 +++ py.cpp 16 Jan 2007 10:51:30 -0000 1.14 @@ -24,6 +24,10 @@ extern void register_scribbler(); extern void register_geometry(); extern void register_color(); +extern void register_key_frame_interpolator(); +extern void register_key_frame_control(); +extern void register_list_view(); +extern void register_icon_view(); #ifdef MAC_OSX extern void register_macutils(); @@ -48,6 +52,10 @@ register_scribbler(); register_geometry(); register_color(); + register_key_frame_interpolator(); + register_key_frame_control(); + register_list_view(); + register_icon_view(); #ifdef MAC_OSX register_macutils(); --- NEW FILE: icon_view.cpp --- // Copyright (C) 2006 VM Inc. // Released under the LGPL. // For more information, see http://www.jahshaka.org. // Boost #include "python.hpp" namespace py = boost::python; #include <string> // Code to be wrapped #include <wrapper/icon_view.hpp> #include <widgets/iconviewDelegate.h> #include "utils/string_utils.hpp" namespace opl = olib::openpluginlib; namespace qt3 = jahwidgets::qt3; namespace jahwidgets { namespace qt3 { // Create the delegate wrapper to properly support virtual functions... class icon_view_delegate : public IconViewDelegate, public py::wrapper< IconViewDelegate > { public: icon_view_delegate( ) : IconViewDelegate() { } icon_view_delegate( const IconViewDelegate& other ) : IconViewDelegate( other ) { } icon_view_delegate( const icon_view_delegate& other ) : IconViewDelegate( other ), py::wrapper< IconViewDelegate >( other ) { } virtual ~icon_view_delegate( ) { } // IconViewDelegate pure-virtual methods - most of which forward onto our 'wstring' python compatible versions int count() const { return get_override( "count" )(); } QString labelForItem( int index ) const { return WStringToQString::convert( label_for_item( index ) ); } /// If the item represents an image on disk return the image path QString pathForItem( int index ) const { return WStringToQString::convert( path_for_item( index ) ); } /// Return the data representing the pixmap QByteArray dataForItem( int index ) const { QByteArray bytes; std::string data = data_for_item( index ); if ( data.size() ) { // deep copy bytes.duplicate( data.data(), data.size() ); } return bytes; } virtual il::image_type_ptr imageForItem( int index ) const { return image_for_item( index ); } // wstring versions which are actually exposed to python virtual opl::wstring label_for_item( int index ) const { if ( py::override o = get_override( "label_for_item" ) ) { return o( index ); } else { return opl::wstring(); } } virtual opl::wstring path_for_item( int index ) const { if ( py::override o = get_override( "path_for_item" ) ) { return o( index ); } else { return opl::wstring(); } } virtual std::string data_for_item( int index ) const { if ( py::override o = get_override( "data_for_item" ) ) { return o( index ); } else { return std::string(); } } virtual il::image_type_ptr image_for_item( int index ) const { if ( py::override o = get_override( "image_for_item" ) ) { return o( index ); } else { return il::image_type_ptr(); } } }; } } void register_icon_view( ) { // The control py::scope scope = py::class_< qt3::iconview, boost::noncopyable >( "icon_view", py::init< qt3::widget_handle* >( ) ) .def( "valid", &qt3::iconview::valid ) .def( "update", &qt3::iconview::update ) .def( "handle", &qt3::iconview::handle ) .def( "register_delegate", &qt3::iconview::setDelegate ) ; // The delegate - scoped by icon_view py::class_< qt3::icon_view_delegate >( "delegate", py::init< >( ) ) .def( "count", &qt3::icon_view_delegate::count ) .def( "label_for_item", &qt3::icon_view_delegate::label_for_item ) .def( "path_for_item", &qt3::icon_view_delegate::path_for_item ) .def( "data_for_item", &qt3::icon_view_delegate::data_for_item ) .def( "image_for_item", &qt3::icon_view_delegate::image_for_item ) ; } Index: python_vc71.vcproj =================================================================== RCS file: /cvsroot/jahshaka/jah/jahwidgets/src/qt3/python/python_vc71.vcproj,v retrieving revision 1.7 retrieving revision 1.8 diff -u -d -r1.7 -r1.8 --- python_vc71.vcproj 14 Sep 2006 10:14:50 -0000 1.7 +++ python_vc71.vcproj 16 Jan 2007 10:51:30 -0000 1.8 @@ -182,6 +182,18 @@ <File RelativePath=".\wrapper.cpp"> </File> + <File + RelativePath=".\key_frame_control.cpp"> + </File> + <File + RelativePath=".\key_frame_interpolator.cpp"> + </File> + <File + RelativePath=".\list_view.cpp"> + </File> + <File + RelativePath=".\icon_view.cpp"> + </File> </Filter> <Filter Name="Header Files" @@ -190,6 +202,9 @@ <File RelativePath=".\python.hpp"> </File> + <File + RelativePath="..\utils\string_utils.hpp"> + </File> </Filter> <Filter Name="Resource Files" Index: python.pro =================================================================== RCS file: /cvsroot/jahshaka/jah/jahwidgets/src/qt3/python/python.pro,v retrieving revision 1.20 retrieving revision 1.21 diff -u -d -r1.20 -r1.21 --- python.pro 12 Dec 2006 11:29:11 -0000 1.20 +++ python.pro 16 Jan 2007 10:51:30 -0000 1.21 @@ -14,7 +14,7 @@ mac { DEFINES += MAC_OSX - INCLUDEPATH += /usr/include/python2.3 + INCLUDEPATH += /usr/include/python2.4 LIBS += -lqui -lboost_python -framework Python -framework CoreFoundation } @@ -29,6 +29,8 @@ INCLUDEPATH += ../wrapper .. LIBS += -L../wrapper -lwrapper +include(../utils/utils.pri) + SOURCES += wrapper.cpp \ widget_handle.cpp \ application.cpp \ @@ -48,7 +50,9 @@ color.cpp \ py.cpp \ key_frame_control.cpp \ - key_frame_interpolator.cpp + key_frame_interpolator.cpp \ + list_view.cpp \ + icon_view.cpp mac: SOURCES += macutils.cpp |