summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--filesystemwidget.cpp2
-rw-r--r--smdirmodel.cpp17
-rw-r--r--smdirmodel.h6
-rw-r--r--smdirwatcher.cpp10
-rw-r--r--smdirwatcher.h2
-rw-r--r--smtreeview.cpp4
6 files changed, 29 insertions, 12 deletions
diff --git a/filesystemwidget.cpp b/filesystemwidget.cpp
index 64dfd1c..6204727 100644
--- a/filesystemwidget.cpp
+++ b/filesystemwidget.cpp
@@ -43,7 +43,7 @@ FilesystemWidget::FilesystemWidget(QWidget *parent) : QWidget(parent), mClipboar
mIconProvider = new SheMovIconProvider;
mModel->setIconProvider(mIconProvider);
- QStringList fHeaders = QStringList() << tr("Name") << tr("Size") << tr("Type") << tr("Created") << tr("Md5Sum") << tr("Duration") << tr("Bitrate") << tr("Full Path");
+ QStringList fHeaders = QStringList() << tr("Name") << tr("Size") << tr("Type") << tr("Created") << tr("Md5Sum") << tr("Duration") << tr("Bitrate") << tr("Full Path") << tr("Pic Size");
mFileModel = new SmDirModel(fHeaders, this);
connect(mFileModel, SIGNAL(needResize()), this, SLOT(resizeFileView()));
diff --git a/smdirmodel.cpp b/smdirmodel.cpp
index 00857ab..82527a0 100644
--- a/smdirmodel.cpp
+++ b/smdirmodel.cpp
@@ -16,7 +16,7 @@
#include "helper.h"
SmDirModel::SmDirModel(const QStringList &headers, QObject *parent) : SmTreeModel(headers, parent), mHeaders(headers){
- mWatch = new SmDirWatcher(this);
+ mWatch = new SmDirWatcher(NumFields, this);
connect(mWatch, SIGNAL(needRefresh()), this, SLOT(refresh()));
mRunTimer = new QTimer(this);
mRunTimer->setInterval(2000);
@@ -57,6 +57,8 @@ QVariant SmDirModel::data(const QModelIndex &index, int role) const{
return i->data(Bitrate);
case FullPathRole:
return i->data(FullPath);
+ case PicSizeRole:
+ return i->data(PicSize);
case Qt::DecorationRole: {
if(index.column() == 0){
QStringList mime = i->data(Type).toString().split('/');
@@ -77,6 +79,14 @@ QVariant SmDirModel::data(const QModelIndex &index, int role) const{
}
return d.toString();
}
+ if(index.column() == PicSize){
+ QSize size = i->data(PicSize).value<QSize>();
+ if(!size.isValid()){
+ return QVariant();
+ }
+ QString retval = QString(tr("%1x%2 px").arg(QString::number(size.width())).arg(QString::number(size.height())));
+ return retval;
+ }
}
default:
@@ -215,5 +225,10 @@ const QList<QVariant> SmDirModel::fileData(const QFileInfo &fi) const{
}
data << Helper::md5Sum(fi.absoluteFilePath());
data << si << fi.absoluteFilePath();
+ if(mime.startsWith("image")){
+ data << QImage(fi.absoluteFilePath()).size();;
+ }else{
+ data << QVariant();
+ }
return data;
}
diff --git a/smdirmodel.h b/smdirmodel.h
index e33392f..ed77ac4 100644
--- a/smdirmodel.h
+++ b/smdirmodel.h
@@ -22,9 +22,9 @@ class SmDataColletor;
class SmDirModel : public SmTreeModel {
Q_OBJECT
public:
- enum CustomRoles { NameRole = Qt::UserRole + 1, SizeRole = Qt::UserRole + 2, TypeRole = Qt::UserRole + 3, CreatedRole = Qt::UserRole + 4, Md5sumRole = Qt::UserRole + 5, DurationRole = Qt::UserRole + 6, BitrateRole = Qt::UserRole + 7, FullPathRole = Qt::UserRole + 8 };
- enum Fields { Name = 0, Size = 1, Type = 2, Created = 3, Md5sum = 4, Duration = 5, Bitrate = 6, FullPath = 7 };
- enum { NumFields = 8 };
+ enum CustomRoles { NameRole = Qt::UserRole + 1, SizeRole = Qt::UserRole + 2, TypeRole = Qt::UserRole + 3, CreatedRole = Qt::UserRole + 4, Md5sumRole = Qt::UserRole + 5, DurationRole = Qt::UserRole + 6, BitrateRole = Qt::UserRole + 7, FullPathRole = Qt::UserRole + 8, PicSizeRole = Qt::UserRole + 9 };
+ enum Fields { Name = 0, Size = 1, Type = 2, Created = 3, Md5sum = 4, Duration = 5, Bitrate = 6, FullPath = 7, PicSize = 8 };
+ enum { NumFields = 9 };
enum FileDate { Access, Modified, Status };
explicit SmDirModel(const QStringList &headers, QObject *parent = 0);
~SmDirModel();
diff --git a/smdirwatcher.cpp b/smdirwatcher.cpp
index 069ebfe..eaff3b3 100644
--- a/smdirwatcher.cpp
+++ b/smdirwatcher.cpp
@@ -10,6 +10,7 @@
#include <QDateTime>
#include <QDir>
#include <QSemaphore>
+#include <QImage>
#include <sys/inotify.h>
#include <stropts.h>
@@ -23,12 +24,12 @@
extern int errno;
-SmDirWatcher::SmDirWatcher(QObject *parent) : QThread(parent), mFd(0), mDescr(0) {
+SmDirWatcher::SmDirWatcher(int numFields, QObject *parent) : QThread(parent), mFd(0), mDescr(0) {
mBufLen = 1024 * (sizeof(struct inotify_event) + 16);
mINdata = new char[mBufLen];
mFd = inotify_init();
- mCollector = new SmDataColletor(8, this);
+ mCollector = new SmDataColletor(numFields, this);
mSemFree = new QSemaphore(1024);
mSemUsed = new QSemaphore;
mDataQueue = new QQueue<QPair<QString, DWEvent> >();
@@ -146,5 +147,10 @@ const QList<QVariant> SmDataColletor::fileData(const QFileInfo &fi) const{
}
data << Helper::md5Sum(fi.absoluteFilePath());
data << si << fi.absoluteFilePath();
+ if(mime.startsWith("image")){
+ data << QImage(fi.absoluteFilePath()).size();
+ }else{
+ data << QVariant();
+ }
return data;
}
diff --git a/smdirwatcher.h b/smdirwatcher.h
index 19cd746..4a85c5a 100644
--- a/smdirwatcher.h
+++ b/smdirwatcher.h
@@ -22,7 +22,7 @@ class SmDirWatcher : public QThread {
Q_OBJECT
public:
enum DWEvent { None, Added, Deleted, Modified, Populate };
- explicit SmDirWatcher(QObject *parent = 0);
+ explicit SmDirWatcher(int numFields, QObject *parent = 0);
SmDataColletor *collector() { return mCollector; }
~SmDirWatcher();
diff --git a/smtreeview.cpp b/smtreeview.cpp
index 411857a..feb64bf 100644
--- a/smtreeview.cpp
+++ b/smtreeview.cpp
@@ -16,8 +16,6 @@ SmTreeView::SmTreeView(const QString &hSetting, QWidget *parent) : QTreeView(par
header()->setSectionResizeMode(QHeaderView::ResizeToContents);
}
-#include <QDebug>
-
void SmTreeView::readHeaderConfig(){
QSettings s;
QByteArray headerPos = s.value(mHeaderSetting).toByteArray();
@@ -31,7 +29,6 @@ void SmTreeView::readHeaderConfig(){
}
for(int i = 0; i < hv->count(); ++i){
if(!hv->isSectionHidden(i)){
- qDebug() << mHeaderSetting << headerActions.value(i) << "checked" << headerActions.value(i)->isCheckable();
headerActions.value(i)->setChecked(true);
}
}
@@ -47,5 +44,4 @@ void SmTreeView::toggleHeader(QObject *action){
int logicalIndex = a->data().toInt();
QHeaderView *hv = header();
hv->setSectionHidden(logicalIndex, !a->isChecked());
- qDebug() << mHeaderSetting << a->text() << "toggled" << a->isChecked();
}