65 if (sourceModel()->rowCount(index) > 0) {
66 for (
int nChild = 0; nChild < sourceModel()->rowCount(index); ++nChild) {
67 QModelIndex childIndex = sourceModel()->index(nChild, 0, index);
68 if (!childIndex.isValid()) {
71 retVal = ShowThis(childIndex);
77 QModelIndex useIndex = sourceModel()->index(index.row(), 0, index.parent());
78 QString path = fs->filePath(useIndex);
79 path = QDir(store).relativeFilePath(path);
81 retVal = path.contains(filterRegularExpression());
169 QByteArray encodedData;
171 QModelIndex index = indexes.at(0);
172 if (index.isValid()) {
173 QModelIndex useIndex = mapToSource(index);
175 info.
isDir = fs->fileInfo(useIndex).isDir();
176 info.
isFile = fs->fileInfo(useIndex).isFile();
177 info.
path = fs->fileInfo(useIndex).absoluteFilePath();
178 QDataStream stream(&encodedData, QIODevice::WriteOnly);
182 auto *mimeData =
new QMimeData();
183 mimeData->setData(
"application/vnd+qtpass.dragAndDropInfoPasswordStore",
199 const QModelIndex &parent)
const ->
bool {
201 qDebug() << action << row;
207 QModelIndex useIndex =
208 this->index(parent.row(), parent.column(), parent.parent());
209 QByteArray encodedData =
210 data->data(
"application/vnd+qtpass.dragAndDropInfoPasswordStore");
211 QDataStream stream(&encodedData, QIODevice::ReadOnly);
214 if (!data->hasFormat(
"application/vnd+qtpass.dragAndDropInfoPasswordStore")) {
223 if (fs->fileInfo(mapToSource(useIndex)).isDir() && info.
isDir) {
227 if (fs->fileInfo(mapToSource(useIndex)).isDir() && info.
isFile) {
231 if (fs->fileInfo(mapToSource(useIndex)).isFile() && info.
isFile) {
248 int row,
int column,
const QModelIndex &parent)
250 if (!canDropMimeData(data, action, row, column, parent)) {
254 if (action == Qt::IgnoreAction) {
257 QByteArray encodedData =
258 data->data(
"application/vnd+qtpass.dragAndDropInfoPasswordStore");
260 QDataStream stream(&encodedData, QIODevice::ReadOnly);
263 QModelIndex destIndex =
264 this->index(parent.row(), parent.column(), parent.parent());
265 QFileInfo destFileinfo = fs->fileInfo(mapToSource(destIndex));
266 QFileInfo srcFileInfo = QFileInfo(info.
path);
267 QString cleanedSrc = QDir::cleanPath(srcFileInfo.absoluteFilePath());
268 QString cleanedDest = QDir::cleanPath(destFileinfo.absoluteFilePath());
271 if (destFileinfo.isDir()) {
272 QDir destDir = QDir(cleanedDest).filePath(srcFileInfo.fileName());
273 QString cleanedDestDir = QDir::cleanPath(destDir.absolutePath());
274 if (action == Qt::MoveAction) {
276 }
else if (action == Qt::CopyAction) {
282 if (destFileinfo.isDir()) {
283 if (action == Qt::MoveAction) {
285 }
else if (action == Qt::CopyAction) {
288 }
else if (destFileinfo.isFile()) {
290 int answer = QMessageBox::question(
291 nullptr, tr(
"force overwrite?"),
292 tr(
"overwrite %1 with %2?").arg(cleanedDest, cleanedSrc),
293 QMessageBox::Yes | QMessageBox::No);
294 bool force = answer == QMessageBox::Yes;
295 if (action == Qt::MoveAction) {
297 }
else if (action == Qt::CopyAction) {
312 const QModelIndex &source_right)
const ->
bool {
315 if (fs && (source_left.column() == 0 || source_left.column() == 1)) {
316 bool leftD = fs->isDir(source_left);
317 bool rightD = fs->isDir(source_right);
319 if (leftD ^ rightD) {
325 return QSortFilterProxyModel::lessThan(source_left, source_right);
auto dropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent) -> bool override
StoreModel::dropMimeData.
auto canDropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent) const -> bool override
StoreModel::canDropMimeData.