VirtualBox

Changeset 71509 in vbox


Ignore:
Timestamp:
Mar 26, 2018 12:16:37 PM (7 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
121482
Message:

FE/Qt: bugref:6699 Replace 'current location line edit' with an combo box

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

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/extensions/QIComboBox.h

    r71027 r71509  
    128128
    129129#endif /* !___QIComboBox_h___ */
    130 
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/guestctrl/UIGuestControlFileTable.cpp

    r71505 r71509  
    2222/* Qt includes: */
    2323# include <QAction>
     24# include <QComboBox>
    2425# include <QDateTime>
    2526# include <QDir>
     
    649650    , m_pPaste(0)
    650651    , m_pMainLayout(0)
    651     , m_pCurrentLocationEdit(0)
     652    , m_pLocationComboBox(0)
    652653    , m_pToolBar(0)
    653654    , m_pGoUp(0)
     
    676677    if (m_pModel)
    677678        m_pModel->endReset();
    678     if (m_pCurrentLocationEdit)
    679         m_pCurrentLocationEdit->clear();
     679    if (m_pLocationComboBox)
     680    {
     681        disconnect(m_pLocationComboBox, static_cast<void(QComboBox::*)(const QString&)>(&QComboBox::currentIndexChanged),
     682                   this, &UIGuestControlFileTable::sltLocationComboCurrentChange);
     683        m_pLocationComboBox->clear();
     684        connect(m_pLocationComboBox, static_cast<void(QComboBox::*)(const QString&)>(&QComboBox::currentIndexChanged),
     685                this, &UIGuestControlFileTable::sltLocationComboCurrentChange);
     686    }
    680687}
    681688
     
    706713    }
    707714
    708     m_pCurrentLocationEdit = new QILineEdit;
    709     if (m_pCurrentLocationEdit)
    710     {
    711         m_pMainLayout->addWidget(m_pCurrentLocationEdit, 1, 1, 1, 4);
    712         m_pCurrentLocationEdit->setReadOnly(true);
    713     }
     715    m_pLocationComboBox = new QComboBox;
     716    if (m_pLocationComboBox)
     717    {
     718        m_pMainLayout->addWidget(m_pLocationComboBox, 1, 1, 1, 4);
     719        m_pLocationComboBox->setEditable(false);
     720        connect(m_pLocationComboBox, static_cast<void(QComboBox::*)(const QString&)>(&QComboBox::currentIndexChanged),
     721                this, &UIGuestControlFileTable::sltLocationComboCurrentChange);
     722    }
     723
    714724
    715725    m_pModel = new UIGuestControlFileModel(this);
     
    860870void UIGuestControlFileTable::updateCurrentLocationEdit(const QString& strLocation)
    861871{
    862     if (!m_pCurrentLocationEdit)
    863         return;
    864     m_pCurrentLocationEdit->setText(strLocation);
     872    if (!m_pLocationComboBox)
     873        return;
     874    int itemIndex = m_pLocationComboBox->findText(strLocation,
     875                                                  Qt::MatchExactly | Qt::MatchCaseSensitive);
     876    if (itemIndex == -1)
     877    {
     878        m_pLocationComboBox->insertItem(m_pLocationComboBox->count(), strLocation);
     879        itemIndex = m_pLocationComboBox->count() - 1;
     880    }
     881    m_pLocationComboBox->setCurrentIndex(itemIndex);
    865882}
    866883
     
    885902        reset();
    886903
     904    const QString startPath("/");
    887905    QList<QVariant> headData;
    888906    headData << "Name" << "Size" << "Change Time" << "Owner";
    889907    m_pRootItem = new UIFileTableItem(headData, 0, FileObjectType_Directory);
    890908    QList<QVariant> startDirData;
    891     startDirData << "/" << 4096 << QDateTime() << "";
     909    startDirData << startPath << 4096 << QDateTime() << "";
    892910    UIFileTableItem* startItem = new UIFileTableItem(startDirData, m_pRootItem, FileObjectType_Directory);
    893911
    894     startItem->setPath("/");
     912    startItem->setPath(startPath);
    895913    m_pRootItem->appendChild(startItem);
    896914
    897915    startItem->setIsOpened(false);
    898916    /* Read the root directory and get the list: */
    899     readDirectory("/", startItem, true);
     917    readDirectory(startPath, startItem, true);
    900918    m_pView->setRootIndex(m_pModel->rootIndex());
    901919    m_pModel->signalUpdate();
    902 
     920    updateCurrentLocationEdit(startPath);
    903921}
    904922
     
    11511169}
    11521170
     1171void UIGuestControlFileTable::sltLocationComboCurrentChange(const QString &strLocation)
     1172{
     1173    QString comboLocation(UIPathOperations::sanitize(strLocation));
     1174    if (comboLocation == currentDirectoryPath())
     1175        return;
     1176
     1177    QList<QString> pathList = comboLocation.split(UIPathOperations::delimiter, QString::SkipEmptyParts);
     1178    goIntoDirectory(pathList);
     1179}
     1180
    11531181void UIGuestControlFileTable::deleteByIndex(const QModelIndex &itemIndex)
    11541182{
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/guestctrl/UIGuestControlFileTable.h

    r71505 r71509  
    3535class QFileInfo;
    3636
     37class QComboBox;
    3738class QILabel;
    3839class QILineEdit;
     
    258259    void sltCreateNewDirectory();
    259260    void sltSelectionChanged(const QItemSelection & selected, const QItemSelection & deselected);
     261    void sltLocationComboCurrentChange(const QString &strLocation);
    260262
    261263private:
     
    271273    void            disableSelectionDependentActions();
    272274    QGridLayout     *m_pMainLayout;
    273     QILineEdit      *m_pCurrentLocationEdit;
     275    QComboBox       *m_pLocationComboBox;
    274276    UIToolBar       *m_pToolBar;
    275277    QAction         *m_pGoUp;
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/guestctrl/UIGuestFileTable.cpp

    r71505 r71509  
    116116        insertItemsToTree(directories, parent, true, isStartDir);
    117117        insertItemsToTree(files, parent, false, isStartDir);
    118         updateCurrentLocationEdit(strPath);
     118        //updateCurrentLocationEdit(strPath);
    119119    }
    120120    directory.Close();
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/guestctrl/UIHostFileTable.cpp

    r71505 r71509  
    198198    insertItemsToTree(directories, parent, true, isStartDir);
    199199    insertItemsToTree(files, parent, false, isStartDir);
    200     updateCurrentLocationEdit(strPath);
     200    //updateCurrentLocationEdit(strPath);
    201201}
    202202
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