Home
About
Blog
Products
Forum
Support
Contact
Sunbelt Computer Software
PL/B Language Development and Support
Home
About
Blog
Products
Forum
Support
Contact
sqlitebrowser/src/RemoteModel.h at master · cocoasprite/sqlitebrowser · GitHub
Skip to content
Navigation Menu
Sign in
Appearance settings
Platform
AI CODE CREATION
GitHub Copilot
Write better code with AI
GitHub Copilot app
Direct agents from issue to merge
MCP Registry
Integrate external tools
DEVELOPER WORKFLOWS
Actions
Automate any workflow
Codespaces
Instant dev environments
Issues
Plan and track work
Code Review
Manage code changes
Code Quality
Enforce quality at merge
APPLICATION SECURITY
GitHub Advanced Security
Find and fix vulnerabilities
Code security
Secure your code as you build
Secret protection
Stop leaks before they start
EXPLORE
Why GitHub
Documentation
Blog
Changelog
Marketplace
View all features
Solutions
BY COMPANY SIZE
Enterprises
Small and medium teams
Startups
Nonprofits
BY USE CASE
App Modernization
DevSecOps
DevOps
CI/CD
View all use cases
BY INDUSTRY
Healthcare
Financial services
Manufacturing
Government
See all industries
View all solutions
Resources
EXPLORE BY TOPIC
AI
Software Development
DevOps
Security
View all topics
EXPLORE BY TYPE
Customer stories
Events & webinars
Ebooks & reports
Business insights
GitHub Skills
SUPPORT & SERVICES
Documentation
Customer support
Community forum
Trust center
Partners
View all resources
Open Source
COMMUNITY
GitHub Sponsors
Fund open source developers
PROGRAMS
Security Lab
Maintainer Community
GitHub Stars
Archive Program
REPOSITORIES
Topics
Trending
Collections
Enterprise
ENTERPRISE SOLUTIONS
Enterprise platform
AI-powered developer platform
AVAILABLE ADD-ONS
GitHub Advanced Security
Enterprise-grade security features
Copilot for Business
Enterprise-grade AI features
Premium Support
Enterprise-grade 24/7 support
Pricing
Search
/
Sign in
Sign up
Appearance settings
You signed in with another tab or window.
Reload
to refresh your session.
You signed out in another tab or window.
Reload
to refresh your session.
You switched accounts on another tab or window.
Reload
to refresh your session.
Dismiss alert
{{ message }}
cocoasprite
sqlitebrowser
Repository navigation
Code
Pull requests
Actions
Projects
Security and quality
Insights
More
items
Files
Expand file tree
master
Breadcrumbs
sqlitebrowser
/
src
/
RemoteModel.h
Copy path
Blame
More file actions
Blame
More file actions
Latest commit
History
History
History
113 lines (85 loc) · 4.17 KB
master
Breadcrumbs
sqlitebrowser
/
src
/
RemoteModel.h
Copy path
Top
File metadata and controls
Code
Blame
113 lines (85 loc) · 4.17 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
#
ifndef
REMOTEMODEL_H
#
define
REMOTEMODEL_H
#
include
<
QAbstractItemModel
>
#
include
<
json.hpp
>
class
RemoteDatabase
;
//
List of fields stored in the JSON data
enum
RemoteModelColumns
{
RemoteModelColumnName,
RemoteModelColumnType,
RemoteModelColumnUrl,
RemoteModelColumnCommitId,
RemoteModelColumnSize,
RemoteModelColumnLastModified,
RemoteModelColumnCount
};
class
RemoteModelItem
{
public:
explicit
RemoteModelItem
(RemoteModelItem* parent =
nullptr
);
~RemoteModelItem
();
QVariant
value
(RemoteModelColumns column)
const
;
void
setValue
(RemoteModelColumns column, QVariant value);
bool
fetchedDirectoryList
()
const
;
void
setFetchedDirectoryList
(
bool
fetched);
void
appendChild
(RemoteModelItem* item);
RemoteModelItem*
child
(
int
row)
const
;
RemoteModelItem*
parent
()
const
;
int
childCount
()
const
;
int
row
()
const
;
//
This function assumes the JSON value it's getting passed is an array ("[{...}, {...}, {...}, ...]"). It returns a list of model items, one
//
per array entry and each with the specified parent set.
static
std::vector<RemoteModelItem*>
loadArray
(
const
nlohmann::json& array, RemoteModelItem* parent =
nullptr
);
private:
//
These are just the fields from the json objects returned by the dbhub.io server
QVariant m_values[RemoteModelColumnCount];
//
Child items and parent item
std::vector<RemoteModelItem*> m_children;
RemoteModelItem* m_parent;
//
Indicates whether we already tried fetching a directory listing for this item. This serves two purposes:
//
1) When having an empty directory this allows us to remove the expandable flag for this item.
//
2) Between sending a network request and getting the reply this flag is already set, avoiding a second or third request being sent in the meantime.
bool
m_fetchedDirectoryList;
};
class
RemoteModel
:
public
QAbstractItemModel
{
Q_OBJECT
public:
explicit
RemoteModel
(QObject* parent, RemoteDatabase& remote);
~RemoteModel
()
override
;
void
setNewRootDir
(
const
QString& url,
const
QString& cert);
QModelIndex
index
(
int
row,
int
column,
const
QModelIndex& parent = QModelIndex())
const
override
;
QModelIndex
parent
(
const
QModelIndex& index)
const
override
;
QVariant
data
(
const
QModelIndex& index,
int
role)
const
override
;
QVariant
headerData
(
int
section, Qt::Orientation orientation,
int
role)
const
override
;
int
rowCount
(
const
QModelIndex& parent = QModelIndex())
const
override
;
int
columnCount
(
const
QModelIndex& parent = QModelIndex())
const
override
;
bool
hasChildren
(
const
QModelIndex& parent)
const
override
;
bool
canFetchMore
(
const
QModelIndex& parent)
const
override
;
void
fetchMore
(
const
QModelIndex& parent)
override
;
//
This helper function takes a model index and returns the according model item. An invalid model index is used to indicate the
//
root item, so if the index is invalid the root item is returned. This means that if you need to check for actual invalid indices
//
this needs to be done prior to calling this function.
const
RemoteModelItem*
modelIndexToItem
(
const
QModelIndex& idx)
const
;
//
Returns the current client certificate
const
QString&
currentClientCertificate
()
const
;
signals:
//
This signal is emitted whenever a directory listing has been received and parsed
void
directoryListingParsed
(QModelIndex parent);
private slots:
//
This is called whenever a network reply containing a directory listing arrives. json contains the reply data, userdata
//
contains some custom data passed to the request. In this case we expect this to be the model index of the parent tree item.
void
parseDirectoryListing
(
const
QString& text,
const
QVariant& userdata);
private:
//
Pointer to the root item. This contains all the actual item data.
RemoteModelItem* rootItem;
//
Reference to the remote database object which is stored somewhere in the main window.
RemoteDatabase& remoteDatabase;
//
This stores the currently used network identity so it can be used for further requests, e.g. for
//
lazy population.
QString currentRootDirectory;
QString currentClientCert;
QString currentUserName;
};
#
endif
You can’t perform that action at this time.