开源 企业版 高校版 私有云 模力方舟 AI 队友
代码拉取完成,页面将自动刷新
forked from 陈炳煌/sqlitebrowser
加入 Gitee
与超过 1400万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
已有帐号? 立即登录
文件
master
分支 (16)
标签 (31)
master
coverity_scan
v3.11.x
issue1831_v1
qdarkstyle
no_savepoints_ro_db
v3.10.x
v3.9.x
v3.6.x
v3.5.x
v3.4.x
v3.3.x
utf8grammar
sqlb-3.2.x
sqlb-3.1.x
sqlb-3.x
continuous
v3.11.2
v3.11.1v2
v3.11.1
v3.11.0
v3.11.0-beta3
v3.11.0-beta2
v3.11.0-beta1
v3.11.0-alpha1
v3.10.1
v3.10.0
v3.10.0-beta2
v3.10.0-beta1
v3.9.1
v3.9.0
v3.9.0-beta1
v3.8.0
v3.7.0
v3.6.0
v3.5.1
master
分支 (16)
标签 (31)
master
coverity_scan
v3.11.x
issue1831_v1
qdarkstyle
no_savepoints_ro_db
v3.10.x
v3.9.x
v3.6.x
v3.5.x
v3.4.x
v3.3.x
utf8grammar
sqlb-3.2.x
sqlb-3.1.x
sqlb-3.x
continuous
v3.11.2
v3.11.1v2
v3.11.1
v3.11.0
v3.11.0-beta3
v3.11.0-beta2
v3.11.0-beta1
v3.11.0-alpha1
v3.10.1
v3.10.0
v3.10.0-beta2
v3.10.0-beta1
v3.9.1
v3.9.0
v3.9.0-beta1
v3.8.0
v3.7.0
v3.6.0
v3.5.1
克隆/下载
克隆/下载
提示
下载代码请复制以下命令到终端执行
为确保你提交的代码身份被 Gitee 正确识别,请执行以下命令完成配置
初次使用 SSH 协议进行代码克隆、推送等操作时,需按下述提示完成 SSH 配置
1 生成 RSA 密钥
2 获取 RSA 公钥内容,并配置到 SSH公钥
在 Gitee 上使用 SVN,请访问 使用指南
使用 HTTPS 协议时,命令行会出现如下账号密码验证步骤。基于安全考虑,Gitee 建议 配置并使用私人令牌 替代登录密码进行克隆、推送等操作
Username for 'https://gitee.com': userName
Password for 'https://userName@gitee.com': # 私人令牌
master
分支 (16)
标签 (31)
master
coverity_scan
v3.11.x
issue1831_v1
qdarkstyle
no_savepoints_ro_db
v3.10.x
v3.9.x
v3.6.x
v3.5.x
v3.4.x
v3.3.x
utf8grammar
sqlb-3.2.x
sqlb-3.1.x
sqlb-3.x
continuous
v3.11.2
v3.11.1v2
v3.11.1
v3.11.0
v3.11.0-beta3
v3.11.0-beta2
v3.11.0-beta1
v3.11.0-alpha1
v3.10.1
v3.10.0
v3.10.0-beta2
v3.10.0-beta1
v3.9.1
v3.9.0
v3.9.0-beta1
v3.8.0
v3.7.0
v3.6.0
v3.5.1
sqlitebrowser
/
src
/
sqlitetablemodel.h
sqlitebrowser
/
src
/
sqlitetablemodel.h
sqlitetablemodel.h 7.71 KB
一键复制 编辑 原始数据 按行查看 历史
Martin Kleusberg 提交于 2019年05月06日 04:12 +08:00 . Use even less Qt containers
#ifndef SQLITETABLEMODEL_H
#define SQLITETABLEMODEL_H
#include <QAbstractTableModel>
#include <QMutex>
#include <QColor>
#include <memory>
#include <vector>
#include <map>
#include "RowCache.h"
#include "sql/Query.h"
#include "sql/sqlitetypes.h"
struct sqlite3;
class DBBrowserDB;
class CondFormat;
class SqliteTableModel : public QAbstractTableModel
{
Q_OBJECT
#ifdef REGEX_UNIT_TEST
friend class TestRegex;
#endif
public:
explicit SqliteTableModel(DBBrowserDB& db, QObject *parent = nullptr, size_t chunkSize = 50000, const QString& encoding = QString());
~SqliteTableModel() override;
/// reset to state after construction
void reset();
/// returns logical amount of rows, whether currently cached or not
int rowCount(const QModelIndex &parent = QModelIndex()) const override;
int columnCount(const QModelIndex &parent = QModelIndex()) const override;
size_t filterCount() const;
QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const override;
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
bool setData(const QModelIndex& index, const QVariant& value, int role = Qt::EditRole) override;
bool setTypedData(const QModelIndex& index, bool isBlob, const QVariant& value, int role = Qt::EditRole);
enum class RowCount
{
Unknown, //< still finding out in background...
Partial, //< some chunk was read and at least a lower bound is thus known
Complete //< total row count of table known
};
/// what kind of information is available through rowCount()?
RowCount rowCountAvailable () const;
/// trigger asynchronous loading of (at least) the specified row
/// into cache.
void triggerCacheLoad (int single_row) const;
/// trigger asynchronous loading of (at least) the specified rows
/// into cache. \param row_end is exclusive.
void triggerCacheLoad (int row_begin, int row_end) const;
/// wait until not reading any data (that does not mean data is
/// complete, just that the background reader is idle)
void waitUntilIdle () const;
/// load all rows into cache, return when done. Returns true if all data was loaded, false if the loading was cancelled.
bool completeCache() const;
/// returns true if all rows are currently available in cache
/// [NOTE: potentially unsafe in case we have a limited-size
/// cache, where entries can vanish again -- however we can't do
/// this for the current implementation of the PlotDock]
bool isCacheComplete () const;
bool insertRows(int row, int count, const QModelIndex& parent = QModelIndex()) override;
bool removeRows(int row, int count, const QModelIndex& parent = QModelIndex()) override;
QModelIndex dittoRecord(int old_row);
/// configure for browsing results of specified query
void setQuery(const QString& sQuery, const QString& sCountQuery = QString(), bool dontClearHeaders = false);
QString query() const { return m_sQuery; }
QString customQuery(bool withRowid) const { return QString::fromStdString(m_query.buildQuery(withRowid)); }
/// configure for browsing specified table
void setQuery(const sqlb::Query& query);
void setChunkSize(size_t chunksize);
size_t chunkSize() { return m_chunkSize; }
void sort(int column, Qt::SortOrder order = Qt::AscendingOrder) override;
void sort(const std::vector<sqlb::SortedColumn>& columns);
sqlb::ObjectIdentifier currentTableName() const { return m_query.table(); }
Qt::ItemFlags flags(const QModelIndex& index) const override;
bool isBinary(const QModelIndex& index) const;
void setEncoding(const QString& encoding) { m_encoding = encoding; }
QString encoding() const { return m_encoding; }
// The pseudo-primary key is exclusively for editing views
void setPseudoPk(std::vector<std::string> pseudoPk);
bool hasPseudoPk() const;
std::vector<std::string> pseudoPk() const { return m_query.rowIdColumns(); }
sqlb::ForeignKeyClause getForeignKeyClause(int column) const;
// This returns true if the model is set up for editing. The model is able to operate in more or less two different modes, table browsing
// and query browsing. We only support editing data for the table browsing mode and not for the query mode. This function returns true if
// the model is currently editable, i.e. it's running in table mode and it isn't a view.
bool isEditable() const;
// Helper function for removing all comments from a SQL query
static void removeCommentsFromQuery(QString& query);
void addCondFormat(int column, const CondFormat& condFormat);
void setCondFormats(int column, const std::vector<CondFormat>& condFormats);
DBBrowserDB& db() { return m_db; }
public slots:
void updateFilter(int column, const QString& value);
signals:
void finishedFetch(int fetched_row_begin, int fetched_row_end);
void finishedRowCount();
protected:
Qt::DropActions supportedDropActions() const override;
bool dropMimeData(const QMimeData* data, Qt::DropAction action, int row, int column, const QModelIndex& parent) override;
private:
friend class RowLoader;
class RowLoader * worker;
/// clears the cache, resets row-count to unknown (but keeps table
/// & query info), increase life_counter
void clearCache();
void handleFinishedFetch(int life_id, unsigned int fetched_row_begin, unsigned int fetched_row_end);
void handleRowCountComplete(int life_id, int num_rows);
void buildQuery();
/// \param pDb connection to query; if null, obtains it from 'm_db'.
std::vector<std::string> getColumns(std::shared_ptr<sqlite3> pDb, const QString& sQuery, std::vector<int>& fieldsTypes);
QByteArray encode(const QByteArray& str) const;
QByteArray decode(const QByteArray& str) const;
// Return matching conditional format color or invalid color, otherwise.
// Only Qt::ForegroundRole and Qt::BackgroundRole are expected in role (Qt::ItemDataRole)
QColor getMatchingCondFormatColor(int column, const QString& value, int role) const;
DBBrowserDB& m_db;
/// counts numbers of clearCache() since instantiation; using this
/// to avoid processing of queued signals originating in an era
/// before the most recent reset().
int m_lifeCounter;
/// note: the row count can be determined by the row-count query
/// (which yields the "final" row count"), or, if it is faster, by
/// the first chunk reading actual data (in which case the row
/// count will be set to that chunk's size and later updated to
/// the full row count, when the row-count query returns)
RowCount m_rowCountAvailable;
unsigned int m_currentRowCount;
std::vector<std::string> m_headers;
/// reading something in background right now? (either counting
/// rows or actually loading data, doesn't matter)
bool readingData() const;
using Row = std::vector<QByteArray>;
mutable RowCache<Row> m_cache;
Row makeDefaultCacheEntry () const;
bool nosync_isBinary(const QModelIndex& index) const;
QString m_sQuery;
std::vector<int> m_vDataTypes;
std::map<int, std::vector<CondFormat>> m_mCondFormats;
sqlb::Query m_query;
/**
* @brief m_chunkSize Size of the next chunk fetch more will try to fetch.
* This value should be rather high, because our query
* uses LIMIT and sqlite3 will still execute the whole query and
* just skip the not wanted rows, but the execution will
* still take nearly the same time as doing the query at all up
* to that row count.
*/
size_t m_chunkSize;
QString m_encoding;
/**
* These are used for multi-threaded population of the table
*/
mutable QMutex m_mutexDataCache;
};
#endif
Loading...
举报
举报成功
我们将于2个工作日内通过站内信反馈结果给你!
请认真填写举报原因,尽可能描述详细。
请选择举报类型
取消
发送
误判申诉

此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。

如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。

取消
提交

简介

Official home of the DB Browser for SQLite (DB4S) project. Previously known as "SQLite Database Browser" and "Database Browser for SQLite". Website at:
取消

发行版

暂无发行版

贡献者

全部

近期动态

不能加载更多了
编辑仓库简介
简介内容
主页
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
C++
1
https://gitee.com/my_open_source_software/sqlitebrowser.git
git@gitee.com:my_open_source_software/sqlitebrowser.git
my_open_source_software
sqlitebrowser
sqlitebrowser
master
点此查找更多帮助

搜索帮助

评论
仓库举报
回到顶部
登录提示
该操作需登录 Gitee 帐号,请先登录后再操作。
立即登录
没有帐号,去注册

AltStyle によって変換されたページ (->オリジナル) /