Index: sources/device/DeviceController.cpp =================================================================== diff -u -r02350a71e85f193287e6c999e816dc5ced6966f2 -rb012c6d1d980d4341faad8719dd33a0bed49b7f8 --- sources/device/DeviceController.cpp (.../DeviceController.cpp) (revision 02350a71e85f193287e6c999e816dc5ced6966f2) +++ sources/device/DeviceController.cpp (.../DeviceController.cpp) (revision b012c6d1d980d4341faad8719dd33a0bed49b7f8) @@ -373,7 +373,7 @@ */ void DeviceController::usbError(const QString &vDevice) { - qDebug()< VLogFilesModel::getLogListFromDir(Storage::Logger::LogType vType, const QString &vDirectory, bool vCheckPreInclude){ QList temp; + + // iterate through directory and subdirectories, looking for files only and no symlinks. QDirIterator dirIterator(vDirectory, QDir::Files | QDir::NoSymLinks | QDir::NoDotAndDotDot, QDirIterator::Subdirectories); QString absolutePath; while(dirIterator.hasNext()) { @@ -118,72 +135,111 @@ LogFileData currentLog(vType, dirIterator.fileInfo()); if(!vCheckPreInclude || !_logFiles.contains(currentLog)) { - //DEBUG qDebug() << " adding " << absolutePath + dirIterator.fileName(); + //DEBUG qDebug() << " adding " << absolutePath << dirIterator.fileInfo().fileName(); temp.append(currentLog); } } } return temp; } +/*! + * \brief VLogFilesModel::updateLogModel + * This log updates the underlying file list with missing files from the + * targeted directory + * \param vDirectory - the target directory + */ void VLogFilesModel::updateLogModel(const QString &vDirectory) { Storage::Logger::LogType type = _Logger.getLogType(vDirectory); //DEBUG: qDebug() << Q_FUNC_INFO << " dir changed : " << vDirectory << " type " << type; QList temp = getLogListFromDir(type, vDirectory, true); + if(temp.count() == 0) return; // No new files, exit - if(temp.count() == 0) return; // No new files - // Update the model - beginInsertRows(QModelIndex(), _logFiles.count(), _logFiles.count() + temp.count()); + beginInsertRows(QModelIndex(), _logFiles.count(), _logFiles.count() + temp.count()-1); _logFiles.append(temp); endInsertRows(); } +/*! + * \brief VLogFilesModel::refreshModel + * Does a complete clear and repopulate the model + */ void VLogFilesModel::refreshModel() -{ qDebug()< logTypes = Storage::Logger::getLogTypeList(); foreach(Storage::Logger::LogType type , logTypes) { + // determine where the corresponding log folders live for each log type QString folderPath = QString("%1%2").arg(Storage::Log_Folder_Base).arg(_Logger.getPathOfLogType(type)); - // Add to systemWatcher to update for changes + // Add to systemWatcher to monitor for changes _DeviceController.doAddDirectoryWatch(folderPath); + // Update the underlying list of log files with data from the log directory _logFiles.append(getLogListFromDir(type, folderPath)); - } } // ============================== VUSBLogFilesModel +/*! + * \brief VUSBLogFilesModel::VUSBLogFilesModel + * Constructor + */ VUSBLogFilesModel::VUSBLogFilesModel(QAbstractListModel *parent) : VLogFilesModel(parent) { // add some additional connections initConnections(); } +/*! + * \brief VUSBLogFilesModel::initConnections + * Do all the necessary signal-slot connections + */ void VUSBLogFilesModel::initConnections() { - connect(&_DeviceController , SIGNAL( didUSBDriveMount ()), - this , SLOT( refreshModel ())); - connect(&_DeviceController , SIGNAL( didUSBDriveUmount ()), - this , SLOT( removeAllRows ())); - connect(&_DeviceController , SIGNAL( didUSBDriveRemove ()), - this , SLOT( removeAllRows ())); + connect(&_DeviceController , SIGNAL( didUSBDriveMount ()), + this , SLOT( refreshModel ())); + connect(&_DeviceController , SIGNAL( didUSBDriveUmount ()), + this , SLOT( removeAllRows ())); + connect(&_DeviceController , SIGNAL( didUSBDriveRemove ()), + this , SLOT( removeAllRows ())); } +/*! + * \brief VUSBLogFilesModel::updateModelOnDirChange + * Override of the base class updateModelOnDirChange virtual function + * This function's purpose is to update the model when the particular + * log folder at Storage::USB_Mount_Point has changed + * \param vDirectory - the directory that has changed based on watcher + */ void VUSBLogFilesModel::updateModelOnDirChange(const QString &vDirectory) { + qDebug()< logTypes = Storage::Logger::getLogTypeList(); foreach(Storage::Logger::LogType type , logTypes) { + // determine where the corresponding log folders live for each log type QString folderPath = QString("%1%2").arg(Storage::USB_Mount_Point).arg(_Logger.getPathOfLogType(type)); - // Add to systemWatcher to update for changes + // Add to systemWatcher to monitor for changes _DeviceController.doAddDirectoryWatch(folderPath); + // Update the underlying list of log files with data from the log directory _logFiles.append(getLogListFromDir(type, folderPath)); } } Index: sources/view/settings/VLogSortFilterProxyModel.cpp =================================================================== diff -u -r02350a71e85f193287e6c999e816dc5ced6966f2 -rb012c6d1d980d4341faad8719dd33a0bed49b7f8 --- sources/view/settings/VLogSortFilterProxyModel.cpp (.../VLogSortFilterProxyModel.cpp) (revision 02350a71e85f193287e6c999e816dc5ced6966f2) +++ sources/view/settings/VLogSortFilterProxyModel.cpp (.../VLogSortFilterProxyModel.cpp) (revision b012c6d1d980d4341faad8719dd33a0bed49b7f8) @@ -22,6 +22,10 @@ using namespace View; +/*! + * \brief VLogSortFilterProxyModel::VLogSortFilterProxyModel + * Constructor + */ VLogSortFilterProxyModel::VLogSortFilterProxyModel(QObject *vParent) : QSortFilterProxyModel(vParent) { @@ -32,21 +36,38 @@ setFilterLogType(0); } +/*! + * \brief VLogSortFilterProxyModel::setFilterLogType + * Sets the filtering key of the source model to only show certain log types + * \param vLogTypeKey - the key to filter the logs with + */ void VLogSortFilterProxyModel::setFilterLogType(int vLogTypeKey) { // TODO need to add a check that the log type is correct or need some sort of enum system + _logType = vLogTypeKey; invalidateFilter(); } +/*! + * \brief VLogSortFilterProxyModel::filterAcceptsRow + * Override of the filterAcceptRows function to determine if a data row is included in view + * For the log model, the log type of the data point determines whether to include a row or not + * see QSortFilterProxyModel::filterAcceptsRow for info + */ bool VLogSortFilterProxyModel::filterAcceptsRow(int source_row, const QModelIndex &source_parent) const { - // column index to match index placement of FileLogType in SDCardFileDataRole QModelIndex modelCellLogType = sourceModel()->index(source_row, 0, source_parent); int rowDataLogType = sourceModel()->data(modelCellLogType, VLogFilesModel::FileLogTypeRole).toInt(); return isLogOfType(rowDataLogType); } +/*! + * \brief VLogSortFilterProxyModel::lessThan + * Override of the lessThan function to compare two data points + * For the log model, the file modification time is the data used to compare + * see QSortFilterProxyModel::lessThan for info + */ bool VLogSortFilterProxyModel::lessThan(const QModelIndex &source_left, const QModelIndex &source_right) const { QVariant leftData = sourceModel()->data( source_left, VLogFilesModel::FileModificationDateTimeRole); @@ -56,6 +77,12 @@ return leftData.toDateTime() < rightData.toDateTime(); } +/*! + * \brief VLogSortFilterProxyModel::isLogOfType + * Determine if the logType passed is the same as the previously set log type to filter + * \param vLogType - the log type to compare + * \return true if vLogType matches stored, false otherwise + */ bool VLogSortFilterProxyModel::isLogOfType(int vLogType) const { return vLogType == _logType;