mirror of
https://github.com/keepassxreboot/keepassxc.git
synced 2024-10-01 01:26:01 -04:00
parent
701013baab
commit
317f603262
@ -28,7 +28,7 @@ EntryModel::EntryModel(QObject* parent)
|
|||||||
: QAbstractTableModel(parent)
|
: QAbstractTableModel(parent)
|
||||||
, m_group(Q_NULLPTR)
|
, m_group(Q_NULLPTR)
|
||||||
{
|
{
|
||||||
setSupportedDragActions(Qt::MoveAction);
|
setSupportedDragActions(Qt::MoveAction | Qt::CopyAction);
|
||||||
}
|
}
|
||||||
|
|
||||||
Entry* EntryModel::entryFromIndex(const QModelIndex& index) const
|
Entry* EntryModel::entryFromIndex(const QModelIndex& index) const
|
||||||
|
@ -40,6 +40,9 @@ EntryView::EntryView(QWidget* parent)
|
|||||||
setSortingEnabled(true);
|
setSortingEnabled(true);
|
||||||
setSelectionMode(QAbstractItemView::ExtendedSelection);
|
setSelectionMode(QAbstractItemView::ExtendedSelection);
|
||||||
|
|
||||||
|
// QAbstractItemView::startDrag() uses this property as the default drag action
|
||||||
|
setDefaultDropAction(Qt::MoveAction);
|
||||||
|
|
||||||
connect(this, SIGNAL(activated(QModelIndex)), SLOT(emitEntryActivated(QModelIndex)));
|
connect(this, SIGNAL(activated(QModelIndex)), SLOT(emitEntryActivated(QModelIndex)));
|
||||||
connect(selectionModel(), SIGNAL(selectionChanged(QItemSelection,QItemSelection)), SIGNAL(entrySelectionChanged()));
|
connect(selectionModel(), SIGNAL(selectionChanged(QItemSelection,QItemSelection)), SIGNAL(entrySelectionChanged()));
|
||||||
connect(m_model, SIGNAL(switchedToEntryListMode()), SLOT(switchToEntryListMode()));
|
connect(m_model, SIGNAL(switchedToEntryListMode()), SLOT(switchToEntryListMode()));
|
||||||
|
@ -182,7 +182,7 @@ Group* GroupModel::groupFromIndex(const QModelIndex& index) const
|
|||||||
|
|
||||||
Qt::DropActions GroupModel::supportedDropActions() const
|
Qt::DropActions GroupModel::supportedDropActions() const
|
||||||
{
|
{
|
||||||
return Qt::MoveAction;
|
return Qt::MoveAction | Qt::CopyAction;
|
||||||
}
|
}
|
||||||
|
|
||||||
Qt::ItemFlags GroupModel::flags(const QModelIndex& modelIndex) const
|
Qt::ItemFlags GroupModel::flags(const QModelIndex& modelIndex) const
|
||||||
@ -203,7 +203,7 @@ bool GroupModel::dropMimeData(const QMimeData* data, Qt::DropAction action,
|
|||||||
{
|
{
|
||||||
Q_UNUSED(column);
|
Q_UNUSED(column);
|
||||||
|
|
||||||
if (!data || (action != Qt::MoveAction) || !parent.isValid()) {
|
if (!data || (action != Qt::MoveAction && action != Qt::CopyAction) || !parent.isValid()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -250,7 +250,15 @@ bool GroupModel::dropMimeData(const QMimeData* data, Qt::DropAction action,
|
|||||||
row--;
|
row--;
|
||||||
}
|
}
|
||||||
|
|
||||||
dragGroup->setParent(parentGroup, row);
|
Group* group;
|
||||||
|
if (action == Qt::MoveAction) {
|
||||||
|
group = dragGroup;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
group = dragGroup->clone();
|
||||||
|
}
|
||||||
|
|
||||||
|
group->setParent(parentGroup, row);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (row != -1) {
|
if (row != -1) {
|
||||||
@ -272,7 +280,15 @@ bool GroupModel::dropMimeData(const QMimeData* data, Qt::DropAction action,
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
dragEntry->setGroup(parentGroup);
|
Entry* entry;
|
||||||
|
if (action == Qt::MoveAction) {
|
||||||
|
entry = dragEntry;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
entry = dragEntry->clone();
|
||||||
|
}
|
||||||
|
|
||||||
|
entry->setGroup(parentGroup);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -45,6 +45,7 @@ GroupView::GroupView(Database* db, QWidget* parent)
|
|||||||
setDragEnabled(true);
|
setDragEnabled(true);
|
||||||
viewport()->setAcceptDrops(true);
|
viewport()->setAcceptDrops(true);
|
||||||
setDropIndicatorShown(true);
|
setDropIndicatorShown(true);
|
||||||
|
setDefaultDropAction(Qt::MoveAction);
|
||||||
}
|
}
|
||||||
|
|
||||||
void GroupView::changeDatabase(Database* newDb)
|
void GroupView::changeDatabase(Database* newDb)
|
||||||
@ -54,6 +55,13 @@ void GroupView::changeDatabase(Database* newDb)
|
|||||||
|
|
||||||
void GroupView::dragMoveEvent(QDragMoveEvent* event)
|
void GroupView::dragMoveEvent(QDragMoveEvent* event)
|
||||||
{
|
{
|
||||||
|
if (event->keyboardModifiers() & Qt::ControlModifier) {
|
||||||
|
event->setDropAction(Qt::CopyAction);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
event->setDropAction(Qt::MoveAction);
|
||||||
|
}
|
||||||
|
|
||||||
QTreeView::dragMoveEvent(event);
|
QTreeView::dragMoveEvent(event);
|
||||||
|
|
||||||
// entries may only be dropped on groups
|
// entries may only be dropped on groups
|
||||||
|
Loading…
Reference in New Issue
Block a user