5 #include <QDirIterator>
15 QAbstractTableModel(parent),
33 printf(
"Deleting file browser model\n");
53 (
int section, Qt::Orientation orientation,
int role)
const
57 if (orientation == Qt::Horizontal && role == Qt::DisplayRole) {
72 return inherited::headerData(section, orientation, role);
82 QModelIndex index = idx;
85 if (role == Qt::DisplayRole) {
86 if (index.isValid()) {
87 if (index.column() == 0) {
88 return info.fileName();
89 }
else if (index.column() == 1) {
92 }
else if (!info.exists()) {
95 qint64 sz = info.size();
98 return tr(
"%1 B").arg(sz);
99 }
else if (sz < 1024*1024) {
100 return tr(
"%1 KB").arg(sz/1024);
101 }
else if (sz < 1024*1024*1024) {
102 return tr(
"%1 MB").arg(sz/(1024*1024));
104 return tr(
"%1 GB").arg(sz/(1024*1024*1024));
107 }
else if (index.column() == 2) {
108 return info.lastModified();
111 }
else if (role == Qt::DecorationRole) {
112 if (index.column() == 0) {
114 return QPixmap(
":/images/folder-16x16.png");
115 }
else if (!info.exists()) {
118 QString suffix = info.suffix();
120 if (suffix ==
"metadata") {
121 return QPixmap(
":/images/file-metadata-16x16.png");
122 }
else if (suffix ==
"avg") {
123 return QPixmap(
":/images/file-integration-16x16.png");
124 }
else if (suffix ==
"tif") {
125 return QPixmap(
":/images/file-image-16x16.png");
127 return QPixmap(
":/images/file-generic-16x16.png");
133 }
else if (role == Qt::BackgroundRole) {
134 double lastMod = info.lastModified().msecsTo(QDateTime::currentDateTime())/1000.0;
137 return QColor(Qt::white);
138 }
else if (info.exists()){
140 emit model->dataChanged(index, index);
198 info = QFileInfo(tr(
"... %1 additional files not displayed...").arg(
m_TrueSize-
m_Limit));
276 updater -> needUpdate();
298 updater -> needUpdate();
QxrdFileBrowserModel(QObject *parent)
QxrdFileBrowserModelUpdaterWPtr m_Updater
QFileInfo fileInfo(const QModelIndex &index) const
QStringList nameFilters() const
QxrdFileBrowserModelUpdaterThreadPtr m_UpdaterThread
QVector< QFileInfo > m_FileList
int rowCount(const QModelIndex &parent=QModelIndex()) const
int columnCount(const QModelIndex &parent=QModelIndex()) const
void setNameFilters(QStringList filters)
void generateFileUpdates(int doIt)
QVector< QFileInfo > m_DirList
QString fileName(const QModelIndex &index) const
void newDataAvailable(QVector< QFileInfo > dirs, QVector< QFileInfo > files, int limit=0, int trueSize=-1)
QStringList m_NameFilters
QSharedPointer< QxrdFileBrowserModelUpdater > QxrdFileBrowserModelUpdaterPtr
QString filePath(const QModelIndex &index) const
Qt::SortOrder sortOrder() const
bool isDir(const QModelIndex &index) const
void fileUpdated(QFileInfo file)
void setRootPath(QString path)
QVariant headerData(int section, Qt::Orientation orientation, int role=Qt::DisplayRole) const
void setNameFilterDisables(bool disables)
void rootChanged(const QString &path)
Qt::SortOrder m_SortOrder
double m_HighlightFadeTime
virtual void sort(int column, Qt::SortOrder order=Qt::AscendingOrder)
QSharedPointer< QxrdFileBrowserModelUpdaterThread > QxrdFileBrowserModelUpdaterThreadPtr
void updatedFile(QFileInfo file)
int m_HighlightSaturation
QVariant data(const QModelIndex &index, int role=Qt::DisplayRole) const