~mzanetti/+junk/ubtd

« back to all changes in this revision

Viewing changes to app/obexd.cpp

  • Committer: Michael Zanetti
  • Date: 2016-08-21 10:28:36 UTC
  • Revision ID: michael.zanetti@canonical.com-20160821102836-mam1manqthov2um9
improve!

Show diffs side-by-side

added added

removed removed

Lines of Context:
20
20
            qWarning() << "Error registering agent for the default adapter:" << reply.error();
21
21
 
22
22
    connect(m_agent, &ObexAgent::authorized, this, &Obexd::newTransfer);
 
23
 
 
24
    QDir dir(QStandardPaths::writableLocation(QStandardPaths::CacheLocation));
 
25
    qDebug() << "have entries:" << dir.entryList() << dir.path();
 
26
    foreach (const QFileInfo &fileInfo, dir.entryInfoList(QDir::Files)) {
 
27
        Transfer* t = new Transfer("/completed", fileInfo.absoluteFilePath(), this);
 
28
        m_transfers.append(t);
 
29
    }
23
30
}
24
31
 
25
32
int Obexd::rowCount(const QModelIndex &parent) const
41
48
        return m_transfers.at(index.row())->transferred();
42
49
    case RoleStatus:
43
50
        return m_transfers.at(index.row())->status();
 
51
    case RoleDate:
 
52
        return QFileInfo(m_transfers.at(index.row())->filePath() + "/" + m_transfers.at(index.row())->filename()).created();
44
53
    }
45
54
    return QVariant();
46
55
}
53
62
    roles.insert(RoleSize, "size");
54
63
    roles.insert(RoleTransferred, "transferred");
55
64
    roles.insert(RoleStatus, "status");
 
65
    roles.insert(RoleDate, "date");
56
66
    return roles;
57
67
}
58
68
 
 
69
void Obexd::deleteFile(int index)
 
70
{
 
71
    beginRemoveRows(QModelIndex(), index, index);
 
72
    Transfer* t = m_transfers.takeAt(index);
 
73
    QFile f(t->filePath() + "/" + t->filename());
 
74
    f.remove();
 
75
    endRemoveRows();
 
76
}
 
77
 
59
78
void Obexd::newTransfer(const QString &path)
60
79
{
61
80
    qDebug() << "new transfer" << path;