Grammar: replaces 'indexes' by 'indices'

Grammar-nazi ran

git grep -l 'indexes' | xargs sed -i '' -e 's/indexes/indices/g'

to prevent future wincing when reading the source code.

Unfortunatly, Qt itself is infected as in
QModelIndexList QItemSelection::indexes() const

Signed-off-by: Robert C. Helling <helling@atdotde.de>
This commit is contained in:
Robert C. Helling 2020-03-11 11:30:51 +01:00 committed by Dirk Hohndel
parent cb28158b9a
commit 285fa8acbc
26 changed files with 88 additions and 88 deletions

View file

@ -7,7 +7,7 @@
# - 2015-01-14: Initial release
#
# Known bugs:
# - Some list item indexes are lost during PO to ASCII conversion (see asciidoc warning messages)
# - Some list item indices are lost during PO to ASCII conversion (see asciidoc warning messages)
#
# Package deps: - po4a (for po4a-translate)
# - git (for git sync)

View file

@ -1041,18 +1041,18 @@ EditWeightBase::EditWeightBase(int index, bool currentDiveOnly) :
// For that purpose, we will determine the indices of the same weightsystem.
std::vector<dive *> divesNew;
divesNew.reserve(dives.size());
indexes.reserve(dives.size());
indices.reserve(dives.size());
for (dive *d: dives) {
if (d == current) {
divesNew.push_back(d);
indexes.push_back(index);
indices.push_back(index);
continue;
}
int idx = find_weightsystem_index(d, ws);
if (idx >= 0) {
divesNew.push_back(d);
indexes.push_back(idx);
indices.push_back(idx);
}
}
dives = std::move(divesNew);
@ -1081,16 +1081,16 @@ RemoveWeight::RemoveWeight(int index, bool currentDiveOnly) :
void RemoveWeight::undo()
{
for (size_t i = 0; i < dives.size(); ++i) {
add_to_weightsystem_table(&dives[i]->weightsystems, indexes[i], clone_weightsystem(ws));
emit diveListNotifier.weightAdded(dives[i], indexes[i]);
add_to_weightsystem_table(&dives[i]->weightsystems, indices[i], clone_weightsystem(ws));
emit diveListNotifier.weightAdded(dives[i], indices[i]);
}
}
void RemoveWeight::redo()
{
for (size_t i = 0; i < dives.size(); ++i) {
remove_weightsystem(dives[i], indexes[i]);
emit diveListNotifier.weightRemoved(dives[i], indexes[i]);
remove_weightsystem(dives[i], indices[i]);
emit diveListNotifier.weightRemoved(dives[i], indices[i]);
}
}
@ -1138,8 +1138,8 @@ EditWeight::~EditWeight()
void EditWeight::redo()
{
for (size_t i = 0; i < dives.size(); ++i) {
set_weightsystem(dives[i], indexes[i], new_ws);
emit diveListNotifier.weightEdited(dives[i], indexes[i]);
set_weightsystem(dives[i], indices[i], new_ws);
emit diveListNotifier.weightEdited(dives[i], indices[i]);
}
std::swap(ws, new_ws);
}

View file

@ -353,7 +353,7 @@ protected:
~EditWeightBase();
weightsystem_t ws;
std::vector<int> indexes; // An index for each dive in the dives vector.
std::vector<int> indices; // An index for each dive in the dives vector.
bool workToBeDone() override;
};

View file

