OTHER: static open method for diriterators and fix typo
This commit is contained in:
parent
e4b23447dc
commit
7d978a25bc
5 changed files with 26 additions and 14 deletions
|
@ -20,15 +20,16 @@
|
||||||
|
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
|
|
||||||
DirIterator::DirIterator (const QDir & dir)
|
DirIterator::DirIterator (const QDir & dir) : DirIteratorBase ()
|
||||||
{
|
{
|
||||||
m_dir = dir;
|
m_dir = dir;
|
||||||
finish_init ();
|
finish_init ();
|
||||||
}
|
}
|
||||||
|
|
||||||
DirIterator::DirIterator (const QString & path)
|
DirIterator::DirIterator (const QString & path) : DirIteratorBase ()
|
||||||
{
|
{
|
||||||
m_dir = QDir (path);
|
m_dir = QDir (path);
|
||||||
|
finish_init ();
|
||||||
}
|
}
|
||||||
|
|
||||||
DirIterator::~DirIterator ()
|
DirIterator::~DirIterator ()
|
||||||
|
@ -105,5 +106,3 @@ DirIterator::entry ()
|
||||||
|
|
||||||
return m_device;
|
return m_device;
|
||||||
}
|
}
|
||||||
|
|
||||||
#include "diriterator.moc"
|
|
||||||
|
|
|
@ -24,10 +24,8 @@
|
||||||
#include <QStringList>
|
#include <QStringList>
|
||||||
|
|
||||||
|
|
||||||
class DirIterator : public QObject, public virtual DirIteratorBase
|
class DirIterator : public DirIteratorBase
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
DirIterator (const QDir & dir);
|
DirIterator (const QDir & dir);
|
||||||
DirIterator (const QString & path);
|
DirIterator (const QString & path);
|
||||||
|
|
|
@ -15,7 +15,10 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "diriteratorbase.h"
|
#include "diriteratorbase.h"
|
||||||
|
#include "diriterator.h"
|
||||||
#include <QDataStream>
|
#include <QDataStream>
|
||||||
|
#include "QFile"
|
||||||
|
|
||||||
|
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
|
|
||||||
|
@ -35,3 +38,14 @@ DirIteratorBase::pixmapEntry ()
|
||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
DirIteratorBase *
|
||||||
|
DirIteratorBase::open(const QString &path)
|
||||||
|
{
|
||||||
|
QDir dir(path);
|
||||||
|
if (!dir.exists ()) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
return new DirIterator (dir);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
@ -15,8 +15,9 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef __DIRITERATORBASE_H__
|
#ifndef __DIRITERATORBASE_H__
|
||||||
#define __DIRITERATIRBASE_H__
|
#define __DIRITERATORBASE_H__
|
||||||
|
|
||||||
|
#include <QDir>
|
||||||
#include <QString>
|
#include <QString>
|
||||||
#include <QPointer>
|
#include <QPointer>
|
||||||
#include <QIODevice>
|
#include <QIODevice>
|
||||||
|
@ -33,11 +34,12 @@ public:
|
||||||
|
|
||||||
virtual QPointer<QIODevice> entry () = 0;
|
virtual QPointer<QIODevice> entry () = 0;
|
||||||
|
|
||||||
|
static DirIteratorBase *open(const QString &path);
|
||||||
|
|
||||||
// Included because I'm lazy, returns a QPixmap for the current entry.
|
// Included because I'm lazy, returns a QPixmap for the current entry.
|
||||||
// If no pixmap can be createt for the current entry, an empty pixmap is
|
// If no pixmap can be createt for the current entry, an empty pixmap is
|
||||||
// returned
|
// returned
|
||||||
QPixmap pixmapEntry ();
|
QPixmap pixmapEntry ();
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -15,7 +15,7 @@
|
||||||
|
|
||||||
#include "skin.h"
|
#include "skin.h"
|
||||||
|
|
||||||
#include "diriterator.h"
|
#include "diriteratorbase.h"
|
||||||
|
|
||||||
#include <QDir>
|
#include <QDir>
|
||||||
#include <QPainter>
|
#include <QPainter>
|
||||||
|
@ -676,9 +676,10 @@ Skin::handle_pledit_txt (QIODevice *device)
|
||||||
bool
|
bool
|
||||||
Skin::setSkin (const QString& path)
|
Skin::setSkin (const QString& path)
|
||||||
{
|
{
|
||||||
QDir dir(path);
|
DirIteratorBase *iter = DirIteratorBase::open(path);
|
||||||
if (!dir.exists ())
|
if (iter == 0) {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
m_path = path;
|
m_path = path;
|
||||||
|
|
||||||
|
@ -699,8 +700,6 @@ Skin::setSkin (const QString& path)
|
||||||
QPixmap p_numbers;
|
QPixmap p_numbers;
|
||||||
QPixmap p_volume;
|
QPixmap p_volume;
|
||||||
|
|
||||||
DirIterator *iter = new DirIterator(dir);
|
|
||||||
|
|
||||||
while (iter->hasNext ()) {
|
while (iter->hasNext ()) {
|
||||||
QString entry = iter->next ().toLower ();
|
QString entry = iter->next ().toLower ();
|
||||||
if (entry.endsWith (".txt")) {
|
if (entry.endsWith (".txt")) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue