From 144d91fee9e0ec0cb672508637c639cfbbf4e750 Mon Sep 17 00:00:00 2001 From: zecke Date: Sat, 24 Jul 2004 13:16:26 +0000 Subject: Delete the Views which are created in the OFileSelector Add a new member and one method to register the view. The views themselves (baseclass) call this function. Simply going over the viewMap wouldn't work as we can have the same instance contained twice under a different name --- (limited to 'libopie2') diff --git a/libopie2/opieui/fileselector/ofileselector.cpp b/libopie2/opieui/fileselector/ofileselector.cpp index 5528aed..b06defd 100644 --- a/libopie2/opieui/fileselector/ofileselector.cpp +++ b/libopie2/opieui/fileselector/ofileselector.cpp @@ -62,9 +62,11 @@ using namespace Opie::Ui::Internal; namespace Opie { namespace Ui { namespace Internal { -OFileViewInterface::OFileViewInterface( OFileSelector* selector ) - : m_selector( selector ) -{} +OFileViewInterface::OFileViewInterface( OFileSelector* _selector ) + : m_selector( _selector ) +{ + selector()->registerView( this ); +} OFileViewInterface::~OFileViewInterface() {} @@ -511,7 +513,7 @@ OFileSelector* OFileViewFileListView::selector() return m_sel; } -bool OFileViewFileListView::eventFilter (QObject *o, QEvent *e) +bool OFileViewFileListView::eventFilter (QObject *, QEvent *e) { if ( e->type() == QEvent::KeyPress ) { @@ -947,7 +949,7 @@ void OFileSelector::initUI() * This will make sure that the return key in the name edit causes dialogs to close */ -bool OFileSelector::eventFilter (QObject *o, QEvent *e) +bool OFileSelector::eventFilter (QObject *, QEvent *e) { if ( e->type() == QEvent::KeyPress ) { @@ -998,11 +1000,18 @@ void OFileSelector::initViews() m_views.insert( QObject::tr("All Files"), in ); } +void OFileSelector::registerView( const Internal::OFileViewInterface* iface ) { + m_viewsPtr.append( iface ); +} + + /** * d'tor */ OFileSelector::~OFileSelector() { + m_viewsPtr.setAutoDelete( true ); + m_viewsPtr.clear(); } diff --git a/libopie2/opieui/fileselector/ofileselector.h b/libopie2/opieui/fileselector/ofileselector.h index 8bcd9ee..de2b98a 100644 --- a/libopie2/opieui/fileselector/ofileselector.h +++ b/libopie2/opieui/fileselector/ofileselector.h @@ -44,6 +44,7 @@ #include #include #include +#include class QLineEdit; class QComboBox; @@ -183,6 +184,13 @@ private: /* init the Views :) */ void initViews(); + + /* + * register a view for deletion. + * This happens on creation of a OFileViewInterface + */ + void registerView( const Internal::OFileViewInterface* ); + private: QLineEdit* m_lneEdit; // the LineEdit for the Name QComboBox *m_cmbView, *m_cmbMime; // two ComboBoxes to select the View and MimeType @@ -194,6 +202,8 @@ private: MimeTypes m_mimeType; // list of mimetypes QMap m_views; // QString translated view name + ViewInterface Ptr + /* views register themselves automatically */ + QList m_viewsPtr; QHBox* m_nameBox; // the LineEdit + Label is hold here QHBox* m_cmbBox; // this holds the two combo boxes -- cgit v0.9.0.2