SbBool SoTexture2::readInstance(SoInput *in, unsigned short flags) // //////////////////////////////////////////////////////////////////////// { // Detach filename sensor temporarily filenameSensor->detach(); // Read field info as usual. SbBool readOK = SoNode::readInstance(in, flags); if (readOK && !filename.isDefault()) { // See the comment in SoFile::readInstance for why we do this // and don't just let the FieldSensor take care of reading in // the image. setReadStatus(readOK); (*(filenameSensor->getFunction()))(filenameSensor->getData(), NULL); // Don't set readOK, because not being able to read the image // isn't a fatal error. But do issue a read error: if (getReadStatus() == FALSE) SoReadError::post(in, "Could not read texture file %s", filename.getValue().getString()); } // Reattach sensor filenameSensor->attach(&filename); return readOK; }
void PostedItem::readToggled(bool checked) { if (mInFill) { return; } RsGxsGrpMsgIdPair msgPair = std::make_pair(groupId(), messageId()); uint32_t token; rsPosted->setMessageReadStatus(token, msgPair, !checked); setReadStatus(false, checked); }
void GxsChannelPostItem::readToggled(bool checked) { if (mInFill) { return; } mCloseOnRead = false; RsGxsGrpMsgIdPair msgPair = std::make_pair(groupId(), messageId()); uint32_t token; rsGxsChannels->setMessageReadStatus(token, msgPair, !checked); setReadStatus(false, checked); }
void PostedItem::fill() { if (isLoading()) { /* Wait for all requests */ return; } mInFill = true; QDateTime qtime; qtime.setTime_t(mPost.mMeta.mPublishTs); QString timestamp = qtime.toString("hh:mm dd-MMM-yyyy"); ui->dateLabel->setText(timestamp); ui->fromLabel->setId(mPost.mMeta.mAuthorId); // Use QUrl to check/parse our URL // The only combination that seems to work: load as EncodedUrl, extract toEncoded(). QByteArray urlarray(mPost.mLink.c_str()); QUrl url = QUrl::fromEncoded(urlarray.trimmed()); QString urlstr = "Invalid Link"; QString sitestr = "Invalid Link"; bool urlOkay = url.isValid(); if (urlOkay) { QString scheme = url.scheme(); if ((scheme != "https") && (scheme != "http") && (scheme != "ftp") && (scheme != "retroshare")) { urlOkay = false; sitestr = "Invalid Link Scheme"; } } if (urlOkay) { urlstr = QString("<a href=\""); urlstr += QString(url.toEncoded()); urlstr += QString("\" ><span style=\" text-decoration: underline; color:#2255AA;\"> "); urlstr += messageName(); urlstr += QString(" </span></a>"); QString siteurl = url.scheme() + "://" + url.host(); sitestr = QString("<a href=\"%1\" ><span style=\" text-decoration: underline; color:#2255AA;\"> %2 </span></a>").arg(siteurl).arg(siteurl); } ui->titleLabel->setText(urlstr); ui->siteLabel->setText(sitestr); //QString score = "Hot" + QString::number(post.mHotScore); //score += " Top" + QString::number(post.mTopScore); //score += " New" + QString::number(post.mNewScore); QString score = QString::number(mPost.mTopScore); ui->scoreLabel->setText(score); // FIX THIS UP LATER. ui->notes->setText(QString::fromUtf8(mPost.mNotes.c_str())); // differences between Feed or Top of Comment. if (mFeedHolder) { // feed. ui->frame_notes->hide(); //frame_comment->show(); ui->commentButton->show(); if (mPost.mComments) { QString commentText = QString::number(mPost.mComments); commentText += " "; commentText += tr("Comments"); ui->commentButton->setText(commentText); } else { ui->commentButton->setText(tr("Comment")); } setReadStatus(IS_MSG_NEW(mPost.mMeta.mMsgStatus), IS_MSG_UNREAD(mPost.mMeta.mMsgStatus) || IS_MSG_NEW(mPost.mMeta.mMsgStatus)); } else { // no feed. if(ui->notes->text().isEmpty()) { ui->frame_notes->hide(); } else { ui->frame_notes->show(); } //frame_comment->hide(); ui->commentButton->hide(); ui->readButton->hide(); ui->newLabel->hide(); } if (mIsHome) { ui->clearButton->hide(); ui->readAndClearButton->hide(); } else { ui->clearButton->show(); ui->readAndClearButton->show(); } // disable voting buttons - if they have already voted. if (mPost.mMeta.mMsgStatus & GXS_SERV::GXS_MSG_STATUS_VOTE_MASK) { ui->voteUpButton->setEnabled(false); ui->voteDownButton->setEnabled(false); } #if 0 uint32_t up, down, nComments; bool ok = rsPosted->retrieveScores(mPost.mMeta.mServiceString, up, down, nComments); if(ok) { int32_t vote = up - down; scoreLabel->setText(QString::number(vote)); numCommentsLabel->setText("<p style=\" margin-top:0px; margin-bottom:0px; margin-left:0px;" "margin-right:0px; -qt-block-indent:0; text-indent:0px;\"><span" "style=\" font-size:10pt; font-weight:600;\">#</span><span " "style=\" font-size:8pt; font-weight:600;\"> Comments: " + QString::number(nComments) + "</span></p>"); } #endif mInFill = false; emit sizeChanged(this); }
void GxsChannelPostItem::fill() { /* fill in */ if (isLoading()) { /* Wait for all requests */ return; } #ifdef DEBUG_ITEM std::cerr << "GxsChannelPostItem::fill()"; std::cerr << std::endl; #endif mInFill = true; QString title; if (!mIsHome) { if (mCloseOnRead && !IS_MSG_NEW(mPost.mMeta.mMsgStatus)) { removeItem(); } title = tr("Channel Feed") + ": "; RetroShareLink link; link.createGxsGroupLink(RetroShareLink::TYPE_CHANNEL, mPost.mMeta.mGroupId, groupName()); title += link.toHtml(); ui->titleLabel->setText(title); RetroShareLink msgLink; msgLink.createGxsMessageLink(RetroShareLink::TYPE_CHANNEL, mPost.mMeta.mGroupId, mPost.mMeta.mMsgId, messageName()); ui->subjectLabel->setText(msgLink.toHtml()); if (IS_GROUP_SUBSCRIBED(mGroup.mMeta.mSubscribeFlags) || IS_GROUP_ADMIN(mGroup.mMeta.mSubscribeFlags)) { ui->unsubscribeButton->setEnabled(true); } else { ui->unsubscribeButton->setEnabled(false); } ui->readButton->hide(); ui->newLabel->hide(); ui->copyLinkButton->hide(); if (IS_MSG_NEW(mPost.mMeta.mMsgStatus)) { mCloseOnRead = true; } } else { /* subject */ ui->titleLabel->setText(QString::fromUtf8(mPost.mMeta.mMsgName.c_str())); ui->subjectLabel->setText(RsHtml().formatText(NULL, QString::fromUtf8(mPost.mMsg.c_str()), RSHTML_FORMATTEXT_EMBED_SMILEYS | RSHTML_FORMATTEXT_EMBED_LINKS)); //QString score = QString::number(post.mTopScore); // scoreLabel->setText(score); /* disable buttons: deletion facility not enabled with cache services yet */ ui->clearButton->setEnabled(false); ui->unsubscribeButton->setEnabled(false); ui->clearButton->hide(); ui->readAndClearButton->hide(); ui->unsubscribeButton->hide(); ui->copyLinkButton->show(); if (IS_GROUP_SUBSCRIBED(mGroup.mMeta.mSubscribeFlags) || IS_GROUP_ADMIN(mGroup.mMeta.mSubscribeFlags)) { ui->readButton->setVisible(true); setReadStatus(IS_MSG_NEW(mPost.mMeta.mMsgStatus), IS_MSG_UNREAD(mPost.mMeta.mMsgStatus) || IS_MSG_NEW(mPost.mMeta.mMsgStatus)); } else { ui->readButton->setVisible(false); ui->newLabel->setVisible(false); } mCloseOnRead = false; } // differences between Feed or Top of Comment. if (mFeedHolder) { if (mIsHome) { ui->commentButton->show(); } else { ui->commentButton->hide(); } // THIS CODE IS doesn't compile - disabling until fixed. #if 0 if (post.mComments) { QString commentText = QString::number(post.mComments); commentText += " "; commentText += tr("Comments"); ui->commentButton->setText(commentText); } else { ui->commentButton->setText(tr("Comment")); } #endif } else { ui->commentButton->hide(); } // disable voting buttons - if they have already voted. /*if (post.mMeta.mMsgStatus & GXS_SERV::GXS_MSG_STATUS_VOTE_MASK) { voteUpButton->setEnabled(false); voteDownButton->setEnabled(false); }*/ ui->msgLabel->setText(RsHtml().formatText(NULL, QString::fromUtf8(mPost.mMsg.c_str()), RSHTML_FORMATTEXT_EMBED_SMILEYS | RSHTML_FORMATTEXT_EMBED_LINKS)); ui->msgFrame->setVisible(!mPost.mMsg.empty()); ui->datetimelabel->setText(DateTime::formatLongDateTime(mPost.mMeta.mPublishTs)); ui->filelabel->setText(QString("(%1 %2) %3").arg(mPost.mCount).arg(tr("Files")).arg(misc::friendlyUnit(mPost.mSize))); if (mFileItems.empty() == false) { std::list<SubFileItem *>::iterator it; for(it = mFileItems.begin(); it != mFileItems.end(); ++it) { delete(*it); } mFileItems.clear(); } std::list<RsGxsFile>::const_iterator it; for(it = mPost.mFiles.begin(); it != mPost.mFiles.end(); ++it) { /* add file */ std::string path; SubFileItem *fi = new SubFileItem(it->mHash, it->mName, path, it->mSize, SFI_STATE_REMOTE | SFI_TYPE_CHANNEL, RsPeerId()); mFileItems.push_back(fi); /* check if the file is a media file */ if (!misc::isPreviewable(QFileInfo(QString::fromUtf8(it->mName.c_str())).suffix())) { fi->mediatype(); /* check if the file is not a media file and change text */ ui->playButton->setText(tr("Open")); ui->playButton->setToolTip(tr("Open File")); } else { ui->playButton->setText(tr("Play")); ui->playButton->setToolTip(tr("Play Media")); } QLayout *layout = ui->expandFrame->layout(); layout->addWidget(fi); } if(mPost.mThumbnail.mData != NULL) { QPixmap thumbnail; thumbnail.loadFromData(mPost.mThumbnail.mData, mPost.mThumbnail.mSize, "PNG"); // Wiping data - as its been passed to thumbnail. ui->logoLabel->setPixmap(thumbnail); } mInFill = false; }