Skip to content

Commit

Permalink
Fixup codestyle
Browse files Browse the repository at this point in the history
  • Loading branch information
neochapay committed Dec 28, 2024
1 parent c575491 commit f05f3a6
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 20 deletions.
30 changes: 15 additions & 15 deletions src/plugin/gallerymodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@
#include <QMimeDatabase>
#include <QStandardPaths>

GalleryModel::GalleryModel(QObject *parent)
: QAbstractListModel{parent}
GalleryModel::GalleryModel(QObject* parent)
: QAbstractListModel { parent }
, m_loading(false)
, m_error(false)
, m_filter(FilterMode::All)
Expand All @@ -41,17 +41,17 @@ GalleryModel::GalleryModel(QObject *parent)

GalleryModel::~GalleryModel()
{
if(m_fileSystemWatcher != nullptr) {
if (m_fileSystemWatcher != nullptr) {
delete m_fileSystemWatcher;
}
}

int GalleryModel::rowCount(const QModelIndex &parent) const
int GalleryModel::rowCount(const QModelIndex& parent) const
{
return m_files.count();
}

QVariant GalleryModel::data(const QModelIndex &index, int role) const
QVariant GalleryModel::data(const QModelIndex& index, int role) const
{
if (!index.isValid()) {
return QVariant();
Expand Down Expand Up @@ -90,23 +90,23 @@ void GalleryModel::setFilter(FilterMode newFilter)

void GalleryModel::addPath(QString url)
{
if(!m_urls.contains(url)) {
if (!m_urls.contains(url)) {
m_urls.append(url);
emit urlsChanged();
}

if(url.isEmpty()) {
if (url.isEmpty()) {
m_urls.append(QStandardPaths::standardLocations(QStandardPaths::PicturesLocation));
emit urlsChanged();
}
}

void GalleryModel::removePatch(QString url)
{
if(url.isEmpty()) {
if (url.isEmpty()) {
m_urls.clear();
emit urlsChanged();
} else if(m_urls.contains(url)) {
} else if (m_urls.contains(url)) {
m_urls.removeAll(url);
emit urlsChanged();
}
Expand All @@ -122,18 +122,18 @@ void GalleryModel::formatFileList()
{
QMimeDatabase db;

if(m_urls.empty()) {
if (m_urls.empty()) {
addPath();
}

foreach (const QString &dirString, m_urls) {
foreach (const QString& dirString, m_urls) {
QDir dir(dirString);
dir.setFilter(QDir::Files | QDir::NoDotAndDotDot | QDir::NoSymLinks);
dir.setSorting(QDir::Time | QDir::Reversed);

QFileInfoList filelistinfo = dir.entryInfoList();
foreach (const QFileInfo &fileinfo, filelistinfo) {
if(m_mimeTypes.contains(db.mimeTypeForFile(fileinfo.absoluteFilePath()).name())) {
foreach (const QFileInfo& fileinfo, filelistinfo) {
if (m_mimeTypes.contains(db.mimeTypeForFile(fileinfo.absoluteFilePath()).name())) {
m_files.append(fileinfo.absoluteFilePath());
}
}
Expand All @@ -152,8 +152,8 @@ void GalleryModel::formatMimeTypes()

m_mimeTypes << "inode/directory";

for (const QMimeType &mime : std::as_const(mimeList)) {
if(m_filter == FilterMode::All) {
for (const QMimeType& mime : std::as_const(mimeList)) {
if (m_filter == FilterMode::All) {
if (mime.name().startsWith(QStringLiteral("image/")) || mime.name().startsWith(QStringLiteral("video/"))) {
m_mimeTypes << mime.name();
}
Expand Down
7 changes: 3 additions & 4 deletions src/plugin/gallerymodel.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,22 +23,21 @@
#include <QAbstractListModel>
#include <QFileSystemWatcher>

class GalleryModel : public QAbstractListModel
{
class GalleryModel : public QAbstractListModel {
Q_OBJECT
Q_PROPERTY(bool loading READ loading NOTIFY loadingChanged FINAL)
Q_PROPERTY(bool error READ error NOTIFY errorChanged FINAL)
Q_PROPERTY(GalleryModel::FilterMode filter READ filter WRITE setFilter NOTIFY filterChanged FINAL)

public:
enum FilterMode{
enum FilterMode {
All,
Images,
Video
};
Q_ENUMS(Filter)

explicit GalleryModel(QObject *parent = nullptr);
explicit GalleryModel(QObject* parent = nullptr);
virtual ~GalleryModel();

int rowCount(const QModelIndex& parent = QModelIndex()) const;
Expand Down
1 change: 0 additions & 1 deletion src/plugin/plugin.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
* Boston, MA 02110-1301, USA.
*/


#ifndef PLUGIN_H
#define PLUGIN_H

Expand Down

0 comments on commit f05f3a6

Please sign in to comment.