VirtualBox

Ignore:
Timestamp:
Mar 25, 2019 9:27:48 AM (6 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
129553
Message:

FE/Qt: bugref:6699. Getting rid of the small dialog during new folder creation

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

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/globals/UICustomFileSystemModel.cpp

    r77286 r77868  
    9090}
    9191
    92 QList<const UICustomFileSystemItem*> UICustomFileSystemItem::children() const
    93 {
    94     QList<const UICustomFileSystemItem*> childList;
     92QList<UICustomFileSystemItem*> UICustomFileSystemItem::children() const
     93{
     94    QList<UICustomFileSystemItem*> childList;
    9595    foreach (UICustomFileSystemItem *child, m_childItems)
    9696        childList << child;
  • trunk/src/VBox/Frontends/VirtualBox/src/globals/UICustomFileSystemModel.h

    r77286 r77868  
    5858    UICustomFileSystemItem *child(const QString &path) const;
    5959    int childCount() const;
    60     QList<const UICustomFileSystemItem*> children() const;
     60    QList<UICustomFileSystemItem*> children() const;
    6161    /** Removes the item from the list of children and !!DELETES!! the item. */
    6262    void removeChild(UICustomFileSystemItem *pItem);
  • trunk/src/VBox/Frontends/VirtualBox/src/guestctrl/UIFileManagerTable.cpp

    r77851 r77868  
    787787    if (!currentIndex.isValid())
    788788        return;
    789     UICustomFileSystemItem *item = static_cast<UICustomFileSystemItem*>(currentIndex.internalPointer());
    790     if (!item)
    791         return;
    792 
    793     QString newDirectoryName = getNewDirectoryName();
    794     if (newDirectoryName.isEmpty())
    795         return;
    796 
    797     if (createDirectory(item->path(), newDirectoryName))
    798     {
    799         /** @todo instead of refreshing here (an overkill) just add the
    800            rows and update the tabel view: */
    801         sltRefresh();
    802     }
     789    UICustomFileSystemItem *parentFolderItem = static_cast<UICustomFileSystemItem*>(currentIndex.internalPointer());
     790    if (!parentFolderItem)
     791        return;
     792
     793    QString newDirectoryName(UICustomFileSystemModel::tr("NewDirectory"));
     794
     795    if (!createDirectory(parentFolderItem->path(), newDirectoryName))
     796        return;
     797
     798    /* Refesh the current directory so that we correctly populate the child list of parentFolderItem: */
     799    /** @todo instead of refreshing here (an overkill) just add the
     800        rows and update the tabel view: */
     801    sltRefresh();
     802
     803    /* Now we try to edit the newly created item thereby enabling the user to rename the new item: */
     804    QList<UICustomFileSystemItem*> content = parentFolderItem->children();
     805    UICustomFileSystemItem* newItem = 0;
     806    /* Search the new item: */
     807    foreach (UICustomFileSystemItem* childItem, content)
     808    {
     809
     810        if (childItem && newDirectoryName == childItem->name())
     811            newItem = childItem;
     812    }
     813
     814    if (!newItem)
     815        return;
     816    QModelIndex newItemIndex = m_pProxyModel->mapFromSource(m_pModel->index(newItem));
     817    if (!newItemIndex.isValid())
     818        return;
     819    m_pView->edit(newItemIndex);
    803820}
    804821
     
    10371054}
    10381055
    1039 
    1040 QString UIFileManagerTable::getNewDirectoryName()
    1041 {
    1042     UIStringInputDialog *dialog = new UIStringInputDialog();
    1043     if (dialog->execute())
    1044     {
    1045         QString strDialog = dialog->getString();
    1046         delete dialog;
    1047         return strDialog;
    1048     }
    1049     delete dialog;
    1050     return QString();
    1051 }
    1052 
    10531056QString UIFileManagerTable::currentDirectoryPath() const
    10541057{
  • trunk/src/VBox/Frontends/VirtualBox/src/guestctrl/UIFileManagerTable.h

    r77528 r77868  
    267267    /** Returns the UICustomFileSystemItem for path / which is a direct (and single) child of m_pRootItem */
    268268    UICustomFileSystemItem *getStartDirectoryItem();
    269     /** Shows a modal dialog with a line edit for user to enter a new directory name and return the entered string*/
    270     QString         getNewDirectoryName();
    271269    void            deSelectUpDirectoryItem();
    272270    void            setSelectionForAll(QItemSelectionModel::SelectionFlags flags);
  • trunk/src/VBox/Frontends/VirtualBox/src/medium/viso/UIVisoContentBrowser.cpp

    r77528 r77868  
    284284
    285285    /*  Check to see if we already have a directory named strNewDirectoryName: */
    286     const QList<const UICustomFileSystemItem*> children = pParentItem->children();
     286    const QList<UICustomFileSystemItem*> children = pParentItem->children();
    287287    foreach (const UICustomFileSystemItem *item, children)
    288288    {
     
    678678    if (!pItem || !pItem->parentItem())
    679679        return;
    680     QList<const UICustomFileSystemItem*> children = pItem->parentItem()->children();
     680    QList<UICustomFileSystemItem*> children = pItem->parentItem()->children();
    681681    bool bDuplicate = false;
    682682    foreach (const UICustomFileSystemItem *item, children)
Note: See TracChangeset for help on using the changeset viewer.

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