@ -43,10 +43,10 @@ const char *divemode_text[] = {"OC", "CCR", "PSCR", "Freedive"};
* We try to keep the same sensor index for the same sensor, so that even
* if the dive computer doesn't give pressure information for every sample,
* we don't move pressure information around between the different sensor
* indexes.
* indices.
*
* The "prepare_sample()" function will always copy the sensor indices
* from the previous sample, so the indexes are pre-populated (but the
* from the previous sample, so the indices are pre-populated (but the
* pressures obviously are not)
*/
void add_sample_pressure(struct sample *sample, int sensor, int mbar)
@ -83,7 +83,7 @@ void add_sample_pressure(struct sample *sample, int sensor, int mbar)
* "o2pressure" that is fixed to the Oxygen sensor for a CCR dive.
*
* For more complex pressure data, we have to use explicit
* cylinder indexes for each sample.
* cylinder indices for each sample.
*
* This function returns a negative number for "no legacy mode",
* or a non-negative number that indicates the o2 sensor index.
@ -2049,11 +2049,11 @@ static void dc_cylinder_renumber(struct dive *dive, struct divecomputer *dc, con
int i;
struct event *ev;
/* Remap or delete the sensor indexes */
/* Remap or delete the sensor indices */
for (i = 0; i < dc->samples; i++)
sample_renumber(dc->sample + i, i, mapping);
/* Remap the gas change indexes */
/* Remap the gas change indices */
for (ev = dc->events; ev; ev = ev->next)
event_renumber(ev, mapping);
@ -2063,8 +2063,8 @@ static void dc_cylinder_renumber(struct dive *dive, struct divecomputer *dc, con
}
/*
* If the cylinder indexes change (due to merging dives or deleting
* cylinders in the middle), we need to change the indexes in the
* If the cylinder indices change (due to merging dives or deleting
* cylinders in the middle), we need to change the indices in the
* dive computer data for this dive.
*
* Also note that we assume that the initial cylinder is cylinder 0,

View file

@ -217,7 +217,7 @@ static void analyze_plot_info_minmax(struct plot_info *pi, int entry_index)
p--;
}
// indexes to the min/max entries
// indices to the min/max entries
min = max = entry_index;
/* Then go forward until we hit an entry past the time */
@ -314,7 +314,7 @@ struct plot_info *analyze_plot_info(struct plot_info *pi)
* we return that. If it doesn't, we return the best
* match based on the gasmix.
*
* Some dive computers give cylinder indexes, some
* Some dive computers give cylinder indices, some
* give just the gas mix.
*/
int get_cylinder_index(const struct dive *dive, const struct event *ev)

View file

@ -408,7 +408,7 @@ static void save_samples(struct membuffer *b, struct dive *dive, struct divecomp
struct sample *s;
struct sample dummy = { .bearing.degrees = -1, .ndl.seconds = -1 };
/* Set up default pressure sensor indexes */
/* Set up default pressure sensor indices */
o2sensor = legacy_format_o2pressures(dive, dc);
if (o2sensor >= 0) {
dummy.sensor[0] = !o2sensor;

View file

@ -199,11 +199,11 @@ void DiveListView::reset()
}
// If items were selected, inform the selection model
void DiveListView::diveSelectionChanged(const QVector<QModelIndex> &indexes)
void DiveListView::diveSelectionChanged(const QVector<QModelIndex> &indices)
{
clearSelection();
QItemSelectionModel *s = selectionModel();
for (const QModelIndex &index: indexes) {
for (const QModelIndex &index: indices) {
s->select(index, QItemSelectionModel::Rows | QItemSelectionModel::Select);
// If an item of a not-yet expanded trip is selected, expand the trip.
@ -420,7 +420,7 @@ void DiveListView::sortIndicatorChanged(int i, Qt::SortOrder order)
if (currentLayout == newLayout) {
sortByColumn(i, order);
} else {
// clear the model, repopulate with new indexes.
// clear the model, repopulate with new indices.
std::vector<int> expandedRows;
if(currentLayout == DiveTripModelBase::TREE)
expandedRows = backupExpandedRows();

View file

@ -60,7 +60,7 @@ slots:
void shiftTimes();
void loadImages();
void loadWebImages();
void diveSelectionChanged(const QVector<QModelIndex> &indexes);
void diveSelectionChanged(const QVector<QModelIndex> &indices);
void currentDiveChanged(QModelIndex index);
void tripChanged(dive_trip *trip, TripField);
private:

View file

@ -362,7 +362,7 @@ DiveLogImportDialog::DiveLogImportDialog(QStringList fn, QWidget *parent) : QDia
hw = "";
txtLog = false;
/* Add indexes of XSLTs requiring special handling to the list */
/* Add indices of XSLTs requiring special handling to the list */
specialCSV << SENSUS;
specialCSV << SUBSURFACE;
specialCSV << DL7;

View file

@ -69,11 +69,11 @@ QVector<QString> TabDivePhotos::getSelectedFilenames() const
QVector<QString> selectedPhotos;
if (!ui->photosView->selectionModel()->hasSelection())
return selectedPhotos;
QModelIndexList indexes = ui->photosView->selectionModel()->selectedRows();
if (indexes.count() == 0)
indexes = ui->photosView->selectionModel()->selectedIndexes();
selectedPhotos.reserve(indexes.count());
for (const auto &photo: indexes) {
QModelIndexList indices = ui->photosView->selectionModel()->selectedRows();
if (indices.count() == 0)
indices = ui->photosView->selectionModel()->selectedIndexes();
selectedPhotos.reserve(indices.count());
for (const auto &photo: indices) {
if (photo.isValid()) {
QString fileUrl = photo.data(Qt::DisplayPropertyRole).toString();
if (!fileUrl.isEmpty())
@ -114,11 +114,11 @@ void TabDivePhotos::saveSubtitles()
QVector<QString> selectedPhotos;
if (!ui->photosView->selectionModel()->hasSelection())
return;
QModelIndexList indexes = ui->photosView->selectionModel()->selectedRows();
if (indexes.count() == 0)
indexes = ui->photosView->selectionModel()->selectedIndexes();
selectedPhotos.reserve(indexes.count());
for (const auto &photo: indexes) {
QModelIndexList indices = ui->photosView->selectionModel()->selectedRows();
if (indices.count() == 0)
indices = ui->photosView->selectionModel()->selectedIndexes();
selectedPhotos.reserve(indices.count());
for (const auto &photo: indices) {
if (photo.isValid()) {
QString fileUrl = photo.data(Qt::DisplayPropertyRole).toString();
if (!fileUrl.isEmpty()) {

View file

@ -107,10 +107,10 @@ void TabDiveSite::on_filterText_textChanged(const QString &text)
QVector<dive_site *> TabDiveSite::selectedDiveSites()
{
const QModelIndexList indexes = ui.diveSites->view()->selectionModel()->selectedRows();
const QModelIndexList indices = ui.diveSites->view()->selectionModel()->selectedRows();
QVector<dive_site *> sites;
sites.reserve(indexes.size());
for (const QModelIndex &idx: indexes) {
sites.reserve(indices.size());
for (const QModelIndex &idx: indices) {
struct dive_site *ds = model.getDiveSite(idx);
sites.append(ds);
}

View file

@ -178,7 +178,7 @@ void MapWidgetHelper::selectVisibleLocations()
QMetaObject::invokeMethod(m_map, "fromCoordinate", Q_RETURN_ARG(QPointF, point),
Q_ARG(QGeoCoordinate, dsCoord));
if (!qIsNaN(point.x()))
#ifndef SUBSURFACE_MOBILE // indexes on desktop
#ifndef SUBSURFACE_MOBILE // indices on desktop
selectedDiveIds.append(idx);
}
#else // use id on mobile instead of index

View file

@ -2123,7 +2123,7 @@ void QMLManager::setFilter(const QString filterText, int index)
QString f = filterText.trimmed();
FilterData data;
if (!f.isEmpty()) {
// This is ugly - the indexes of the mode are hardcoded!
// This is ugly - the indices of the mode are hardcoded!
switch(index) {
default:
case 0: data.mode = FilterData::Mode::FULLTEXT; break;

View file

@ -2036,14 +2036,14 @@ void ProfileWidget2::keyDeleteAction()
DivePlannerPointsModel *plannerModel = DivePlannerPointsModel::instance();
int selCount = scene()->selectedItems().count();
if (selCount) {
QVector<int> selectedIndexes;
QVector<int> selectedIndices;
Q_FOREACH (QGraphicsItem *i, scene()->selectedItems()) {
if (DiveHandler *handler = qgraphicsitem_cast<DiveHandler *>(i)) {
selectedIndexes.push_back(handles.indexOf(handler));
selectedIndices.push_back(handles.indexOf(handler));
handler->hide();
}
}
plannerModel->removeSelectedPoints(selectedIndexes);
plannerModel->removeSelectedPoints(selectedIndices);
}
}

View file

@ -512,7 +512,7 @@ void CylindersModel::remove(QModelIndex index)
changed = true;
endRemoveRows();
// Create a mapping of cylinder indexes:
// Create a mapping of cylinder indices:
// 1) Fill mapping[0]..mapping[index-1] with 0..index
// 2) Set mapping[index] to -1
// 3) Fill mapping[index+1]..mapping[end] with index..
@ -537,7 +537,7 @@ void CylindersModel::moveAtFirst(int cylid)
memmove(get_cylinder(&displayed_dive, i + 1), get_cylinder(&displayed_dive, i), sizeof(temp_cyl));
memmove(get_cylinder(&displayed_dive, 0), &temp_cyl, sizeof(temp_cyl));
// Create a mapping of cylinder indexes:
// Create a mapping of cylinder indices:
// 1) Fill mapping[0]..mapping[cyl] with 0..index
// 2) Set mapping[cyl] to 0
// 3) Fill mapping[cyl+1]..mapping[end] with cyl..

View file

@ -153,7 +153,7 @@ std::pair<struct dive_table, struct dive_site_table> DiveImportedModel::consumeT
move_dive_table(&diveTable, &dives);
move_dive_site_table(&sitesTable, &sites);
// Reset indexes
// Reset indices
checkStates.clear();
endResetModel();

View file

@ -18,7 +18,7 @@ public:
int rowCount(const QModelIndex& index = QModelIndex()) const;
QVariant data(const QModelIndex& index, int role) const;
QVariant headerData(int section, Qt::Orientation orientation, int role) const;
void setImportedDivesIndexes(int first, int last);
void setImportedDivesIndices(int first, int last);
Qt::ItemFlags flags(const QModelIndex &index) const;
Q_INVOKABLE void clearTable();
QHash<int, QByteArray> roleNames() const;

View file

@ -1412,19 +1412,19 @@ void DiveTripModelTree::divesSelected(const QVector<dive *> &divesIn, dive *curr
// We got a number of dives that have been selected. Turn this into QModelIndexes and
// emit a signal, so that views can change the selection.
QVector<QModelIndex> indexes;
indexes.reserve(dives.count());
QVector<QModelIndex> indices;
indices.reserve(dives.count());
processByTrip(dives, [this, &indexes] (dive_trip *trip, const QVector<dive *> &divesInTrip)
{ divesSelectedTrip(trip, divesInTrip, indexes); });
processByTrip(dives, [this, &indices] (dive_trip *trip, const QVector<dive *> &divesInTrip)
{ divesSelectedTrip(trip, divesInTrip, indices); });
emit selectionChanged(indexes);
emit selectionChanged(indices);
// The current dive has changed. Transform the current dive into an index and pass it on to the view.
currentChanged();
}
void DiveTripModelTree::divesSelectedTrip(dive_trip *trip, const QVector<dive *> &dives, QVector<QModelIndex> &indexes)
void DiveTripModelTree::divesSelectedTrip(dive_trip *trip, const QVector<dive *> &dives, QVector<QModelIndex> &indices)
{
if (!trip) {
// This is at the top level.
@ -1436,7 +1436,7 @@ void DiveTripModelTree::divesSelectedTrip(dive_trip *trip, const QVector<dive *>
++j;
if (j >= (int)items.size())
break;
indexes.append(createIndex(j, 0, noParent));
indices.append(createIndex(j, 0, noParent));
}
} else {
// Find the trip.
@ -1457,7 +1457,7 @@ void DiveTripModelTree::divesSelectedTrip(dive_trip *trip, const QVector<dive *>
++j;
if (j >= (int)entry.dives.size())
break;
indexes.append(createIndex(j, 0, idx));
indices.append(createIndex(j, 0, idx));
}
}
}
@ -1672,8 +1672,8 @@ void DiveTripModelList::divesSelected(const QVector<dive *> &divesIn, dive *curr
// We got a number of dives that have been selected. Turn this into QModelIndexes and
// emit a signal, so that views can change the selection.
QVector<QModelIndex> indexes;
indexes.reserve(dives.count());
QVector<QModelIndex> indices;
indices.reserve(dives.count());
// Since both lists are sorted, we can do this linearly. Perhaps a binary search
// would be better?
@ -1683,10 +1683,10 @@ void DiveTripModelList::divesSelected(const QVector<dive *> &divesIn, dive *curr
++j;
if (j >= (int)items.size())
break;
indexes.append(createIndex(j, 0, noParent));
indices.append(createIndex(j, 0, noParent));
}
emit selectionChanged(indexes);
emit selectionChanged(indices);
// The current dive has changed. Transform the current dive into an index and pass it on to the view.
currentChanged();

View file

@ -83,9 +83,9 @@ signals:
// Commands/DiveListNotifier ---(dive */dive_trip *)---> DiveTripModel ---(QModelIndex)---> DiveListView
// i.e. The command objects send changes in terms of pointer-to-dives, which the DiveTripModel transforms
// into QModelIndexes according to the current view (tree/list). Finally, the DiveListView transforms these
// indexes into local indexes according to current sorting/filtering and instructs the QSelectionModel to
// indices into local indices according to current sorting/filtering and instructs the QSelectionModel to
// perform the appropriate actions.
void selectionChanged(const QVector<QModelIndex> &indexes);
void selectionChanged(const QVector<QModelIndex> &indices);
void currentDiveChanged(QModelIndex index);
protected:
dive *oldCurrent;

View file

@ -36,20 +36,20 @@ void MultiFilterSortModel::clear()
model->clear();
}
// Translate selection into local indexes and re-emit signal
void MultiFilterSortModel::selectionChangedSlot(const QVector<QModelIndex> &indexes)
// Translate selection into local indices and re-emit signal
void MultiFilterSortModel::selectionChangedSlot(const QVector<QModelIndex> &indices)
{
QVector<QModelIndex> indexesLocal;
indexesLocal.reserve(indexes.size());
for (const QModelIndex &index: indexes) {
QVector<QModelIndex> indicesLocal;
indicesLocal.reserve(indices.size());
for (const QModelIndex &index: indices) {
QModelIndex local = mapFromSource(index);
if (local.isValid())
indexesLocal.push_back(local);
indicesLocal.push_back(local);
}
emit selectionChanged(indexesLocal);
emit selectionChanged(indicesLocal);
}
// Translate current dive into local indexes and re-emit signal
// Translate current dive into local indices and re-emit signal
void MultiFilterSortModel::currentDiveChangedSlot(QModelIndex index)
{
QModelIndex local = mapFromSource(index);

View file

@ -19,10 +19,10 @@ public:
void resetModel(DiveTripModelBase::Layout layout);
void clear();
signals:
void selectionChanged(const QVector<QModelIndex> &indexes);
void selectionChanged(const QVector<QModelIndex> &indices);
void currentDiveChanged(QModelIndex index);
private slots:
void selectionChangedSlot(const QVector<QModelIndex> &indexes);
void selectionChangedSlot(const QVector<QModelIndex> &indices);
void currentDiveChangedSlot(QModelIndex index);
private:
MultiFilterSortModel(QObject *parent = 0);

View file

@ -94,7 +94,7 @@ MobileListModel::MobileListModel(DiveTripModelBase *source) : MobileListModelBas
}
// We want to show the newest dives first. Therefore, we have to invert
// the indexes with respect to the source model. To avoid mental gymnastics
// the indices with respect to the source model. To avoid mental gymnastics
// in the rest of the code, we do this right before sending to the
// source model and just after recieving from the source model, respectively.
QModelIndex MobileListModel::sourceIndex(int row, int col, int parentRow) const

View file

@ -136,7 +136,7 @@ private:
mutable QModelIndex cacheSourceParent;
mutable int cacheSourceRow = -1;
// Translate indexes from/to source
// Translate indices from/to source
int topLevelRowCountInSource(int sourceRow) const;
QModelIndex mapToSource(const QModelIndex &index) const;
int mapTopLevelFromSource(int row) const;

View file

@ -1,7 +1,7 @@
// SPDX-License-Identifier: GPL-2.0
/*
* An .slg file is composed of a main table (Dives), a bunch of tables directly
* linked to Dives by their indexes (Site, Suit, Tank, etc) and another group of
* linked to Dives by their indices (Site, Suit, Tank, etc) and another group of
* independent tables (Activity, Type, Gear, Fish ...) which connect with the dives
* via a related group of tables (ActivityRelation, TypeRelation ...) that contain
* just the dive index number and the related table index number.

View file

@ -357,7 +357,7 @@ int TestParse::parseCSVmanual(int units, std::string file)
params[pnr++] = intdup(21);
params[pnr++] = strdup("tagsField");
params[pnr++] = intdup(22);
// Numbers are indexes of possible options
// Numbers are indices of possible options
params[pnr++] = strdup("separatorIndex");
params[pnr++] = intdup(0);
params[pnr++] = strdup("datefmt");
@ -410,7 +410,7 @@ int TestParse::parseCSVprofile(int units, std::string file)
params[pnr++] = intdup(5);
params[pnr++] = strdup("pressureField");
params[pnr++] = intdup(6);
// Numbers are indexes of possible options
// Numbers are indices of possible options
params[pnr++] = strdup("datefmt");
params[pnr++] = intdup(2);
params[pnr++] = strdup("units");

View file

@ -1,9 +1,9 @@
var itemsToShow = new Array(); //list of indexes to all dives to view
var itemsToShow = new Array(); //list of indices to all dives to view
var items = new Array();
var start; //index of first element viewed in itemsToShow
var sizeofpage; //size of viewed page
var numberofwords = 0; //just for stats
var olditemstoshow; //to reference the indexes to all dives if changed
var olditemstoshow; //to reference the indices to all dives if changed
//////////////////////////////////
// //
// View Model //
@ -40,8 +40,8 @@ function viewInPage()
}
/**
*addHTML this Method puts the HTML of items of given indexes
*@param {array} indexes array of indexes to put in HTML
*addHTML this Method puts the HTML of items of given indices
*@param {array} indices array of indices to put in HTML
*/
function updateView(start, end)
{
@ -56,17 +56,17 @@ function updateView(start, end)
}
/**
*addHTML this Method puts the HTML of items of given indexes
*@param {array} indexes array of indexes to put in HTML
*addHTML this Method puts the HTML of items of given indices
*@param {array} indices array of indices to put in HTML
*/
function addHTML(indexes)
function addHTML(indices)
{
var divelist = document.getElementById('diveslist');
divelist.innerHTML = "";
for (var i = 0; i < indexes.length; i++) {
divelist.innerHTML += '<ul id="' + indexes[i] + '" onclick="toggleExpansion(event, this)"></ul>';
expand(document.getElementById(indexes[i]));
itemsToShow[indexes[i]].expanded = true;
for (var i = 0; i < indices.length; i++) {
divelist.innerHTML += '<ul id="' + indices[i] + '" onclick="toggleExpansion(event, this)"></ul>';
expand(document.getElementById(indices[i]));
itemsToShow[indices[i]].expanded = true;
};
}