multi select and removal. Slides aren't perfect yet.
This commit is contained in:
parent
4bf1790708
commit
7a8c7cc389
7 changed files with 77 additions and 3 deletions
|
@ -372,6 +372,22 @@ void ServiceItemModel::removeItem(int index) {
|
||||||
endRemoveRows();
|
endRemoveRows();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ServiceItemModel::removeItems() {
|
||||||
|
for (int i = m_items.length() - 1; i > -1; i--) {
|
||||||
|
QModelIndex idx = index(i);
|
||||||
|
ServiceItem *item = m_items[idx.row()];
|
||||||
|
if (item->selected()) {
|
||||||
|
qDebug() << "Removing item:" << i;
|
||||||
|
beginRemoveRows(QModelIndex(), i, i);
|
||||||
|
m_items.removeAt(i);
|
||||||
|
endRemoveRows();
|
||||||
|
emit rowRemoved(i, *item);
|
||||||
|
qDebug() << "emitted removal of item:" << item->name();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
bool ServiceItemModel::moveRows(int sourceIndex, int destIndex, int count) {
|
bool ServiceItemModel::moveRows(int sourceIndex, int destIndex, int count) {
|
||||||
qDebug() << sourceIndex;
|
qDebug() << sourceIndex;
|
||||||
qDebug() << destIndex;
|
qDebug() << destIndex;
|
||||||
|
|
|
@ -95,6 +95,7 @@ public:
|
||||||
const QString &audio, const QString &font,
|
const QString &audio, const QString &font,
|
||||||
const int &fontSize, const int &slideNumber);
|
const int &fontSize, const int &slideNumber);
|
||||||
Q_INVOKABLE void removeItem(int index);
|
Q_INVOKABLE void removeItem(int index);
|
||||||
|
Q_INVOKABLE void removeItems();
|
||||||
Q_INVOKABLE bool moveRows(int sourceIndex, int destIndex, int count);
|
Q_INVOKABLE bool moveRows(int sourceIndex, int destIndex, int count);
|
||||||
Q_INVOKABLE bool moveDown(int index);
|
Q_INVOKABLE bool moveDown(int index);
|
||||||
Q_INVOKABLE bool moveUp(int index);
|
Q_INVOKABLE bool moveUp(int index);
|
||||||
|
@ -114,6 +115,7 @@ signals:
|
||||||
void itemAdded(const int &, const ServiceItem &);
|
void itemAdded(const int &, const ServiceItem &);
|
||||||
void itemInserted(const int &, const ServiceItem &);
|
void itemInserted(const int &, const ServiceItem &);
|
||||||
void rowMoved(const int &, const int &, const ServiceItem &);
|
void rowMoved(const int &, const int &, const ServiceItem &);
|
||||||
|
void rowRemoved(const int &, const ServiceItem &);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
|
|
|
@ -112,7 +112,7 @@ void Slide::setServiceItemId(int serviceItemId)
|
||||||
if (m_serviceItemId == serviceItemId)
|
if (m_serviceItemId == serviceItemId)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
qDebug() << "####changing serviceItemId to: " << serviceItemId;
|
qDebug() << "####changing serviceItemId of" << "to:" << serviceItemId;
|
||||||
m_serviceItemId = serviceItemId;
|
m_serviceItemId = serviceItemId;
|
||||||
emit serviceItemIdChanged(m_serviceItemId);
|
emit serviceItemIdChanged(m_serviceItemId);
|
||||||
}
|
}
|
||||||
|
|
|
@ -287,6 +287,39 @@ void SlideModel::removeItem(int index) {
|
||||||
endRemoveRows();
|
endRemoveRows();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SlideModel::removeServiceItem(const int &index, const ServiceItem &item) {
|
||||||
|
qDebug() << "Need to remove serviceItem:" << item.name() << "with" << item.slideNumber() << "slides.";
|
||||||
|
int id = findSlideIdFromServItm(index);
|
||||||
|
if (item.slideNumber() > 1) {
|
||||||
|
for (int i = item.slideNumber() + id; i > id - 1; i--) {
|
||||||
|
qDebug() << "Removing serviceItem:" << i;
|
||||||
|
beginRemoveRows(QModelIndex(), i, i);
|
||||||
|
m_items.removeAt(i);
|
||||||
|
endRemoveRows();
|
||||||
|
m_items[i]->setServiceItemId(index);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
qDebug() << "Removing serviceItem:" << id;
|
||||||
|
beginRemoveRows(QModelIndex(), id, id);
|
||||||
|
m_items.removeAt(id);
|
||||||
|
endRemoveRows();
|
||||||
|
m_items[id]->setServiceItemId(index);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void SlideModel::removeItems() {
|
||||||
|
for (int i = m_items.length() - 1; i > -1; i--) {
|
||||||
|
QModelIndex idx = index(i);
|
||||||
|
Slide *item = m_items[idx.row()];
|
||||||
|
if (item->selected()) {
|
||||||
|
qDebug() << "Removing item:" << i;
|
||||||
|
beginRemoveRows(QModelIndex(), i, i);
|
||||||
|
m_items.removeAt(i);
|
||||||
|
endRemoveRows();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
bool SlideModel::moveRows(int sourceIndex, int destIndex, int count) {
|
bool SlideModel::moveRows(int sourceIndex, int destIndex, int count) {
|
||||||
qDebug() << index(sourceIndex).row();
|
qDebug() << index(sourceIndex).row();
|
||||||
qDebug() << index(destIndex).row();
|
qDebug() << index(destIndex).row();
|
||||||
|
|
|
@ -72,6 +72,7 @@ public:
|
||||||
const int &slideIndex,
|
const int &slideIndex,
|
||||||
const int &imageCount);
|
const int &imageCount);
|
||||||
Q_INVOKABLE void removeItem(int index);
|
Q_INVOKABLE void removeItem(int index);
|
||||||
|
Q_INVOKABLE void removeItems();
|
||||||
Q_INVOKABLE bool moveRows(int sourceIndex, int destIndex, int count);
|
Q_INVOKABLE bool moveRows(int sourceIndex, int destIndex, int count);
|
||||||
Q_INVOKABLE bool moveDown(int index);
|
Q_INVOKABLE bool moveDown(int index);
|
||||||
Q_INVOKABLE bool moveUp(int index);
|
Q_INVOKABLE bool moveUp(int index);
|
||||||
|
@ -84,6 +85,7 @@ public slots:
|
||||||
Q_INVOKABLE bool select(int id);
|
Q_INVOKABLE bool select(int id);
|
||||||
Q_INVOKABLE bool activate(int id);
|
Q_INVOKABLE bool activate(int id);
|
||||||
Q_INVOKABLE bool deactivate(int id);
|
Q_INVOKABLE bool deactivate(int id);
|
||||||
|
Q_INVOKABLE void removeServiceItem(const int &index, const ServiceItem &item);
|
||||||
void addItemFromService(const int &index, const ServiceItem &item);
|
void addItemFromService(const int &index, const ServiceItem &item);
|
||||||
void insertItemFromService(const int &index, const ServiceItem &item);
|
void insertItemFromService(const int &index, const ServiceItem &item);
|
||||||
void moveRowFromService(const int &fromIndex, const int &toIndex, const ServiceItem &item);
|
void moveRowFromService(const int &fromIndex, const int &toIndex, const ServiceItem &item);
|
||||||
|
|
|
@ -155,6 +155,10 @@ int main(int argc, char *argv[])
|
||||||
SIGNAL(rowMoved(const int&, const int&, const ServiceItem&)),
|
SIGNAL(rowMoved(const int&, const int&, const ServiceItem&)),
|
||||||
slideModel.get(),
|
slideModel.get(),
|
||||||
SLOT(moveRowFromService(const int&, const int&, const ServiceItem&)));
|
SLOT(moveRowFromService(const int&, const int&, const ServiceItem&)));
|
||||||
|
QObject::connect(serviceItemModel.get(),
|
||||||
|
SIGNAL(rowRemoved(const int&, const ServiceItem&)),
|
||||||
|
slideModel.get(),
|
||||||
|
SLOT(removeServiceItem(const int&, const ServiceItem&)));
|
||||||
|
|
||||||
bool loading = serviceItemModel.get()->loadLastSaved();
|
bool loading = serviceItemModel.get()->loadLastSaved();
|
||||||
|
|
||||||
|
|
|
@ -90,6 +90,8 @@ Item {
|
||||||
implicitWidth: serviceItemList.width
|
implicitWidth: serviceItemList.width
|
||||||
height: Kirigami.Units.gridUnit * 2
|
height: Kirigami.Units.gridUnit * 2
|
||||||
|
|
||||||
|
property var selectedItems
|
||||||
|
|
||||||
DropArea {
|
DropArea {
|
||||||
id: serviceDrop
|
id: serviceDrop
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
|
@ -238,8 +240,13 @@ Item {
|
||||||
}
|
}
|
||||||
|
|
||||||
onClicked: {
|
onClicked: {
|
||||||
if (mouse.button === Qt.RightButton)
|
if (mouse.button === Qt.RightButton) {
|
||||||
|
if (!selected) {
|
||||||
|
serviceItemList.currentIndex = index;
|
||||||
|
ServiceItemModel.select(index);
|
||||||
|
}
|
||||||
rightClickMenu.popup(mouse);
|
rightClickMenu.popup(mouse);
|
||||||
|
}
|
||||||
else if ((mouse.button === Qt.LeftButton) && (mouse.modifiers === Qt.ShiftModifier)) {
|
else if ((mouse.button === Qt.LeftButton) && (mouse.modifiers === Qt.ShiftModifier)) {
|
||||||
selectItems(index);
|
selectItems(index);
|
||||||
} else {
|
} else {
|
||||||
|
@ -276,9 +283,15 @@ Item {
|
||||||
id: rightClickMenu
|
id: rightClickMenu
|
||||||
x: mouse.mouseX
|
x: mouse.mouseX
|
||||||
y: mouse.mouseY + 10
|
y: mouse.mouseY + 10
|
||||||
|
Kirigami.Action {
|
||||||
|
text: "copy"
|
||||||
|
}
|
||||||
|
Kirigami.Action {
|
||||||
|
text: "paste"
|
||||||
|
}
|
||||||
Kirigami.Action {
|
Kirigami.Action {
|
||||||
text: "delete"
|
text: "delete"
|
||||||
onTriggered: removeItem(index);
|
onTriggered: removeItems()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -513,6 +526,10 @@ Item {
|
||||||
/* totalServiceItems--; */
|
/* totalServiceItems--; */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function removeItems() {
|
||||||
|
ServiceItemModel.removeItems();
|
||||||
|
}
|
||||||
|
|
||||||
function addItem(index, name, type,
|
function addItem(index, name, type,
|
||||||
background, backgroundType, text, audio,
|
background, backgroundType, text, audio,
|
||||||
font, fontSize, itemID) {
|
font, fontSize, itemID) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue