Added generators for remove_rows for lists
This patch was contributed by Pearce Keesling. It was applied and tested with cat D8120.diff | patch -p1 ninja test REVIEW: D8120master
parent
1de0533601
commit
e63ca9e924
|
@ -433,6 +433,7 @@ pub trait FibonacciListTrait {
|
|||
fn emit(&self) -> &FibonacciListEmitter;
|
||||
fn row_count(&self) -> usize;
|
||||
fn insert_rows(&mut self, row: usize, count: usize) -> bool { false }
|
||||
fn remove_rows(&mut self, row: usize, count: usize) -> bool { false }
|
||||
fn can_fetch_more(&self) -> bool {
|
||||
false
|
||||
}
|
||||
|
@ -486,6 +487,10 @@ pub unsafe extern "C" fn fibonacci_list_insert_rows(ptr: *mut FibonacciList, row
|
|||
(&mut *ptr).insert_rows(row as usize, count as usize)
|
||||
}
|
||||
#[no_mangle]
|
||||
pub unsafe extern "C" fn fibonacci_list_remove_rows(ptr: *mut FibonacciList, row: c_int, count: c_int) -> bool {
|
||||
(&mut *ptr).remove_rows(row as usize, count as usize)
|
||||
}
|
||||
#[no_mangle]
|
||||
pub unsafe extern "C" fn fibonacci_list_can_fetch_more(ptr: *const FibonacciList) -> bool {
|
||||
(&*ptr).can_fetch_more()
|
||||
}
|
||||
|
@ -1088,6 +1093,7 @@ pub trait TimeSeriesTrait {
|
|||
fn emit(&self) -> &TimeSeriesEmitter;
|
||||
fn row_count(&self) -> usize;
|
||||
fn insert_rows(&mut self, row: usize, count: usize) -> bool { false }
|
||||
fn remove_rows(&mut self, row: usize, count: usize) -> bool { false }
|
||||
fn can_fetch_more(&self) -> bool {
|
||||
false
|
||||
}
|
||||
|
@ -1145,6 +1151,10 @@ pub unsafe extern "C" fn time_series_insert_rows(ptr: *mut TimeSeries, row: c_in
|
|||
(&mut *ptr).insert_rows(row as usize, count as usize)
|
||||
}
|
||||
#[no_mangle]
|
||||
pub unsafe extern "C" fn time_series_remove_rows(ptr: *mut TimeSeries, row: c_int, count: c_int) -> bool {
|
||||
(&mut *ptr).remove_rows(row as usize, count as usize)
|
||||
}
|
||||
#[no_mangle]
|
||||
pub unsafe extern "C" fn time_series_can_fetch_more(ptr: *const TimeSeries) -> bool {
|
||||
(&*ptr).can_fetch_more()
|
||||
}
|
||||
|
|
|
@ -153,6 +153,7 @@ extern "C" {
|
|||
|
||||
int fibonacci_list_row_count(const FibonacciList::Private*);
|
||||
bool fibonacci_list_insert_rows(FibonacciList::Private*, int, int);
|
||||
bool fibonacci_list_remove_rows(FibonacciList::Private*, int, int);
|
||||
bool fibonacci_list_can_fetch_more(const FibonacciList::Private*);
|
||||
void fibonacci_list_fetch_more(FibonacciList::Private*);
|
||||
}
|
||||
|
@ -176,6 +177,11 @@ bool FibonacciList::insertRows(int row, int count, const QModelIndex &parent)
|
|||
return fibonacci_list_insert_rows(m_d, row, count);
|
||||
}
|
||||
|
||||
bool FibonacciList::removeRows(int row, int count, const QModelIndex &parent)
|
||||
{
|
||||
return fibonacci_list_remove_rows(m_d, row, count);
|
||||
}
|
||||
|
||||
QModelIndex FibonacciList::index(int row, int column, const QModelIndex &parent) const
|
||||
{
|
||||
if (!parent.isValid() && row >= 0 && row < rowCount(parent) && column >= 0 && column < 2) {
|
||||
|
@ -322,6 +328,11 @@ bool FileSystemTree::insertRows(int, int, const QModelIndex &)
|
|||
return false; // not supported yet
|
||||
}
|
||||
|
||||
bool FileSystemTree::removeRows(int, int, const QModelIndex &)
|
||||
{
|
||||
return false; // not supported yet
|
||||
}
|
||||
|
||||
QModelIndex FileSystemTree::index(int row, int column, const QModelIndex &parent) const
|
||||
{
|
||||
if (row < 0 || column < 0 || column >= 5) {
|
||||
|
@ -549,6 +560,11 @@ bool Processes::insertRows(int, int, const QModelIndex &)
|
|||
return false; // not supported yet
|
||||
}
|
||||
|
||||
bool Processes::removeRows(int, int, const QModelIndex &)
|
||||
{
|
||||
return false; // not supported yet
|
||||
}
|
||||
|
||||
QModelIndex Processes::index(int row, int column, const QModelIndex &parent) const
|
||||
{
|
||||
if (row < 0 || column < 0 || column >= 3) {
|
||||
|
@ -742,6 +758,7 @@ extern "C" {
|
|||
|
||||
int time_series_row_count(const TimeSeries::Private*);
|
||||
bool time_series_insert_rows(TimeSeries::Private*, int, int);
|
||||
bool time_series_remove_rows(TimeSeries::Private*, int, int);
|
||||
bool time_series_can_fetch_more(const TimeSeries::Private*);
|
||||
void time_series_fetch_more(TimeSeries::Private*);
|
||||
}
|
||||
|
@ -765,6 +782,11 @@ bool TimeSeries::insertRows(int row, int count, const QModelIndex &parent)
|
|||
return time_series_insert_rows(m_d, row, count);
|
||||
}
|
||||
|
||||
bool TimeSeries::removeRows(int row, int count, const QModelIndex &parent)
|
||||
{
|
||||
return time_series_remove_rows(m_d, row, count);
|
||||
}
|
||||
|
||||
QModelIndex TimeSeries::index(int row, int column, const QModelIndex &parent) const
|
||||
{
|
||||
if (!parent.isValid() && row >= 0 && row < rowCount(parent) && column >= 0 && column < 3) {
|
||||
|
|
|
@ -103,6 +103,7 @@ public:
|
|||
QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const override;
|
||||
bool setHeaderData(int section, Qt::Orientation orientation, const QVariant &value, int role = Qt::EditRole) override;
|
||||
Q_INVOKABLE bool insertRows(int row, int count, const QModelIndex &parent = QModelIndex()) override;
|
||||
Q_INVOKABLE bool removeRows(int row, int count, const QModelIndex &parent = QModelIndex()) override;
|
||||
Q_INVOKABLE QVariant fibonacciNumber(int row) const;
|
||||
Q_INVOKABLE QVariant row(int row) const;
|
||||
|
||||
|
@ -146,6 +147,7 @@ public:
|
|||
QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const override;
|
||||
bool setHeaderData(int section, Qt::Orientation orientation, const QVariant &value, int role = Qt::EditRole) override;
|
||||
Q_INVOKABLE bool insertRows(int row, int count, const QModelIndex &parent = QModelIndex()) override;
|
||||
Q_INVOKABLE bool removeRows(int row, int count, const QModelIndex &parent = QModelIndex()) override;
|
||||
Q_INVOKABLE QVariant fileIcon(const QModelIndex& index) const;
|
||||
Q_INVOKABLE QVariant fileName(const QModelIndex& index) const;
|
||||
Q_INVOKABLE QVariant filePath(const QModelIndex& index) const;
|
||||
|
@ -194,6 +196,7 @@ public:
|
|||
QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const override;
|
||||
bool setHeaderData(int section, Qt::Orientation orientation, const QVariant &value, int role = Qt::EditRole) override;
|
||||
Q_INVOKABLE bool insertRows(int row, int count, const QModelIndex &parent = QModelIndex()) override;
|
||||
Q_INVOKABLE bool removeRows(int row, int count, const QModelIndex &parent = QModelIndex()) override;
|
||||
Q_INVOKABLE QVariant cmd(const QModelIndex& index) const;
|
||||
Q_INVOKABLE QVariant cpuPercentage(const QModelIndex& index) const;
|
||||
Q_INVOKABLE QVariant cpuUsage(const QModelIndex& index) const;
|
||||
|
@ -240,6 +243,7 @@ public:
|
|||
QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const override;
|
||||
bool setHeaderData(int section, Qt::Orientation orientation, const QVariant &value, int role = Qt::EditRole) override;
|
||||
Q_INVOKABLE bool insertRows(int row, int count, const QModelIndex &parent = QModelIndex()) override;
|
||||
Q_INVOKABLE bool removeRows(int row, int count, const QModelIndex &parent = QModelIndex()) override;
|
||||
bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole) override;
|
||||
Q_INVOKABLE QVariant cos(int row) const;
|
||||
Q_INVOKABLE bool setCos(int row, const QVariant& value);
|
||||
|
|
12
src/cpp.cpp
12
src/cpp.cpp
|
@ -79,6 +79,7 @@ void writeHeaderItemModel(QTextStream& h, const Object& o) {
|
|||
QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const override;
|
||||
bool setHeaderData(int section, Qt::Orientation orientation, const QVariant &value, int role = Qt::EditRole) override;
|
||||
Q_INVOKABLE bool insertRows(int row, int count, const QModelIndex &parent = QModelIndex()) override;
|
||||
Q_INVOKABLE bool removeRows(int row, int count, const QModelIndex &parent = QModelIndex()) override;
|
||||
)");
|
||||
if (modelIsWritable(o)) {
|
||||
h << " bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole) override;\n";
|
||||
|
@ -226,6 +227,7 @@ void writeCppModel(QTextStream& cpp, const Object& o) {
|
|||
cpp << QString(R"(
|
||||
int %2_row_count(const %1::Private*);
|
||||
bool %2_insert_rows(%1::Private*, int, int);
|
||||
bool %2_remove_rows(%1::Private*, int, int);
|
||||
bool %2_can_fetch_more(const %1::Private*);
|
||||
void %2_fetch_more(%1::Private*);
|
||||
}
|
||||
|
@ -249,6 +251,11 @@ bool %1::insertRows(int row, int count, const QModelIndex &parent)
|
|||
return %2_insert_rows(m_d, row, count);
|
||||
}
|
||||
|
||||
bool %1::removeRows(int row, int count, const QModelIndex &parent)
|
||||
{
|
||||
return %2_remove_rows(m_d, row, count);
|
||||
}
|
||||
|
||||
QModelIndex %1::index(int row, int column, const QModelIndex &parent) const
|
||||
{
|
||||
if (!parent.isValid() && row >= 0 && row < rowCount(parent) && column >= 0 && column < %3) {
|
||||
|
@ -306,6 +313,11 @@ bool %1::insertRows(int, int, const QModelIndex &)
|
|||
return false; // not supported yet
|
||||
}
|
||||
|
||||
bool %1::removeRows(int, int, const QModelIndex &)
|
||||
{
|
||||
return false; // not supported yet
|
||||
}
|
||||
|
||||
QModelIndex %1::index(int row, int column, const QModelIndex &parent) const
|
||||
{
|
||||
if (row < 0 || column < 0 || column >= %3) {
|
||||
|
|
|
@ -285,6 +285,7 @@ pub trait %1Trait {
|
|||
if (o.type == ObjectType::List) {
|
||||
r << R"( fn row_count(&self) -> usize;
|
||||
fn insert_rows(&mut self, row: usize, count: usize) -> bool { false }
|
||||
fn remove_rows(&mut self, row: usize, count: usize) -> bool { false }
|
||||
fn can_fetch_more(&self) -> bool {
|
||||
false
|
||||
}
|
||||
|
@ -419,6 +420,10 @@ pub unsafe extern "C" fn %2_insert_rows(ptr: *mut %1, row: c_int, count: c_int)
|
|||
(&mut *ptr).insert_rows(row as usize, count as usize)
|
||||
}
|
||||
#[no_mangle]
|
||||
pub unsafe extern "C" fn %2_remove_rows(ptr: *mut %1, row: c_int, count: c_int) -> bool {
|
||||
(&mut *ptr).remove_rows(row as usize, count as usize)
|
||||
}
|
||||
#[no_mangle]
|
||||
pub unsafe extern "C" fn %2_can_fetch_more(ptr: *const %1) -> bool {
|
||||
(&*ptr).can_fetch_more()
|
||||
}
|
||||
|
|
|
@ -148,6 +148,7 @@ pub trait PersonsTrait {
|
|||
fn emit(&self) -> &PersonsEmitter;
|
||||
fn row_count(&self) -> usize;
|
||||
fn insert_rows(&mut self, row: usize, count: usize) -> bool { false }
|
||||
fn remove_rows(&mut self, row: usize, count: usize) -> bool { false }
|
||||
fn can_fetch_more(&self) -> bool {
|
||||
false
|
||||
}
|
||||
|
@ -201,6 +202,10 @@ pub unsafe extern "C" fn persons_insert_rows(ptr: *mut Persons, row: c_int, coun
|
|||
(&mut *ptr).insert_rows(row as usize, count as usize)
|
||||
}
|
||||
#[no_mangle]
|
||||
pub unsafe extern "C" fn persons_remove_rows(ptr: *mut Persons, row: c_int, count: c_int) -> bool {
|
||||
(&mut *ptr).remove_rows(row as usize, count as usize)
|
||||
}
|
||||
#[no_mangle]
|
||||
pub unsafe extern "C" fn persons_can_fetch_more(ptr: *const Persons) -> bool {
|
||||
(&*ptr).can_fetch_more()
|
||||
}
|
||||
|
|
|
@ -45,6 +45,7 @@ extern "C" {
|
|||
|
||||
int persons_row_count(const Persons::Private*);
|
||||
bool persons_insert_rows(Persons::Private*, int, int);
|
||||
bool persons_remove_rows(Persons::Private*, int, int);
|
||||
bool persons_can_fetch_more(const Persons::Private*);
|
||||
void persons_fetch_more(Persons::Private*);
|
||||
}
|
||||
|
@ -68,6 +69,11 @@ bool Persons::insertRows(int row, int count, const QModelIndex &parent)
|
|||
return persons_insert_rows(m_d, row, count);
|
||||
}
|
||||
|
||||
bool Persons::removeRows(int row, int count, const QModelIndex &parent)
|
||||
{
|
||||
return persons_remove_rows(m_d, row, count);
|
||||
}
|
||||
|
||||
QModelIndex Persons::index(int row, int column, const QModelIndex &parent) const
|
||||
{
|
||||
if (!parent.isValid() && row >= 0 && row < rowCount(parent) && column >= 0 && column < 1) {
|
||||
|
|
|
@ -34,6 +34,7 @@ public:
|
|||
QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const override;
|
||||
bool setHeaderData(int section, Qt::Orientation orientation, const QVariant &value, int role = Qt::EditRole) override;
|
||||
Q_INVOKABLE bool insertRows(int row, int count, const QModelIndex &parent = QModelIndex()) override;
|
||||
Q_INVOKABLE bool removeRows(int row, int count, const QModelIndex &parent = QModelIndex()) override;
|
||||
bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole) override;
|
||||
Q_INVOKABLE QVariant userName(int row) const;
|
||||
Q_INVOKABLE bool setUserName(int row, const QVariant& value);
|
||||
|
|
|
@ -73,6 +73,11 @@ bool Persons::insertRows(int, int, const QModelIndex &)
|
|||
return false; // not supported yet
|
||||
}
|
||||
|
||||
bool Persons::removeRows(int, int, const QModelIndex &)
|
||||
{
|
||||
return false; // not supported yet
|
||||
}
|
||||
|
||||
QModelIndex Persons::index(int row, int column, const QModelIndex &parent) const
|
||||
{
|
||||
if (row < 0 || column < 0 || column >= 1) {
|
||||
|
|
|
@ -34,6 +34,7 @@ public:
|
|||
QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const override;
|
||||
bool setHeaderData(int section, Qt::Orientation orientation, const QVariant &value, int role = Qt::EditRole) override;
|
||||
Q_INVOKABLE bool insertRows(int row, int count, const QModelIndex &parent = QModelIndex()) override;
|
||||
Q_INVOKABLE bool removeRows(int row, int count, const QModelIndex &parent = QModelIndex()) override;
|
||||
bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole) override;
|
||||
Q_INVOKABLE QVariant userName(const QModelIndex& index) const;
|
||||
Q_INVOKABLE bool setUserName(const QModelIndex& index, const QVariant& value);
|
||||
|
|
Loading…
Reference in New Issue