Hello.
I am creating an FtpFileSystemModel, and, for that, I am using QAbstractItemModel as a base, which I have never subclassed before.
After quite a few problems I have reached the point where my ftp files are displayed in a QTreeView, just like a QFileSystemModel would do with a local fs.
There are a few quirks here and there, though. The thing that worries me is that all the indexes (or "cells"), show a ticker next to them. This is better illustrated with a screenshot:
20140517.122325.jpg
See the ftp file listing to the middle-right portion of the screenshot.
Before you ask, the flags() method is this:
Qt
::ItemFlags FtpFileSystemModel
::flags(const QModelIndex &index
) const{
if(!index.isValid())
{
return 0;
}
Qt::ItemFlags flags = Qt::ItemIsEnabled | Qt::ItemIsSelectable;
qDebug
() << Q_FUNC_INFO <<
QString("flags: %1").
arg(flags
);
return flags;
}
Qt::ItemFlags FtpFileSystemModel::flags(const QModelIndex &index) const
{
if(!index.isValid())
{
return 0;
}
Qt::ItemFlags flags = Qt::ItemIsEnabled | Qt::ItemIsSelectable;
qDebug() << Q_FUNC_INFO << QString("flags: %1").arg(flags);
return flags;
}
To copy to clipboard, switch view to plain text mode
As you see, neither of Qt::ItemIsUserCheckable or Qt::ItemIsTristate is set.
I have also a problem with alignment, but I haven't dug much into it. I am setting these in data(), but they don't seem to do anything:
if(role == Qt::TextAlignmentRole)
{
Qt::Alignment flags = 0;
if(index.column() == 0 || index.column() == 1)
{
flags = Qt::AlignVCenter | Qt::AlignLeft;
}
else
{
flags = Qt::AlignVCenter | Qt::AlignRight;
}
}
if(role == Qt::TextAlignmentRole)
{
Qt::Alignment flags = 0;
if(index.column() == 0 || index.column() == 1)
{
flags = Qt::AlignVCenter | Qt::AlignLeft;
}
else
{
flags = Qt::AlignVCenter | Qt::AlignRight;
}
}
To copy to clipboard, switch view to plain text mode
Thanks for any idea you can share
Bookmarks