From d32377845bf718c03c9305f705788d774eec1073 Mon Sep 17 00:00:00 2001 From: Tobias Doerffel Date: Mon, 24 Mar 2014 19:19:18 +0100 Subject: [PATCH] ComboBoxModel: coding style fixes --- include/ComboBoxModel.h | 30 +++++++++++++++--------------- src/core/ComboBoxModel.cpp | 19 ++++++++++--------- 2 files changed, 25 insertions(+), 24 deletions(-) diff --git a/include/ComboBoxModel.h b/include/ComboBoxModel.h index 436fd50cf..b11af8832 100644 --- a/include/ComboBoxModel.h +++ b/include/ComboBoxModel.h @@ -1,7 +1,7 @@ /* * ComboBoxModel.h - declaration of class ComboBoxModel * - * Copyright (c) 2008-2011 Tobias Doerffel + * Copyright (c) 2008-2014 Tobias Doerffel * * This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net * @@ -38,11 +38,10 @@ class EXPORT ComboBoxModel : public IntModel { Q_OBJECT public: - ComboBoxModel( Model * _parent = NULL, - const QString & _display_name = QString(), - bool _default_constructed = false ) : - IntModel( 0, 0, 0, _parent, _display_name, - _default_constructed ) + ComboBoxModel( Model* parent = NULL, + const QString& displayName = QString(), + bool isDefaultConstructed = false ) : + IntModel( 0, 0, 0, parent, displayName, isDefaultConstructed ) { } @@ -51,37 +50,38 @@ public: clear(); } - void addItem( const QString & _item, PixmapLoader * _loader = NULL ); + void addItem( const QString& item, PixmapLoader* loader = NULL ); void clear(); - int findText( const QString & _txt ) const; + int findText( const QString& txt ) const; - inline QString currentText() const + QString currentText() const { return ( size() > 0 && value() < size() ) ? m_items[value()].first : QString(); } - inline const PixmapLoader * currentData() const + const PixmapLoader* currentData() const { return m_items[value()].second; } - inline const QString & itemText( int _i ) const + const QString & itemText( int i ) const { - return m_items[tLimit( _i, minValue(), maxValue() )].first; + return m_items[qBound( minValue(), i, maxValue() )].first; } - inline const PixmapLoader * itemPixmap( int _i ) const + const PixmapLoader* itemPixmap( int i ) const { - return m_items[tLimit( _i, minValue(), maxValue() )].second; + return m_items[qBound( minValue(), i, maxValue() )].second; } - inline int size() const + int size() const { return m_items.size(); } + private: typedef QPair Item; diff --git a/src/core/ComboBoxModel.cpp b/src/core/ComboBoxModel.cpp index 1b8efb3fc..8206f3c37 100644 --- a/src/core/ComboBoxModel.cpp +++ b/src/core/ComboBoxModel.cpp @@ -1,7 +1,7 @@ /* * ComboBoxModel.cpp - implementation of ComboBoxModel * - * Copyright (c) 2008-2009 Tobias Doerffel + * Copyright (c) 2008-2014 Tobias Doerffel * * This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net * @@ -27,9 +27,9 @@ -void ComboBoxModel::addItem( const QString & _item, PixmapLoader * _pl ) +void ComboBoxModel::addItem( const QString& item, PixmapLoader* loader ) { - m_items.push_back( qMakePair( _item, _pl ) ); + m_items.push_back( qMakePair( item, loader ) ); setRange( 0, m_items.size() - 1 ); } @@ -39,23 +39,24 @@ void ComboBoxModel::addItem( const QString & _item, PixmapLoader * _pl ) void ComboBoxModel::clear() { setRange( 0, 0 ); - foreach( const Item & _i, m_items ) + foreach( const Item& i, m_items ) { - delete _i.second; + delete i.second; } + m_items.clear(); + emit propertiesChanged(); } -int ComboBoxModel::findText( const QString & _txt ) const +int ComboBoxModel::findText( const QString& txt ) const { - for( QVector::ConstIterator it = m_items.begin(); - it != m_items.end(); ++it ) + for( QVector::ConstIterator it = m_items.begin(); it != m_items.end(); ++it ) { - if( ( *it ).first == _txt ) + if( ( *it ).first == txt ) { return it - m_items.begin(); }