fix insert_item_from_service
This commit is contained in:
parent
6377182ab3
commit
0efccdfa54
4 changed files with 28 additions and 123 deletions
|
@ -188,23 +188,6 @@ Qt::ItemFlags ServiceItemModel::flags(const QModelIndex &index) const {
|
|||
return Qt::ItemIsEditable; // FIXME: Implement me!
|
||||
}
|
||||
|
||||
// int ServiceItemModel::index(int row, int column, const QModelIndex &parent) {
|
||||
// if (!hasIndex(row, column, parent))
|
||||
// return QModelIndex();
|
||||
|
||||
// ServiceItem *parentItem;
|
||||
|
||||
// if (!parent.isValid())
|
||||
// parentItem = rootItem;
|
||||
// else
|
||||
// parentItem = static_cast<ServiceItem*>(parent.internalPointer());
|
||||
|
||||
// ServiceItem *childItem = parentItem->child(row);
|
||||
// if (childItem)
|
||||
// return createIndex(row, column, childItem);
|
||||
// return QModelIndex();
|
||||
// }
|
||||
|
||||
void ServiceItemModel::addItem(ServiceItem *item) {
|
||||
const int index = m_items.size();
|
||||
qDebug() << index;
|
||||
|
@ -223,56 +206,6 @@ void ServiceItemModel::insertItem(const int &index, ServiceItem *item) {
|
|||
qDebug() << "Success";
|
||||
}
|
||||
|
||||
// void ServiceItemModel::addItem(const QString &name, const QString &type) {
|
||||
// ServiceItem *item = new ServiceItem(name, type);
|
||||
// item->setSelected(false);
|
||||
// item->setActive(false);
|
||||
// addItem(item);
|
||||
// }
|
||||
|
||||
// void ServiceItemModel::addItem(const QString &name, const QString &type,
|
||||
// const QString &background, const QString &backgroundType) {
|
||||
// ServiceItem *item = new ServiceItem(name, type, background, backgroundType);
|
||||
// item->setSelected(false);
|
||||
// item->setActive(false);
|
||||
// addItem(item);
|
||||
// }
|
||||
|
||||
// void ServiceItemModel::addItem(const QString &name, const QString &type,
|
||||
// const QString &background, const QString &backgroundType,
|
||||
// const QStringList &text) {
|
||||
// ServiceItem *item = new ServiceItem(name, type, background, backgroundType, text);
|
||||
// item->setSelected(false);
|
||||
// item->setActive(false);
|
||||
// addItem(item);
|
||||
// qDebug() << name << type << background;
|
||||
// }
|
||||
|
||||
// void ServiceItemModel::addItem(const QString &name, const QString &type,
|
||||
// const QString &background, const QString &backgroundType,
|
||||
// const QStringList &text, const QString &audio) {
|
||||
// ServiceItem *item = new ServiceItem(name, type, background, backgroundType,
|
||||
// text, audio);
|
||||
// item->setSelected(false);
|
||||
// item->setActive(false);
|
||||
// addItem(item);
|
||||
// qDebug() << name << type << background;
|
||||
// }
|
||||
|
||||
// void ServiceItemModel::addItem(const QString &name, const QString &type,
|
||||
// const QString &background, const QString &backgroundType,
|
||||
// const QStringList &text, const QString &audio,
|
||||
// const QString &font, const int &fontSize) {
|
||||
// ServiceItem *item = new ServiceItem(name, type, background, backgroundType,
|
||||
// text, audio, font, fontSize);
|
||||
// item->setSelected(false);
|
||||
// item->setActive(false);
|
||||
// addItem(item);
|
||||
// qDebug() << "#################################";
|
||||
// qDebug() << name << type << font << fontSize;
|
||||
// qDebug() << "#################################";
|
||||
// }
|
||||
|
||||
void ServiceItemModel::addItem(const QString &name, const QString &type,
|
||||
const QString &background, const QString &backgroundType,
|
||||
const QStringList &text, const QString &audio,
|
||||
|
@ -314,58 +247,6 @@ void ServiceItemModel::addItem(const QString &name, const QString &type,
|
|||
qDebug() << "#################################";
|
||||
}
|
||||
|
||||
// void ServiceItemModel::insertItem(const int &index, const QString &name, const QString &type) {
|
||||
// ServiceItem *item = new ServiceItem(name, type);
|
||||
// item->setSelected(false);
|
||||
// item->setActive(false);
|
||||
// insertItem(index, item);
|
||||
// qDebug() << name << type;
|
||||
// }
|
||||
|
||||
// void ServiceItemModel::insertItem(const int &index, const QString &name, const QString &type,
|
||||
// const QString &background, const QString &backgroundType) {
|
||||
// ServiceItem *item = new ServiceItem(name, type, background, backgroundType);
|
||||
// item->setSelected(false);
|
||||
// item->setActive(false);
|
||||
// insertItem(index, item);
|
||||
// qDebug() << name << type << background;
|
||||
// }
|
||||
|
||||
// void ServiceItemModel::insertItem(const int &index, const QString &name, const QString &type,
|
||||
// const QString &background, const QString &backgroundType,
|
||||
// const QStringList &text) {
|
||||
// ServiceItem *item = new ServiceItem(name, type, background, backgroundType, text);
|
||||
// insertItem(index, item);
|
||||
// qDebug() << name << type << background << text;
|
||||
// }
|
||||
|
||||
// void ServiceItemModel::insertItem(const int &index, const QString &name,
|
||||
// const QString &type,const QString &background,
|
||||
// const QString &backgroundType,const QStringList &text,
|
||||
// const QString &audio) {
|
||||
// ServiceItem *item = new ServiceItem(name, type, background, backgroundType,
|
||||
// text, audio);
|
||||
// item->setSelected(false);
|
||||
// item->setActive(false);
|
||||
// insertItem(index, item);
|
||||
// qDebug() << name << type << background << text;
|
||||
// }
|
||||
|
||||
// void ServiceItemModel::insertItem(const int &index, const QString &name,
|
||||
// const QString &type,const QString &background,
|
||||
// const QString &backgroundType,const QStringList &text,
|
||||
// const QString &audio, const QString &font, const int &fontSize) {
|
||||
// ServiceItem *item = new ServiceItem(name, type, background, backgroundType,
|
||||
// text, audio, font, fontSize);
|
||||
// item->setSelected(false);
|
||||
// item->setActive(false);
|
||||
// insertItem(index, item);
|
||||
// qDebug() << "#################################";
|
||||
// qDebug() << "missing slidenumber and slidemodel";
|
||||
// qDebug() << name << type << font << fontSize;
|
||||
// qDebug() << "#################################";
|
||||
// }
|
||||
|
||||
void ServiceItemModel::insertItem(const int &index, const QString &name,
|
||||
const QString &type,const QString &background,
|
||||
const QString &backgroundType,const QStringList &text,
|
||||
|
@ -380,7 +261,26 @@ void ServiceItemModel::insertItem(const int &index, const QString &name,
|
|||
item->setSelected(false);
|
||||
item->setActive(false);
|
||||
insertItem(index, item);
|
||||
|
||||
QVariantMap itm;
|
||||
const QModelIndex idx = this->index(index);
|
||||
qDebug() << idx;
|
||||
if( idx.isValid() ) {
|
||||
const QHash<int,QByteArray> rn = roleNames();
|
||||
// qDebug() << rn;
|
||||
QHashIterator<int,QByteArray> it(rn);
|
||||
while (it.hasNext()) {
|
||||
it.next();
|
||||
qDebug() << "trains";
|
||||
qDebug() << it.key() << ":" << it.value() << ":" << idx.data(it.key());
|
||||
itm[it.value()] = idx.data(it.key());
|
||||
}
|
||||
} else
|
||||
qDebug() << "idx isn't valid";
|
||||
|
||||
emit itemInserted(index, *item);
|
||||
emit itemInsertedRust(index, itm);
|
||||
|
||||
qDebug() << "EMITTED ITEM INSERTED";
|
||||
qDebug() << "#################################";
|
||||
qDebug() << "INSERTING SERVICE ITEM!";
|
||||
|
|
|
@ -117,6 +117,7 @@ signals:
|
|||
void itemAdded(const int &, const ServiceItem &);
|
||||
void itemAddedRust(const int &, const QVariantMap &);
|
||||
void itemInserted(const int &, const ServiceItem &);
|
||||
void itemInsertedRust(const int &, const QVariantMap &);
|
||||
void rowMoved(const int &, const int &, const ServiceItem &);
|
||||
void rowRemoved(const int &, const ServiceItem &);
|
||||
void allRemoved();
|
||||
|
|
|
@ -158,6 +158,10 @@ int main(int argc, char *argv[])
|
|||
&ServiceItemModel::itemAddedRust,
|
||||
slideMod.get(),
|
||||
&SlideyMod::addItemFromService);
|
||||
QObject::connect(serviceItemModel.get(),
|
||||
&ServiceItemModel::itemInsertedRust,
|
||||
slideMod.get(),
|
||||
&SlideyMod::insertItemFromService);
|
||||
QObject::connect(serviceItemModel.get(),
|
||||
SIGNAL(rowMoved(const int&, const int&, const ServiceItem&)),
|
||||
slideModel.get(),
|
||||
|
|
|
@ -310,7 +310,7 @@ mod slide_model {
|
|||
self.as_mut()
|
||||
.begin_insert_rows(&QModelIndex::default(), id, id);
|
||||
self.as_mut().slides_mut().insert(id as usize, slide);
|
||||
self.as_mut().end_remove_rows();
|
||||
self.as_mut().end_insert_rows();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -444,7 +444,7 @@ mod slide_model {
|
|||
slide.video_background = background.clone();
|
||||
slide.image_background = QString::from("");
|
||||
}
|
||||
self.as_mut().insert_slide(&slide, index);
|
||||
self.as_mut().insert_slide(&slide, index + i as i32);
|
||||
}
|
||||
}
|
||||
Some(ty) if ty == QString::from("video") => {
|
||||
|
@ -460,7 +460,7 @@ mod slide_model {
|
|||
slide.image_background = background.clone();
|
||||
slide.video_background = QString::from("");
|
||||
slide.slide_id = i;
|
||||
self.as_mut().insert_slide(&slide, index);
|
||||
self.as_mut().insert_slide(&slide, index + i as i32);
|
||||
}
|
||||
}
|
||||
_ => println!("It's somethign else!"),
|
||||
|
@ -475,7 +475,7 @@ mod slide_model {
|
|||
index: i32,
|
||||
service_item: &QMap_QString_QVariant,
|
||||
) {
|
||||
println!("add rust slide");
|
||||
println!("add rust slide {:?}", index);
|
||||
let ty = service_item
|
||||
.get(&QString::from("type"))
|
||||
.unwrap_or(QVariant::from(&QString::from("")))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue