mirror of
https://github.com/YACReader/yacreader
synced 2025-07-18 21:14:33 -04:00
Format code using clang-format
This commit is contained in:
@ -2,19 +2,19 @@
|
||||
|
||||
#include "comic_model.h"
|
||||
|
||||
YACReaderComicsSelectionHelper::YACReaderComicsSelectionHelper(QObject *parent) : QObject(parent), _selectionModel(nullptr)
|
||||
YACReaderComicsSelectionHelper::YACReaderComicsSelectionHelper(QObject *parent)
|
||||
: QObject(parent), _selectionModel(nullptr)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void YACReaderComicsSelectionHelper::setModel(ComicModel *model)
|
||||
{
|
||||
if(model == NULL)
|
||||
if (model == NULL)
|
||||
return;
|
||||
|
||||
this->model = model;
|
||||
|
||||
if(_selectionModel != nullptr)
|
||||
if (_selectionModel != nullptr)
|
||||
delete _selectionModel;
|
||||
|
||||
_selectionModel = new QItemSelectionModel(model);
|
||||
@ -22,9 +22,8 @@ void YACReaderComicsSelectionHelper::setModel(ComicModel *model)
|
||||
|
||||
void YACReaderComicsSelectionHelper::selectIndex(int index)
|
||||
{
|
||||
if(_selectionModel != nullptr && model!=NULL)
|
||||
{
|
||||
_selectionModel->select(model->index(index,0),QItemSelectionModel::Select | QItemSelectionModel::Rows);
|
||||
if (_selectionModel != nullptr && model != NULL) {
|
||||
_selectionModel->select(model->index(index, 0), QItemSelectionModel::Select | QItemSelectionModel::Rows);
|
||||
|
||||
emit selectionChanged();
|
||||
}
|
||||
@ -32,9 +31,8 @@ void YACReaderComicsSelectionHelper::selectIndex(int index)
|
||||
|
||||
void YACReaderComicsSelectionHelper::deselectIndex(int index)
|
||||
{
|
||||
if(_selectionModel != nullptr && model!=NULL)
|
||||
{
|
||||
_selectionModel->select(model->index(index,0),QItemSelectionModel::Deselect | QItemSelectionModel::Rows);
|
||||
if (_selectionModel != nullptr && model != NULL) {
|
||||
_selectionModel->select(model->index(index, 0), QItemSelectionModel::Deselect | QItemSelectionModel::Rows);
|
||||
|
||||
emit selectionChanged();
|
||||
}
|
||||
@ -42,9 +40,8 @@ void YACReaderComicsSelectionHelper::deselectIndex(int index)
|
||||
|
||||
bool YACReaderComicsSelectionHelper::isSelectedIndex(int index) const
|
||||
{
|
||||
if(_selectionModel != nullptr && model!=NULL)
|
||||
{
|
||||
QModelIndex mi = model->index(index,0);
|
||||
if (_selectionModel != nullptr && model != NULL) {
|
||||
QModelIndex mi = model->index(index, 0);
|
||||
return _selectionModel->isSelected(mi);
|
||||
}
|
||||
return false;
|
||||
@ -52,8 +49,7 @@ bool YACReaderComicsSelectionHelper::isSelectedIndex(int index) const
|
||||
|
||||
void YACReaderComicsSelectionHelper::clear()
|
||||
{
|
||||
if(_selectionModel != nullptr)
|
||||
{
|
||||
if (_selectionModel != nullptr) {
|
||||
_selectionModel->clear();
|
||||
|
||||
emit selectionChanged();
|
||||
@ -62,16 +58,16 @@ void YACReaderComicsSelectionHelper::clear()
|
||||
|
||||
QModelIndex YACReaderComicsSelectionHelper::currentIndex()
|
||||
{
|
||||
if(!_selectionModel)
|
||||
if (!_selectionModel)
|
||||
return QModelIndex();
|
||||
|
||||
QModelIndexList indexes = _selectionModel->selectedRows();
|
||||
if(indexes.length()>0)
|
||||
if (indexes.length() > 0)
|
||||
return indexes[0];
|
||||
|
||||
this->selectIndex(0);
|
||||
indexes = _selectionModel->selectedRows();
|
||||
if(indexes.length()>0)
|
||||
if (indexes.length() > 0)
|
||||
return indexes[0];
|
||||
else
|
||||
return QModelIndex();
|
||||
@ -80,7 +76,7 @@ QModelIndex YACReaderComicsSelectionHelper::currentIndex()
|
||||
void YACReaderComicsSelectionHelper::selectAll()
|
||||
{
|
||||
QModelIndex top = model->index(0, 0);
|
||||
QModelIndex bottom = model->index(model->rowCount()-1, 0);
|
||||
QModelIndex bottom = model->index(model->rowCount() - 1, 0);
|
||||
QItemSelection selection(top, bottom);
|
||||
_selectionModel->select(selection, QItemSelectionModel::Select | QItemSelectionModel::Rows);
|
||||
|
||||
@ -99,8 +95,7 @@ QList<QModelIndex> YACReaderComicsSelectionHelper::selectedIndexes() const
|
||||
|
||||
int YACReaderComicsSelectionHelper::numItemsSelected() const
|
||||
{
|
||||
if(_selectionModel != nullptr)
|
||||
{
|
||||
if (_selectionModel != nullptr) {
|
||||
return _selectionModel->selectedRows().length();
|
||||
}
|
||||
|
||||
@ -109,8 +104,7 @@ int YACReaderComicsSelectionHelper::numItemsSelected() const
|
||||
|
||||
int YACReaderComicsSelectionHelper::lastSelectedIndex() const
|
||||
{
|
||||
if(_selectionModel != nullptr)
|
||||
{
|
||||
if (_selectionModel != nullptr) {
|
||||
return _selectionModel->selectedRows().last().row();
|
||||
}
|
||||
|
||||
@ -120,7 +114,7 @@ int YACReaderComicsSelectionHelper::lastSelectedIndex() const
|
||||
QItemSelectionModel *YACReaderComicsSelectionHelper::selectionModel()
|
||||
{
|
||||
QModelIndexList indexes = _selectionModel->selectedRows();
|
||||
if(indexes.length()==0)
|
||||
if (indexes.length() == 0)
|
||||
this->selectIndex(0);
|
||||
|
||||
return _selectionModel;
|
||||
|
Reference in New Issue
Block a user