void FTrip::AddListItem(Osp::Base::String col1, Osp::Base::String col2, Osp::Base::String col3, int itemId) { CustomListItem * newItem = new CustomListItem(); CustomListElementTrip * custom_element = new CustomListElementTrip(); newItem->Construct(100); newItem->SetItemFormat(*pCustomListItemFormat); custom_element->col1 = col1; custom_element->col2 = col2; custom_element->col3 = col3; newItem->SetElement(LEL_BG, *(static_cast<ICustomListElement *>(custom_element))); pExList->AddItem(*newItem, itemId); }
void FTrip::AddListItemSearch(Osp::Base::String col1, Osp::Base::String col2, Osp::Base::String col3, Osp::Base::String col4, int itemId, int searchposcol1, int searchposcol2) { CustomListItem * newItem = new CustomListItem(); CustomListElementTrip * custom_element = new CustomListElementTrip(); newItem->Construct(150); newItem->SetItemFormat(*pCustomListItemSearchFormat); custom_element->col1 = col1; custom_element->col2 = col2; custom_element->col3 = col3; custom_element->col4 = col4; if (custom_element->col4.GetLength() > 0) custom_element->col4.Replace("\n"," "); if (searchposcol1 > -1) { if (searchposcol1 > 10) { custom_element->col1.SubString(searchposcol1-3,custom_element->col1); custom_element->col1.Insert("...",0); searchposcol1 = 6; } custom_element->col1.SubString(0,searchposcol1,custom_element->col1b); custom_element->col1.SubString(searchposcol1,this->searchq.GetLength(),custom_element->col1s); if (searchposcol1+searchq.GetLength() < custom_element->col1.GetLength()) custom_element->col1.SubString(searchposcol1+searchq.GetLength(), custom_element->col1a); } if (searchposcol2 > -1) { if (searchposcol2 > 10) { custom_element->col4.SubString(searchposcol2-3,custom_element->col4); custom_element->col4.Insert("...",0); searchposcol2 = 6; } custom_element->col4.SubString(0,searchposcol2,custom_element->col4b); custom_element->col4.SubString(searchposcol2,this->searchq.GetLength(),custom_element->col4s); if (searchposcol2+searchq.GetLength() < custom_element->col4.GetLength()) custom_element->col4.SubString(searchposcol2+searchq.GetLength(), custom_element->col4a); } Osp::Base::String lowercasedsearchq; this->searchq.ToLower(lowercasedsearchq); custom_element->searchq = lowercasedsearchq; newItem->SetElement(LEL_BG, *(static_cast<ICustomListElement *>(custom_element))); pExList->AddItem(*newItem, itemId); }
void ThemeCellCreator::updateCell ( const QModelIndex &index, MWidget *cell) const { CustomListItem *listItem; QString title; QString codeName; QString iconName; QString changingTheme; bool isChangingTheme; if(!cell || !index.isValid()) return; listItem = qobject_cast<CustomListItem *>(cell); changingTheme = index.data (ThemeListModel::ChangingNameRole).toString(); title = index.data (ThemeListModel::NameRole).toString(); codeName = index.data (ThemeListModel::CodeNameRole).toString(); iconName = index.data (ThemeListModel::IconNameRole).toString(); isChangingTheme = !codeName.isEmpty() && changingTheme == codeName; #if 1 SYS_DEBUG ("************** %d ***************", index.row()); SYS_DEBUG ("title = %s", SYS_STR(title)); SYS_DEBUG ("changingTheme = %s", SYS_STR(changingTheme)); SYS_DEBUG ("codeName = %s", SYS_STR(codeName)); SYS_DEBUG ("iconName = %s", SYS_STR(iconName)); SYS_DEBUG ("isChangingTheme = %s", SYS_BOOL(isChangingTheme)); #endif // The title if (m_HighlightText.isEmpty()) { listItem->setTitle(title); } else { int matchingIndex = title.indexOf ( m_HighlightText, 0, Qt::CaseInsensitive); if (matchingIndex != -1) { title.insert (matchingIndex + m_HighlightText.length(), SelectionEndTag); title.insert (matchingIndex, SelectionStartTag); } listItem->setTitle (title); } // The icon if (listItem->imageWidget()->image() != iconName) listItem->imageWidget()->setImage (iconName); // The spinner. if (isChangingTheme) { listItem->progressIndicator()->show(); } else { listItem->progressIndicator()->hide(); } updateListItemMode(index, listItem); }
// Implements an ITextEventListener void StringOptionView::OnTextValueChanged(const Control& source) { // Todo: AppLog("OnTextValueChanged"); CustomListItem* pItem = new OptionListItem(this); pItem->Construct(100); pItem->SetItemFormat(*myTab->form()->__pStringViewListItemFormat); pItem->SetElement(ID_LIST_TEXT_TITLE,String((ZLOptionView::name()).c_str())); pItem->SetElement(ID_LIST_TEXT_SUBTITLE, __pKeypad->GetText()); myTab->form()->__pCustomList->SetItemAt(groupIndex,itemIndex, *pItem, ID_LIST_ITEM); ByteBuffer* bb = Tizen::Base::Utility::StringUtil:: StringToUtf8N(__pKeypad->GetText()); myValue = std::string((char *)bb->GetPointer()); AppLog( "pKeypad->GetText %s",myValue.c_str()); }
void PanelView::RescanAttr(node_ref nref) //////////////////////////////////////////////////////////////////////// { if (m_PanelMode != PM_NORMAL) return; CustomListItem *item = m_CustomListView->FindItemByNodeRef(nref); if (item) { BString fullentryname(m_Path); fullentryname << "/" << item->m_FileName; item->GetIcon(fullentryname.String()); m_CustomListView->InvalidateItem(m_CustomListView->IndexOf(item)); m_CurrentTotalSize = m_CustomListView->GetCurrentTotalSize(); SelectionChanged(); } }
MWidget * ThemeCellCreator::createCell( const QModelIndex &index, MWidgetRecycler &recycler) const { CustomListItem *cell; cell = qobject_cast <CustomListItem *> ( recycler.take(CustomListItem::staticMetaObject.className())); if (!cell) { cell = new CustomListItem ( MAdvancedListItem::IconWithTitleProgressIndicatorAndTwoSideIcons); cell->progressIndicator()->setUnknownDuration (true); cell->sideTopImageWidget()->hide(); cell->sideBottomImageWidget()->hide(); } updateCell(index, cell); return cell; }
void PanelView::ReadDisks(void) //////////////////////////////////////////////////////////////////////// { char drivename[256]; char drivepath[256]; // SetMousePointer(CR_HOURGLASS); MAINWINDOW->SetMousePointer(GenesisWindow::CR_HOURGLASS); CustomListItem *item; item = new CustomListItem("..",m_Path.String(),FT_DISKBACK, 0); item->AddIcon(m_ParentIcon); m_CustomListView->AddItem(item); item->SetHeight(15.0f); // Collect available volumes... BVolumeRoster *vr = new BVolumeRoster(); if (vr) { BVolume v; while (vr->GetNextVolume(&v)==B_NO_ERROR) { if (v.GetName(drivename)==B_NO_ERROR) { if (strlen(drivename)>0) { BDirectory dir; BEntry entry; BPath path; v.GetRootDirectory(&dir); dir.GetEntry(&entry); entry.GetPath(&path); sprintf(drivepath,"%s",path.Path()); item = new CustomListItem(drivename,drivepath,FT_DISKITEM,v.FreeBytes(),v.Capacity(),v.Device()); m_CustomListView->AddItem(item); if (m_Setting_ShowIcons) { if (!item->GetIcon(&v)) item->AddIcon(m_UnknownIcon); item->SetHeight(15.0f); } } } } delete vr; } m_CustomListView->DoSortList(); m_CustomListView->Select(0,false); // SetMousePointer(CR_DEFAULT); MAINWINDOW->SetMousePointer(GenesisWindow::CR_DEFAULT); }
result FPlaylistForm::AddListItem(int itemid, String itemTextArtist, String itemTextTitle, Bitmap* pBitmapNormal) { CustomListItem* pItem = new CustomListItem(); CustomListElement * custom_element = new CustomListElement(); CustomListElement * custom_element2 = new CustomListElement(); custom_element->text = itemTextArtist; custom_element2->text = itemTextTitle; pItem->Construct(80); pItem->SetItemFormat(*__pCustomListItemFormat); if (pBitmapNormal != null) { pItem->SetElement(ID_LIST_TEXTARTIST, *(static_cast<ICustomListElement *>(custom_element))); pItem->SetElement(ID_LIST_TEXTTITLE, *(static_cast<ICustomListElement *>(custom_element2))); pItem->SetElement(ID_LIST_ICON, *pBitmapNormal, pBitmapNormal); } else { pItem->SetElement(ID_LIST_TEXTARTIST, *(static_cast<ICustomListElement *>(custom_element))); pItem->SetElement(ID_LIST_TEXTTITLE, *(static_cast<ICustomListElement *>(custom_element2))); } UList_->AddItem(*pItem, itemid); return E_SUCCESS; }
result InfoForm::OnInitializing(void) { Rectangle rect = this->GetClientAreaBounds(); result r = E_SUCCESS; TabsForm::OnInitializing(); AppResource *pAppResource = Application::GetInstance()->GetAppResource(); Bitmap* _bitmap; CategoryList = new CustomList(); CategoryList->Construct(Rectangle(0, 0, this->GetWidth(), rect.height), CUSTOM_LIST_STYLE_NORMAL); CategoryList->SetBackgroundColor(Color(239,239,239)); CategoryList->AddCustomItemEventListener(*this); // Category element format pCustomListItemFormat = new CustomListItemFormat(); pCustomListItemFormat->Construct(); pCustomListItemFormat->AddElement(LIST_ELEMENT_IMG, Rectangle(Retina::GetInt(5), Retina::GetInt(5), Retina::GetInt(65), Retina::GetInt(65))); pCustomListItemFormat->AddElement(LIST_ELEMENT_DESC, Rectangle(Retina::GetInt(75), Retina::GetInt(5), Retina::GetInt(180), Retina::GetInt(120)), Retina::GetInt(12), Color(151,151,151), Osp::Ui::Controls::SYSTEM_COLOR_LIST_ITEM_PRESSED_TEXT); CreateArray(); int i=0; // Adds an item to the CustomList while(__pProducts[i][0]->GetLength() == 12) { CustomListItem * newItem = new CustomListItem(); newItem->Construct(Retina::GetInt(75)); newItem->SetItemFormat(*pCustomListItemFormat); int k=0; Integer::Parse(*__pProducts[i][1], k); switch (k) { case 451549: case 451431: newItem->SetElement(LIST_ELEMENT_DESC, Helper::GetTraslation("IDS_SPACESHUFFLE")); _bitmap = pAppResource->GetBitmapN(L"Ikonka_512.png"); break; case 53471: newItem->SetElement(LIST_ELEMENT_DESC, Helper::GetTraslation("IDS_UCONVERTOR")); _bitmap = pAppResource->GetBitmapN(L"uc_icon2.png"); break; case 287131: case 287177: case 232222: case 279563: newItem->SetElement(LIST_ELEMENT_DESC, Helper::GetTraslation("IDS_sCalc")); _bitmap = pAppResource->GetBitmapN(L"scalc_icon.png"); break; } newItem->SetElement(LIST_ELEMENT_IMG, *_bitmap, _bitmap); CategoryList->AddItem(*newItem, i); i++; } this->AddControl(*CategoryList); return r; }
CustomListItem *PanelView::AddDirectoryEntry(BEntry *entry, bool sorted) //////////////////////////////////////////////////////////////////////// { CustomListItem *item; char name[B_FILE_NAME_LENGTH]; entry->GetName(name); if (entry->IsDirectory()) { item = new CustomListItem(name,m_Path.String(),FT_DIRECTORY, 0, this); if (sorted) m_CustomListView->AddSortedItem(item); else m_CustomListView->AddItem(item); if (m_Setting_ShowIcons) { if (!item->GetIcon(entry)) item->AddIcon(m_UnknownIcon); item->SetHeight(15.0f); } } else if (entry->IsSymLink()) { BEntry symlinkentry; entry_ref ref; struct stat statbuf; entry->GetRef(&ref); if (symlinkentry.SetTo(&ref, true)==B_OK) { if (symlinkentry.IsDirectory()) { item = new CustomListItem(name,m_Path.String(),FT_SYMLINKDIR, 0, this); if (sorted) m_CustomListView->AddSortedItem(item); else m_CustomListView->AddItem(item); if (m_Setting_ShowIcons) { if (!item->GetIcon(&symlinkentry)) item->AddIcon(m_UnknownIcon); item->SetHeight(15.0f); } } else { symlinkentry.GetStat(&statbuf); item = new CustomListItem(name,m_Path.String(),FT_SYMLINKFILE,statbuf.st_size, this); if (sorted) m_CustomListView->AddSortedItem(item); else m_CustomListView->AddItem(item); if (m_Setting_ShowIcons) { if (!item->GetIcon(&symlinkentry)) item->AddIcon(m_UnknownIcon); item->SetHeight(15.0f); } } } else { // Broken link... item = new CustomListItem(name, m_Path.String(), FT_SYMLINKBROKEN, 0 , this); if (sorted) m_CustomListView->AddSortedItem(item); else m_CustomListView->AddItem(item); if (m_Setting_ShowIcons) { if (!item->GetIcon(entry)) item->AddIcon(m_UnknownIcon); item->SetHeight(15.0f); } } } else { struct stat statbuf; entry->GetStat(&statbuf); item = new CustomListItem(name,m_Path.String(),FT_FILE,statbuf.st_size, this); if (sorted) m_CustomListView->AddSortedItem(item); else m_CustomListView->AddItem(item); if (m_Setting_ShowIcons) { if (!item->GetIcon(entry)) item->AddIcon(m_UnknownIcon); item->SetHeight(15.0f); } } return item; }
void PanelView::ReadDirectory(const char *itemname) //////////////////////////////////////////////////////////////////////// { BDirectory *dir; CustomListItem *item; stop_watching(this); // SetMousePointer(CR_HOURGLASS); MAINWINDOW->SetMousePointer(GenesisWindow::CR_HOURGLASS); // If we are not in the root directory, simply start the dir with a '..' entry... if (strcmp(m_Path.String(),"/")!=0) { item = new CustomListItem("..", m_Path.String(), FT_PARENT, 0); m_CustomListView->AddItem(item); if (m_Setting_ShowIcons) { item->AddIcon(m_ParentIcon); item->SetHeight(15.0f); } } dir = new BDirectory(m_Path.String()); if (dir) { BEntry entry; if (dir->GetEntry(&entry)==B_OK) { while (dir->GetNextEntry(&entry)==B_OK) { AddDirectoryEntry(&entry); } } delete dir; } m_CustomListView->DoSortList(); // Always select the first item in the list or the child where we came from... if (itemname) { CustomListItem *item; int n = m_CustomListView->CountItems(); for (int i=0;i<n;i++) { item = (CustomListItem *)m_CustomListView->ItemAt(i); if (strcasecmp(itemname,item->m_FileName.String())==0) { m_CustomListView->Select(i,false); m_CustomListView->ScrollToSelection(); break; } } // When the given file disappeared, we have to select the first entry... if (m_CustomListView->CountSelectedEntries(CT_WITHPARENT)==0) m_CustomListView->Select(0,false); } else m_CustomListView->Select(0,false); m_CurrentTotalSize = m_CustomListView->GetCurrentTotalSize(); // Probably we have to update the path of the command line... Parent()->Looper()->PostMessage(new BMessage(MSG_UPDATECOMMANDLINE_PATH)); // To update command line... EnableMonitoring(); // SetMousePointer(CR_DEFAULT); MAINWINDOW->SetMousePointer(GenesisWindow::CR_DEFAULT); }
void MainForm::OnParsingCompleted(ArrayList &feedData) { AppResource *pAppResource = Application::GetInstance()->GetAppResource(); if (feedData.GetCount() == 0) { // no service this day String emptyText; pAppResource->GetString("IDS_NOSERVICE", emptyText); __pListFood->SetTextOfEmptyList(emptyText); } else { IEnumerator *pEnum = feedData.GetEnumeratorN(); HashMap *pItem = null; int mensaIndex = -1; String *currentMensa = null; String currencySymbol; pAppResource->GetString("IDS_CURRENCY", currencySymbol); String soldOut; pAppResource->GetString("IDS_SOLDOUT", soldOut); // iterate over items (meals) in feed while (pEnum->MoveNext() == E_SUCCESS) { pItem = (HashMap *)pEnum->GetCurrent(); // check if mensa is already in the list (we assume the feed to be ordered) if (!currentMensa || !(static_cast<String *>(pItem->GetValue(*(new String("author")))))->Equals(*currentMensa, false)) { currentMensa = static_cast<String *>(pItem->GetValue(*(new String("author")))); mensaIndex++; // Create a main item of the ExpandableList CustomListItem* pMainItem = new CustomListItem(); pMainItem->Construct(100); pMainItem->SetItemFormat(*__pMainItemFormat); pMainItem->SetElement(TEXT_ID, *(new String(*currentMensa))); // Add the item to the ExpandableList __pListFood->AddItem(*pMainItem, mensaIndex); } String *title = static_cast<String *>(pItem->GetValue(*(new String("title")))); title->Trim(); String priceStudents; String priceStaff; int stringLength = title->GetLength(); // Create a sub item of the ExpandableList CustomListItem *pSubItem = new CustomListItem(); pSubItem->Construct(100); pSubItem->SetItemFormat(*__pSubItemFormat); // get prices if (title->EndsWith(L" EUR)")) { // parse price title->SubString(stringLength - 20, 5, priceStudents); priceStudents.Append(currencySymbol); title->SubString(stringLength - 9, 5, priceStaff); priceStaff.Append(currencySymbol); title->Remove(stringLength - 22, 22); pSubItem->SetElement(PRICESTUDENT_ID, priceStudents); pSubItem->SetElement(PRICESTAFF_ID, priceStaff); } else if (title->EndsWith(L"(ausverkauft)")) { // sold out title->Remove(stringLength - 14, 14); pSubItem->SetElement(REMARK_ID, soldOut); } pSubItem->SetElement(TEXT_ID, *title); // Add sub item to the ExpandableList __pListFood->AddSubItem(mensaIndex, *pSubItem); } // clean up delete pEnum; } __pListFood->RequestRedraw(); __pListFood->ScrollToTop(); StopLoadingAnimation(); }
void FPlaylistForm::OnActionPerformed(const Control& source, int actionId) { if (actionId == APLAY) { FMainForm *pMainForm = static_cast<FMainForm *>(Application::GetInstance()->GetAppFrame()->GetFrame()->GetControl("FMainForm")); int playlistitemscount = 0; if (pMainForm->isstreaming) { playlistitemscount = pMainForm->playliststream->GetCount(); } else { playlistitemscount = publicfunc_->playlist->GetCount(); } if ((curselitemid > 0) && (curselitemid <= playlistitemscount)) { if (publicfunc_->sendingcommand == false) { //if (curplayingitemid != curselitemid) { PlayListItem * playlistitem_; if (pMainForm->isstreaming) { playlistitem_ = static_cast<PlayListItem *> (pMainForm->playliststream->GetAt(curselitemid-1)); pMainForm->StreamingPlayListPlayItem(curselitemid-1); } else { playlistitem_ = static_cast<PlayListItem *> (publicfunc_->playlist->GetAt(curselitemid-1)); publicfunc_->SendCommand(L"pl_play&id=" + Osp::Base::Integer::ToString(playlistitem_->id)); } int listitemindex = -1; if (curplayingitemid >= 0) { PlayListItem * playlistitemold_; if (pMainForm->isstreaming) { playlistitemold_ = static_cast<PlayListItem *> (pMainForm->playliststream->GetAt(curplayingitemid-1)); } else { playlistitemold_ = static_cast<PlayListItem *> (publicfunc_->playlist->GetAt(curplayingitemid-1)); } listitemindex = UList_->GetItemIndexFromItemId(curplayingitemid); if (listitemindex >= 0) { CustomListItem* pItem = const_cast <CustomListItem*>(UList_->GetItemAt(listitemindex)); pItem->SetElement(ID_LIST_ICON, L""); UList_->RefreshItem(listitemindex); } } listitemindex = UList_->GetItemIndexFromItemId(curselitemid); if (listitemindex >= 0) { CustomListItem* pItem = const_cast <CustomListItem*>(UList_->GetItemAt(listitemindex)); pItem->SetElement(ID_LIST_ICON, *currenticon, currenticon); UList_->RefreshItem(listitemindex); } this->RequestRedraw(); curplayingitemid = curselitemid; //} } } } else if (actionId == AREMOVE) { FMainForm *pMainForm = static_cast<FMainForm *>(Application::GetInstance()->GetAppFrame()->GetFrame()->GetControl("FMainForm")); int playlistitemscount = 0; if (pMainForm->isstreaming) { playlistitemscount = pMainForm->playliststream->GetCount(); } else { playlistitemscount = publicfunc_->playlist->GetCount(); } if ((curselitemid > 0) && (curselitemid <= playlistitemscount)) { if (publicfunc_->sendingcommand == false) { if (curplayingitemid == curselitemid) { curplayingitemid = -1; } PlayListItem * playlistitem_; if (pMainForm->isstreaming) { playlistitem_ = static_cast<PlayListItem *> (pMainForm->playliststream->GetAt(curselitemid-1)); pMainForm->StreamingPlayListRemoveItem(curselitemid-1); UList_->RemoveAllItems(); FillListItems(); } else { playlistitem_ = static_cast<PlayListItem *> (publicfunc_->playlist->GetAt(curselitemid-1)); publicfunc_->SendCommand(L"pl_delete&id=" + Osp::Base::Integer::ToString(playlistitem_->id)); publicfunc_->playlist->RemoveAt(curselitemid-1,true); UList_->RemoveAllItems(); FillListItems(); } } } } else if (actionId == ACLEAR) { MessageBox msgbox; int modalResult = 0; msgbox.Construct("Clear playlist?", "Do you want to clear playlist?", MSGBOX_STYLE_YESNO, 0); msgbox.ShowAndWait(modalResult); if (modalResult == MSGBOX_RESULT_YES) { FMainForm *pMainForm = static_cast<FMainForm *>(Application::GetInstance()->GetAppFrame()->GetFrame()->GetControl("FMainForm")); if (pMainForm->isstreaming) { pMainForm->StreamingPlayListClear(); } UList_->RemoveAllItems(); publicfunc_->ClearPlayList(); FillListItems(); } } else if (actionId == AADD) { Frame *pFrame = Application::GetInstance()->GetAppFrame()->GetFrame(); FormMgr *pFormMgr = static_cast<FormMgr *>(pFrame->GetControl("FormMgr")); pFormMgr->SendUserEvent(FormMgr::REQUEST_BROWSEFORMADDTOPLAYLIST, null); } else if (actionId == ABACK) { Frame *pFrame = Application::GetInstance()->GetAppFrame()->GetFrame(); FormMgr *pFormMgr = static_cast<FormMgr *>(pFrame->GetControl("FormMgr")); pFormMgr->SendUserEvent(FormMgr::REQUEST_MAINFORM, null); } }