void DetailView
::on_DriveView_clicked(const QModelIndex &index
) {
int m_count_row = 0;
QString sPath
= m_SystemModel
->fileInfo
(index
).
absoluteFilePath();
m_SystemListViewModel->setRootPath(sPath);
ui->DriveListView->setRootIndex(m_SystemListViewModel->index(sPath));
m_SystemModel
->setRootPath
(QDir::currentPath());
m_SystemModel
->setFilter
(QDir::NoDotAndDotDot |
QDir::AllDirs );
m_SystemListViewModel
->setFilter
( QDir::Files |
QDir::NoDotAndDotDot );
QDirIterator dirIt(sPath,QDirIterator::Subdirectories);
while (dirIt.hasNext())
{
dirIt.next();
{
if (QFileInfo(dirIt.
filePath()).
suffix() == "mp3" ||
(QFileInfo(dirIt.
filePath()).
suffix() == "mts" ) ||
(QFileInfo(dirIt.
filePath()).
suffix() == "m2ts" )) {
m_list << dirIt.filePath();
model->setHeaderData( 0, Qt::Horizontal, "Name" );
model->setHeaderData( 1, Qt::Horizontal, "Type" );
model->setHeaderData( 2, Qt::Horizontal, "Size" );
model->setHeaderData( 3, Qt::Horizontal, "Date Modified" );
model->setData( m_index, dirIt.fileName(), Qt::DecorationRole );
model->setItem(m_count_row, 0, itemName);
model->setData( m_index, dirIt.fileInfo().suffix(), Qt::DecorationRole );
model->setItem(m_count_row, 1, itemExtention);
model->setData( m_index, dirIt.fileInfo().size(), Qt::DecorationRole );
float fFileSize = dirIt.fileInfo().size();
float fFileKB = fFileSize / 1024; //kilobyte
float fFileMB = fFileKB / 1024; //megabyte
float fFinalSize = ceilf(fFileMB * 100) / 100;
model->setItem(m_count_row, 2, itemSize);
ui->DriveListView->setModel(model);
ui->DriveListView->setRootIsDecorated(false);
m_count_row++;
}
}
m_SystemListViewModel->setNameFilterDisables(false);
}
}
void DetailView::on_DriveView_clicked(const QModelIndex &index)
{
int m_count_row = 0;
QStandardItemModel *model = new QStandardItemModel(0,0);
QString sPath = m_SystemModel->fileInfo(index).absoluteFilePath();
m_SystemListViewModel->setRootPath(sPath);
ui->DriveListView->setRootIndex(m_SystemListViewModel->index(sPath));
m_SystemModel->setRootPath(QDir::currentPath());
m_SystemModel->setFilter(QDir::NoDotAndDotDot | QDir::AllDirs );
m_SystemListViewModel->setFilter( QDir::Files | QDir::NoDotAndDotDot );
QStringList m_list;
QDirIterator dirIt(sPath,QDirIterator::Subdirectories);
while (dirIt.hasNext())
{
dirIt.next();
if (QFileInfo(dirIt.filePath()).isFile())
{
if (QFileInfo(dirIt.filePath()).suffix() == "mp3" ||(QFileInfo(dirIt.filePath()).suffix() == "mts" ) ||(QFileInfo(dirIt.filePath()).suffix() == "m2ts" ))
{
m_list << dirIt.filePath();
QModelIndex m_index = model->index(m_count_row, 0, QModelIndex());
model->setHeaderData( 0, Qt::Horizontal, "Name" );
model->setHeaderData( 1, Qt::Horizontal, "Type" );
model->setHeaderData( 2, Qt::Horizontal, "Size" );
model->setHeaderData( 3, Qt::Horizontal, "Date Modified" );
model->setData( m_index, dirIt.fileName(), Qt::DecorationRole );
QStandardItem *itemName = new QStandardItem(dirIt.fileName());
model->setItem(m_count_row, 0, itemName);
model->setData( m_index, dirIt.fileInfo().suffix(), Qt::DecorationRole );
QStandardItem *itemExtention = new QStandardItem( dirIt.fileInfo().suffix());
model->setItem(m_count_row, 1, itemExtention);
model->setData( m_index, dirIt.fileInfo().size(), Qt::DecorationRole );
float fFileSize = dirIt.fileInfo().size();
float fFileKB = fFileSize / 1024; //kilobyte
float fFileMB = fFileKB / 1024; //megabyte
float fFinalSize = ceilf(fFileMB * 100) / 100;
QString sSizeValue = QString::number(fFinalSize);
QStandardItem *itemSize = new QStandardItem(sSizeValue + " MB");
model->setItem(m_count_row, 2, itemSize);
ui->DriveListView->setModel(model);
ui->DriveListView->setRootIsDecorated(false);
m_count_row++;
}
}
m_SystemListViewModel->setNameFilterDisables(false);
}
}
To copy to clipboard, switch view to plain text mode
Bookmarks