Skip to content

Commit

Permalink
Merge branch 'dev' of github.com:svetter/pal into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
svetter committed Mar 1, 2024
2 parents 0a9092d + fab0bd6 commit faa34f2
Show file tree
Hide file tree
Showing 11 changed files with 92 additions and 90 deletions.
3 changes: 1 addition & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
# This file is used to ignore files which are generated
# ----------------------------------------------------------------------------
build/

*~
*.autosave
Expand Down
8 changes: 5 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ Each peak itself has the following associated fields:
- Mountain range
- Country
- Continent
- Links to Wikipedia, Google Earth/Maps
- Links to Wikipedia, Google Maps/Earth

Other features:

Expand All @@ -68,16 +68,18 @@ Other features:

The codebase is fully documented.

PAL uses Qt's [SQLite](https://www.sqlite.org) driver, so its project files can be opened, inspected and manipulated with any compatible software.
PAL employs an [SQLite](https://www.sqlite.org) database, so its project files can be opened, inspected and manipulated with any compatible software.



Building PAL
------------

[![Build PAL status](https://github.com/svetter/pal/actions/workflows/build.yml/badge.svg)](https://github.com/svetter/pal/actions/workflows/build.yml)

PAL is built on [Qt 6.6.2](https://wiki.qt.io/Qt_6.6_Release).

If there is no release suitable for you or you want to make changes in the code, the easiest way to build PAL yourself is to install Qt Creator, open the top-level project file [PAL.pro], let Qt Creator configure the project and click build.
If there is no [release](https://github.com/svetter/pal/releases) suitable for you or you want to make changes in the code, the easiest way to build PAL yourself is to install Qt6 along with Qt Creator, open the top-level project file [PAL.pro](PAL.pro), let Qt Creator configure the project and click build.



Expand Down
20 changes: 10 additions & 10 deletions src/comp_tables/breadcrumbs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ bool Breadcrumbs::goesVia(const Table& table) const
{
for (int i = 1; i < list.size(); i++) {
const Breadcrumb& crumb = list.at(i);
if (&crumb.firstColumn.table == &table) {
if (Q_UNLIKELY(&crumb.firstColumn.table == &table)) {
return true;
}
}
Expand All @@ -256,9 +256,9 @@ bool Breadcrumbs::goesVia(const Table& table) const
*/
bool Breadcrumbs::operator==(const Breadcrumbs& other) const
{
if (list.size() != other.list.size()) return false;
if (Q_LIKELY(list.size() != other.list.size())) return false;
for (int i = 0; i < list.size(); i++) {
if (list.at(i) != other.list.at(i)) return false;
if (Q_UNLIKELY(list.at(i) != other.list.at(i))) return false;
}
return true;
}
Expand All @@ -282,7 +282,7 @@ bool Breadcrumbs::operator!=(const Breadcrumbs& other) const
*/
void Breadcrumbs::append(const Breadcrumb& breadcrumb)
{
if (list.isEmpty()) {
if (Q_UNLIKELY(list.isEmpty())) {
assert(!breadcrumb.firstColumn.table.isAssociative);
} else {
assert(&list.last().secondColumn.table == &breadcrumb.firstColumn.table);
Expand Down Expand Up @@ -344,7 +344,7 @@ QSet<BufferRowIndex> Breadcrumbs::evaluate(BufferRowIndex initialBufferRowIndex)
currentKeySet.insert(FORCE_VALID(key));
}

if (currentKeySet.isEmpty()) return QSet<BufferRowIndex>();
if (Q_UNLIKELY(currentKeySet.isEmpty())) return QSet<BufferRowIndex>();

currentRowIndexSet.clear();
const Table& table = crumb.secondColumn.table;
Expand All @@ -370,7 +370,7 @@ QSet<BufferRowIndex> Breadcrumbs::evaluate(BufferRowIndex initialBufferRowIndex)
}
}

if (currentRowIndexSet.isEmpty()) return QSet<BufferRowIndex>();
if (Q_UNLIKELY(currentRowIndexSet.isEmpty())) return QSet<BufferRowIndex>();
}

return currentRowIndexSet;
Expand All @@ -394,7 +394,7 @@ BufferRowIndex Breadcrumbs::evaluateAsForwardChain(BufferRowIndex initialBufferR
const ForeignKeyColumn& currentColumn = (ForeignKeyColumn&) crumb.firstColumn;
const ItemID key = currentColumn.getValueAt(currentRowIndex);

if (key.isInvalid()) return BufferRowIndex();
if (Q_UNLIKELY(key.isInvalid())) return BufferRowIndex();

// Get referenced primary key column of other table
const PrimaryKeyColumn& referencedColumn = currentColumn.getReferencedForeignColumn();
Expand Down Expand Up @@ -437,7 +437,7 @@ QList<BufferRowIndex> Breadcrumbs::evaluateForStats(const QSet<BufferRowIndex>&
currentKeyList.append(FORCE_VALID(key));
}

if (currentKeyList.isEmpty()) return QList<BufferRowIndex>();
if (Q_UNLIKELY(currentKeyList.isEmpty())) return QList<BufferRowIndex>();

currentRowIndexList.clear();
const Table& table = crumb.secondColumn.table;
Expand All @@ -462,14 +462,14 @@ QList<BufferRowIndex> Breadcrumbs::evaluateForStats(const QSet<BufferRowIndex>&
}
}

if (crumb.firstColumn.table.isAssociative && initialBufferRowIndices.size() > 1) {
if (Q_UNLIKELY(crumb.firstColumn.table.isAssociative && initialBufferRowIndices.size() > 1)) {
// Coming out of associative table => Remove all duplicates
const QSet<BufferRowIndex> currentRowIndexSet = QSet<BufferRowIndex>(currentRowIndexList.constBegin(), currentRowIndexList.constEnd());
currentRowIndexList.clear();
currentRowIndexList = QList<BufferRowIndex>(currentRowIndexSet.constBegin(), currentRowIndexSet.constEnd());
}

if (currentRowIndexList.isEmpty()) return QList<BufferRowIndex>();
if (Q_UNLIKELY(currentRowIndexList.isEmpty())) return QList<BufferRowIndex>();
}

return currentRowIndexList;
Expand Down
18 changes: 9 additions & 9 deletions src/comp_tables/composite_column.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -486,7 +486,7 @@ QVariant ReferenceCompositeColumn::computeValueAt(BufferRowIndex rowIndex) const
{
BufferRowIndex targetRowIndex = breadcrumbs.evaluateAsForwardChain(rowIndex);

if (targetRowIndex.isInvalid()) return QVariant();
if (Q_UNLIKELY(targetRowIndex.isInvalid())) return QVariant();

// Look up content column at last row index
QVariant content = contentColumn.getValueAt(targetRowIndex);
Expand Down Expand Up @@ -547,7 +547,7 @@ QVariant DifferenceCompositeColumn::computeValueAt(BufferRowIndex rowIndex) cons
QVariant minuendContent = minuendColumn.getValueAt(rowIndex);
QVariant subtrahendContent = subtrahendColumn.getValueAt(rowIndex);

if (!minuendContent.isValid() || !subtrahendContent.isValid()) return QVariant();
if (Q_UNLIKELY(!minuendContent.isValid() || !subtrahendContent.isValid())) return QVariant();

switch (minuendColumn.type) {
case Integer: {
Expand Down Expand Up @@ -625,7 +625,7 @@ QVariant DependentEnumCompositeColumn::computeValueAt(BufferRowIndex rowIndex) c
int discerning = discerningContent.toInt();
int displayed = displayedContent.toInt();

if (discerning < 1 || displayed < 1) return QVariant();
if (Q_UNLIKELY(discerning < 1 || displayed < 1)) return QVariant();

return QVariant(QList<QVariant>({ discerning, displayed }));
}
Expand Down Expand Up @@ -796,20 +796,20 @@ QList<QVariant> OrdinalCompositeColumn::computeWholeColumn() const
int ordinal = 1;
for (const BufferRowIndex& rowIndex : order) {
ItemID currentKey = separatingColumn.getValueAt(rowIndex);
if (!currentKey.isValid()) {
if (Q_UNLIKELY(!currentKey.isValid())) {
// No key, reset ordinal and append empty
ordinal = 1;
lastKey = currentKey;
ordinals.replace(rowIndex.get(), QVariant());
} else if (currentKey == lastKey) {
// Same key, increase ordinal
ordinal++;
ordinals.replace(rowIndex.get(), ordinal);
} else {
} else if (Q_LIKELY(currentKey != lastKey)) {
// Next key, reset ordinal
ordinal = 1;
lastKey = currentKey;
ordinals.replace(rowIndex.get(), ordinal);
} else {
// Same key, increase ordinal
ordinal++;
ordinals.replace(rowIndex.get(), ordinal);
}
}

Expand Down
6 changes: 3 additions & 3 deletions src/comp_tables/composite_table.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,7 @@ void CompositeTable::initBuffer(QProgressDialog* progressDialog, bool deferCompu
}
newRow->append(newCell);

if (progressDialog && !computeWholeColumn) progressDialog->setValue(progressDialog->value() + 1);
if (Q_LIKELY(progressDialog && !computeWholeColumn)) progressDialog->setValue(progressDialog->value() + 1);
}
buffer.appendRow(newRow);
}
Expand All @@ -353,7 +353,7 @@ void CompositeTable::initBuffer(QProgressDialog* progressDialog, bool deferCompu
QList<QVariant> cells = computeWholeColumnContent(column->getIndex());
for (BufferRowIndex bufferRowIndex = BufferRowIndex(0); bufferRowIndex.isValid(baseTable.getNumberOfRows()); bufferRowIndex++) {
buffer.replaceCell(bufferRowIndex, column->getIndex(), cells.at(bufferRowIndex.get()));
if (progressDialog) progressDialog->setValue(progressDialog->value() + 1);
if (Q_LIKELY(progressDialog)) progressDialog->setValue(progressDialog->value() + 1);
}
}

Expand Down Expand Up @@ -1016,7 +1016,7 @@ QVariant CompositeTable::computeCellContent(BufferRowIndex bufferRowIndex, int c
const CompositeColumn& column = *columns.at(columnIndex);
QVariant result = column.computeValueAt(bufferRowIndex);

if (!result.isValid()) return QVariant();
if (Q_UNLIKELY(!result.isValid())) return QVariant();

return result;
}
Expand Down
6 changes: 3 additions & 3 deletions src/data/item_id.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ int ItemID::get() const
*/
QVariant ItemID::asQVariant() const
{
if (isValid()) {
if (Q_LIKELY(isValid())) {
return QVariant(id);
} else {
return QVariant();
Expand Down Expand Up @@ -201,8 +201,8 @@ void ValidItemID::operator=(const ValidItemID& other)
*/
bool operator==(const ItemID& id1, const ItemID& id2)
{
if (id1.isInvalid() && id2.isInvalid()) return true;
if (id1.isValid() != id2.isValid()) return false;
if (Q_UNLIKELY(id1.isInvalid() && id2.isInvalid())) return true;
if (Q_UNLIKELY(id1.isValid() != id2.isValid())) return false;
return id1.get() == id2.get();
}

Expand Down
2 changes: 1 addition & 1 deletion src/db/normal_table.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ BufferRowIndex NormalTable::getBufferIndexForPrimaryKey(ValidItemID primaryKey)
{
BufferRowIndex index = BufferRowIndex(0);
for (const QList<QVariant>* const bufferRow : buffer) {
if (bufferRow->at(0) == ID_GET(primaryKey)) return index;
if (Q_UNLIKELY(bufferRow->at(0) == ID_GET(primaryKey))) return index;
index++;
}
return BufferRowIndex();
Expand Down
4 changes: 2 additions & 2 deletions src/db/table_buffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ bool ViewOrderBuffer::isEmpty() const
*/
BufferRowIndex ViewOrderBuffer::getBufferRowIndexForViewRow(ViewRowIndex viewRowIndex) const
{
if (viewRowIndex.isInvalid(order.size())) return BufferRowIndex();
if (Q_UNLIKELY(viewRowIndex.isInvalid(order.size()))) return BufferRowIndex();
return order.at(viewRowIndex.get());
}

Expand All @@ -233,7 +233,7 @@ BufferRowIndex ViewOrderBuffer::getBufferRowIndexForViewRow(ViewRowIndex viewRow
*/
ViewRowIndex ViewOrderBuffer::findViewRowIndexForBufferRow(BufferRowIndex bufferRowIndex) const
{
if (bufferRowIndex.isInvalid()) return ViewRowIndex();
if (Q_UNLIKELY(bufferRowIndex.isInvalid())) return ViewRowIndex();
return ViewRowIndex(order.indexOf(bufferRowIndex));
}

Expand Down
2 changes: 1 addition & 1 deletion src/dialogs/peak_dialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ PeakDialog::PeakDialog(QWidget& parent, QMainWindow& mainWindow, Database& db, D
{volcanoCheckbox, { &db.peaksTable.volcanoColumn }}
});

setWindowIcon(QIcon(":/icons/ico/peak_multisize_square.ico"));
setWindowIcon(QIcon(":/icons/ico/logo_peak_multisize_square.ico"));

restoreDialogGeometry(*this, mainWindow, Settings::peakDialog_geometry);
setFixedHeight(minimumSizeHint().height());
Expand Down
1 change: 1 addition & 0 deletions src/main/main_window.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ MainWindow::MainWindow() :
{
setupUi(this);
createTypesHandler();
setWindowIcon(QIcon(":/icons/ico/logo_peak_multisize_square.ico"));
setupMenuIcons();
statusbar->addPermanentWidget(statusBarTableSizeLabel);
statusbar->addPermanentWidget(statusBarFiltersLabel);
Expand Down
Loading

0 comments on commit faa34f2

Please sign in to comment.