Switch to QVector instead of QList. Insertions aren't really needed.
This commit is contained in:
		
					parent
					
						
							
								cfbfef9651
							
						
					
				
			
			
				commit
				
					
						1886dbf53c
					
				
			
		
					 3 changed files with 7 additions and 6 deletions
				
			
		| 
						 | 
				
			
			@ -78,6 +78,7 @@ namespace Danbooru {
 | 
			
		|||
    DanbooruPost::~DanbooruPost()
 | 
			
		||||
    {
 | 
			
		||||
        delete m_pixmap;
 | 
			
		||||
        m_pixmap = 0;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -40,18 +40,19 @@ namespace Danbooru {
 | 
			
		|||
    DanbooruTableModel::~DanbooruTableModel()
 | 
			
		||||
    {
 | 
			
		||||
        qDeleteAll(m_posts);
 | 
			
		||||
        m_posts.clear();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    int DanbooruTableModel::rowCount(const QModelIndex& parent) const
 | 
			
		||||
    {
 | 
			
		||||
        Q_UNUSED(parent)
 | 
			
		||||
        return m_posts.length();
 | 
			
		||||
        return m_posts.size();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    void DanbooruTableModel::addPost(Danbooru::DanbooruPost* post)
 | 
			
		||||
    {
 | 
			
		||||
 | 
			
		||||
        beginInsertRows(QModelIndex(), m_posts.length(), m_posts.length() + 1);
 | 
			
		||||
        beginInsertRows(QModelIndex(), m_posts.size(), m_posts.size() + 1);
 | 
			
		||||
        m_posts.append(post);
 | 
			
		||||
        endInsertRows();
 | 
			
		||||
    }
 | 
			
		||||
| 
						 | 
				
			
			@ -60,11 +61,10 @@ namespace Danbooru {
 | 
			
		|||
    {
 | 
			
		||||
 | 
			
		||||
        if (!index.isValid()) {
 | 
			
		||||
 | 
			
		||||
            return QVariant();
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        if (index.row() >= m_posts.length() || index.row() < 0) {
 | 
			
		||||
        if (index.row() >= m_posts.size() || index.row() < 0) {
 | 
			
		||||
            return QVariant();
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -30,7 +30,7 @@
 | 
			
		|||
 **/
 | 
			
		||||
 | 
			
		||||
#include <QAbstractListModel>
 | 
			
		||||
#include <QList>
 | 
			
		||||
#include <QVector>
 | 
			
		||||
 | 
			
		||||
namespace Danbooru {
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -59,7 +59,7 @@ namespace Danbooru {
 | 
			
		|||
        QVariant data(const QModelIndex& index, int role) const;
 | 
			
		||||
 | 
			
		||||
    private:
 | 
			
		||||
        QList<DanbooruPost*> m_posts;
 | 
			
		||||
        QVector<DanbooruPost*> m_posts;
 | 
			
		||||
 | 
			
		||||
    public Q_SLOTS:
 | 
			
		||||
        /**
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue