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>
|
||||
|
||||
DirIterator::DirIterator (const QDir & dir)
|
||||
DirIterator::DirIterator (const QDir & dir) : DirIteratorBase ()
|
||||
{
|
||||
m_dir = dir;
|
||||
finish_init ();
|
||||
}
|
||||
|
||||
DirIterator::DirIterator (const QString & path)
|
||||
DirIterator::DirIterator (const QString & path) : DirIteratorBase ()
|
||||
{
|
||||
m_dir = QDir (path);
|
||||
finish_init ();
|
||||
}
|
||||
|
||||
DirIterator::~DirIterator ()
|
||||
|
@ -105,5 +106,3 @@ DirIterator::entry ()
|
|||
|
||||
return m_device;
|
||||
}
|
||||
|
||||
#include "diriterator.moc"
|
||||
|
|
|
@ -24,10 +24,8 @@
|
|||
#include <QStringList>
|
||||
|
||||
|
||||
class DirIterator : public QObject, public virtual DirIteratorBase
|
||||
class DirIterator : public DirIteratorBase
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
DirIterator (const QDir & dir);
|
||||
DirIterator (const QString & path);
|
||||
|
|
|
@ -15,7 +15,10 @@
|
|||
*/
|
||||
|
||||
#include "diriteratorbase.h"
|
||||
#include "diriterator.h"
|
||||
#include <QDataStream>
|
||||
#include "QFile"
|
||||
|
||||
|
||||
#include <QDebug>
|
||||
|
||||
|
@ -35,3 +38,14 @@ DirIteratorBase::pixmapEntry ()
|
|||
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__
|
||||
#define __DIRITERATIRBASE_H__
|
||||
#define __DIRITERATORBASE_H__
|
||||
|
||||
#include <QDir>
|
||||
#include <QString>
|
||||
#include <QPointer>
|
||||
#include <QIODevice>
|
||||
|
@ -33,11 +34,12 @@ public:
|
|||
|
||||
virtual QPointer<QIODevice> entry () = 0;
|
||||
|
||||
static DirIteratorBase *open(const QString &path);
|
||||
|
||||
// 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
|
||||
// returned
|
||||
QPixmap pixmapEntry ();
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
|
||||
#include "skin.h"
|
||||
|
||||
#include "diriterator.h"
|
||||
#include "diriteratorbase.h"
|
||||
|
||||
#include <QDir>
|
||||
#include <QPainter>
|
||||
|
@ -676,9 +676,10 @@ Skin::handle_pledit_txt (QIODevice *device)
|
|||
bool
|
||||
Skin::setSkin (const QString& path)
|
||||
{
|
||||
QDir dir(path);
|
||||
if (!dir.exists ())
|
||||
DirIteratorBase *iter = DirIteratorBase::open(path);
|
||||
if (iter == 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
m_path = path;
|
||||
|
||||
|
@ -699,8 +700,6 @@ Skin::setSkin (const QString& path)
|
|||
QPixmap p_numbers;
|
||||
QPixmap p_volume;
|
||||
|
||||
DirIterator *iter = new DirIterator(dir);
|
||||
|
||||
while (iter->hasNext ()) {
|
||||
QString entry = iter->next ().toLower ();
|
||||
if (entry.endsWith (".txt")) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue