diff --git a/qml/EncryptedGroup.qml b/qml/EncryptedGroup.qml index c567271..aed6740 100644 --- a/qml/EncryptedGroup.qml +++ b/qml/EncryptedGroup.qml @@ -14,6 +14,7 @@ Item { property var foilModel property var flickable + property string groupId property alias title: groupHeaderLabel.text property alias picsModel: grid.model property alias cellSize: grid.cellSize @@ -29,6 +30,7 @@ Item { property bool expanded: true property bool _constructed + readonly property var _groupModel: foilModel ? foilModel.groupModel : null signal decryptItem(int globalIndex) signal deleteItem(int globalIndex) @@ -144,6 +146,19 @@ Item { clip: true } + function selectGroup() { + var imageId = model.imageId + var stack = pageStack + var page = stack.push(Qt.resolvedUrl("EditGroupPage.qml"), { + groupModel: _groupModel, + selectedGroupId: groupId + }) + page.groupSelected.connect(function(index) { + foilModel.setGroupId(imageId, _groupModel.groupId(index)) + stack.pop() + }) + } + function decrypt() { thisItem.decryptItem(picsModel.mapToSource(modelIndex)) } @@ -201,6 +216,7 @@ Item { ContextMenu { id: contextMenuItem + x: parent !== null ? -parent.x : 0.0 function openMenu(item) { @@ -232,6 +248,12 @@ Item { text: qsTrId("foilpics-menu-decrypt") onClicked: grid.expandItem.decrypt() } + MenuItem { + //: Generic menu item + //% "Move" + text: qsTrId("foilpics-menu-move") + onClicked: grid.expandItem.selectGroup() + } MenuItem { //: Generic menu item //% "Delete" diff --git a/qml/EncryptedList.qml b/qml/EncryptedList.qml index 24b8afc..a4c920f 100644 --- a/qml/EncryptedList.qml +++ b/qml/EncryptedList.qml @@ -118,6 +118,7 @@ SilicaListView { flickable: view foilModel: view.foilModel title: groupName + groupId: model.groupId picsModel: groupPicsModel picsCount: groupPicsCount isFirstGroup: firstGroup diff --git a/src/FoilPicsModel.cpp b/src/FoilPicsModel.cpp index d5aef94..8e1a106 100644 --- a/src/FoilPicsModel.cpp +++ b/src/FoilPicsModel.cpp @@ -1907,6 +1907,7 @@ class FoilPicsModel::Private : public QObject { FoilPicsModel* parentModel(); ModelData* dataAt(int aIndex); + int find(QString aImageId); int compare(const ModelData* aData1, const ModelData* aData2) const; static int sortProc(const void* aPtr1, const void* aPtr2, void* aThis); @@ -2135,6 +2136,18 @@ FoilPicsModel::ModelData* FoilPicsModel::Private::dataAt(int aIndex) } } +int FoilPicsModel::Private::find(QString aImageId) +{ + const int n = iData.count(); + for (int i = 0; i < n; i++) { + ModelData* data = iData.at(i); + if (data->iImageId == aImageId) { + return i; + } + } + return -1; +} + void FoilPicsModel::Private::queueSignal(Signal aSignal) { if (aSignal > NoSignal && aSignal < SignalCount) { @@ -3561,6 +3574,17 @@ int FoilPicsModel::groupIndexAt(int aIndex) const } } +void FoilPicsModel::setGroupId(QString aImageId, QString aId) +{ + int i = iPrivate->find(aImageId); + if (i >= 0) { + iPrivate->setGroupIdAt(i, aId.toLatin1()); + iPrivate->emitQueuedSignals(); + } else { + HWARN("Invalid image id" << aImageId); + } +} + void FoilPicsModel::setGroupIdAt(int aIndex, QString aId) { iPrivate->setGroupIdAt(aIndex, aId.toLatin1()); diff --git a/src/FoilPicsModel.h b/src/FoilPicsModel.h index 08d58b5..71598cd 100644 --- a/src/FoilPicsModel.h +++ b/src/FoilPicsModel.h @@ -111,6 +111,7 @@ class FoilPicsModel : public QAbstractListModel { Q_INVOKABLE void removeAt(int aIndex); Q_INVOKABLE void removeFiles(QList aRows); Q_INVOKABLE void setTitleAt(int aIndex, QString aTitle); + Q_INVOKABLE void setGroupId(QString aImageId, QString aId); Q_INVOKABLE void setGroupIdAt(int aIndex, QString aId); Q_INVOKABLE void setGroupIdForRows(QList aRows, QString aId); Q_INVOKABLE int groupIndexAt(int aIndex) const; diff --git a/translations/harbour-foilpics-de.ts b/translations/harbour-foilpics-de.ts index 9740393..4fbc9d3 100644 --- a/translations/harbour-foilpics-de.ts +++ b/translations/harbour-foilpics-de.ts @@ -43,6 +43,11 @@ Context menu item In Zwischenablage kopieren + + Move + Generic menu item + Verschieben + Generate a new key Pulley menu item diff --git a/translations/harbour-foilpics-es.ts b/translations/harbour-foilpics-es.ts index 5f80634..65ca138 100644 --- a/translations/harbour-foilpics-es.ts +++ b/translations/harbour-foilpics-es.ts @@ -43,6 +43,11 @@ Context menu item Copiar en el portapapeles + + Move + Generic menu item + Mover + Generate a new key Pulley menu item diff --git a/translations/harbour-foilpics-fr.ts b/translations/harbour-foilpics-fr.ts index e01d02f..8d1c394 100644 --- a/translations/harbour-foilpics-fr.ts +++ b/translations/harbour-foilpics-fr.ts @@ -43,6 +43,11 @@ Context menu item Copier dans le presse-papier + + Move + Generic menu item + Déplacer + Generate a new key Pulley menu item diff --git a/translations/harbour-foilpics-hu.ts b/translations/harbour-foilpics-hu.ts index 01d9948..8749efe 100644 --- a/translations/harbour-foilpics-hu.ts +++ b/translations/harbour-foilpics-hu.ts @@ -43,6 +43,11 @@ Context menu item Másolás vágólapra + + Move + Generic menu item + Áthelyezés + Generate a new key Pulley menu item diff --git a/translations/harbour-foilpics-nl.ts b/translations/harbour-foilpics-nl.ts index 623efcc..7f8d077 100644 --- a/translations/harbour-foilpics-nl.ts +++ b/translations/harbour-foilpics-nl.ts @@ -43,6 +43,11 @@ Context menu item Kopiëren naar klembord + + Move + Generic menu item + Verplaatsen + Generate a new key Pulley menu item diff --git a/translations/harbour-foilpics-pl.ts b/translations/harbour-foilpics-pl.ts index 55413be..313f37e 100644 --- a/translations/harbour-foilpics-pl.ts +++ b/translations/harbour-foilpics-pl.ts @@ -43,6 +43,11 @@ Context menu item Kopiuj do schowka + + Move + Generic menu item + Przenieś + Generate a new key Pulley menu item diff --git a/translations/harbour-foilpics-ru.ts b/translations/harbour-foilpics-ru.ts index 55766da..6e523ff 100644 --- a/translations/harbour-foilpics-ru.ts +++ b/translations/harbour-foilpics-ru.ts @@ -43,6 +43,11 @@ Context menu item Скопировать + + Move + Generic menu item + Переместить + Generate a new key Pulley menu item diff --git a/translations/harbour-foilpics-sv.ts b/translations/harbour-foilpics-sv.ts index 33ea777..69f3ccc 100644 --- a/translations/harbour-foilpics-sv.ts +++ b/translations/harbour-foilpics-sv.ts @@ -43,6 +43,11 @@ Context menu item Kopiera till urklipp + + Move + Generic menu item + Flytta + Generate a new key Pulley menu item diff --git a/translations/harbour-foilpics-zh_CN.ts b/translations/harbour-foilpics-zh_CN.ts index 0e94403..57dfb35 100644 --- a/translations/harbour-foilpics-zh_CN.ts +++ b/translations/harbour-foilpics-zh_CN.ts @@ -43,6 +43,11 @@ Context menu item 复制到剪切板 + + Move + Generic menu item + 移动 + Generate a new key Pulley menu item diff --git a/translations/harbour-foilpics.ts b/translations/harbour-foilpics.ts index 3f4d032..18fda2a 100644 --- a/translations/harbour-foilpics.ts +++ b/translations/harbour-foilpics.ts @@ -43,6 +43,11 @@ Context menu item Copy to clipboard + + Move + Generic menu item + Move + Generate a new key Pulley menu item