VirtualBox

Changeset 100389 in vbox


Ignore:
Timestamp:
Jul 5, 2023 1:26:22 PM (19 months ago)
Author:
vboxsync
Message:

FE/Qt: bugref:9080. A first attempt for loading file entries from a Viso file.

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

Legend:

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

    r100075 r100389  
    14271427}
    14281428
     1429bool UIMessageCenter::confirmVisoDiscard(QWidget *pParent /* = 0*/) const
     1430{
     1431    return questionBinary(pParent, MessageType_Question,
     1432                          tr("<p>To open a Viso file you will have to discard the current content.</p>"
     1433                             "<p>Are you sure you want to proceed?</p>"),
     1434                          0 /* auto-confirm id */,
     1435                          tr("&Discard") /* ok button text */,
     1436                          QString() /* cancel button text */,
     1437                          false /* ok button by default? */);
     1438}
     1439
    14291440bool UIMessageCenter::confirmCloudNetworkRemoval(const QString &strName, QWidget *pParent /* = 0*/) const
    14301441{
  • trunk/src/VBox/Frontends/VirtualBox/src/globals/UIMessageCenter.h

    r99946 r100389  
    363363        bool confirmMediumRelease(const UIMedium &medium, bool fInduced, QWidget *pParent = 0) const;
    364364        bool confirmMediumRemoval(const UIMedium &medium, QWidget *pParent = 0) const;
    365         int confirmDeleteHardDiskStorage(const QString &strLocation, QWidget *pParent = 0) const;
     365        int  confirmDeleteHardDiskStorage(const QString &strLocation, QWidget *pParent = 0) const;
    366366        bool confirmInaccesibleMediaClear(const QStringList &mediaNameList, UIMediumDeviceType enmType, QWidget *pParent = 0);
     367        bool confirmVisoDiscard(QWidget *pParent = 0) const;
    367368    /** @} */
    368369
  • trunk/src/VBox/Frontends/VirtualBox/src/medium/viso/UIVisoContentBrowser.cpp

    r100348 r100389  
    3535#include <QMimeData>
    3636#include <QTableView>
     37#include <QTextStream>
    3738
    3839/* GUI includes: */
     
    5152#include <iprt/mem.h>
    5253#include <iprt/err.h>
     54
     55const ULONG uAllowedFileSize = _4K;
    5356
    5457struct ISOFileObject
     
    351354        return;
    352355
     356    /* Insert items to the current directory shown in the table view: */
    353357    QModelIndex parentIndex = m_pTableProxyModel->mapToSource(m_pTableView->rootIndex());
    354358    if (!parentIndex.isValid())
     
    358362    if (!pParentItem)
    359363        return;
     364
    360365    foreach (const QString &strPath, pathList)
    361366    {
     
    777782void UIVisoContentBrowser::parseVisoFileContent(const QString &strFileName)
    778783{
    779     Q_UNUSED(strFileName);
     784    sltResetAction();
     785    QFile file(strFileName);
     786    if (!file.exists() || !file.open(QIODevice::ReadOnly | QIODevice::Text))
     787        return;
     788    if (file.size() > uAllowedFileSize)
     789        return;
     790    QTextStream stream(&file);
     791    QString strFileContent = stream.readAll();
     792    strFileContent.replace(' ', '\n');
     793    QStringList list = strFileContent.split("\n", Qt::SkipEmptyParts);
     794    QMap<QString, QString> fileEntries;
     795    foreach (const QString &strPart, list)
     796    {
     797        /* We currently do not support different on-ISO names for different namespaces. */
     798        if (strPart.startsWith("/") && strPart.count('=') <= 1)
     799        {
     800            QStringList fileEntry = strPart.split("=", Qt::SkipEmptyParts);
     801            if (fileEntry.size() == 1)
     802            {
     803                QFileInfo fileInfo(fileEntry[0]);
     804                if (fileInfo.exists())
     805                {
     806                    QString isoName = QString("/%1").arg(fileInfo.fileName());
     807                    fileEntries[isoName] = fileEntry[0];
     808                }
     809            }
     810            else if (fileEntry.size() == 2)
     811            {
     812                if (QFileInfo(fileEntry[1]).exists())
     813                    fileEntries[fileEntry[0]] = fileEntry[1];
     814            }
     815        }
     816    }
     817    file.close();
    780818}
    781819
     
    925963    if (m_pTableProxyModel)
    926964        m_pTableProxyModel->invalidate();
     965    m_strImportedISOPath.clear();
    927966}
    928967
     
    948987{
    949988    goUp();
    950 }
    951 
    952 void UIVisoContentBrowser::reset()
    953 {
    954     m_entryMap.clear();
    955989}
    956990
  • trunk/src/VBox/Frontends/VirtualBox/src/medium/viso/UIVisoContentBrowser.h

    r100348 r100389  
    128128     *  from the iso image. */
    129129    void                    createVisoEntry(UICustomFileSystemItem *pItem, bool bRemove = false);
    130     void                    reset();
    131130    QString                 currentPath() const;
    132131    /** Returns a list of items which are currecntly selected
  • trunk/src/VBox/Frontends/VirtualBox/src/medium/viso/UIVisoCreator.cpp

    r100348 r100389  
    4444#include "QILabel.h"
    4545#include "QILineEdit.h"
     46#include "UIMessageCenter.h"
    4647#include "QIToolBar.h"
    4748#include "UIActionPool.h"
     
    407408void UIVisoCreatorWidget::sltOpenAction()
    408409{
     410    if (!msgCenter().confirmVisoDiscard(this))
     411        return;
     412
    409413    QString strFileName =  QIFileDialog::getOpenFileName(uiCommon().defaultFolderPathForType(UIMediumDeviceType_DVD),
    410414                                                         "VISO files (*.viso)", this, UIVisoCreatorWidget::tr("Select a VISO file to load"));
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