{
if(!head || row < 0 || column < 0)
{
}
ParseNode * parentNode = nodeFromIndex(parent);
ParseNode * childNode = parentNode->getChild(row);
if(!childNode)
{
}
return createIndex(row, column, childNode);
}
{
ParseNode * node = nodeFromIndex(child);
if(!node)
ParseNode * parentNode = node->getParent();
if(!parentNode)
{
}
ParseNode * grandparentNode = parentNode->getParent();
if(!grandparentNode)
{
}
int row = grandparentNode->indexOf(parentNode);
return createIndex(row, 0, parentNode);
}
int ParseList
::rowCount(const QModelIndex &parent
) const {
if (parent.column() > 0)
{
return 0;
}
ParseNode *parentNode = nodeFromIndex(parent);
if(!parentNode)
{
return 0;
}
return parentNode->childCount();
}
int ParseList
::columnCount(const QModelIndex &parent
) const {
return ParseNode::dataColumns;
}
{
if(!index.isValid())
{
}
ParseNode * node = nodeFromIndex(index);
if (!node)
{
}
//TODO: Decide if smaller functions would be better
// - small private functions
switch(index.column())
{
case 0:
switch(role)
{
case Qt::DisplayRole:
{
return node->getPathString(); //stored as QString in node
}
case Qt::WhatsThisRole:
case Qt::StatusTipRole:
case Qt::ToolTipRole:
return node->getPathString();//tr("Path of selected log"); //Added for debug
default:
}
case 1:
switch(role)
{
case Qt::DisplayRole:
return node->getParseStatus() ? tr("Yes") : tr("No"); //Stored as bool in underlying class
case Qt::WhatsThisRole:
case Qt::StatusTipRole:
case Qt::ToolTipRole:
return node->getParseStatus() ?
tr("Log has been parsed") :
tr("Log has not been parsed");
default:
}
case 2:
switch(role)
{
case Qt::DisplayRole:
switch(node->getPathType()) //public enum declared by ParseNode
{
case ParseNode::File:
return tr("File");
case ParseNode::FileButNotReadable:
return tr("File - Unreadable");
case ParseNode::Directory:
return tr("Directory");
case ParseNode::Invalid:
return tr("Invalid");
case ParseNode::Device:
return tr("Device");
default:
}
case Qt::WhatsThisRole:
case Qt::StatusTipRole:
case Qt::ToolTipRole:
switch(node->getPathType())
{
case ParseNode::File:
return tr("File from system");
case ParseNode::FileButNotReadable:
return tr("File exists, but is unreadable");
case ParseNode::Directory:
return tr("Directory from system");
case ParseNode::Invalid:
return tr("Invalid path specified");
default:
}
default:
}
default:
}
}
QModelIndex ParseList::index(int row, int column, const QModelIndex &parent) const
{
if(!head || row < 0 || column < 0)
{
return QModelIndex();
}
ParseNode * parentNode = nodeFromIndex(parent);
ParseNode * childNode = parentNode->getChild(row);
if(!childNode)
{
return QModelIndex();
}
QModelIndex temp = createIndex(row,column, childNode);
return createIndex(row, column, childNode);
}
QModelIndex ParseList::parent(const QModelIndex &child) const
{
ParseNode * node = nodeFromIndex(child);
if(!node)
return QModelIndex();
ParseNode * parentNode = node->getParent();
if(!parentNode)
{
return QModelIndex();
}
ParseNode * grandparentNode = parentNode->getParent();
if(!grandparentNode)
{
return QModelIndex();
}
int row = grandparentNode->indexOf(parentNode);
return createIndex(row, 0, parentNode);
}
int ParseList::rowCount(const QModelIndex &parent) const
{
if (parent.column() > 0)
{
return 0;
}
ParseNode *parentNode = nodeFromIndex(parent);
if(!parentNode)
{
return 0;
}
return parentNode->childCount();
}
int ParseList::columnCount(const QModelIndex &parent) const
{
return ParseNode::dataColumns;
}
QVariant ParseList::data(const QModelIndex &index, int role) const
{
if(!index.isValid())
{
return QVariant();
}
ParseNode * node = nodeFromIndex(index);
if (!node)
{
return QVariant();
}
//TODO: Decide if smaller functions would be better
// - small private functions
switch(index.column())
{
case 0:
switch(role)
{
case Qt::DisplayRole:
{
return node->getPathString(); //stored as QString in node
}
case Qt::WhatsThisRole:
case Qt::StatusTipRole:
case Qt::ToolTipRole:
return node->getPathString();//tr("Path of selected log"); //Added for debug
default:
return QVariant();
}
case 1:
switch(role)
{
case Qt::DisplayRole:
return node->getParseStatus() ? tr("Yes") : tr("No"); //Stored as bool in underlying class
case Qt::WhatsThisRole:
case Qt::StatusTipRole:
case Qt::ToolTipRole:
return node->getParseStatus() ?
tr("Log has been parsed") :
tr("Log has not been parsed");
default:
return QVariant();
}
case 2:
switch(role)
{
case Qt::DisplayRole:
switch(node->getPathType()) //public enum declared by ParseNode
{
case ParseNode::File:
return tr("File");
case ParseNode::FileButNotReadable:
return tr("File - Unreadable");
case ParseNode::Directory:
return tr("Directory");
case ParseNode::Invalid:
return tr("Invalid");
case ParseNode::Device:
return tr("Device");
default:
return QVariant();
}
case Qt::WhatsThisRole:
case Qt::StatusTipRole:
case Qt::ToolTipRole:
switch(node->getPathType())
{
case ParseNode::File:
return tr("File from system");
case ParseNode::FileButNotReadable:
return tr("File exists, but is unreadable");
case ParseNode::Directory:
return tr("Directory from system");
case ParseNode::Invalid:
return tr("Invalid path specified");
default:
return QVariant();
}
default:
return QVariant();
}
default:
return QVariant();
}
}
To copy to clipboard, switch view to plain text mode
Bookmarks