Changeset 28344 in vbox
- Timestamp:
- Apr 15, 2010 2:50:36 AM (15 years ago)
- svn:sync-xref-src-repo-rev:
- 60103
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/VBoxVMLogViewer.cpp
r26719 r28344 164 164 { 165 165 /* Clearing old data if any */ 166 mLogFiles List.clear();166 mLogFiles.clear(); 167 167 mLogList->setEnabled (true); 168 168 while (mLogList->count()) … … 175 175 bool isAnyLogPresent = false; 176 176 177 /* Entering log files folder */ 178 QString logFilesPath = mMachine.GetLogFolder(); 179 QDir logFilesDir (logFilesPath); 180 if (logFilesDir.exists()) 181 { 182 /* Reading log files folder */ 183 QStringList filters; 184 filters << "*.log" << "*.log.*"; 185 logFilesDir.setNameFilters (filters); 186 QStringList logList = logFilesDir.entryList (QDir::Files); 187 if (!logList.empty()) isAnyLogPresent = true; 188 foreach (QString logFile, logList) 189 loadLogFile (logFilesDir.filePath (logFile)); 177 const CSystemProperties &sys = vboxGlobal().virtualBox().GetSystemProperties(); 178 int cMaxLogs = sys.GetLogHistoryCount(); 179 for (int i=0; i <= cMaxLogs; ++i) 180 { 181 /* Query the log file name for index i */ 182 QString file = mMachine.QueryLogFilename(i); 183 if (!file.isEmpty()) 184 { 185 /* Try to read the log file with the index i */ 186 ULONG uOffset = 0; 187 QString text; 188 while (true) 189 { 190 QVector<BYTE> data = mMachine.ReadLog(i, uOffset, _1M); 191 if (data.size() == 0) 192 break; 193 text.append(QString::fromUtf8((char*)data.data(), data.size())); 194 uOffset += data.size(); 195 } 196 /* Anything read at all? */ 197 if (uOffset > 0) 198 { 199 /* Create a log viewer page and append the read text to it */ 200 QTextEdit *logViewer = createLogPage(QFileInfo(file).fileName()); 201 logViewer->setPlainText(text); 202 /* Add the actual file name and the QTextEdit containing the 203 content to a list. */ 204 mLogFiles << qMakePair(file, logViewer); 205 isAnyLogPresent = true; 206 } 207 } 190 208 } 191 209 … … 198 216 "<b>Refresh</b> button to rescan the log folder " 199 217 "<nobr><b>%1</b></nobr>.</p>") 200 .arg ( logFilesPath));218 .arg (mMachine.GetLogFolder())); 201 219 /* We don't want it to remain white */ 202 220 QPalette pal = dummyLog->palette(); … … 222 240 { 223 241 /* Prepare "save as" dialog */ 224 QFileInfo fileInfo (mLogFiles List [mLogList->currentIndex()]);242 QFileInfo fileInfo (mLogFiles.at(mLogList->currentIndex()).first); 225 243 QDateTime dtInfo = fileInfo.lastModified(); 226 244 QString dtString = dtInfo.toString ("yyyy-MM-dd-hh-mm-ss"); … … 236 254 { 237 255 /* Reread log data */ 238 QFile oldFile (mLogFilesList [mLogList->currentIndex()]);239 256 QFile newFile (newFileName); 240 if (!oldFile.open (QIODevice::ReadOnly) || 241 !newFile.open (QIODevice::WriteOnly)) 257 if (!newFile.open (QIODevice::WriteOnly)) 242 258 return; 243 259 244 260 /* Save log data into the new file */ 245 newFile.write ( oldFile.readAll());261 newFile.write (mLogFiles.at(mLogList->currentIndex()).second->toPlainText().toUtf8()); 246 262 } 247 263 } … … 255 271 { 256 272 if (aIndex >= 0 && 257 aIndex < mLogFiles List.count())258 setFileForProxyIcon (mLogFilesList.at (aIndex));273 aIndex < mLogFiles.count()) 274 setFileForProxyIcon(mLogFiles.at(aIndex).first); 259 275 } 260 276 … … 311 327 if (w) 312 328 w->setFocus(); 313 }314 315 void VBoxVMLogViewer::loadLogFile (const QString &aFileName)316 {317 /* Prepare log file */318 QFile logFile (aFileName);319 if (!logFile.exists() || !logFile.open (QIODevice::ReadOnly))320 return;321 322 /* Read log file and write it into the log page */323 QTextEdit *logViewer = createLogPage (QFileInfo (aFileName).fileName());324 logViewer->setPlainText (logFile.readAll());325 326 mLogFilesList << aFileName;327 329 } 328 330 -
trunk/src/VBox/Frontends/VirtualBox/src/VBoxVMLogViewer.h
r25171 r28344 73 73 74 74 void showEvent (QShowEvent *aEvent); 75 void loadLogFile (const QString &aName);76 75 QTextEdit* createLogPage (const QString &aPage); 77 76 … … 82 81 CMachine mMachine; 83 82 QTabWidget *mLogList; 84 QStringList mLogFilesList;85 83 VBoxLogSearchPanel *mSearchPanel; 84 QList< QPair<QString, QTextEdit*> > mLogFiles; 86 85 87 86 QPushButton *mBtnHelp;
Note:
See TracChangeset
for help on using the changeset viewer.