QVariant CommentsModel::data (const QModelIndex& index, int role) const
{
if (!index.isValid ())
return QVariant ();
LJComment *comment = static_cast<LJComment*> (index.internalPointer ());
switch (role)
{
case CRParentTalkID:
return comment->GetParentTalkID ();
case CRPosterID:
return comment->GetPosterID ();
case CRState:
return comment->GetState ();
case CRSubject:
return comment->GetSubject ();
case CRBody:
return comment->GetBody ();
case CRLevel:
return comment->GetTempLevel () % 4;
case CRDTalkID:
return comment->GetDTalkID ();
case CRPosterName:
return comment->GetPosterName ();
case CRPostDate:
return comment->GetPostDate ();
case CRIsShown:
return comment->IsShown ();
case CRIsLoaded:
return comment->IsLoaded ();
case CRUserPicUrl:
return comment->GetUserPicUrl ();
case CRPrivileges:
return static_cast<int> (comment->GetPrivileges ());
case CRChildrenCount:
return comment->GetChildrenCount ();
case CRComment:
return QVariant::fromValue (parent (index).internalPointer ());
default:
return QVariant ();
}
return QVariant ();
}
QHash<int, QByteArray> CommentsModel::roleNames () const
{
QHash<int, QByteArray> roles;
roles [CRParentTalkID] = "commentParentTalkID";
roles [CRPosterID] = "commentPosterID";
roles [CRState] = "commentState";
roles [CRSubject] = "commentSubject";
roles [CRBody] = "commentBody";
roles [CRLevel] = "commentLevel";
roles [CRDTalkID] = "commentDTalkID";
roles [CRPosterName] = "commentPosterName";
roles [CRPostDate] = "commentPostDate";
roles [CRIsShown] = "commentIsShown";
roles [CRIsLoaded] = "commentIsLoaded";
roles [CRUserPicUrl] = "commentUserPicUrl";
roles [CRPrivileges] = "commentPrivileges";
roles [CRChildrenCount] = "commentChildrenCount";
return roles;
}
Button {
anchors.horizontalCenter: parent.horizontalCenter
visible: commentChildrenCount
//enabled: commentChildrenCount != 0
text: qsTr ("Load comments (%1)").arg (commentChildrenCount)
onClicked: {
console.log ("condition:", commentChildrenCount)
console.log ("visible:", visible)
mnemosyManager.loadComment (commentDTalkID)
}
}