File indexing completed on 2024-12-15 04:54:40

0001 /******************************************************************************
0002  *
0003  *  SPDX-FileCopyrightText: 2008 Szymon Tomasz Stefanek <pragma@kvirc.net>
0004  *
0005  *  SPDX-License-Identifier: GPL-2.0-or-later
0006  *
0007  *******************************************************************************/
0008 
0009 #include "core/modelinvariantindex.h"
0010 #include "core/modelinvariantindex_p.h"
0011 #include "core/modelinvariantrowmapper.h"
0012 #include "core/modelinvariantrowmapper_p.h"
0013 
0014 using namespace MessageList::Core;
0015 
0016 ModelInvariantIndex::ModelInvariantIndex()
0017     : d(new ModelInvariantIndexPrivate)
0018 {
0019 }
0020 
0021 ModelInvariantIndex::~ModelInvariantIndex()
0022 {
0023     if (d->mRowMapper) {
0024         d->mRowMapper->d->indexDead(this);
0025     }
0026 }
0027 
0028 bool ModelInvariantIndex::isValid() const
0029 {
0030     return d->mRowMapper != nullptr;
0031 }
0032 
0033 int ModelInvariantIndex::currentModelIndexRow()
0034 {
0035     if (d->mRowMapper) {
0036         return d->mRowMapper->modelInvariantIndexToModelIndexRow(this);
0037     }
0038     return -1;
0039 }