Tizen::Ui::Controls::ListItemBase* SelectCalendarPopup::CreateItem(int index, int itemWidth) { CustomItem* pItem = new (std::nothrow) CustomItem(); Calendar* pCalendar = null; String calendarName; pCalendar = static_cast< Calendar* >(__pCalendarList->GetAt(index)); TryReturn(pCalendar != null, null, "Failed to get a calendar"); calendarName = pCalendar->GetName(); if (calendarName.IsEmpty() == true) { calendarName = L"(Calendar ID: "; calendarName.Append(pCalendar->GetRecordId()); calendarName.Append(L")"); } pItem->Construct(Dimension(itemWidth, 100), LIST_ANNEX_STYLE_NORMAL); pItem->AddElement(Rectangle(32, 0, GetClientAreaBounds().width - 64, 112), 1, calendarName, true); if (__selectedCalendarId == pCalendar->GetRecordId()) { __pListView->SetItemChecked(index, true); } return pItem; }
CustomItem *Dictionary::CreateCustomWordItem(int itemWidth) { ListAnnexStyle style = LIST_ANNEX_STYLE_NORMAL; CustomItem *pItem = new CustomItem(); pItem->Construct(Osp::Graphics::Dimension(itemWidth, ITEM_HEIGHT), style); pItem->SetBackgroundColor(LIST_ITEM_DRAWING_STATUS_NORMAL, LangSetting::CUSTOM_WORD); String examples = L""; ArrayList *words = __WCtrl->GetWordsN(WordCtrl::CUSTOM_WORD_LESSON_ID); if (words && words->GetCount() > 0) { int cnt = words->GetCount(); for (int i = 0; i != cnt; i++) { Word * w = static_cast<Word*> (words->GetAt(i)); if (i > 0) examples.Append(","); examples.Append(w->__lern); } words->RemoveAll(true); delete words; } else examples = Utils::GetString("IDS_EMPTY_CUSTOM_LIST"); String name = Utils::GetString("IDS_CUSTOM_WORD_ITEM"); AddItemTitle(pItem, name, itemWidth); AddItemExamples(pItem, itemWidth, examples); return pItem; }
void tst_QGraphicsEffect::inheritOpacity() { QGraphicsScene scene; QGraphicsRectItem *rectItem = new QGraphicsRectItem(0, 0, 10, 10); CustomItem *item = new CustomItem(0, 0, 10, 10, rectItem); scene.addItem(rectItem); item->setGraphicsEffect(new DeviceEffect); item->setPen(Qt::NoPen); item->setBrush(Qt::red); rectItem->setOpacity(0.5); QGraphicsView view(&scene); view.show(); QTest::qWaitForWindowShown(&view); QTRY_VERIFY(item->numRepaints >= 1); int numRepaints = item->numRepaints; rectItem->setOpacity(1); // item should have been rerendered due to opacity changing QTRY_VERIFY(item->numRepaints > numRepaints); }
//Shows image on view. void CustomGraphicsView::addItemToScene(QString strEmfFile) { //Calculate maximum column to be displayed in a view. m_nMaxColumn = (m_nWidth - (m_nOffsetX + (m_nOffsetX / 2))) / (nItemWidth + m_nItemSpace); CustomItem* pImageLabel = new CustomItem(strEmfFile, ++nViewItem); pImageLabel->setPos(m_nOffsetX + (m_nColoumn * (nItemWidth + m_nItemSpace)), m_nOffsetY + (m_nRow * (nItemHeight + m_nItemSpace))); pImageLabel->setAcceptHoverEvents(true); m_graphicsScene.addItem(pImageLabel); if ((0 == m_nRow) && (0 == m_nColoumn)) { m_sceneRect.setX(0); m_sceneRect.setY(0); //m_sceneRect.setWidth(m_nOffsetX + (m_nOffsetX / 2) + nItemWidth); m_sceneRect.setHeight(m_nOffsetY + (m_nOffsetY / 2) + nItemHeight); } else if (0 == m_nColoumn) { m_sceneRect.setHeight(m_sceneRect.height() + nItemHeight + m_nItemSpace); } m_graphicsScene.setSceneRect(m_sceneRect); if (m_nColoumn < (m_nMaxColumn - 1)) { m_nColoumn++; } else { m_nRow++; m_nColoumn = 0; } if (m_sceneRect.height() < m_nHeight) { m_sceneRect.setHeight(m_nHeight); m_graphicsScene.setSceneRect(m_sceneRect); } QList<QGraphicsItem*> visibleItems = this->items(viewport()->rect()); if ((visibleItems.contains(pImageLabel)) && (false == timer->isActive())) { emit loadImage(visibleItems); } }
Tizen::Ui::Controls::ListItemBase* Lanking::CreateItem(int index, int itemWidth) { String* pItemText = null; pItemText = static_cast<String *>(__pRankingTextList->GetAt(index)); CustomItem* pItem = new (std::nothrow) CustomItem(); pItem->Construct(Tizen::Graphics::Dimension(itemWidth,74), LIST_ANNEX_STYLE_NORMAL); pItem->AddElement(Rectangle(10, 10, 460, 74), 300, *pItemText, true); return pItem; }
ListItemBase* PartnerListForm::CreateItem(int groupIndex, int itemIndex, float itemWidth) { ListAnnexStyle style = LIST_ANNEX_STYLE_NORMAL; CustomItem* pItem = new (std::nothrow) CustomItem(); pItem->Construct(Tizen::Graphics::FloatDimension(itemWidth, 210.0f), style); PartnerItem *p; p= new PartnerItem; ArrPartnerItem.GetAt(ITEM_CREATE_CNT++, *p); pItem->AddElement(Rectangle(0, 0, itemWidth, 210.0f), 0, *(static_cast<ICustomElement *>(p))); return pItem; }
void CustomGraphicsView::updateView() { int nRow = 0; int nColoumn = 0; QList<QGraphicsItem *> items = this->items(); m_nMaxColumn = (m_nWidth - (m_nOffsetX + (m_nOffsetX / 2))) / (nItemWidth + m_nItemSpace); if (0 == m_nMaxColumn) { m_nMaxColumn = 1; } m_sceneRect.setWidth(m_nWidth); m_sceneRect.setHeight(m_nOffsetY + (m_nOffsetY / 2) + (ceil(float(items.count()) / m_nMaxColumn) * (nItemHeight + m_nItemSpace))); if (m_sceneRect.height() < m_nHeight) { m_sceneRect.setHeight(m_nHeight); } m_graphicsScene.setSceneRect(m_sceneRect); for (INT index = items.count() - 1; index >= 0; index--) { CustomItem* item = dynamic_cast<CustomItem*> (items[index]); item->setPos(m_nOffsetX + (nColoumn * (nItemWidth + m_nItemSpace)), m_nOffsetY + (nRow * (nItemHeight + m_nItemSpace))); if (nColoumn < (m_nMaxColumn - 1)) { nColoumn++; } else { nRow++; nColoumn = 0; } } m_nRow = nRow; m_nColoumn = nColoumn; timer->start(500); }
void tst_QGraphicsEffect::opacity() { // Make sure the painter's opacity is correct in QGraphicsEffect::draw. QGraphicsScene scene; CustomItem *item = new CustomItem(0, 0, 100, 100); item->setOpacity(0.5); CustomEffect *effect = new CustomEffect; item->setGraphicsEffect(effect); scene.addItem(item); QGraphicsView view(&scene); view.show(); QTest::qWaitForWindowShown(&view); QTRY_VERIFY(effect->numRepaints > 0); QCOMPARE(effect->m_opacity, qreal(0.5)); }
void Item::createItem() { int rndItemIndex = ofRandom(0,3); //int rndItemIndex = 1; if (rndItemIndex ==0) GlobalData::itemType = "letter"; if (rndItemIndex==1) GlobalData::itemType = "health"; if (rndItemIndex ==2 || rndItemIndex ==3) GlobalData::itemType ="multiplier"; CustomItem p; p.setPhysics(1.0, 0.5, 0.3); p.setup(GlobalData::box2dworld.getWorld(), 10, 500, 1); if (GlobalData::itemType == "letter") { if (GlobalData::itemIndex ==0) p. setupTheCustomData("S"); else if (GlobalData::itemIndex ==1) p. setupTheCustomData("P"); else if (GlobalData::itemIndex ==2) p. setupTheCustomData("E"); else if (GlobalData::itemIndex ==3) p. setupTheCustomData("E"); else if (GlobalData::itemIndex ==4) p. setupTheCustomData("C"); else if (GlobalData::itemIndex ==5) p. setupTheCustomData("H"); else GlobalData::itemType = "health"; } if (GlobalData::itemType == "health") { p.setupTheCustomData("health"); } if (GlobalData::itemType =="multiplier") p.setupTheCustomData("multiplier"); GlobalData::items.push_back(p); //GlobalData::box2dworld.getWorld()->SetContactListener(&contactListener); //ofAddListener(GlobalData::box2dworld.contactStartEvents, this, &Item::contactStart); //ofAddListener(GlobalData::box2dworld.contactEndEvents, this, &Item::contactEnd); }
CustomItem *Dictionary::CreateLessonItem(int itemWidth, int lesson) { ListAnnexStyle style = LIST_ANNEX_STYLE_MARK; CustomItem *pItem = new CustomItem(); pItem->Construct(Osp::Graphics::Dimension(itemWidth, ITEM_HEIGHT), style); pItem->SetBackgroundColor(LIST_ITEM_DRAWING_STATUS_NORMAL, LangSetting::LESSON_COLORS[lesson - 1]); String name = LangSetting::GetNameOfLesson(lesson); if (__progressState[lesson - 1]) AddItemPreparing(pItem, itemWidth); AddItemTitle(pItem, name, itemWidth); int count; wchar_t ** words = LangSetting::GetInitDataN(CommonSetting::GetInstance().lern, lesson, count); String examples = L""; count = count > EXAMPLES_MAX ? EXAMPLES_MAX : count; bool first = true; for (int i = 0; i != count; i++) { int indexOfComa; String word = words[i]; //word.IndexOf(",", 0, indexOfComa); if (word.IndexOf(",", 0, indexOfComa) == E_SUCCESS) { String neww; word.SubString(0, indexOfComa, neww); word = neww; } if (!first) examples.Append(L", "); examples.Append(word); first = false; } AddItemExamples(pItem, itemWidth, examples); SetupInitSetting(); return pItem; }
Tizen::Ui::Controls::ListItemBase * ShoppingListTab1::CreateItem(int index, int itemWidth) { String* pvalueText; DbRow* pRow = theTableLists.GetRow(index); if (pRow) { pRow->GetText(1, pvalueText); } String strName = *pvalueText; int textWidth = GetWidth() - INDENT*2; EnrichedText enrichedText; enrichedText.Construct(FloatDimension(textWidth, 112)); enrichedText.SetVerticalAlignment(TEXT_ALIGNMENT_MIDDLE); enrichedText.SetHorizontalAlignment(TEXT_ALIGNMENT_LEFT); enrichedText.SetTextWrapStyle(TEXT_WRAP_WORD_WRAP); Font pFont; pFont.Construct(FONT_STYLE_BOLD, 44.0f); TextElement* pTextElement = new (std::nothrow) TextElement(); pTextElement->Construct(strName + "\n"); pTextElement->SetFont(pFont); enrichedText.Add(*pTextElement); int textHeight = enrichedText.GetTotalLineHeight(); CustomItem* pItem = new CustomItem(); pItem->Construct(Dimension(GetWidth(), textHeight + INDENT*2), LIST_ANNEX_STYLE_NORMAL); pItem->AddElement(Rectangle(INDENT, INDENT, textWidth, textHeight), 0, enrichedText); AppAssert(pItemContext); pItem->SetContextItem(pItemContext); return pItem; }
void tst_QGraphicsEffect::deviceCoordinateTranslateCaching() { QGraphicsScene scene; CustomItem *item = new CustomItem(0, 0, 10, 10); scene.addItem(item); scene.setSceneRect(0, 0, 50, 0); item->setGraphicsEffect(new DeviceEffect); item->setPen(Qt::NoPen); item->setBrush(Qt::red); QGraphicsView view(&scene); view.show(); QTest::qWaitForWindowShown(&view); QTRY_VERIFY(item->numRepaints >= 1); int numRepaints = item->numRepaints; item->translate(10, 0); QTRY_VERIFY(item->numRepaints == numRepaints); }
ListItemBase* SettingForm::CreateItem(int index, float itemWidth) { ListAnnexStyle style = LIST_ANNEX_STYLE_NORMAL; CustomItem* pItem = new (std::nothrow) CustomItem; pItem->Construct(CoordinateSystem::AlignToDevice(Tizen::Graphics::FloatDimension(itemWidth, 112.0f)), style); FloatRectangle mainListItemRect(26.0f, 32.0f, GetClientAreaBoundsF().width, 60.0f); switch(index) { case 0: pItem->AddElement(mainListItemRect, ID_FORMAT_STRING, L"Chatting1", true); break; case 1: pItem->AddElement(mainListItemRect, ID_FORMAT_STRING, L"Chatting2", true); break; case 2: pItem->AddElement(mainListItemRect, ID_FORMAT_STRING, L"Chatting3", true); break; default: break; } return pItem; }
ListItemBase * BMCategoriesForm::CreateItem (int index, float itemWidth) { CustomItem * pItem = new CustomItem(); BookMarkManager & mngr = GetBMManager(); pItem->Construct(FloatDimension(itemWidth, lstItmHght), LIST_ANNEX_STYLE_NORMAL); int addWdth = 0; bool bShowDelete = index == m_categoryToDelete; if (m_bEditState) { FloatRectangle imgRect(btwWdth, topHght, imgWdth, imgHght); pItem->AddElement(imgRect, ID_DELETE, *GetBitmap(bShowDelete ? IDB_BOOKMARK_DELETE_CUR : IDB_BOOKMARK_DELETE), null, null); addWdth = btwWdth + imgWdth; } FloatRectangle imgRect(addWdth + btwWdth, topHght, imgWdth, imgHght); pItem->AddElement(imgRect, ID_EYE, *GetBitmap(mngr.IsCategoryVisible(index) ? IDB_EYE : IDB_EMPTY), null, null); int beg = addWdth + btwWdth + imgWdth + btwWdth; int end = 2 * btwWdth + (bShowDelete ? deleteWidth : imgWdth); String itemText = mngr.GetCategoryName(index); pItem->AddElement(FloatRectangle(beg, topHght, itemWidth - beg - end, imgHght), ID_NAME, itemText, mainFontSz, gray, gray, gray); if (bShowDelete) { pItem->AddElement(FloatRectangle(itemWidth - end + btwWdth, topHght, deleteWidth, imgHght), ID_DELETE_TXT, "Delete", mainFontSz, red, red, red); } else { int count = mngr.GetCategorySize(index); String sz; sz.Append(count); pItem->AddElement(FloatRectangle(itemWidth - btwWdth - imgWdth, topHght, imgWdth, imgHght), ID_SIZE, sz, mainFontSz, gray, gray, gray); } return pItem; }
Controls::ListItemBase * EnrichedTextForm::CreateItem(int index, int itemWidth) { // TODO: Add your implementation codes here ListAnnexStyle style = LIST_ANNEX_STYLE_NORMAL; CustomItem* pItem = new (std::nothrow) CustomItem(); pItem->Construct(Tizen::Graphics::Dimension(itemWidth, 112), style); Rectangle mainListItemRect(26, 32, GetClientAreaBounds().width, 50); switch(index) { case 0: pItem->AddElement(mainListItemRect, TEXT_WRAP_NONE_INDEX, L"Text Wrap None", true); break; case 1: pItem->AddElement(mainListItemRect, TEXT_WRAP_WORD_WRAP_INDEX, L"Text Wrap Word", true); break; case 2: pItem->AddElement(mainListItemRect, TEXT_WRAP_CHARACTER_WRAP_INDEX, L"Text Wrap Character Wrap", true); break; case 3: pItem->AddElement(mainListItemRect, TEXT_ALIGNMENT_LEFT_INDEX, L"Text Alignment Left", true); break; case 4: pItem->AddElement(mainListItemRect, TEXT_ALIGNMENT_CENTER_INDEX, L"Text Alignment Center", true); break; case 5: pItem->AddElement(mainListItemRect, TEXT_ALIGNMENT_RIGHT_INDEX, L"Text Alignment Right", true); break; case 6: pItem->AddElement(mainListItemRect, TEXT_ALIGNMENT_TOP_INDEX, L"Text Alignment Top", true); break; case 7: pItem->AddElement(mainListItemRect, TEXT_ALIGNMENT_MIDDLE_INDEX, L"Text Alignment Middle", true); break; case 8: pItem->AddElement(mainListItemRect, TEXT_ALIGNMENT_BOTTOM_INDEX, L"Text Alignment Bottom", true); break; case 9: pItem->AddElement(mainListItemRect, ABBREVIATION_ENABLED_TRUE, L"Abbreviation Enabled", true); break; case 10: pItem->AddElement(mainListItemRect, ABBREVIATION_ENABLED_FALSE, L"Abbreviation Disabled", true); break; default: break; } return pItem; }
void tst_QStandardItem::subclassing() { qMetaTypeId<QStandardItem*>(); CustomItem *item = new CustomItem; QCOMPARE(item->type(), int(QStandardItem::UserType + 1)); item->setText(QString::fromLatin1("foo")); QCOMPARE(item->text(), QString::fromLatin1("foo")); item->emitDataChanged(); // does nothing QStandardItemModel model; model.appendRow(item); QSignalSpy itemChangedSpy(&model, SIGNAL(itemChanged(QStandardItem*))); item->emitDataChanged(); QCOMPARE(itemChangedSpy.count(), 1); QCOMPARE(itemChangedSpy.at(0).count(), 1); QCOMPARE(qvariant_cast<QStandardItem*>(itemChangedSpy.at(0).at(0)), (QStandardItem*)item); CustomItem *child0 = new CustomItem("cc"); CustomItem *child1 = new CustomItem("bbb"); CustomItem *child2 = new CustomItem("a"); item->appendRow(child0); item->appendRow(child1); item->appendRow(child2); item->sortChildren(0); QCOMPARE(item->child(0), (QStandardItem*)child2); QCOMPARE(item->child(1), (QStandardItem*)child0); QCOMPARE(item->child(2), (QStandardItem*)child1); }
ListItemBase* DeviceInfoForm::CreateItem(int groupIndex, int itemIndex, int itemWidth) { static const int LIST_ITEM_HEIGHT = 60; static const int ID_LIST_VALUE = 101; static const int LIST_DATA_HEIGHT = 50; static const int DEFAULT_MARGIN = 20; static const int ELEMENT_X = 26; static const int ELEMENT_Y = 0; int clientAreaWidth = GetClientAreaBounds().width; const IListT<WifiWpsConfigurationMode>* pWifiWpsConfigurationModes = null; CustomItem* pItem = new CustomItem(); // skip IP addrss and SSID if ((groupIndex >= DeviceInfoType::IP_ADDRESS) && (__pLocalDeviceInfo->GetGroupMemberType() == WIFI_DIRECT_GROUP_MEMBER_TYPE_NONE)) { groupIndex += 2; } if (groupIndex == DeviceInfoType::WPS_MODE) { pWifiWpsConfigurationModes = static_cast<const IListT<WifiWpsConfigurationMode>*>(__pLocalDeviceInfo->GetSupportedWpsConfigurationModeList()); int wpsModeCount = pWifiWpsConfigurationModes->GetCount(); if (wpsModeCount == 0) { // set default value to display "Unknown" wpsModeCount = 1; } if (pWifiWpsConfigurationModes != null) { pItem->Construct(Dimension(clientAreaWidth, ELEMENT_Y + (LIST_DATA_HEIGHT * wpsModeCount)), LIST_ANNEX_STYLE_NORMAL); for (int i = 0; i < wpsModeCount; i++) { WifiWpsConfigurationMode wpsConfigurationMode = WIFI_WPS_CONFIG_MODE_NONE; pWifiWpsConfigurationModes->GetAt(i, wpsConfigurationMode); pItem->AddElement(Rectangle(ELEMENT_X, ELEMENT_Y + (LIST_DATA_HEIGHT * i), clientAreaWidth - DEFAULT_MARGIN, LIST_DATA_HEIGHT), ID_LIST_VALUE + i, GetDeviceWpsConfigurationMode(wpsConfigurationMode)); } } } else { pItem->Construct(Tizen::Graphics::Dimension(GetClientAreaBounds().width, LIST_ITEM_HEIGHT), LIST_ANNEX_STYLE_NORMAL); switch (groupIndex) { case DeviceInfoType::DEVICE_NAME: pItem->AddElement(Rectangle(ELEMENT_X, ELEMENT_Y, clientAreaWidth - DEFAULT_MARGIN, LIST_DATA_HEIGHT), ID_LIST_VALUE, __pLocalDeviceInfo->GetDeviceName()); break; case DeviceInfoType::MAC_ADDRESS: { String macAddress = __pLocalDeviceInfo->GetMacAddress(); if (macAddress.GetLength() == 0) { macAddress = L"xx-xx-xx-xx-xx-xx"; } pItem->AddElement(Rectangle(ELEMENT_X, ELEMENT_Y, clientAreaWidth - DEFAULT_MARGIN, LIST_DATA_HEIGHT), ID_LIST_VALUE, macAddress); } break; case DeviceInfoType::IP_ADDRESS: if (__pLocalDeviceInfo->GetIpAddress() != null) { pItem->AddElement(Rectangle(ELEMENT_X, ELEMENT_Y, clientAreaWidth - DEFAULT_MARGIN, LIST_DATA_HEIGHT), ID_LIST_VALUE, __pLocalDeviceInfo->GetIpAddress()->ToString()); } break; case DeviceInfoType::SSID: pItem->AddElement(Rectangle(ELEMENT_X, ELEMENT_Y, clientAreaWidth - DEFAULT_MARGIN, LIST_DATA_HEIGHT), ID_LIST_VALUE, __pLocalDeviceInfo->GetSsid()); break; case DeviceInfoType::DEVICE_STATUS: pItem->AddElement(Rectangle(ELEMENT_X, ELEMENT_Y, clientAreaWidth - DEFAULT_MARGIN, LIST_DATA_HEIGHT), ID_LIST_VALUE, GetDeviceStatus()); break; case DeviceInfoType::MEMBER_TYPE: pItem->AddElement(Rectangle(ELEMENT_X, ELEMENT_Y, clientAreaWidth - DEFAULT_MARGIN, LIST_DATA_HEIGHT), ID_LIST_VALUE, GetGroupMemberType()); break; case DeviceInfoType::DEVICE_TYPE: pItem->AddElement(Rectangle(ELEMENT_X, ELEMENT_Y, clientAreaWidth - DEFAULT_MARGIN, LIST_DATA_HEIGHT), ID_LIST_VALUE, GetDeviceTypeCategory()); break; default: break; } } return pItem; }
void ViewWorkerThread::prepareImage(QList<QGraphicsItem*> items) { stopLoading(); QVector<CustomItem*> itemsNotLoaded; QVector<CustomItem*> itemsBeingProcessed; //Find all items whose images are not loaded. for (int index = 0; index < items.count(); index++) { CustomItem* item = dynamic_cast<CustomItem*> (items[index]); if ((true == item->pixmap().isNull()) || ((nItemWidth > (item->pixmap().width() + CustomItem::getItemMargin())) && (nItemHeight > (item->pixmap().height() + CustomItem::getItemMargin())))) { if (EProcessingState::eNone == item->processingState()) { itemsNotLoaded.push_front(item); } else if (EProcessingState::eProcessed == item->processingState()) { item->updateItem(); item->setProcessing(EProcessingState::eRenderred); } } else if ((EProcessingState::eNone != item->processingState()) && (EProcessingState::eRenderred != item->processingState())) { item->updateItem(); item->setProcessing(EProcessingState::eRenderred); } } CustomGraphicsView* parentView = dynamic_cast<CustomGraphicsView*> (parent()); QList<QGraphicsItem *> viewItems = parentView->items(); //Clear images from items that are not currently viewed. //(To optimize memory consumption) for (int index = 0; index < viewItems.count(); index++) { if (!items.contains(viewItems[index])) { CustomItem* item = dynamic_cast<CustomItem*> (viewItems[index]); item->setPixmap(0); item->setProcessing(EProcessingState::eNone); } } if (itemsNotLoaded.isEmpty()) { return; } m_ItemsNotLoaded.clear(); m_ItemsNotLoaded = itemsNotLoaded; //Load images. m_pImageLoadThreadWatcher->setFuture(QtConcurrent::mapped(m_ItemsNotLoaded, readEmf)); }
Tizen::Ui::Controls::ListItemBase* TreeViewForm::CreateItem (int index, int itemWidth){ AppLog("CreateItem %d",index); CustomItem* pItem = null; ZLTreeNode* node = myTreeDialog->myCurrentNode->children().at(index); if (const ZLTreeTitledNode *TitledNode = zlobject_cast<const ZLTreeTitledNode*>(node)) { AppLog("ZLTreeTitledNode.titile %s",TitledNode->title().c_str()); //AppLog("ZLTreeTitledNode.imageUrl = %s",TitledNode->imageUrl().c_str()); String strName = String(TitledNode->title().c_str()); String strSub = String(TitledNode->subtitle().c_str()); pItem = new (std::nothrow) CustomItem(); Dimension itemDimension(itemWidth,100); pItem->Construct(itemDimension, LIST_ANNEX_STYLE_NORMAL); Bitmap *pBmp = null; Color blk = Color::GetColor(COLOR_ID_BLACK); if (showIcons) { //if (false) { shared_ptr<ZLImage> cover; if (TitledNode->imageIsUploaded()) cover = TitledNode->image(); else cover = TitledNode->extractCoverImage(); if (!cover.isNull()) { shared_ptr<ZLImageData> coverData = ZLImageManager::Instance().imageData(*cover); if (!coverData.isNull()) { ZLImageData &image = *coverData; Bitmap *tmpBmp = ((ZLbadaImageData&)image).pBitmap; pBmp = makeIcon(tmpBmp); } else { cover = TitledNode->extractCoverImage(); shared_ptr<ZLImageData> coverData = ZLImageManager::Instance().imageData(*cover); ZLImageData &image = *coverData; Bitmap *tmpBmp = ((ZLbadaImageData&)image).pBitmap; pBmp = makeIcon(tmpBmp); } } pItem->AddElement(iconRect, ID_FORMAT_BITMAP, *pBmp, null, null); pItem->AddElement(Rectangle(85, 12, formArea.width - 85, 40), ID_FORMAT_TITLE, strName,30, blk,blk,blk, true); pItem->AddElement(Rectangle(85, 37, formArea.width - 85, 80), ID_FORMAT_SUBTITLE, strSub,22, blk,blk,blk, true); } else { pItem->AddElement(Rectangle(15, 12, formArea.width - 15, 40), ID_FORMAT_TITLE, strName,30, blk,blk,blk, true); pItem->AddElement(Rectangle(15, 37, formArea.width - 15, 80), ID_FORMAT_SUBTITLE, strSub,22, blk,blk,blk, true); } if (pBmp != null) delete pBmp; } return pItem; }
void tst_QGraphicsEffect::draw() { QGraphicsScene scene; CustomItem *item = new CustomItem(0, 0, 100, 100); scene.addItem(item); QGraphicsView view(&scene); view.show(); QTest::qWaitForWindowShown(&view); QTRY_VERIFY(item->numRepaints > 0); item->reset(); // Make sure installing the effect triggers a repaint. CustomEffect *effect = new CustomEffect; item->setGraphicsEffect(effect); QTRY_COMPARE(effect->numRepaints, 1); QTRY_COMPARE(item->numRepaints, 1); // Make sure QPainter* and QStyleOptionGraphicsItem* stays persistent // during QGraphicsEffect::draw/QGraphicsItem::paint. QVERIFY(effect->m_painter); QCOMPARE(effect->m_painter, item->m_painter); QCOMPARE(effect->m_styleOption, item->m_styleOption); // Make sure QGraphicsEffect::source is persistent. QCOMPARE(effect->m_source, effect->source()); effect->reset(); item->reset(); // Make sure updating the source triggers a repaint. item->update(); QTRY_COMPARE(effect->numRepaints, 1); QTRY_COMPARE(item->numRepaints, 1); QVERIFY(effect->m_sourceChangedFlags & QGraphicsEffect::SourceInvalidated); effect->reset(); item->reset(); // Make sure changing the effect's bounding rect triggers a repaint. effect->setMargin(20); QTRY_COMPARE(effect->numRepaints, 1); QTRY_COMPARE(item->numRepaints, 1); effect->reset(); item->reset(); // Make sure change the item's bounding rect triggers a repaint. item->setRect(0, 0, 50, 50); QTRY_COMPARE(effect->numRepaints, 1); QTRY_COMPARE(item->numRepaints, 1); QVERIFY(effect->m_sourceChangedFlags & QGraphicsEffect::SourceBoundingRectChanged); effect->reset(); item->reset(); // Make sure the effect is the one to issue a repaint of the item. effect->doNothingInDraw = true; item->update(); QTRY_COMPARE(effect->numRepaints, 1); QCOMPARE(item->numRepaints, 0); effect->doNothingInDraw = false; effect->reset(); item->reset(); // Make sure we update the source when disabling/enabling the effect. effect->setEnabled(false); QTest::qWait(50); QCOMPARE(effect->numRepaints, 0); QCOMPARE(item->numRepaints, 1); effect->reset(); item->reset(); effect->setEnabled(true); QTRY_COMPARE(effect->numRepaints, 1); QTRY_COMPARE(item->numRepaints, 1); effect->reset(); item->reset(); // Effect is already enabled; nothing should happen. effect->setEnabled(true); QTest::qWait(50); QCOMPARE(effect->numRepaints, 0); QCOMPARE(item->numRepaints, 0); // Make sure uninstalling an effect triggers a repaint. QPointer<CustomEffect> ptr = effect; item->setGraphicsEffect(0); QVERIFY(!ptr); QTRY_COMPARE(item->numRepaints, 1); }