Changeset 59920 in vbox
- Timestamp:
- Mar 4, 2016 11:01:11 AM (9 years ago)
- svn:sync-xref-src-repo-rev:
- 105853
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src/runtime/information
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/runtime/information/UIInformation.cpp
r59709 r59920 54 54 { 55 55 /* Create main-layout: */ 56 m_pMainLayout = new QVBoxLayout (this);56 m_pMainLayout = new QVBoxLayout; 57 57 AssertPtrReturnVoid(m_pMainLayout); 58 58 { 59 /* Prepare main-layout: */59 /* Configure main-layout: */ 60 60 m_pMainLayout->setContentsMargins(2, 0, 0, 0); 61 61 m_pMainLayout->setSpacing(0); … … 66 66 void UIInformation::prepareModel() 67 67 { 68 /* Create model: */68 /* Create information-model: */ 69 69 m_pModel = new UIInformationModel(this, m_machine, m_console); 70 70 AssertPtrReturnVoid(m_pModel); 71 71 { 72 /* Prepare data forinformation-model: */73 /* General data-item: */72 /* Add data to information-model: */ 73 /* Create General data-item: */ 74 74 UIInformationDataItem *pGeneral = new UIInformationDataGeneral(m_machine, m_console, m_pModel); 75 75 AssertPtrReturnVoid(pGeneral); … … 78 78 } 79 79 80 /* System data-item: */80 /* Create System data-item: */ 81 81 UIInformationDataItem *pSystem = new UIInformationDataSystem(m_machine, m_console, m_pModel); 82 82 AssertPtrReturnVoid(pSystem); … … 85 85 } 86 86 87 /* Display data-item: */87 /* Create Display data-item: */ 88 88 UIInformationDataItem *pDisplay = new UIInformationDataDisplay(m_machine, m_console, m_pModel); 89 89 AssertPtrReturnVoid(pDisplay); … … 92 92 } 93 93 94 /* Storage data-item: */94 /* Create Storage data-item: */ 95 95 UIInformationDataItem *pStorage = new UIInformationDataStorage(m_machine, m_console, m_pModel); 96 96 AssertPtrReturnVoid(pStorage); … … 99 99 } 100 100 101 /* Audio data-item: */101 /* Create Audio data-item: */ 102 102 UIInformationDataItem *pAudio = new UIInformationDataAudio(m_machine, m_console, m_pModel); 103 103 AssertPtrReturnVoid(pAudio); … … 106 106 } 107 107 108 /* Network data-item: */108 /* Create Network data-item: */ 109 109 UIInformationDataItem *pNetwork = new UIInformationDataNetwork(m_machine, m_console, m_pModel); 110 110 AssertPtrReturnVoid(pNetwork); … … 113 113 } 114 114 115 /* Serialports data-item: */115 /* Create Serial-ports data-item: */ 116 116 UIInformationDataItem *pSerialPorts = new UIInformationDataSerialPorts(m_machine, m_console, m_pModel); 117 117 AssertPtrReturnVoid(pSerialPorts); … … 121 121 122 122 #ifdef VBOX_WITH_PARALLEL_PORTS 123 /* Parallelports data-item: */123 /* Create Parallel-ports data-item: */ 124 124 UIInformationDataItem *pParallelPorts = new UIInformationDataParallelPorts(m_machine, m_console, m_pModel); 125 125 AssertPtrReturnVoid(pParallelPorts); … … 129 129 #endif /* VBOX_WITH_PARALLEL_PORTS */ 130 130 131 /* USB data-item: */131 /* Create USB data-item: */ 132 132 UIInformationDataItem *pUSB = new UIInformationDataUSB(m_machine, m_console, m_pModel); 133 133 AssertPtrReturnVoid(pUSB); … … 136 136 } 137 137 138 /* Sharedfolders data-item: */138 /* Create Shared-folders data-item: */ 139 139 UIInformationDataItem *pSharedFolders = new UIInformationDataSharedFolders(m_machine, m_console, m_pModel); 140 140 AssertPtrReturnVoid(pSharedFolders); … … 147 147 void UIInformation::prepareView() 148 148 { 149 /* Create view: */149 /* Create information-view: */ 150 150 m_pView = new UIInformationView; 151 151 AssertPtrReturnVoid(m_pView); 152 152 { 153 /* Prepareview: */153 /* Configure information-view: */ 154 154 m_pView->setResizeMode(QListView::Adjust); 155 155 /* Create information-delegate item: */ … … 163 163 m_pView, SLOT(updateData(const QModelIndex&, const QModelIndex&))); 164 164 165 /* Set model : */165 /* Set model for view: */ 166 166 m_pView->setModel(m_pModel); 167 /* Layout view: */167 /* Add information-view to the main-layout: */ 168 168 m_pMainLayout->addWidget(m_pView); 169 169 } -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/information/UIInformationItem.cpp
r59709 r59920 28 28 /* GUI includes: */ 29 29 # include "UIInformationItem.h" 30 # include "VBoxGlobal.h" 30 31 31 32 #endif /* !VBOX_WITH_PRECOMPILED_HEADERS */ … … 34 35 : QStyledItemDelegate(pParent) 35 36 { 37 /* Create text-document: */ 36 38 m_pTextDocument = new QTextDocument(this); 39 AssertPtrReturnVoid(m_pTextDocument); 37 40 } 38 41 39 42 void UIInformationItem::setIcon(const QString &strIcon) const 40 43 { 44 /* Cache icon: */ 41 45 m_strIcon = strIcon; 46 /* Update text-layout: */ 42 47 updateTextLayout(); 43 48 } … … 47 52 /* Cache name: */ 48 53 m_strName = strName; 54 /* Update text-layout: */ 49 55 updateTextLayout(); 50 56 } … … 52 58 const UITextTable& UIInformationItem::text() const 53 59 { 60 /* Return text: */ 54 61 return m_text; 55 62 } … … 60 67 m_text.clear(); 61 68 62 /* For each theline of the passed table: */69 /* For each line of the passed table: */ 63 70 foreach (const UITextTableLine &line, text) 64 71 { … … 78 85 /* Parse the 1st one to sub-lines: */ 79 86 QStringList subLines = strLeftLine.split(QRegExp("\\n")); 87 /* Parse sub-lines: */ 80 88 foreach (const QString &strSubLine, subLines) 81 89 m_text << UITextTableLine(strSubLine, QString()); … … 89 97 void UIInformationItem::paint(QPainter *pPainter, const QStyleOptionViewItem &option, const QModelIndex &index) const 90 98 { 99 /* Save the painter: */ 91 100 pPainter->save(); 101 /* Update data: */ 92 102 updateData(index); 93 103 104 /* Draw item as per application style: */ 94 105 QApplication::style()->drawControl(QStyle::CE_ItemViewItem, &option, pPainter); 95 106 pPainter->resetTransform(); 96 107 pPainter->translate(option.rect.topLeft()); 97 108 109 /* Draw the content of text-document: */ 98 110 m_pTextDocument->drawContents(pPainter); 111 /* Restore the painter: */ 99 112 pPainter->restore(); 100 113 } … … 102 115 QSize UIInformationItem::sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const 103 116 { 117 /* Update data: */ 104 118 updateData(index); 119 /* Return size: */ 105 120 return m_pTextDocument->size().toSize(); 106 121 } … … 108 123 void UIInformationItem::updateData(const QModelIndex &index) const 109 124 { 125 /* Set name: */ 110 126 setName(index.data().toString()); 127 /* Set icon: */ 111 128 setIcon(index.data(Qt::DecorationRole).toString()); 129 /* Set text: */ 112 130 setText(index.data(Qt::UserRole + 1).value<UITextTable>()); 131 /* Get type of the item: */ 113 132 m_type = index.data(Qt::UserRole + 2).value<InformationElementType>(); 114 133 } … … 116 135 QString UIInformationItem::htmlData() 117 136 { 137 /* Return html-data: */ 118 138 return m_pTextDocument->toHtml(); 119 139 } … … 121 141 void UIInformationItem::updateTextLayout() const 122 142 { 123 /* Details templates */143 /* Details templates: */ 124 144 static const char *sSectionBoldTpl = 125 145 "<tr><td width=22 rowspan=%1 align=left><img width=16 height=16 src='%2'></td>" … … 127 147 "%4"; 128 148 static const char *sSectionItemTpl2 = 129 "<tr><td width= 300><nobr>%1</nobr></td><td/><td>%2</td></tr>";149 "<tr><td width=200><nobr>%1</nobr></td><td/><td>%2</td></tr>"; 130 150 131 151 const QString §ionTpl = sSectionBoldTpl; … … 135 155 { 136 156 QString item; 157 /* Parse lines from text and add it to text: */ 137 158 foreach (const UITextTableLine &line, m_text) 138 159 item = item + QString(sSectionItemTpl2).arg(line.first, line.second); 139 160 140 report = sectionTpl141 142 .arg(m_strIcon, /* icon */143 m_strName, /* title */144 item); /* items */161 /* Format the entire item: */ 162 report = sectionTpl.arg(m_text.count() + 1) /* rows */ 163 .arg(m_strIcon, /* icon */ 164 m_strName, /* title */ 165 item); /* items */ 145 166 } 146 167 -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/information/UIInformationModel.cpp
r59702 r59920 50 50 } 51 51 52 int UIInformationModel::rowCount(const QModelIndex 52 int UIInformationModel::rowCount(const QModelIndex& /*parent */) const 53 53 { 54 /* Return row-count: */ 54 55 return m_list.count(); 55 56 } … … 57 58 QVariant UIInformationModel::data(const QModelIndex &index, int role) const 58 59 { 60 /* Get row: */ 59 61 int row = index.row(); 60 int col = index.column();62 /* Get item at the row: */ 61 63 UIInformationDataItem *pItem = m_list.at(row); 64 /* Return the data for the corresponding role: */ 62 65 return pItem->data(index, role); 63 66 } … … 81 84 QHash<int, QByteArray> UIInformationModel::roleNames() const 82 85 { 86 /* Add supported roles and return: */ 83 87 QHash<int, QByteArray> roleNames; 84 88 roleNames[Qt::DisplayRole] = ""; … … 91 95 void UIInformationModel::addItem(UIInformationDataItem *pItem) 92 96 { 97 /* Make sure item is valid: */ 93 98 AssertPtrReturnVoid(pItem); 99 /* Add item: */ 94 100 m_list.append(pItem); 95 101 } … … 97 103 void UIInformationModel::updateData(const QModelIndex &idx) 98 104 { 105 /* Emit data-changed signal: */ 99 106 emit dataChanged(idx, idx); 100 107 } -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/information/UIInformationRuntime.cpp
r59646 r59920 57 57 AssertPtrReturnVoid(m_pMainLayout); 58 58 { 59 /* Prepare main-layout: */59 /* Configure main-layout: */ 60 60 m_pMainLayout->setContentsMargins(2, 0, 0, 0); 61 61 m_pMainLayout->setSpacing(0); … … 70 70 AssertPtrReturnVoid(m_pModel); 71 71 72 /* Prepare data forinformation-model: */72 /* Add data to information-model: */ 73 73 UIInformationDataRuntimeAttributes *pGeneral = new UIInformationDataRuntimeAttributes(m_machine, m_console, m_pModel); 74 74 AssertPtrReturnVoid(pGeneral); … … 77 77 } 78 78 79 /* Prepare data for information-model: */79 /* Create data for information-model: */ 80 80 UIInformationDataNetworkStatistics *pNetwork = new UIInformationDataNetworkStatistics(m_machine, m_console, m_pModel); 81 81 AssertPtrReturnVoid(pNetwork); … … 84 84 } 85 85 86 /* Prepare data for information-model: */86 /* Create data for information-model: */ 87 87 UIInformationDataStorageStatistics *pStorage = new UIInformationDataStorageStatistics(m_machine, m_console, m_pModel); 88 88 AssertPtrReturnVoid(pStorage); -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/information/UIInformationView.cpp
r59699 r59920 20 20 #else /* !VBOX_WITH_PRECOMPILED_HEADERS */ 21 21 22 # include <QTextEdit> 22 23 # include <QClipboard> 24 # include <QDebug> 23 25 24 26 /* GUI includes: */ … … 31 33 : QListView(pParent) 32 34 { 35 /* Create a dummy textEdit for copying rich-text as, 36 * manual copying to clipboard is not working: */ 37 m_pTextEdit = new QTextEdit(this); 38 /* Hide textedit: */ 39 m_pTextEdit->setVisible(false); 40 /* Set selection mode: */ 41 setSelectionMode(QAbstractItemView::ExtendedSelection); 33 42 } 34 43 35 44 void UIInformationView::updateData(const QModelIndex &topLeft, const QModelIndex &bottomRight) 36 45 { 46 /* Update: */ 37 47 update(topLeft); 38 48 } … … 40 50 void UIInformationView::keyPressEvent(QKeyEvent *pEvent) 41 51 { 52 /* Copy the text: */ 42 53 if (pEvent == QKeySequence::Copy) 43 54 { 44 if (selectionModel()) 55 QString strText; 56 /* Get Selection model: */ 57 QItemSelectionModel *pSelectionModel = selectionModel(); 58 if (pSelectionModel) 45 59 { 46 QString strText;47 foreach (const QModelIndex &index, selectionModel()->selectedIndexes())60 /* Check all the selected-indexes and copy the text: */ 61 foreach (const QModelIndex &index, pSelectionModel->selectedIndexes()) 48 62 { 49 63 UIInformationItem *pItem = dynamic_cast<UIInformationItem*>(itemDelegate(index)); 50 64 if (pItem) 51 65 { 66 /* Update the data corresponding data: */ 67 pItem->updateData(index); 68 /* Get and add the html-data of item: */ 52 69 strText.append(pItem->htmlData()); 53 70 } 54 71 } 55 QApplication::clipboard()->setText(strText);56 pEvent->accept();57 72 } 73 /* Set the text to text-edit and copy from it: */ 74 m_pTextEdit->setText(strText); 75 m_pTextEdit->selectAll(); 76 m_pTextEdit->copy(); 77 /* Accept/acknowledge event: */ 78 pEvent->accept(); 58 79 } 80 /* Call to base-class: */ 81 else 82 QListView::keyPressEvent(pEvent); 59 83 } 60 84 -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/information/UIInformationView.h
r59699 r59920 23 23 #include <QModelIndex> 24 24 25 /* Forward declarations: */ 26 class QTextEdit; 27 class UIInformationItem; 28 25 29 /** QListView extension 26 30 * providing GUI with information-view in session-information window. */ … … 40 44 /** Handles Qt key-press @a pEvent. */ 41 45 void keyPressEvent(QKeyEvent *pEvent); 46 47 private: 48 /** Holds the instance of textedit we create: */ 49 QTextEdit *m_pTextEdit; 42 50 }; 43 51
Note:
See TracChangeset
for help on using the changeset viewer.