void TodoModel::addTodoItem(const QMap <QString, QVariant> &values) { QStandardItem *item = new QStandardItem(values ["summary"].toString()); item->setData(values ["categories"].toString(), Qt::UserRole); item->setData(values ["percentComplete"].toInt(), TodoModel::PercentRole); item->setData(values ["uid"].toString(), TodoModel::UIDRole); item->setData(values ["startDate"].toDate(), TodoModel::StartDateRole); item->setData(values ["dueDate"].toDate(), TodoModel::DueDateRole); item->setToolTip(values ["tooltip"].toString()); // if today is the due date we show an alarm icon on the todo if (values ["dueDate"].toDate() == QDate::currentDate() || (values ["dueDate"].toDate () < QDate::currentDate() && values ["percentComplete"].toInt() < 100)) { item->setIcon(KIcon("appointment-reminder")); } categorizeItem(item); insertRow(0, item); }
/** * research a regular expression in the entire vocabulary */ bool QSearchItemModel::searchSelection( QRegExp searchRegExp ) { insertRow( 0 );//status row setData( index(0, 0), tr("search in progress...") ); setData( index(0, 0), QColor( 255, 240, 240 ), Qt::BackgroundRole); setData( index(0, 1), QColor( 255, 240, 240 ), Qt::BackgroundRole); QFont foundFont = QApplication::font(); foundFont.setBold(true); short success = 0; for ( short row=1; row < m_rowCount; ++row ) { for ( short col=0; col < 2; ++col ) { const QString dataString = data( index(row, col) ).toString(); if ( dataString.contains( searchRegExp ) ) { ++success; item( row, col )->setFont(foundFont); } } } if ( success == 0 ) { setData( index(0, 0), tr("No result found.") ); setData( index(0, 0), QColor( 255, 240, 240 ), Qt::BackgroundRole); setData( index(0, 1), QColor( 255, 240, 240 ), Qt::BackgroundRole); } else { QString msg = QString::number( success ); msg.append(tr(" expressions found with: ")).append( searchRegExp.pattern() ); setData( index(0, 0), msg ); setData( index(0, 0), QColor( 240, 255, 240 ), Qt::BackgroundRole); setData( index(0, 1), QColor( 240, 255, 240 ), Qt::BackgroundRole); } return true; }
void HostBrower::refresh(const QHash<QString, int>& hosts) { int row = rowCount(); for (int i=0; i<=row; i++){ removeRow(i); } QHashIterator<QString, int> it(hosts); while(it.hasNext()){ it.next(); QString host = it.key(); QStringList hostlist = host.split(":"); row = rowCount(); insertRow(row); for (int i=0; i<hostlist.size(); i++){ QTableWidgetItem* item = new QTableWidgetItem; item->setTextAlignment(Qt::AlignVCenter | Qt::AlignHCenter); item->setText(hostlist.at(i)); setItem(row, i, item); } } }
void QSearchItemModel::setSearchCouple(QString word1, QString word2, QString topicName, QRegExp searchRegExp) { insertRow( m_rowCount ); QModelIndex currentIndex = index( m_rowCount, 0 ); QFont foundFont = QApplication::font(); foundFont.setBold(true); setData( currentIndex, word1 ); setData( currentIndex, tr("In ").append(topicName), Qt::ToolTipRole ); if ( word1.contains( searchRegExp ) ) item( m_rowCount, 0 )->setFont(foundFont); currentIndex = index( m_rowCount, 1 ); setData( currentIndex, word2 ); setData( currentIndex, tr("In ").append(topicName), Qt::ToolTipRole ); if ( word2.contains( searchRegExp ) ) item( m_rowCount, 1 )->setFont(foundFont); ++m_rowCount; }
void QgsAttributeActionDialog::init( const QgsActionManager& actions, const QgsAttributeTableConfig& attributeTableConfig ) { // Start from a fresh slate. mAttributeActionTable->setRowCount( 0 ); int i = 0; // Populate with our actions. Q_FOREACH ( const QgsAction& action, actions.listActions() ) { insertRow( i++, action ); } updateButtons(); QgsAttributeTableConfig::ColumnConfig visibleActionWidgetConfig = QgsAttributeTableConfig::ColumnConfig(); visibleActionWidgetConfig.type = QgsAttributeTableConfig::Action; visibleActionWidgetConfig.hidden = false; mShowInAttributeTable->setChecked( attributeTableConfig.actionWidgetVisible() ); mAttributeTableWidgetType->setCurrentIndex( attributeTableConfig.actionWidgetStyle() ); }
void ListaEventosEdit::resizeEvent( QResizeEvent *event) { //damos forma a las columnas int ancho = this->width(); this->setColumnWidth(0,150); //Hora this->setColumnWidth(1,80); //Comienzo this->setColumnWidth(2,ancho - 400); //Fichero this->setColumnWidth(3,80); //Prioridad this->setColumnWidth(4,80); //Espera this->setColumnWidth(5,150); //Dias de la semana this->setColumnWidth(6,80); //horas this->setColumnWidth(7,150); //Expiracion this->setColumnHidden(8, true); //ocultamos columnas codigo /// refrescar la lista es un parche************************************ /// genera un cuelge si no se pone vscroll en el qtable insertRow(0); removeRow(0); }
void CDCTableWidget::setNoteItemList(const QList<CNoteItem*>& lstNoteItems) { clearContent(); m_lstNoteItems = lstNoteItems; foreach(CNoteItem* pNoteItem, m_lstNoteItems) { connect(pNoteItem, SIGNAL(dataChanged()), this, SLOT(onNoteItemDataChanged())); connect(pNoteItem, SIGNAL(selectedChanged()), this, SLOT(onNoteItemSelectedChanged())); connect(pNoteItem, SIGNAL(itemStateChanged()), this, SLOT(onNoteItemStateChanged())); int nRowIdx = rowCount(); insertRow(nRowIdx); QTableWidgetItem* pTypeWidgetItem = new QTableWidgetItem(pNoteItem->getIcon(), QString()); pTypeWidgetItem->setData(Qt::UserRole, (qulonglong)pNoteItem); pTypeWidgetItem->setTextAlignment(Qt::AlignCenter); setItem(nRowIdx, 0, pTypeWidgetItem); if(pNoteItem->isNote()) { pTypeWidgetItem->setData(Qt::ToolTipRole, tr("Note")); QTableWidgetItem* pDateWidgetItem = new QTableWidgetItem(pNoteItem->getSetAt().toString(DATE_FORMAT)); pDateWidgetItem->setData(Qt::ToolTipRole, pNoteItem->getSetAt().toString(DATE_FORMAT)); setItem(nRowIdx, 1, pDateWidgetItem); } else { pTypeWidgetItem->setData(Qt::ToolTipRole, tr("Schedule")); QTableWidgetItem* pDateWidgetItem = new QTableWidgetItem(pNoteItem->getSetAt().toString(DATE_TIME_FORMAT)); pDateWidgetItem->setData(Qt::ToolTipRole, pNoteItem->getSetAt().toString(DATE_TIME_FORMAT)); setItem(nRowIdx, 1, pDateWidgetItem); } QTableWidgetItem* pTitleWidgetItem = new QTableWidgetItem(pNoteItem->getTitle()); pTitleWidgetItem->setData(Qt::ToolTipRole, pNoteItem->getTitle()); setItem(nRowIdx, 2, pTitleWidgetItem); }
void QCustomTableWidget::addCharacter(int index) { if (index < 0) { // if no row is selected, we insert it at the end index += rowCount(); } if(pChangeCharacterDial->exec()==QDialog::Accepted) { // updating the CharacterList if (pCharacters) { Character character(pChangeCharacterDial->name().toStdString(), pChangeCharacterDial->shortDescription().toStdString()); pCharacters->add(character,index+1); emit modificationDone(new CharacterModification(pCharacters, new Character(character), index+1, true)); } // updating the display int column_nb = columnCount(); // created cells iCreatedCells = column_nb; insertRow(index+1); for (int i = 0; i < column_nb; i++) { QTableWidgetItem *row1 = new QTableWidgetItem("0"); setItem(index+1,i,row1); } QTableWidgetItem *rowHeaderItem = verticalHeaderItem(index+1); if (rowHeaderItem) { rowHeaderItem->setText(headerText(pChangeCharacterDial->name(), pChangeCharacterDial->shortDescription())); } else { rowHeaderItem = new QTableWidgetItem(headerText(pChangeCharacterDial->name(), pChangeCharacterDial->shortDescription())); setVerticalHeaderItem(index+1, rowHeaderItem); } scrollTo(index+1, -1); } }
void QCustomTableWidget::setLists(SkillList *skills, CharacterList *chars) { pSkills = skills; pCharacters = chars; clear(); setColumnCount(0); setRowCount(0); int i=0; for (SkillList::iterator it = skills->begin(); it != skills->end(); it++) { insertColumn(i); setHorizontalHeaderItem(i,new QTableWidgetItem((*it).c_str())); i++; } int j=0,k; for (CharacterList::iterator it = chars->begin(); it != chars->end(); it++) { insertRow(j); setVerticalHeaderItem(j,new QTableWidgetItem(((*it).name()+"\n"+(*it).playerName()).c_str())); // creating items for (k=0;k<i;k++) { } // setting values k = 0; for (Character::SkillIterator itSkill = (*it).begin(); itSkill != (*it).end() && k<i; itSkill++) { setItem(j,k,new QTableWidgetItem((*itSkill).c_str())); k++; } for (;k<i;k++) { setItem(j,k,new QTableWidgetItem("0")); } j++; } resizeRowsToContents(); resizeColumnsToContents(); }
void ZMessageManagerModel::update() { //removeAllRows(); insertRow(0, QModelIndex()); ZMessageManager &rootManager = ZMessageManager::getRootManager(); /* const QObjectList &managerList = rootManager.children(); for (size_t ) std::vector<std::string> uuidList = m_dag.getBreadthFirstList(); for (size_t i = 1; i < uuidList.size(); ++i) { std::vector<std::string> parentList = m_dag.getParentList(uuidList[i]); for (std::vector<std::string>::const_iterator iter = parentList.begin(); iter != parentList.end(); ++iter) { insertRow(m_dag.getSiblingIndex(uuidList[i]), createIndex(m_dag.getSiblingIndex(*iter),0, *iter)); } } */ }
void RepoTreeModel::checkGroupRepo(const ServerRepo& repo) { QStandardItem *root = invisibleRootItem(); RepoCategoryItem *group = NULL; int row, n = root->rowCount(); for (row = 0; row < n; row ++) { RepoCategoryItem *item = (RepoCategoryItem *)(root->child(row)); if (item->groupId() == repo.group_id) { group = item; break; } } if (!group) { if (repo.group_name == "Organization") { group = new RepoCategoryItem(CAT_INDEX_PUBLIC_REPOS, tr("Organization"), repo.group_id); // Insert pub repos after "recent updated", "my libraries", "shared libraries" insertRow(3, group); } else { group = new RepoCategoryItem(CAT_INDEX_GROUP_REPOS, repo.group_name, repo.group_id); appendRow(group); } } // Find the repo in this group n = group->rowCount(); for (row = 0; row < n; row++) { RepoItem *item = (RepoItem *)(group->child(row)); if (item->repo().id == repo.id) { updateRepoItem(item, repo); return; } } // Current repo not in this group yet RepoItem *item = new RepoItem(repo); group->appendRow(item); }
void ListaGrupos::resizeEvent( QResizeEvent *event) { //damos forma a las columnas int ancho = this->width(); this->setColumnWidth(0,20); this->setColumnWidth(2,100); this->setColumnWidth(1,ancho- 140); this->setColumnHidden(3, true); //ocultamos columnas segundos this->setColumnHidden(4, true); //ocultamos columnas fichero this->setColumnHidden(5, true); //ocultamos columnas segundos pisador this->setColumnHidden(6, true); //ocultamos columnas url pisador in this->setColumnHidden(7, true); //ocultamos columnas url pisador out /// refrescar la lista es un parche************************************ /// genera un cuelge si no se pone vscroll en el qtable insertRow( 0 ); removeRow( 0 ); }
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent) { setupUi(this); #ifdef Q_WS_MAEMO_5 // Alternating row colors look bad on Maemo view->setAlternatingRowColors(false); #endif QStringList headers; headers << tr("Title") << tr("Description"); QFile file(":/default.txt"); file.open(QIODevice::ReadOnly); TreeModel *model = new TreeModel(headers, file.readAll()); file.close(); view->setModel(model); for (int column = 0; column < model->columnCount(); ++column) view->resizeColumnToContents(column); connect(exitAction, SIGNAL(triggered()), qApp, SLOT(quit())); connect(view->selectionModel(), SIGNAL(selectionChanged(const QItemSelection &, const QItemSelection &)), this, SLOT(updateActions())); connect(actionsMenu, SIGNAL(aboutToShow()), this, SLOT(updateActions())); connect(insertRowAction, SIGNAL(triggered()), this, SLOT(insertRow())); connect(insertColumnAction, SIGNAL(triggered()), this, SLOT(insertColumn())); connect(removeRowAction, SIGNAL(triggered()), this, SLOT(removeRow())); connect(removeColumnAction, SIGNAL(triggered()), this, SLOT(removeColumn())); connect(insertChildAction, SIGNAL(triggered()), this, SLOT(insertChild())); updateActions(); }
/* May be expanded to have a thread-view of messages. Ignore all disabled code for now ( doesn't work yet either way ) */ void MailListView::treeInsert(const QMailId& id, const QSoftMenuBar::StandardLabel label) { // bool isEmail = (message.messageType() == QMailMessage::Email); // if ((showEmailsOnly() && !isEmail) || // !showEmailsOnly() && isEmail) // return; insertRow(0); setItem(0, 0, new EmailListItem(this, id, 0) ); QSoftMenuBar::setLabel(this, Qt::Key_Select, rowCount() ? label : QSoftMenuBar::NoLabel); /* if ( mail->inReplyTo().isEmpty() ) { new EmailListItem(this, mail); return; } QString mId = mail->inReplyTo(); Email *m; EmailListItem *item = NULL; QListWidgetItemIterator it( this ); for ( ; it.current(); ++it ) { m = ( (EmailListItem *) it.current() )->getMail(); if ( m->messageId() == mId ) { item = (EmailListItem *) it.current(); break; } } if ( item ) { new EmailListItem(item, mail); item->setOpen(true); } else { new EmailListItem(this, mail); } */ emit enableMessageActions( true ); }
int gui::TreeWindow::qt_metacall(QMetaObject::Call _c, int _id, void **_a) { _id = QWidget::qt_metacall(_c, _id, _a); if (_id < 0) return _id; if (_c == QMetaObject::InvokeMetaMethod) { switch (_id) { case 0: updateActions((*reinterpret_cast< const QModelIndex(*)>(_a[1]))); break; case 1: updateActions(); break; case 2: clickedTree((*reinterpret_cast< const QModelIndex(*)>(_a[1]))); break; case 3: { string _r = ObtType((*reinterpret_cast< const QModelIndex(*)>(_a[1]))); if (_a[0]) *reinterpret_cast< string*>(_a[0]) = _r; } break; case 4: insertChild(); break; case 5: { bool _r = insertColumn((*reinterpret_cast< const QModelIndex(*)>(_a[1]))); if (_a[0]) *reinterpret_cast< bool*>(_a[0]) = _r; } break; case 6: { bool _r = insertColumn(); if (_a[0]) *reinterpret_cast< bool*>(_a[0]) = _r; } break; case 7: insertRow(); break; case 8: { bool _r = removeColumn((*reinterpret_cast< const QModelIndex(*)>(_a[1]))); if (_a[0]) *reinterpret_cast< bool*>(_a[0]) = _r; } break; case 9: { bool _r = removeColumn(); if (_a[0]) *reinterpret_cast< bool*>(_a[0]) = _r; } break; case 10: removeRow(); break; case 11: editObject(); break; case 12: saveShow(); break; case 13: loadShow(); break; case 14: setOrbitmode(); break; case 15: setRollmode(); break; case 16: setDollymode(); break; case 17: setPanymode(); break; case 18: setCalibration(); break; case 19: quit(); break; default: ; } _id -= 20; } return _id; }
void LabelView::onAddLabel(medusa::Address const& address, medusa::Label const& label) { if (label.GetType() & medusa::Label::Local) return; setUpdatesEnabled(false); QString labelType = ""; switch (label.GetType() & medusa::Label::AccessMask) { case medusa::Label::Exported: labelType += "exported "; break; case medusa::Label::Imported: labelType += "imported "; break; default: break; } switch (label.GetType() & medusa::Label::CellMask) { case medusa::Label::Code: labelType += "code"; break; case medusa::Label::Function: labelType += "function"; break; case medusa::Label::Data: labelType += "data"; break; case medusa::Label::String: labelType += "string"; break; default: labelType += "unknown"; break; } auto model = this->model(); _mutex.lock(); const int row = model->rowCount(); model->insertRow(row); model->setData(model->index(row, 0), QString::fromStdString(label.GetLabel())); model->setData(model->index(row, 1), labelType); model->setData(model->index(row, 2), QString::fromStdString(address.ToString())); // This method can assert //resizeColumnToContents(0); //resizeColumnToContents(1); //resizeColumnToContents(2); _mutex.unlock(); setUpdatesEnabled(true); }
TableGroupBox::TableGroupBox(const QString & title, QWidget * parent) : QGroupBox(title, parent) { m_lastRowFixed = false; m_buttonRow = new QHBoxLayout; const int spacing = 5; // Create the buttons m_addButton = new QPushButton(QIcon(":/images/list-add.svg"), tr("Add")); connect(m_addButton, SIGNAL(clicked()), this, SLOT(addRow())); m_buttonRow->addWidget(m_addButton); m_buttonRow->addSpacing(spacing); m_insertButton = new QPushButton(tr("Insert")); m_insertButton->setEnabled(false); connect(m_insertButton, SIGNAL(clicked()), this, SLOT(insertRow())); m_buttonRow->addWidget(m_insertButton); m_buttonRow->addSpacing(spacing); m_removeButton = new QPushButton(QIcon(":/images/list-remove.svg"), tr("Remove")); m_removeButton->setEnabled(false); connect(m_removeButton, SIGNAL(clicked()), this, SLOT(removeRow())); m_buttonRow->addWidget(m_removeButton); m_buttonRow->addStretch(1); // Create the tableview m_table = new MyTableView; m_table->setSelectionMode(QAbstractItemView::ContiguousSelection); // Create the layout of the group box QVBoxLayout * layout = new QVBoxLayout; layout->addItem(m_buttonRow); layout->addWidget(m_table); setLayout(layout); }
void choseWaveToExtract::refreshOptChoi() { //---------------------------------------------- //Clear tables //---------------------------------------------- while (ui->tableOptions->rowCount() > 0) { ui->tableOptions->removeRow(0); } while (ui->tableChoises->rowCount() > 0) { ui->tableChoises->removeRow(0); } //---------------------------------------------- //Fill tables //---------------------------------------------- QString options, choises; options = readAllFile(_PATH_WAVE_OPTIONS); choises = readAllFile(_PATH_WAVE_CHOISES); QList<QString> lstOptions = options.split(","); QList<QString> lstChoises = choises.split(","); QList<float> lstOptNumber; QList<float> lstChoisesNumber; int i; for(i=1;i<lstOptions.size();i++) lstOptNumber.append(lstOptions.at(i).toFloat()); for(i=1;i<lstChoises.size();i++) lstChoisesNumber.append(lstChoises.at(i).toFloat()); std::sort(lstOptNumber.begin(), lstOptNumber.end()); std::sort(lstChoisesNumber.begin(), lstChoisesNumber.end()); Q_FOREACH(const float option, lstOptNumber) { insertRow(QString::number(option),ui->tableOptions); }
void QQuestionsTableWidget::addQuestionRow() { bool restore_sort = false; if (isSortingEnabled()) { setSortingEnabled(false); restore_sort = true; } insertRow(rowCount()); for (unsigned int i = 0; i < 1 + CHOICE_COUNT; i++) setItem(rowCount() - 1,i,new QTableWidgetItem()); QComboBox * combobox = new QComboBox(); for (unsigned int i = 1; i <= CHOICE_COUNT; i++) combobox -> addItem(QString::number(i)); setCellWidget(rowCount() - 1, 1 + CHOICE_COUNT,combobox); setItem(rowCount() - 1, 1 + CHOICE_COUNT,new QComboBoxTableItem()); if (RATING) { connect(combobox,SIGNAL(currentIndexChanged(int)),this,SIGNAL(signalNeedSave())); combobox = new QComboBox(); for (unsigned int i = 1; i <= RATING; i++) combobox -> addItem(QString::number(i)); setCellWidget(rowCount() - 1,1 + CHOICE_COUNT + 1,combobox); setItem(rowCount() - 1, 1 + CHOICE_COUNT + 1,new QComboBoxTableItem()); } connect(combobox,SIGNAL(currentIndexChanged(int)),this,SIGNAL(signalNeedSave())); if (restore_sort) { setSelectionMode(QAbstractItemView::SingleSelection); setCurrentCell(rowCount()-1,0); setSelectionMode(QAbstractItemView::ExtendedSelection); setSortingEnabled(true); } }
void DCellView::addItem(DCellViewItem *item) { if( columnCount() < MAX_COLUMNS) { insertColumn( columnCount() ); } if( m_countColor % MAX_COLUMNS == 0) { insertRow( rowCount() ); m_row++; m_col = 0; } else { m_col++; } m_countColor++; setItem(m_row-1 , m_col , item); fixSize(); }
void RecentListItemModel::addRecent(QString name, QString value, QString type, QString sender, qint64 size) { QStandardItem* it = new QStandardItem(); // Format timestamp QDateTime now = QDateTime::currentDateTime(); QString datetime = now.toString(Qt::SystemLocaleShortDate); // Convert size data QString sizeFormatted; if (size < 1024) sizeFormatted = QString::number(size) + " B"; else if (size < 1048576) sizeFormatted = QString::number(size * BYTES_TO_KB, 'f', 1) + " KB"; else sizeFormatted = QString::number(size * BYTES_TO_MB, 'f', 1) + " MB"; // Icon if (type == "text") it->setData("RecentText.png", RecentListItemModel::TypeIcon); else if (type == "file") it->setData("RecentFile.png", RecentListItemModel::TypeIcon); else it->setData("RecentFiles.png", RecentListItemModel::TypeIcon); if (type == "text") it->setData(name, RecentListItemModel::Name); else it->setData(name + " (" + sizeFormatted + ")", RecentListItemModel::Name); it->setData(value, RecentListItemModel::Value); it->setData(type, RecentListItemModel::Type); it->setData(datetime, RecentListItemModel::DateTime); it->setData(sender, RecentListItemModel::Sender); it->setData(sizeFormatted, RecentListItemModel::Size); insertRow(0, it); }
/****************************************************************************** * version: 1.0 * author: link * date: 2016.02.26 * brief: 更新电阻设置 ******************************************************************************/ void widget_Res::updateShow(QStringList str) { int i,j; setting = str; QStringList string; string.append(tr("铜")); string.append(tr("铝")); string.append(tr("铜铝")); int row = (setting.size()-OTHER)/RES_NUM; for(i=0; i<RES_OTHER; i++) otherSpin[i]->setValue(setting[i].toDouble()); if (row > RES_ROW){ tableWidget->setRowCount(row); for (i=0; i<row-RES_ROW; i++) insertRow(); } for (i=0; i<row; i++){ if (setting[OTHER+i*RES_NUM].toInt()) checkBox[i]->setChecked(true); else checkBox[i]->setChecked(false); for (j=0; j<RES_COL; j++) spinBox[j][i]->setValue(setting[OTHER+i*RES_NUM+1+j].toDouble()); QTableWidgetItem *pItem = new QTableWidgetItem; pItem->setTextAlignment(Qt::AlignCenter); pItem->setText(string[setting[OTHER+i*NUM_RES+6].toInt()%string.size()]); tableWidget->setItem(i,6,pItem); } }
void TableViewModel::addNodeIntoModel( int rowNumber, QString type, QString text ) { // 將簡寫轉為單字 if (type == LETTER_ATTRIBUTE) type = TYPE_ATTRIBUTE; else if (type == LETTER_ENTITY) type = TYPE_ENTITY; else if (type == LETTER_RELATIONSHIP) type = TYPE_RELATIONSHIP; else type = TYPE_CONNECTOR; QStandardItem *typeItem = new QStandardItem(type); QStandardItem *textItem = new QStandardItem(text); // 設定type那欄不可點選、編輯 typeItem->setFlags(typeItem->flags() & ~Qt::ItemIsEditable & ~Qt::ItemIsSelectable); // 新增row QList<QStandardItem*> rowContent; rowContent << typeItem << textItem; //appendRow(row); insertRow(rowNumber, rowContent); }
void DomModel::addSite(const QModelIndex &index) { QString newUuid = QUuid::createUuid().toString(); // Clone current site or default site QString uuid; if (type(index) == Site || type(index) == Favorite) uuid = data(index, Qt::UserRole).toString(); else uuid = QUuid().toString(); QDomNodeList siteList = domDocument.elementsByTagName("site"); for (int i=0; i<siteList.count(); i++) { QDomElement site = siteList.item(i).toElement(); if (site.attribute("uuid") == uuid) { QDomElement newSite = site.cloneNode().toElement(); newSite.setAttribute("uuid", newUuid); QDomElement root = domDocument.documentElement(); root.appendChild(newSite); break; } } // Create site reference QDomElement newSiteRef = domDocument.createElement("addsite"); newSiteRef.setAttribute("uuid", newUuid); // New site reference is either child or sibyling QModelIndex parentIndex; int row; if (type(index) == Folder) { parentIndex = index; row = -1; } else { parentIndex = index.parent(); row = index.row(); } DomItem *item = new DomItem(newSiteRef); insertRow(row, parentIndex, item); }
void EventTableWidget::addRow(RowData& rowData) { insertRow(0); QTableWidgetItem* item = createTableWidgetItem(rowData[EVENT_ID], rowData.isActive()); setItem(0, EVENT_ID, item); item = createTableWidgetItem(rowData[ORIGIN_TIME], rowData.isActive()); setItem(0, ORIGIN_TIME, item); item = createTableWidgetItem(rowData[MAGNITUDE], rowData.isActive()); setItem(0, MAGNITUDE, item); item = createTableWidgetItem(rowData[MAGNITUDE_TYPE], rowData.isActive()); setItem(0, MAGNITUDE_TYPE, item); item = createTableWidgetItem(rowData[EVENT_REGION], rowData.isActive()); setItem(0, EVENT_REGION, item); item = createTableWidgetItem(rowData[LATITUDE], rowData.isActive()); setItem(0, LATITUDE, item); item = createTableWidgetItem(rowData[LONGITUDE], rowData.isActive()); setItem(0, LONGITUDE, item); item = createTableWidgetItem(rowData[DEPTH], rowData.isActive()); setItem(0, DEPTH, item); if ( rowData.isSelected() ) selectRow(0); resizeColumnsToContents(); QHeaderView* horizontalHeaderRef = horizontalHeader(); horizontalHeaderRef->setResizeMode(horizontalHeaderRef->count()-1, QHeaderView::Stretch); }
bool CQCreatorDM::setData(const QModelIndex &index, const QVariant &value, int role) { if (index.isValid() && role == Qt::EditRole) { if (isDefaultRow(index)) { if (index.data() != value) insertRow(); else return false; } switch (index.column()) { case COL_FAMILY_NAME: mpMIRIAMInfo->getCreators()[index.row()]->setFamilyName(TO_UTF8(value.toString())); break; case COL_GIVEN_NAME: mpMIRIAMInfo->getCreators()[index.row()]->setGivenName(TO_UTF8(value.toString())); break; case COL_EMAIL: mpMIRIAMInfo->getCreators()[index.row()]->setEmail(TO_UTF8(value.toString())); break; case COL_ORG: mpMIRIAMInfo->getCreators()[index.row()]->setORG(TO_UTF8(value.toString())); break; } emit dataChanged(index, index); emit notifyGUI(ListViews::MIRIAM, ListViews::CHANGE, ""); return true; } return false; }
void LoggingTableWidget::AppendRow( jha::LoggingTableWidgetRow *newRow ) { if( newRow == nullptr ) { return; } if( newRow->m_Items.isEmpty() == true ) { return; } int newRowIndex = rowCount(); insertRow( newRowIndex ); for( int i=0;i<newRow->m_Items.size();i++ ) { setItem(newRowIndex,i,newRow->m_Items.at(i)); } delete newRow; newRow = nullptr; RowsAdded = true; }
// Read a matrix, with unknown dimensions, from a text file // Return an empty matrix (0 rows, 0 columns) if there is an error MatrixXd readMatrixXd(const string &filename) { ifstream instrm(filename.c_str(), ios::in); if (!instrm.is_open( )) { return (MatrixXd::Zero(0,0)); } string line; getline(instrm,line); boost::algorithm::trim(line); // Split the first line into numbers VectorXd row = split(line); // This tells us the number of columns int cols = row.size(); if (!cols) { return (MatrixXd::Zero(0,0)); } MatrixXd mat(1,cols); mat.row(0) = row; while (getline(instrm,line)) { boost::algorithm::trim(line); row = split(line); if (row.size()==cols) { // Resize the matrix to add each row (done once at the start of EEMS, so okay) insertRow(mat,row); } else { return (MatrixXd::Zero(0,0)); } } instrm.close(); return(mat); }
void QCustomTableWidget::updateDisplay(int row, int column) { // storing the scroll state QScrollBar *hbar = horizontalScrollBar(); QScrollBar *vbar = verticalScrollBar(); int x = hbar->value(); int y = vbar->value(); // iterating over characters and properties to populate the table bUpdate = true; clear(); setColumnCount(0); setRowCount(0); int i=0; for (PropertyList::iterator it = pProperties->begin(); it != pProperties->end(); it++) { insertColumn(i); setHorizontalHeaderItem(i,new QTableWidgetItem((*it).c_str())); i++; } int j=0,k; for (CharacterList::iterator it = pCharacters->begin(); it != pCharacters->end(); it++) { insertRow(j); setVerticalHeaderItem(j, new QTableWidgetItem(headerText((*it).name().c_str(), (*it).shortDescription().c_str()))); // creating items for (k=0;k<i;k++) { } // setting values k = 0; for (Character::PropertyIterator itProperty = (*it).begin(); itProperty != (*it).end() && k<i; itProperty++) { setItem(j,k,new QTableWidgetItem((*itProperty).c_str())); k++; } for (;k<i;k++) { setItem(j,k,new QTableWidgetItem("0")); } j++; } bUpdate = false; if (row > -1 || column > -1) { // restoring the scroll state hbar->setValue(x); vbar->setValue(y); scrollTo(row, column); // setting the current cell, row or column QItemSelectionModel::SelectionFlags flags = QItemSelectionModel::Select; if (row == -1) { flags |= QItemSelectionModel::Columns; row = 0; } if (column == -1) { flags |= QItemSelectionModel::Rows; column = 0; } setCurrentCell(row, column, flags); } }
SubscribeServerThread::SubscribeStatus SubscribeServerThread::addSubscription( const int timeNow, const SipMessage* subscribeMessage, const char* domain, const UtlString& eventType, const UtlString& eventId, const UtlHashMap& eventParams, UtlString& newToTag, int& grantedExpiration) { SubscribeStatus returnStatus = STATUS_INTERNAL_ERROR; int subscribeCseqInt = 0; UtlString callId; UtlString contactEntry; UtlString to; UtlString from; UtlString route; UtlString key; UtlString method; Url identity; // Construct the identity UtlString uriUser, requestUri; subscribeMessage->getUri( NULL, NULL, NULL, &uriUser ); subscribeMessage->getRequestUri( &requestUri ); identity.setUserId( uriUser ); identity.setUrlType( "sip" ); identity.setHostAddress( domain ); subscribeMessage->getToField(&to); subscribeMessage->getFromField(&from); subscribeMessage->getCallIdField(&callId); subscribeMessage->getCSeqField(&subscribeCseqInt, &method); subscribeMessage->getContactEntry(0, &contactEntry); subscribeMessage->buildRouteField(&route); Url toUrl; subscribeMessage->getToUrl(toUrl); int commonExpires = -1; if ( subscribeMessage->getExpiresField( &commonExpires ) ) { if( commonExpires > 0 ) // came from request { if (commonExpires < mMinExpiresTimeint) { returnStatus = STATUS_LESS_THAN_MINEXPIRES; OsSysLog::add( FAC_SIP, PRI_ERR, "addSubscription: " "Expires (%d) less than Minimum (%d)", commonExpires, mMinExpiresTimeint); return returnStatus; } else if (commonExpires > mDefaultSubscribePeriod) { commonExpires = mDefaultSubscribePeriod; } else { // commonExpires is in the allowed range - use the requested value } } else if( commonExpires == 0 ) { // remove subscription binding // remove all bindings because one contact value is * OsSysLog::add(FAC_SIP, PRI_DEBUG,"SubscribeServerThread::addSubscription -" " subscription for url %s and event %s to be removed after sending NOTIFY", toUrl.toString().data(), eventType.data()); returnStatus = STATUS_TO_BE_REMOVED; return returnStatus; } else if( commonExpires == -1) // no expires value in request { // Assume the default value commonExpires = mDefaultSubscribePeriod; OsSysLog::add(FAC_SIP, PRI_DEBUG,"SubscribeServerThread::addSubscription -" " No Expires Value, assigning default value (%d)", commonExpires); } } UtlString sipxImpliedParameter(SIPX_IMPLIED_SUB); UtlString* sipxImpliedDuration = NULL; int grantedExpirationTime; if (( sipxImpliedDuration = dynamic_cast<UtlString*>(eventParams.findValue(&sipxImpliedParameter)))) { /* * This request was generated by the registrar as an implied subscription; * its duration must therefore match that of the registration, which has * already been randomized. */ grantedExpirationTime = atoi(sipxImpliedDuration->data()); } else { /* * The request is for a new or refreshed subscription (other cases were handled above); * commonExpires is now the requested duration in the range: * mMinExpiresTimeint <= commonExpires <= mDefaultSubscribePeriod * In order to distribute expirations smoothly, we actually grant a randomized duration */ int spreadFloor = mMinExpiresTimeint*2; if ( commonExpires > spreadFloor ) { // a normal (long) registration // - spread it between twice the min and the longest they asked for grantedExpirationTime = ( (rand() % (commonExpires - spreadFloor)) + spreadFloor); } else if ( commonExpires > mMinExpiresTimeint ) { // a short but not minimum registration // - spread it between the min and the longest they asked for grantedExpirationTime = ( (rand() % (commonExpires - mMinExpiresTimeint) ) + mMinExpiresTimeint ); } else // longestExpiration == mMinExpiresTimeint { // minimum - can't randomize because we can't shorten or lengthen it grantedExpirationTime = mMinExpiresTimeint; } } // Handle the to-tag: // If no to-tag, this is a new subscription, for which we must create // a to-tag. // If there is a to-tag, this is a renewal of a subscription, and we // must first check that the subscription exists. (This is because if // the UA thinks there is a subscription, but we do not know of it, we // cannot reconstitute the subscription, as we do not know the NOTIFY CSeq // that the UA expects. See XECS-406 for the ill consequences of // this problem.) // Clear the returned new to-tag. newToTag.remove(0); { UtlString x; bool r = toUrl.getFieldParameter("tag", x); OsSysLog::add(FAC_SIP, PRI_DEBUG,"SubscribeServerThread::addSubscription getting to-tag, return %d, value '%s'", (int) r, x.data()); } UtlString toTag; if (toUrl.getFieldParameter("tag", toTag)) { // Check to see if this subscription exists. // Critical Section here OsLock mutex(mLock); bool exists = SubscriptionDB::getInstance()->subscriptionExists( SUBSCRIPTION_COMPONENT_STATUS, to, from, callId, OsDateTime::getSecsSinceEpoch()); OsSysLog::add(FAC_SIP, PRI_DEBUG,"SubscribeServerThread::addSubscription subscriptionExists(..., '%s', '%s', '%s', %d) = %d", to.data(), from.data(), callId.data(), (int) OsDateTime::getSecsSinceEpoch(), exists); if (!exists) { returnStatus = STATUS_BAD_SUBSCRIPTION; return returnStatus; } } else { // Generate a random to-tag. CallId::getNewTag(newToTag); // Add it to the remembered To header value. to.append(";tag="); to.append(newToTag); OsSysLog::add(FAC_SIP, PRI_DEBUG,"SubscribeServerThread::addSubscription generated to-tag '%s'", newToTag.data()); } OsSysLog::add(FAC_SIP, PRI_DEBUG, "SubscribeServerThread::addSubscription -" " Adding/updating subscription for URI '%s' event %s duration %d to '%s'", toUrl.toString().data(), eventType.data(), grantedExpirationTime, contactEntry.data()); // trim the contact to just the uri Url contactUrl(contactEntry); contactUrl.getUri(contactEntry); // add bindings identity.getIdentity( key ); // Insert or update the information for this subscription. // (Note that the "notify CSeq" parameter is ignored if there is // an existing SubscriptionDB row for this subscription.) if (insertRow(requestUri, // identity, callId, contactEntry, grantedExpirationTime + timeNow, subscribeCseqInt, eventType, eventId, to, from, key, // this will be searched for later route, 1)) // initial notify cseq (sent to phone) { grantedExpiration = grantedExpirationTime; returnStatus = STATUS_SUCCESS; } else { // log the error and send error indication to subscriber OsSysLog::add(FAC_SIP, PRI_ERR, "SubscribeServerThread::addSubscription -" " Could not insert record in Database"); returnStatus = STATUS_INTERNAL_ERROR; } return returnStatus; }