1
/**************************************************************************
3
* Copyright 2015 Canonical Ltd.
4
* Copyright 2015 Carlos J Mazieri <carlos.mazieri@gmail.com>
6
* This program is free software; you can redistribute it and/or modify
7
* it under the terms of the GNU Lesser General Public License as published by
8
* the Free Software Foundation; version 3.
10
* This program is distributed in the hope that it will be useful,
11
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
* GNU Lesser General Public License for more details.
15
* You should have received a copy of the GNU Lesser General Public License
16
* along with this program. If not, see <http://www.gnu.org/licenses/>.
18
* File: smblocationdiriterator.cpp
22
#include "smblocationdiriterator.h"
23
#include "smbiteminfo.h"
26
#define INIT_ATTR(path,smb) SmbObject(path,smb), m_curItem(-1)
28
#define GOOD_INDEX() (m_curItem >= 0 && m_curItem < m_urlItems.count())
31
SmbLocationDirIterator::SmbLocationDirIterator(const QString &path,
32
const QStringList &nameFilters,
33
QDir::Filters filters,
34
QDirIterator::IteratorFlags flags,
35
Const_SmbUtil_Ptr smb,
36
LocationItemDirIterator::LoadMode loadmode)
37
: LocationItemDirIterator(path, nameFilters, filters, flags, loadmode)
38
, INIT_ATTR(path, smb)
40
if (loadmode == LocationItemDirIterator::LoadOnConstructor)
47
SmbLocationDirIterator::SmbLocationDirIterator(const QString &path,
48
QDir::Filters filters,
49
QDirIterator::IteratorFlags flags,
50
Const_SmbUtil_Ptr smb,
51
LocationItemDirIterator::LoadMode loadmode)
52
: LocationItemDirIterator(path,filters,flags, loadmode)
53
, INIT_ATTR(path, smb)
55
if (loadmode == LocationItemDirIterator::LoadOnConstructor)
62
SmbLocationDirIterator::SmbLocationDirIterator(const QString &path,
63
QDirIterator::IteratorFlags flags,
64
Const_SmbUtil_Ptr smb,
65
LocationItemDirIterator::LoadMode loadmode)
66
: LocationItemDirIterator(path,flags, loadmode)
67
, INIT_ATTR(path, smb)
69
if (loadmode == LocationItemDirIterator::LoadOnConstructor)
76
SmbLocationDirIterator::~SmbLocationDirIterator()
82
QString SmbLocationDirIterator::next()
87
ret = m_urlItems.at(++m_curItem);
93
bool SmbLocationDirIterator::hasNext() const
95
return m_urlItems.count() > 0 && m_curItem < (m_urlItems.count() -1);
99
DirItemInfo SmbLocationDirIterator::fileInfo() const
103
SmbItemInfo info(m_urlItems.at(m_curItem), m_smb);
106
return SmbItemInfo();
110
QString SmbLocationDirIterator::fileName() const
115
QStringList paths = UrlItemInfo::separatePathFilename(m_urlItems.at(m_curItem));
116
if (paths.count() == 2)
125
QString SmbLocationDirIterator::filePath() const
127
QString fullpathname;
130
fullpathname = m_urlItems.at(m_curItem);
136
void SmbLocationDirIterator::load()
138
bool recursive = m_flags == QDirIterator::Subdirectories ? true : false;
139
m_urlItems = smbObj()->listContent(path(), recursive, m_filters, m_nameFilters);