Create bindings for canFetchMore and fetchMore
parent
de596c1972
commit
d66e16f764
|
@ -203,6 +203,8 @@ pub trait DirectoryTrait {
|
|||
fn get_path(&self) -> String;
|
||||
fn set_path(&mut self, value: String);
|
||||
fn row_count(&self) -> c_int;
|
||||
fn can_fetch_more(&self) -> bool { false }
|
||||
fn fetch_more(&self) {}
|
||||
fn file_icon(&self, row: c_int) -> Variant;
|
||||
fn file_path(&self, row: c_int) -> Variant;
|
||||
fn file_name(&self, row: c_int) -> Variant;
|
||||
|
@ -258,6 +260,14 @@ pub unsafe extern "C" fn directory_path_set(ptr: *mut Directory, v: QStringIn) {
|
|||
pub unsafe extern "C" fn directory_row_count(ptr: *const Directory) -> c_int {
|
||||
(&*ptr).row_count()
|
||||
}
|
||||
#[no_mangle]
|
||||
pub unsafe extern "C" fn directory_can_fetch_more(ptr: *const Directory) -> bool {
|
||||
(&*ptr).can_fetch_more()
|
||||
}
|
||||
#[no_mangle]
|
||||
pub unsafe extern "C" fn directory_fetch_more(ptr: *mut Directory) {
|
||||
(&mut *ptr).fetch_more()
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub unsafe extern "C" fn directory_data_file_icon(ptr: *const Directory,
|
||||
|
|
|
@ -223,7 +223,9 @@ extern "C" {
|
|||
void directory_data_file_name(DirectoryInterface*, int, QVariant*, qvariant_set);
|
||||
void directory_data_file_permissions(DirectoryInterface*, int, QVariant*, qvariant_set);
|
||||
|
||||
int directory_row_count(DirectoryInterface*, qmodelindex_t parent);
|
||||
int directory_row_count(DirectoryInterface*);
|
||||
bool directory_can_fetch_more(DirectoryInterface*);
|
||||
void directory_fetch_more(DirectoryInterface*);
|
||||
}
|
||||
int Directory::columnCount(const QModelIndex &parent) const
|
||||
{
|
||||
|
@ -232,7 +234,7 @@ int Directory::columnCount(const QModelIndex &parent) const
|
|||
|
||||
int Directory::rowCount(const QModelIndex &parent) const
|
||||
{
|
||||
return (parent.isValid()) ? 0 : directory_row_count(d, parent);
|
||||
return (parent.isValid()) ? 0 : directory_row_count(d);
|
||||
}
|
||||
|
||||
QModelIndex Directory::index(int row, int column, const QModelIndex &parent) const
|
||||
|
@ -248,6 +250,18 @@ QModelIndex Directory::parent(const QModelIndex &) const
|
|||
return QModelIndex();
|
||||
}
|
||||
|
||||
bool Directory::canFetchMore(const QModelIndex &parent) const
|
||||
{
|
||||
return (parent.isValid()) ? 0 : directory_can_fetch_more(d);
|
||||
}
|
||||
|
||||
void Directory::fetchMore(const QModelIndex &parent)
|
||||
{
|
||||
if (!parent.isValid()) {
|
||||
directory_fetch_more(d);
|
||||
}
|
||||
}
|
||||
|
||||
QVariant Directory::data(const QModelIndex &index, int role) const
|
||||
{
|
||||
QVariant v;
|
||||
|
|
|
@ -59,6 +59,8 @@ public:
|
|||
QModelIndex index(int row, int column, const QModelIndex &parent) const;
|
||||
QModelIndex parent(const QModelIndex &index) const;
|
||||
int rowCount(const QModelIndex &parent) const;
|
||||
bool canFetchMore(const QModelIndex &parent) const;
|
||||
void fetchMore(const QModelIndex &parent);
|
||||
QHash<int, QByteArray> roleNames() const;
|
||||
signals:
|
||||
void newDataReady();
|
||||
|
|
|
@ -227,6 +227,8 @@ void writeHeaderItemModel(QTextStream& h, const Object&) {
|
|||
QModelIndex index(int row, int column, const QModelIndex &parent) const;
|
||||
QModelIndex parent(const QModelIndex &index) const;
|
||||
int rowCount(const QModelIndex &parent) const;
|
||||
bool canFetchMore(const QModelIndex &parent) const;
|
||||
void fetchMore(const QModelIndex &parent);
|
||||
QHash<int, QByteArray> roleNames() const;
|
||||
signals:
|
||||
void newDataReady();
|
||||
|
@ -248,7 +250,9 @@ void writeCppListModel(QTextStream& cpp, const Object& o) {
|
|||
.arg(o.name, lcname, snakeCase(role.name));
|
||||
}
|
||||
cpp << QString(R"(
|
||||
int %2_row_count(%1Interface*, qmodelindex_t parent);
|
||||
int %2_row_count(%1Interface*);
|
||||
bool %2_can_fetch_more(%1Interface*);
|
||||
void %2_fetch_more(%1Interface*);
|
||||
}
|
||||
int %1::columnCount(const QModelIndex &parent) const
|
||||
{
|
||||
|
@ -257,7 +261,7 @@ int %1::columnCount(const QModelIndex &parent) const
|
|||
|
||||
int %1::rowCount(const QModelIndex &parent) const
|
||||
{
|
||||
return (parent.isValid()) ? 0 : %2_row_count(d, parent);
|
||||
return (parent.isValid()) ? 0 : %2_row_count(d);
|
||||
}
|
||||
|
||||
QModelIndex %1::index(int row, int column, const QModelIndex &parent) const
|
||||
|
@ -273,6 +277,18 @@ QModelIndex %1::parent(const QModelIndex &) const
|
|||
return QModelIndex();
|
||||
}
|
||||
|
||||
bool %1::canFetchMore(const QModelIndex &parent) const
|
||||
{
|
||||
return (parent.isValid()) ? 0 : %2_can_fetch_more(d);
|
||||
}
|
||||
|
||||
void %1::fetchMore(const QModelIndex &parent)
|
||||
{
|
||||
if (!parent.isValid()) {
|
||||
%2_fetch_more(d);
|
||||
}
|
||||
}
|
||||
|
||||
QVariant %1::data(const QModelIndex &index, int role) const
|
||||
{
|
||||
QVariant v;
|
||||
|
@ -681,6 +697,8 @@ pub trait %1Trait {
|
|||
}
|
||||
if (o.type == ObjectTypeList) {
|
||||
r << " fn row_count(&self) -> c_int;\n";
|
||||
r << " fn can_fetch_more(&self) -> bool { false }\n";
|
||||
r << " fn fetch_more(&self) {}\n";
|
||||
for (auto role: o.roles) {
|
||||
r << QString(" fn %1(&self, row: c_int) -> Variant;\n")
|
||||
.arg(snakeCase(role.name));
|
||||
|
@ -781,6 +799,14 @@ pub unsafe extern "C" fn %2_set(ptr: *mut %1, v: %4) {
|
|||
pub unsafe extern "C" fn %2_row_count(ptr: *const %1) -> c_int {
|
||||
(&*ptr).row_count()
|
||||
}
|
||||
#[no_mangle]
|
||||
pub unsafe extern "C" fn %2_can_fetch_more(ptr: *const %1) -> bool {
|
||||
(&*ptr).can_fetch_more()
|
||||
}
|
||||
#[no_mangle]
|
||||
pub unsafe extern "C" fn %2_fetch_more(ptr: *mut %1) {
|
||||
(&mut *ptr).fetch_more()
|
||||
}
|
||||
)").arg(o.name, lcname);
|
||||
for (auto role: o.roles) {
|
||||
r << QString(R"(
|
||||
|
|
Loading…
Reference in New Issue