VirtualBox

Ignore:
Timestamp:
Jul 10, 2023 1:00:06 PM (20 months ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
158201
Message:

FE/Qt: bugref:9080. bugref:6699. Add a numerical suffix to the new directory name in case there is a collision.

Location:
trunk/src/VBox/Frontends/VirtualBox/src
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/guestctrl/UIFileManagerTable.cpp

    r100420 r100455  
    808808    if (!parentFolderItem)
    809809        return;
    810 
    811     QString newDirectoryName(UICustomFileSystemModel::tr("NewDirectory"));
     810    QString strBase(UICustomFileSystemModel::tr("NewDirectory"));
     811    QString newDirectoryName(strBase);
     812    QStringList nameList = currentDirectoryListing();
     813    int iSuffix = 1;
     814    while (nameList.contains(newDirectoryName))
     815        newDirectoryName = QString("%1_%2").arg(strBase).arg(QString::number(iSuffix++));
    812816
    813817    if (!createDirectory(parentFolderItem->path(), newDirectoryName))
     
    13211325    }
    13221326}
     1327
     1328QStringList UIFileManagerTable::currentDirectoryListing() const
     1329{
     1330    UICustomFileSystemItem *pItem = static_cast<UICustomFileSystemItem*>(currentRootIndex().internalPointer());
     1331    if (!pItem)
     1332        return QStringList();
     1333    QStringList list;
     1334    foreach (const UICustomFileSystemItem *pChild, pItem->children())
     1335    {
     1336        if (pChild)
     1337            list << pChild->fileObjectName();
     1338    }
     1339    return list;
     1340}
     1341
    13231342#include "UIFileManagerTable.moc"
  • trunk/src/VBox/Frontends/VirtualBox/src/guestctrl/UIFileManagerTable.h

    r100410 r100455  
    310310      * uses m_searchLineUnmarkColor and m_searchLineMarkColor. */
    311311    void            markUnmarkSearchLineEdit(bool fMark);
    312 
     312    QStringList     currentDirectoryListing() const;
    313313    UICustomFileSystemModel       *m_pModel;
    314314    UIGuestControlFileView        *m_pView;
  • trunk/src/VBox/Frontends/VirtualBox/src/medium/viso/UIVisoContentBrowser.cpp

    r100440 r100455  
    464464    if (!m_pTableView)
    465465        return;
    466     QString strNewDirectoryName("NewDirectory");
     466    QString strBaseName("NewDirectory");
     467    QString strNewDirectoryName(strBaseName);
     468    QStringList currentListing = currentDirectoryListing();
     469    int iSuffix = 1;
     470    while (currentListing.contains(strNewDirectoryName))
     471        strNewDirectoryName = QString("%1_%2").arg(strBaseName).arg(QString::number(iSuffix++));
    467472
    468473    QModelIndex parentIndex = m_pTableProxyModel->mapToSource(m_pTableView->rootIndex());
     
    11141119    }
    11151120}
     1121
     1122const UICustomFileSystemItem* UIVisoContentBrowser::currentDirectoryItem() const
     1123{
     1124    if (!m_pTableView || !m_pTableView->rootIndex().isValid())
     1125        return 0;
     1126    QModelIndex currentRoot = m_pTableProxyModel->mapToSource(m_pTableView->rootIndex());
     1127
     1128    return static_cast<UICustomFileSystemItem*>(currentRoot.internalPointer());
     1129}
     1130
     1131QStringList UIVisoContentBrowser::currentDirectoryListing() const
     1132{
     1133    const UICustomFileSystemItem *pCurrentDirectoryItem = currentDirectoryItem();
     1134    if (!pCurrentDirectoryItem)
     1135        return QStringList();
     1136    QStringList nameList;
     1137    foreach (const UICustomFileSystemItem *pChild, pCurrentDirectoryItem->children())
     1138    {
     1139        if (pChild)
     1140            nameList << pChild->fileObjectName();
     1141    }
     1142    return nameList;
     1143}
     1144
    11161145#include "UIVisoContentBrowser.moc"
  • trunk/src/VBox/Frontends/VirtualBox/src/medium/viso/UIVisoContentBrowser.h

    r100438 r100455  
    135135     *  in the table view. */
    136136    QList<UICustomFileSystemItem*> tableSelectedItems();
     137    /* Names of the file objects of the current directory. */
     138    QStringList                    currentDirectoryListing() const;
    137139    bool                           onStartItem();
    138140    void                           goUp();
    139141    void                           createLoadedFileEntries(const QMap<QString, QString> &fileEntries);
     142    const UICustomFileSystemItem*  currentDirectoryItem() const;
    140143    UIVisoContentTableView        *m_pTableView;
    141144    UICustomFileSystemModel       *m_pModel;
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette