BibleTime
btinstallpagemodel.cpp
Go to the documentation of this file.
1/*********
2*
3* In the name of the Father, and of the Son, and of the Holy Spirit.
4*
5* This file is part of BibleTime's source code, https://bibletime.info/
6*
7* Copyright 1999-2025 by the BibleTime developers.
8* The BibleTime source code is licensed under the GNU General Public License
9* version 2.0.
10*
11**********/
12
13#include "btinstallpagemodel.h"
14
15#include <QtGlobal>
16#include "../../backend/bookshelfmodel/btbookshelftreemodel.h"
17#include "../../backend/drivers/cswordmoduleinfo.h"
18#include "../../backend/managers/cswordbackend.h"
19
20
28
29QVariant BtInstallPageModel::data(QModelIndex const & i, int role) const {
30 switch (role) {
31 case Qt::DisplayRole:
32 switch (i.column()) {
33 case 0:
35 case 1:
36 if (CSwordModuleInfo * const m =
37 module(index(i.row(), 0, i.parent())))
38 {
40 CSwordBackend::instance().findModuleByName(
41 m->name()))
42 return QStringLiteral("%1 => %2")
43 .arg(imodule->config(
45 m->config(
47 return m->config(CSwordModuleInfo::ModuleVersion);
48 }
49 break;
50 case 2:
51 if (CSwordModuleInfo * const m =
52 module(index(i.row(), 0, i.parent())))
53 return m->config(CSwordModuleInfo::Description);
54 break;
55 default:
56 break;
57 }
58 break;
59 default:
60 if (i.column() == 0)
62 break;
63 }
64
65 return QVariant();
66}
67
68int BtInstallPageModel::columnCount(QModelIndex const & parent) const {
70 return 3;
71}
72
73QVariant BtInstallPageModel::headerData(int section,
74 Qt::Orientation orientation,
75 int role) const
76{
77 if (role == Qt::DisplayRole && orientation == Qt::Horizontal) {
78 switch (section) {
79 case 0: return tr("Work");
80 case 1: return tr("Version");
81 case 2: return tr("Description");
82 default: break;
83 }
84 }
85 return QVariant();
86}
QVariant data(QModelIndex const &index, int role=Qt::DisplayRole) const override
QModelIndex index(int row, int column, QModelIndex const &parent=QModelIndex()) const override
void setDefaultChecked(CheckedBehavior const b)
QModelIndex parent(QModelIndex const &index) const override
void setCheckable(bool checkable)
CSwordModuleInfo * module(QModelIndex const &index) const
QModelIndex getGroup(CSwordModuleInfo const &module, QModelIndex const parentIndex, bool &beginInsert)
QVariant data(QModelIndex const &index, int role=Qt::DisplayRole) const final override
QVariant headerData(int section, Qt::Orientation orientation, int role=Qt::DisplayRole) const final override
BtInstallPageModel(Grouping const &grouping, QObject *const parent=nullptr)
int columnCount(QModelIndex const &parent=QModelIndex()) const final override
static CSwordBackend & instance() noexcept