renaming utility: allow absolute paths
This commit is contained in:
parent
e8610cdc26
commit
1add0e7612
|
@ -150,13 +150,20 @@ FileSystemItem *FileSystemItem::makeChildAvailable(const QString &relativePath)
|
|||
{
|
||||
QStringList dirs = relativePath.split(QDir::separator(), QString::SkipEmptyParts);
|
||||
FileSystemItem *parent = this;
|
||||
for(const QString &dir : dirs) {
|
||||
FileSystemItem *child = parent->findChild(dir);
|
||||
if(!child) {
|
||||
child = new FileSystemItem(ItemStatus::New, ItemType::Dir, dir);
|
||||
child->setParent(parent);
|
||||
if(!dirs.isEmpty()) {
|
||||
if(relativePath.startsWith(QChar('/'))) {
|
||||
// we actually just got an absolute path
|
||||
// -> just leave the / there to handle absolute path as well
|
||||
dirs.front().prepend(QChar('/'));
|
||||
}
|
||||
for(const QString &dir : dirs) {
|
||||
FileSystemItem *child = parent->findChild(dir);
|
||||
if(!child) {
|
||||
child = new FileSystemItem(ItemStatus::New, ItemType::Dir, dir);
|
||||
child->setParent(parent);
|
||||
}
|
||||
parent = child;
|
||||
}
|
||||
parent = child;
|
||||
}
|
||||
return parent;
|
||||
}
|
||||
|
@ -180,7 +187,7 @@ void FileSystemItem::relativePath(QString &res) const
|
|||
if(m_parent) {
|
||||
m_parent->relativePath(res);
|
||||
if(!res.isEmpty()) {
|
||||
res.append("/");
|
||||
res.append(QLatin1Char('/'));
|
||||
}
|
||||
res.append(name());
|
||||
}
|
||||
|
|
|
@ -257,7 +257,7 @@ void RemamingEngine::applyChangings(FileSystemItem *parentItem)
|
|||
item->setNote(tr("unable to move, there is already an entry with the same name"));
|
||||
}
|
||||
item->setErrorOccured(true);
|
||||
} if(m_dir.rename(currentPath, newPath)) {
|
||||
} else if(m_dir.rename(currentPath, newPath)) {
|
||||
if(item->parent() == counterpartItem->parent()) {
|
||||
item->setNote(tr("renamed"));
|
||||
} else {
|
||||
|
|
Loading…
Reference in New Issue