void ChaserEditor::updateStepList(int selectIndex) { m_tree->clear(); QListIterator <t_function_id> it(*m_chaser->steps()); while (it.hasNext() == true) { QTreeWidgetItem* item; Function* function; t_function_id fid; QString str; fid = it.next(); function = _app->doc()->function(fid); Q_ASSERT(function != NULL); item = new QTreeWidgetItem(m_tree); item->setText(KColumnNumber, "###"); item->setText(KColumnFunction, function->name()); item->setText(KColumnFunctionID, str.setNum(fid)); } /* Select the specified item */ m_tree->setCurrentItem(m_tree->topLevelItem(selectIndex)); /* Update the order number column */ updateOrderNumbers(); }
void ChaserEditor::slotLowerClicked() { QListViewItem* currentItem = m_functionList->currentItem(); if (currentItem != NULL) { QString deviceString = currentItem->text(1); QString functionString = currentItem->text(2); QListViewItem* below = NULL; if (currentItem->itemBelow() != NULL) { below = currentItem->itemBelow(); } if (below != NULL) { m_functionList->takeItem(currentItem); delete currentItem; QListViewItem* newItem; newItem = new QListViewItem(m_functionList, below, "", deviceString, functionString); m_functionList->setSelected(newItem, true); } } updateOrderNumbers(); }
void ChaserEditor::slotRaiseClicked() { QListViewItem* currentItem = m_functionList->currentItem(); if (currentItem != NULL) { QString deviceString = currentItem->text(1); QString functionString = currentItem->text(2); QListViewItem* above = NULL; if (currentItem->itemAbove() != NULL && currentItem->itemAbove()->itemAbove() != NULL) { above = currentItem->itemAbove()->itemAbove(); } m_functionList->takeItem(currentItem); delete currentItem; QListViewItem* newItem; if (above != NULL) { newItem = new QListViewItem(m_functionList, above, "", deviceString, functionString); } else { newItem = new QListViewItem(m_functionList, "", deviceString, functionString); } m_functionList->setSelected(newItem, true); } updateOrderNumbers(); }
void ChaserEditor::slotRemoveClicked() { QListViewItem* item = m_functionList->currentItem(); if (item != NULL) { m_functionList->takeItem(item); delete item; } updateOrderNumbers(); }
void ChaserEditor::slotAddClicked() { FunctionTree* ft = new FunctionTree(this); if (ft->exec() == QDialog::Accepted && ft->deviceString() != QString::null && ft->functionString() != QString::null) { if (m_prevItem == NULL) { m_prevItem = new QListViewItem(m_functionList, "", ft->deviceString(), ft->functionString()); } else { m_prevItem = new QListViewItem(m_functionList, m_prevItem, "", ft->deviceString(), ft->functionString()); } } updateOrderNumbers(); }
void ChaserEditor::updateStepList() { QString device = QString::null; QString function = QString::null; m_stepList->clear(); QValueList<t_function_id>::iterator it; it = m_chaser->steps()->end(); for (unsigned int i = 0; i < m_chaser->steps()->count(); i++) { --it; Function* f = _app->doc()->function(*it); if (!f) { device = QString("Invalid"); function = QString("Invalid"); } else if (f->device() != KNoID) { function = f->name(); Device* d = _app->doc()->device(f->device()); if (!d) { device = QString("Invalid"); } else { device = d->name(); } } else { function = f->name(); device = QString("Global"); } QString fid; fid.setNum(*it); new QListViewItem(m_stepList, "###", device, function, fid); } updateOrderNumbers(); }
void ChaserEditor::addItems() { ChaserStep* step = NULL; QListViewItem* prev = NULL; QString deviceName; QList <ChaserStep> *steps = m_function->steps(); for (unsigned int i = 0; i < steps->count(); i++) { step = steps->at(i); if (prev == NULL) { if (step->device() != NULL) { deviceName = step->device()->name(); } else { deviceName = QString("Global"); } prev = new QListViewItem(m_functionList, "", deviceName, step->function()->name()); } else { if (step->device() != NULL) { deviceName = step->device()->name(); } else { deviceName = QString("Global"); } prev = new QListViewItem(m_functionList, prev, "", deviceName, step->function()->name()); } m_prevItem = prev; } updateOrderNumbers(); }