MCPcopy Create free account
hub / github.com/YACReader/yacreader / getLabels

Method getLabels

YACReaderLibrary/db_helper.cpp:1753–1800  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1751}
1752
1753QList<Label> DBHelper::getLabels(qulonglong libraryId)
1754{
1755 QString libraryPath = DBHelper::getLibraries().getPath(libraryId);
1756 QString connectionName = "";
1757 QList<Label> labels;
1758 {
1759 QSqlDatabase db = DataBaseManagement::loadDatabase(LibraryPaths::libraryDataPath(libraryPath));
1760
1761 QSqlQuery selectQuery("SELECT * FROM label ORDER BY ordering,name", db); // TODO add some kind of
1762 QSqlRecord record = selectQuery.record();
1763
1764 int name = record.indexOf("name");
1765 int id = record.indexOf("id");
1766 int ordering = record.indexOf("ordering");
1767
1768 while (selectQuery.next()) {
1769 Label item(selectQuery.value(name).toString(),
1770 selectQuery.value(id).toLongLong(),
1771 static_cast<YACReader::LabelColors>(selectQuery.value(ordering).toInt()));
1772
1773 if (labels.isEmpty()) {
1774 labels << item;
1775 } else {
1776 int i = 0;
1777
1778 while (i < labels.count() && (labels.at(i).getColorID() < item.getColorID()))
1779 i++;
1780
1781 if (i < labels.count()) {
1782 if (labels.at(i).getColorID() == item.getColorID()) // sort by name
1783 {
1784 while (i < labels.count() && labels.at(i).getColorID() == item.getColorID() && naturalSortLessThanCI(labels.at(i).getName(), item.getName()))
1785 i++;
1786 }
1787 }
1788 if (i >= labels.count()) {
1789 labels << item;
1790 } else {
1791 labels.insert(i, item);
1792 }
1793 }
1794 }
1795 connectionName = db.connectionName();
1796 }
1797 QSqlDatabase::removeDatabase(connectionName);
1798
1799 return labels;
1800}
1801
1802void DBHelper::updateFolderTreeType(qulonglong id, QSqlDatabase &db, YACReader::FileType type)
1803{

Callers 1

setupAddToSubmenuMethod · 0.45

Calls 8

naturalSortLessThanCIFunction · 0.85
getPathMethod · 0.80
toStringMethod · 0.80
isEmptyMethod · 0.80
getColorIDMethod · 0.80
nextMethod · 0.45
getNameMethod · 0.45
insertMethod · 0.45

Tested by

no test coverage detected