initial
This commit is contained in:
+68
-27
@@ -1,32 +1,73 @@
|
||||
# Prerequisites
|
||||
*.d
|
||||
# This file is used to ignore files which are generated
|
||||
# ----------------------------------------------------------------------------
|
||||
|
||||
# Compiled Object files
|
||||
*.slo
|
||||
*.lo
|
||||
*~
|
||||
*.autosave
|
||||
*.a
|
||||
*.core
|
||||
*.moc
|
||||
*.o
|
||||
*.obj
|
||||
|
||||
# Precompiled Headers
|
||||
*.gch
|
||||
*.pch
|
||||
|
||||
# Compiled Dynamic libraries
|
||||
*.orig
|
||||
*.rej
|
||||
*.so
|
||||
*.dylib
|
||||
*.dll
|
||||
|
||||
# Fortran module files
|
||||
*.mod
|
||||
*.smod
|
||||
|
||||
# Compiled Static libraries
|
||||
*.lai
|
||||
*.la
|
||||
*.a
|
||||
*.lib
|
||||
|
||||
# Executables
|
||||
*.exe
|
||||
*.out
|
||||
*.so.*
|
||||
*_pch.h.cpp
|
||||
*_resource.rc
|
||||
*.qm
|
||||
.#*
|
||||
*.*#
|
||||
core
|
||||
!core/
|
||||
tags
|
||||
.DS_Store
|
||||
.directory
|
||||
*.debug
|
||||
Makefile*
|
||||
*.prl
|
||||
*.app
|
||||
moc_*.cpp
|
||||
ui_*.h
|
||||
qrc_*.cpp
|
||||
Thumbs.db
|
||||
*.res
|
||||
*.rc
|
||||
/.qmake.cache
|
||||
/.qmake.stash
|
||||
|
||||
# qtcreator generated files
|
||||
*.pro.user*
|
||||
|
||||
# xemacs temporary files
|
||||
*.flc
|
||||
|
||||
# Vim temporary files
|
||||
.*.swp
|
||||
|
||||
# Visual Studio generated files
|
||||
*.ib_pdb_index
|
||||
*.idb
|
||||
*.ilk
|
||||
*.pdb
|
||||
*.sln
|
||||
*.suo
|
||||
*.vcproj
|
||||
*vcproj.*.*.user
|
||||
*.ncb
|
||||
*.sdf
|
||||
*.opensdf
|
||||
*.vcxproj
|
||||
*vcxproj.*
|
||||
|
||||
# MinGW generated files
|
||||
*.Debug
|
||||
*.Release
|
||||
|
||||
# Python byte code
|
||||
*.pyc
|
||||
|
||||
# Binaries
|
||||
# --------
|
||||
*.dll
|
||||
*.exe
|
||||
|
||||
|
||||
+109
@@ -0,0 +1,109 @@
|
||||
#include "cmainwindow.h"
|
||||
#include "ui_cmainwindow.h"
|
||||
|
||||
#include "cmediainfo.h"
|
||||
|
||||
#include <QDir>
|
||||
#include <QMimeType>
|
||||
|
||||
#include <QFile>
|
||||
#include <QTextStream>
|
||||
|
||||
#include <QDebug>
|
||||
|
||||
|
||||
cMainWindow::cMainWindow(QWidget *parent)
|
||||
: QMainWindow(parent)
|
||||
, ui(new Ui::cMainWindow),
|
||||
m_scanImages(true),
|
||||
m_scanVideos(true)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
}
|
||||
|
||||
cMainWindow::~cMainWindow()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
|
||||
void cMainWindow::addFile(const QString& fileName)
|
||||
{
|
||||
QMimeType mimeType = m_mimeDB.mimeTypeForFile(fileName);
|
||||
|
||||
if((mimeType.name().startsWith("image") && m_scanImages) || (mimeType.name().startsWith("video") && m_scanVideos))
|
||||
{
|
||||
ui->statusbar->showMessage(fileName);
|
||||
qApp->processEvents();
|
||||
m_mediaInfoList.add(fileName);
|
||||
}
|
||||
}
|
||||
|
||||
void cMainWindow::on_pushButton_clicked()
|
||||
{
|
||||
// m_scanImages = true;
|
||||
|
||||
scan("E:\\Babs\\Photos 2013 bis jetzt", "c:\\Temp\\CSV\\Babs.csv");
|
||||
scan("C:\\Users\\birkeh\\OneDrive\\__MEDIA__", "c:\\Temp\\CSV\\OneDrive.csv");
|
||||
|
||||
ui->statusbar->showMessage("done.", 5000);
|
||||
qApp->processEvents();
|
||||
}
|
||||
|
||||
void cMainWindow::scan(const QString& dir, const QString& fileName)
|
||||
{
|
||||
m_mediaInfoList.clear();
|
||||
scanDir(dir);
|
||||
writeFile(fileName);
|
||||
}
|
||||
|
||||
void cMainWindow::scanDir(const QString& dir)
|
||||
{
|
||||
QDir d(dir);
|
||||
QStringList files = d.entryList(QDir::Files);
|
||||
|
||||
for(int x = 0;x < files.count();x++)
|
||||
addFile(dir + "\\" + files[x]);
|
||||
|
||||
QStringList dirs = d.entryList(QDir::Dirs | QDir::NoDotAndDotDot | QDir::Hidden);
|
||||
|
||||
for(int x = 0;x < dirs.count();x++)
|
||||
scanDir(dir + "\\" + dirs[x]);
|
||||
}
|
||||
|
||||
void cMainWindow::writeFile(const QString& fileName)
|
||||
{
|
||||
ui->statusbar->showMessage("writing...");
|
||||
qApp->processEvents();
|
||||
|
||||
QStringList keys = m_mediaInfoList.keys();
|
||||
|
||||
QFile file(fileName);
|
||||
if(file.open(QIODevice::WriteOnly | QIODevice::Text))
|
||||
{
|
||||
QTextStream out(&file);
|
||||
|
||||
for(int x = 0;x < keys.count();x++)
|
||||
{
|
||||
if(x)
|
||||
out << ";";
|
||||
|
||||
out << "\"" << keys[x] << "\"";
|
||||
}
|
||||
out << "\n";
|
||||
|
||||
for(int x = 0;x < m_mediaInfoList.count();x++)
|
||||
{
|
||||
cMediaInfo* lpMediaInfo = m_mediaInfoList[x];
|
||||
|
||||
for(int y = 0;y < keys.count();y++)
|
||||
{
|
||||
if(y)
|
||||
out << ";";
|
||||
|
||||
out << "\"" << lpMediaInfo->value(keys[y]) << "\"";
|
||||
}
|
||||
out << "\n";
|
||||
}
|
||||
file.close();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
#ifndef CMAINWINDOW_H
|
||||
#define CMAINWINDOW_H
|
||||
|
||||
|
||||
#include "cmediainfo.h"
|
||||
|
||||
#include <QMainWindow>
|
||||
#include <QMimeDatabase>
|
||||
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
namespace Ui { class cMainWindow; }
|
||||
QT_END_NAMESPACE
|
||||
|
||||
|
||||
class cMainWindow : public QMainWindow
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
cMainWindow(QWidget *parent = nullptr);
|
||||
~cMainWindow();
|
||||
|
||||
private:
|
||||
Ui::cMainWindow* ui;
|
||||
cMediaInfoList m_mediaInfoList;
|
||||
QMimeDatabase m_mimeDB;
|
||||
bool m_scanImages;
|
||||
bool m_scanVideos;
|
||||
|
||||
void scan(const QString& dir, const QString& fileName);
|
||||
|
||||
void addFile(const QString& fileName);
|
||||
void scanDir(const QString& dir);
|
||||
void writeFile(const QString& fileName);
|
||||
|
||||
private slots:
|
||||
void on_pushButton_clicked();
|
||||
};
|
||||
#endif // CMAINWINDOW_H
|
||||
@@ -0,0 +1,45 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>cMainWindow</class>
|
||||
<widget class="QMainWindow" name="cMainWindow">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>800</width>
|
||||
<height>600</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>cMainWindow</string>
|
||||
</property>
|
||||
<widget class="QWidget" name="centralwidget">
|
||||
<widget class="QPushButton" name="pushButton">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>40</x>
|
||||
<y>30</y>
|
||||
<width>75</width>
|
||||
<height>23</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>start</string>
|
||||
</property>
|
||||
</widget>
|
||||
</widget>
|
||||
<widget class="QMenuBar" name="menubar">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>800</width>
|
||||
<height>21</height>
|
||||
</rect>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QStatusBar" name="statusbar"/>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
@@ -0,0 +1,83 @@
|
||||
#include "cmediainfo.h"
|
||||
#include "MediaInfoDLL.h"
|
||||
|
||||
#include <QDebug>
|
||||
|
||||
|
||||
using namespace MediaInfoDLL;
|
||||
|
||||
|
||||
cMediaInfo::cMediaInfo()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
bool cMediaInfo::fromFile(const QString& fileName)
|
||||
{
|
||||
MediaInfo info;
|
||||
|
||||
if(!info.Open(fileName.toStdWString().c_str()))
|
||||
return(false);
|
||||
|
||||
QString informString = QString::fromStdWString(info.Inform());
|
||||
QStringList list = informString.split("\r\n");
|
||||
|
||||
info.Close();
|
||||
|
||||
QString category;
|
||||
|
||||
for(int x = 0;x < list.count();x++)
|
||||
{
|
||||
if(list[x].isEmpty())
|
||||
continue;
|
||||
|
||||
if(list[x].length() < 41)
|
||||
{
|
||||
category = list[x];
|
||||
if(category == "General")
|
||||
category = "_General";
|
||||
continue;
|
||||
}
|
||||
|
||||
if(category == "_General" || category.startsWith("video", Qt::CaseInsensitive) || category.startsWith("audio", Qt::CaseInsensitive))
|
||||
{
|
||||
QString key = list[x].left(41).trimmed();
|
||||
QString value = list[x].mid(42).trimmed();
|
||||
|
||||
m_values.insert(category + "|" + key, value);
|
||||
}
|
||||
}
|
||||
return(true);
|
||||
}
|
||||
|
||||
QStringList cMediaInfo::keys()
|
||||
{
|
||||
return(m_values.keys());
|
||||
}
|
||||
|
||||
QString cMediaInfo::value(const QString& key)
|
||||
{
|
||||
return(m_values.value(key));
|
||||
}
|
||||
|
||||
cMediaInfoList::cMediaInfoList()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
cMediaInfo* cMediaInfoList::add(const QString& fileName)
|
||||
{
|
||||
cMediaInfo* lpNew = new cMediaInfo;
|
||||
append(lpNew);
|
||||
lpNew->fromFile(fileName);
|
||||
m_keyList.append(lpNew->keys());
|
||||
m_keyList.removeDuplicates();
|
||||
|
||||
return(lpNew);
|
||||
}
|
||||
|
||||
QStringList cMediaInfoList::keys()
|
||||
{
|
||||
m_keyList.sort(Qt::CaseInsensitive);
|
||||
return(m_keyList);
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
#ifndef CMEDIAINFO_H
|
||||
#define CMEDIAINFO_H
|
||||
|
||||
#include <QString>
|
||||
#include <QMap>
|
||||
#include <QList>
|
||||
#include <QStringList>
|
||||
|
||||
#include <QMetaType>
|
||||
|
||||
|
||||
class cMediaInfo
|
||||
{
|
||||
public:
|
||||
cMediaInfo();
|
||||
|
||||
bool fromFile(const QString& fileName);
|
||||
QStringList keys();
|
||||
|
||||
QString value(const QString& key);
|
||||
|
||||
private:
|
||||
QMap<QString, QString> m_values;
|
||||
};
|
||||
|
||||
Q_DECLARE_METATYPE(cMediaInfo*)
|
||||
|
||||
class cMediaInfoList : public QList<cMediaInfo*>
|
||||
{
|
||||
public:
|
||||
cMediaInfoList();
|
||||
|
||||
cMediaInfo* add(const QString& fileName);
|
||||
QStringList keys();
|
||||
|
||||
private:
|
||||
QStringList m_keyList;
|
||||
bool m_pictures;
|
||||
bool m_videos;
|
||||
};
|
||||
|
||||
#endif // CMEDIAINFO_H
|
||||
@@ -0,0 +1,51 @@
|
||||
QT += core gui sql multimedia
|
||||
|
||||
win32-msvc* {
|
||||
contains(QT_ARCH, i386) {
|
||||
message("msvc 32-bit")
|
||||
} else {
|
||||
message("msvc 64-bit")
|
||||
}
|
||||
}
|
||||
|
||||
win32-g++ {
|
||||
message("mingw")
|
||||
INCLUDEPATH += C:\dev\3rdParty\libmediainfo\Developers\Source\MediaInfoDLL
|
||||
LIBS += -LC:\dev\3rdParty\libmediainfo -lMediaInfo
|
||||
}
|
||||
|
||||
unix {
|
||||
message("*nix")
|
||||
}
|
||||
|
||||
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
|
||||
|
||||
CONFIG += c++11
|
||||
|
||||
# The following define makes your compiler emit warnings if you use
|
||||
# any Qt feature that has been marked deprecated (the exact warnings
|
||||
# depend on your compiler). Please consult the documentation of the
|
||||
# deprecated API in order to know how to port your code away from it.
|
||||
DEFINES += QT_DEPRECATED_WARNINGS
|
||||
|
||||
# You can also make your code fail to compile if it uses deprecated APIs.
|
||||
# In order to do so, uncomment the following line.
|
||||
# You can also select to disable deprecated APIs only up to a certain version of Qt.
|
||||
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0
|
||||
|
||||
SOURCES += \
|
||||
cmediainfo.cpp \
|
||||
main.cpp \
|
||||
cmainwindow.cpp
|
||||
|
||||
HEADERS += \
|
||||
cmainwindow.h \
|
||||
cmediainfo.h
|
||||
|
||||
FORMS += \
|
||||
cmainwindow.ui
|
||||
|
||||
# Default rules for deployment.
|
||||
qnx: target.path = /tmp/$${TARGET}/bin
|
||||
else: unix:!android: target.path = /opt/$${TARGET}/bin
|
||||
!isEmpty(target.path): INSTALLS += target
|
||||
Reference in New Issue
Block a user