void TItemList::RenameItem(LPCSTR fn0, LPCSTR fn1, EItemType type) { if (!OnItemRenameEvent.empty()) OnItemRenameEvent(fn0,fn1,type); if (type==TYPE_OBJECT){ TElTreeItem* item0 = FHelper.FindObject(tvItems,fn0); VERIFY(item0); ListItem* prop = (ListItem*)item0->Tag; VERIFY(prop); prop->SetName (fn1); TElTreeItem* item1 = FHelper.FindObject(tvItems,fn1); if (item1) prop->item = item1; } }
void __fastcall TfrmEditLightAnim::OnItemFocused(TElTreeItem* item) { if (item&&FHelper.IsObject(item)){ ListItem* prop = (ListItem*)item->Tag; VERIFY(prop); AnsiString nm = prop->Key(); CLAItem* I = LALib.FindItem(nm.c_str()); SetCurrentItem (I,prop); }else{ SetCurrentItem (0,0); } }
bool ListModel::isNewItemCheckable(ListItem* parent, int row) { if (row > 0) { ListItem* previous = parent->child(row - 1); if (previous) return previous->isCheckable(); } else return parent->isProject() || parent->isMilestone(); return false; }
int &List::getNthElement(int n) { if (currentSize >= n + 1 && n >= 0) { ListItem* tmp = first; for (int i = 0; i < n; i++) { tmp = tmp->getNext(); } return tmp->getContent(); } else throw std::out_of_range("List index out of range"); }
void ListBox::CreateItems() { if (format_.fontPointSize() > 16.0) format_.setFontPointSize(16.0); for (size_t i = 0; i < data_.size(); i++) { ListItem* item = new ListItem(ctx_, data_[i], this); item->setFont(format_.font()); } setMinimumSize(minimumSize().width(), sizeHint().height()); }
const std::string& ComboBox::getItemText(int itemIndex) const { if (itemIndex >= 0 && (size_t)itemIndex < m_items.size()) { ListItem* item = m_items[itemIndex]; return item->getText(); } else { // Returns the text of the combo-box (it should be empty). ASSERT(getText().empty()); return getText(); } }
void ListWidget::addItem(const std::string &content) { ListItem* item = new ListItem(); item->setText(content); item->setRelativePosition(computeItemPosition(items_.size())); item->setSize({this->getSize().x - SCROLLBAR_WIDTH, ITEM_HEIGHT}); items_.push_back(std::unique_ptr<ListItem>(item)); // If this is the first item, select it if(items_.size() == 1) selectItem(*item); }
int List::deleteLast() { if (currentSize != 0) { int tmp = last->getContent(); ListItem *del = last; last = del->getPrevious(); delete del; currentSize--; return tmp; } else return 0; }
int List::addItem(std::vector< std::string >* values) { ListItem tempItem; //Creating a tempororary item tempItem.create(colWidth, values, x, nextItemY); listItems->push_back(tempItem); nextItemY = nextItemY + rowHeight; return 0; }
void C4PortraitSelDlg::LoaderThread::Execute() { // list empty? if (!LoadItems.size()) { // then we're done! SignalStop(); return; } // load one item at the time ListItem *pLoadItem = LoadItems.front(); pLoadItem->Load(); LoadItems.erase(LoadItems.begin()); }
void NotesWidget::insertNewNote(QString guid, QString noteBook, QString title) { ListItem* item = new ListItem(this); item->setText(title); item->setNoteBookGUID(noteBook); item->setIcon(QIcon::fromTheme("basket")); item->setGUID(guid); signalsDisabled = true; setCurrentItem(item); signalsDisabled = false; }
int List::deleteFirst() { if (currentSize != 0) { int tmp = first->getContent(); ListItem *del = first; first = del->getNext(); delete del; currentSize--; return tmp; } else return 0; }
STDMETHODIMP OrxEvent::CheckEvent(LPCOLESTR Code, IDispatch **pbIDispatch) { ListItem *Current; ESource *Content; HRESULT RetCode=DISP_E_UNKNOWNNAME; int i=0; size_t CodeLen; RetCode = DISP_E_UNKNOWNNAME; if (!Code) { RetCode = E_POINTER; } else { CodeLen = wcslen(Code); } if (!pbIDispatch) { RetCode = E_POINTER; } else { *pbIDispatch = (IDispatch *)NULL; } if (RetCode == DISP_E_UNKNOWNNAME) { while (Current = EventSourceChain->FindItem(i++)) { Content = (ESource *)Current->GetContent(); if (Content->EventType == ESource::ParseProcedure) { if (CodeLen == Content->CodeLen) { if (Content->Code) { if (wcsicmp(Code,Content->Code) == 0) { *pbIDispatch = (IDispatch *)Content; RetCode = S_OK; ((IDispatch*) Content)->AddRef(); break; } } } } } } FPRINTF2(logfile,"OrxEvent::CheckEvent() HRESULT %08x. \n",RetCode); return RetCode; }
void NotesWidget::setNoteSortType(qint8 type) { sortType = type; for (int i = 0; i < count(); i++) { ListItem* item = reinterpret_cast<ListItem*>(this->item(i)); item->setSortType(sortType); } sortItems(); sql::updateSyncStatus("noteSortType", sortType); }
ListItem* NotesWidget::getNoteWithGuid(QString guid) { ListItem* item = reinterpret_cast<ListItem*>(this->currentItem()); if ((item != NULL) && (item->getGUID() == guid)) return item; for (int i = 0; i < count(); i++) { ListItem* item = reinterpret_cast<ListItem*>(this->item(i)); if (item->getGUID() == guid) { return item; } } return NULL; }
int TagMngrListModel::rowCount(const QModelIndex &parent) const { ListItem* parentItem = 0; if (parent.column() > 0) return 0; if (!parent.isValid()) parentItem = d->rootItem; else parentItem = static_cast<ListItem*>(parent.internalPointer()); return parentItem->childCount(); }
void ComboBox::setSelectedItemIndex(int itemIndex) { if (itemIndex >= 0 && (size_t)itemIndex < m_items.size() && m_selected != itemIndex) { m_selected = itemIndex; ListItems::iterator it = m_items.begin() + itemIndex; ListItem* item = *it; m_entry->setText(item->getText()); onChange(); } }
void List::insertElementAt(int i, int pos) { if (pos <= 0) prependElement(i); else if (pos >= getSize()) appendElement(i); else { ListItem *tmp = first; while (pos-- > 0) { tmp = tmp->getNext(); } new ListItem(tmp->getPrevious(), tmp, i); currentSize++; } }
ListItem* _FindStringItem(BObjectList<ListItem>& list, const char* text, ListItem* parent) { for (int32 i = 0; i < list.CountItems(); i++) { ListItem* item = list.ItemAt(i); ListItem* superItem = (ListItem*)fListView->Superitem(item); if (parent != NULL && parent != superItem) continue; if (strcmp(item->Text(), text) == 0) return item; } return NULL; }
void __fastcall TfrmSoundLib::OnItemsFocused(ListItemsVec& items) { PropItemVec props; RegisterModifiedTHM (); m_Snd.destroy (); m_THM_Current.clear (); if (!items.empty()){ for (ListItemsIt it=items.begin(); it!=items.end(); it++){ ListItem* prop = *it; if (prop){ ESoundThumbnail* thm=FindUsedTHM(prop->Key()); if (!thm) m_THM_Used.push_back(thm=xr_new<ESoundThumbnail>(prop->Key())); m_THM_Current.push_back(thm); thm->FillProp (props); } } } ButtonValue* B=0; if (m_THM_Current.size()==1) { ESoundThumbnail* thm=m_THM_Current.back(); u32 size=0; u32 time=0; PlaySound(thm->SrcName(), size, time); CanvasValue* C=0; C=PHelper().CreateCanvas (props,"Attenuation", "", 64); C->tag = (int)this; C->OnDrawCanvasEvent.bind (this,&TfrmSoundLib::OnAttenuationDraw); // C->OnTestEqual.bind (this,&TfrmSoundLib::OnPointDataTestEqual); B=PHelper().CreateButton (props,"Auto Att", "By Min,By Max",ButtonValue::flFirstOnly); B->OnBtnClickEvent.bind (this,&TfrmSoundLib::OnAttClick); PHelper().CreateCaption (props,"File Length", shared_str().sprintf("%.2f Kb",float(size)/1024.f)); PHelper().CreateCaption (props,"Total Time", shared_str().sprintf("%.2f sec",float(time)/1000.f)); if (!m_Flags.is(flReadOnly)){ B=PHelper().CreateButton(props,"Control", "Play,Stop",ButtonValue::flFirstOnly); B->OnBtnClickEvent.bind (this,&TfrmSoundLib::OnControlClick); } } if (!m_Flags.is(flReadOnly)){ B=PHelper().CreateButton (props,"Auto Play", bAutoPlay?"on":"off",ButtonValue::flFirstOnly); B->OnBtnClickEvent.bind (this,&TfrmSoundLib::OnControl2Click); } m_ItemProps->AssignItems (props); }
void MainWindow::noteTitleChange(QString newTitle) { QString guid = ui->noteTitle->objectName(); if (guid.isEmpty()) return; emit titleChanged(newTitle, guid); ListItem *note = ui->NotesList->getNoteWithGuid(guid); if (note == NULL) return; note->setText(newTitle); }
void MainWindow::switchNote() { ListItem* l = reinterpret_cast<ListItem*>(ui->NotesList->currentItem()); QString id = l->getGUID(); if (id.isEmpty()) return; ui->noteTitle->clear(); ui->titleBar->show(); ui->editButton->setChecked(false); clearConflictBar(); JS(QString("loadNote('%1', false);").arg(id)); }
QModelIndex ListModel::parent(const QModelIndex& index) const { if (!index.isValid()) // root return QModelIndex(); ListItem* item = itemFromIndex(index); if (!item) return QModelIndex(); ListItem* parent = item->parent(); if (parent->isRoot()) // top level item return QModelIndex(); return createIndex(parent->row(), 0, parent); }
QModelIndex ListModel::index(int row, int column, const QModelIndex& parent) const { if (row < 0 || column < 0) return QModelIndex(); ListItem* parentItem = itemFromIndex(parent); if (!parentItem || row >= parentItem->childCount()) return QModelIndex(); ListItem* childItem = parentItem->child(row); if (!childItem) return QModelIndex(); return createIndex(row, column, childItem); }
ListItem* ListModel::itemFromId(int itemId, ListItem* parent) const { if (!parent) parent = root(); for (int i = 0, n = parent->childCount(); i < n; ++i) { ListItem* child = parent->child(i); if (child->id() == itemId) return child; } for (int i = 0, n = parent->childCount(); i < n; ++i) { ListItem* found = itemFromId(itemId, parent->child(i)); if (found) return found; } return nullptr; }
int List::deleteAt(int pos) { if (pos <= 0) return deleteFirst(); else if (pos >= getSize()) return deleteLast(); else { ListItem *del = first; while (pos-- > 0) { del = del->getNext(); } int val = del->getContent(); delete del; currentSize--; return val; } }
void List::insertElementAt(int i, int pos) { if (pos <= 0) { prependElement(i); } else if (pos >= getSize()) { appendElement(i); } else { ListItem* p = first; // iterate over elements while (pos-- > 0) { p = p->getNext(); } new ListItem(p->getPrevious(), p, i); ++currentSize; } }
void NotesWidget::startDrag( Qt::DropActions supportedActions ) { ListItem* l = reinterpret_cast<ListItem*>(currentItem()); if (l == NULL) return; QMimeData *data = new QMimeData; data->setData("qevernote/note", l->encode()); QDrag *drag = new QDrag(this); drag->setPixmap(l->icon().pixmap(24, 24)); drag->setHotSpot(QPoint(12,12)); drag->setMimeData(data); drag->exec(supportedActions, Qt::MoveAction); }
void C4Network2ResDlg::Update() { // check through own resources and current res list ListItem *pItem = static_cast<ListItem *>(pClientWindow->GetFirst()), *pNext; C4Network2Res *pRes; int iResID=-1; while ((pRes = ::Network.ResList.getRefNextRes(++iResID))) { iResID = pRes->getResID(); // resource checking: deleted resource(s) present? while (pItem && (pItem->GetResID() < iResID)) { pNext = static_cast<ListItem *>(pItem->GetNext()); delete pItem; pItem = pNext; } // same resource present for update? if (pItem && pItem->GetResID() == iResID) { pItem->Update(pRes); pItem = static_cast<ListItem *>(pItem->GetNext()); } else // not present: insert (or add if pItem=NULL) InsertElement(new ListItem(this, pRes), pItem); } // del trailing items while (pItem) { pNext = static_cast<ListItem *>(pItem->GetNext()); delete pItem; pItem = pNext; } }
// Add an item to the list (returns id) ListItem* ListBox::AddItem(std::string text) { // Add a ListItem to the contentbox ListItem *item; item = (ListItem*)contentBox->AddItem(new ListItem(menuSystem, []() {})); // Size item to fit box item->SetSize(Vec2(size.x, _ITEMHEIGHT)); // Set onClick function to select this item item->SetOnClick([=]() { this->SetSelectedItem(item); }); // Parse the text, and extract each substring GLint pos1, pos2; pos1 = 0; pos2 = 0; while (pos1 < text.length()) { // Find next tag-character pos2 = text.find_first_of("#", pos1); // If none was found... if (pos2 == std::string::npos) { // Set pos2 to the end of the string pos2 = text.length(); } // Add substring to list-item item->AddItem(text.substr(pos1, pos2 - pos1)); // Move pos1 to one character after next pos1 = pos2 + 1; } // Add list item to listItems listItems.push_back(item); // Return id of the new item return item; }