void GraphPlotDialog::setGraphVisibility(int currentVisibility) { QTableWidget *currentList = NULL; QTableWidget *endList = NULL; if (currentVisibility == 1) { currentList = mUi.visibleGraph; endList = mUi.invisibleGraph; } else if (currentVisibility == 0) { currentList = mUi.invisibleGraph; endList = mUi.visibleGraph; } else { return; } QTableWidgetItem *item = currentList->takeItem(currentList->currentRow(), 0); QTableWidgetItem *valueItem = currentList->takeItem(currentList->currentRow(), 1); if (!item || !valueItem) { return; } currentList->removeRow(currentList->currentRow()); unsigned graphId = item->data(Qt::UserRole).toUInt(); mData[graphId].isSelected = false; int rowCount = endList->rowCount(); endList->setRowCount(rowCount + 1); endList->setItem(rowCount, 0, item); endList->setItem(rowCount, 1, valueItem); }
void Player::playNext() { stop(); _isPaused = false; int r; QTableWidget *widget = 0; QList<Track*> *playlist = 0; // Track *track = 0; if (_ui->tabWidget->currentWidget() == _ui->libraryTab) { widget = _ui->tracks; playlist = &_libTracks; } else { widget = _ui->playlist; playlist = &_plistTracks; } r = widget->currentRow() + 1; if (r >= playlist->size()) return; widget->setCurrentCell(r, 0); play(); }
void model_import_dlg::on_texture_dialog_done(bool add, QString path, QString type) { QTableWidget * table = mesh_tab->findChild<QTableWidget*>("texturesTable"); int row = 0; if (add) { row = table->rowCount(); table->insertRow(row); } else { row = table->currentRow(); } table->setItem(row, 0, new QTableWidgetItem(path)); table->setItem(row, 1, new QTableWidgetItem(type)); table->setColumnWidth(0, 350); table->setColumnWidth(1, 150); for (int i = 0; i < table->rowCount(); i++) for (int j = 0; j < table->columnCount(); j++) table->item(i, j)->setTextAlignment(Qt::AlignHCenter | Qt::AlignVCenter); }
void Player::playPrevious() { stop(); _isPaused = false; int r; QTableWidget *widget = 0; // QList<Track*> *playlist = 0; // Track *track = 0; if (_ui->tabWidget->currentWidget() == _ui->libraryTab) { widget = _ui->tracks; // playlist = &_libTracks; } else { widget = _ui->playlist; // playlist = &_plistTracks; } r = widget->currentRow(); if (r <= 0) return; widget->setCurrentCell(--r, 0); play(); }
void model_import_dlg::on_texture_delete() { QTableWidget * table = mesh_tab->findChild<QTableWidget*>("texturesTable"); auto current = table->currentRow(); table->removeRow(current); }
void MainWindow::slotMount() { QTableWidget * table = m_ui->tableWidget ; int row = table->currentRow() ; QString device = table->item( row,0 )->text() ; QString type = table->item( row,2 )->text() ; QString label = table->item( row,3 )->text() ; this->mount( type,device,label ) ; }
void NotifyItemDelegate::selectRow(const QString & text) { QComboBox *combo = qobject_cast<QComboBox *>(sender()); QTableWidget *table = new QTableWidget; table = (QTableWidget *)(combo->parent()); qNotifyDebug() << table->columnCount(); qNotifyDebug() << table->rowCount(); qNotifyDebug() << table->currentRow(); }
void model_import_dlg::on_texture_edit() { QTableWidget * table = mesh_tab->findChild<QTableWidget*>("texturesTable"); int row = table->currentRow(); QString path = table->item(row, 0)->text(); QString type = table->item(row, 1)->text(); texture_import_dlg dialog; dialog.init(path, type); dialog.setFixedSize(400, 120); dialog.set_callback(boost::bind(&model_import_dlg::on_texture_dialog_done, this, false, _1, _2)); dialog.exec(); }
void model_import_dlg::on_color_pick() { QTableWidget * table = mesh_tab->findChild<QTableWidget*>("colorsTable"); int row = table->currentRow(); int r = table->item(row, 0)->text().toInt(); int g = table->item(row, 1)->text().toInt(); int b = table->item(row, 2)->text().toInt(); QColor color(r, g, b); color = QColorDialog::getColor(color, this, "Pick color"); table->item(row, 0)->setText(QString::number(color.red())); table->item(row, 1)->setText(QString::number(color.green())); table->item(row, 2)->setText(QString::number(color.blue())); }
void favorites::removeEntryFromFavoriteList() { QTableWidget * table = m_ui->tableWidget ; table->setEnabled( false ) ; int row = table->currentRow() ; QString txt1 = table->item( row,0 )->text() ; QString txt2 = table->item( row,1 )->text() ; QString entry = QString( "%1\t%2\n" ).arg( txt1 ).arg( txt2 ) ; utility::removeFavoriteEntry( entry ) ; tablewidget::deleteRowFromTable( table,row ) ; table->setEnabled( true ) ; }
bool TableEventHandler::eventFilter(QObject *o, QEvent *e) { if( !o ) qWarning("TableEventHandler::eventFilter called with 0 object?"); if( QString(o->metaObject()->className()) != tr("QTableWidget") ) { #ifdef EI_DEBUG qDebug("Only QTableWidget objects accepted! Returning!"); #endif return false; } QTableWidget *to = (QTableWidget *)o; if( e->type() == QEvent::KeyPress ) { QKeyEvent *ke = (QKeyEvent*)e; if(ke->matches(QKeySequence::Copy) ){ QString cellText; itemCopy.clear(); copyRange.clear(); QList<QTableWidgetSelectionRange> ts = to->selectedRanges(); if(!ts.isEmpty()) { for ( int irow = ts.first().topRow(); irow <= ts.first().bottomRow(); irow++){ for ( int icol = ts.first().leftColumn(); icol <= ts.first().rightColumn(); icol++){ QTableWidgetItem *w = to->item(irow,icol); if(w) cellText = w->text(); if ( !cellText.isEmpty() ){ itemCopy << cellText; } else itemCopy << " "; } } copyRange = ts; //cout << itemCopy.join(", ").toLatin1().data() << endl; } else { QTableWidgetItem *w = to->item(to->currentRow(), to->currentColumn()); if (w) cellText = w->text(); if ( !cellText.isEmpty() ) itemCopy << cellText; else itemCopy << ""; } return true; } else if(ke->matches(QKeySequence::Paste) && !itemCopy.isEmpty() && !copyRange.isEmpty()){ QList<QTableWidgetSelectionRange> cs = to->selectedRanges(); int top = cs.first().topRow(), left = cs.first().leftColumn(), icount = 0; QTableWidgetSelectionRange ts = QTableWidgetSelectionRange( top , left, top + copyRange.first().rowCount()-1, left + copyRange.first().columnCount()-1); for ( int irow = ts.topRow(); irow <= ts.bottomRow(); irow++){ for ( int icol = ts.leftColumn(); icol <= ts.rightColumn(); icol++){ if ( ++icount <= itemCopy.size() ) to->setItem(irow, icol, new QTableWidgetItem(itemCopy[icount-1])); } } return true; } else if(ke->matches(QKeySequence::Cut) ){ QString cellText; itemCopy.clear(); copyRange.clear(); QList<QTableWidgetSelectionRange> ts = to->selectedRanges(); if(!ts.isEmpty()) { for (int irow = ts.first().topRow(); irow <= ts.first().bottomRow(); irow++) { for(int icol = ts.first().leftColumn(); icol <= ts.first().rightColumn(); icol++) { QTableWidgetItem *w = to->item(irow,icol); if(w) cellText = w->text(); if ( !cellText.isEmpty() ){ itemCopy << cellText; } else itemCopy << ""; to->setItem(irow,icol,0); } } copyRange = ts; //cout << itemCopy.join(", ").toLatin1().data() << endl; } return true; } else if(ke->matches(QKeySequence::Delete) ){ QList<QTableWidgetSelectionRange> ts = to->selectedRanges(); if(!ts.isEmpty()) { for (int irow = ts.first().topRow(); irow <= ts.first().bottomRow(); irow++) { for(int icol = ts.first().leftColumn(); icol <= ts.first().rightColumn(); icol++) { to->setItem(irow,icol,0); } } } return true; } else to->eventFilter(o, e); } return false; }
void AddEditBlog::fetchedBlogId(const QList< QMap < QString, QString > > &list) { if (d->mFetchBlogIdTimer) { d->mFetchBlogIdTimer->deleteLater(); d->mFetchBlogIdTimer = Q_NULLPTR; } hideWaitWidget(); QString blogId, blogName, blogUrl, apiUrl; const int listCount(list.count()); if (listCount > 1) { qCDebug(BLOGILO_LOG) << "User has more than ONE blog!"; QDialog *blogsDialog = new QDialog(this); QTableWidget *blogsList = new QTableWidget(blogsDialog); blogsList->setSelectionBehavior(QAbstractItemView::SelectRows); QList< QMap<QString, QString> >::const_iterator it = list.constBegin(); QList< QMap<QString, QString> >::const_iterator endIt = list.constEnd(); int i = 0; blogsList->setColumnCount(4); QStringList headers; headers << i18n("Title") << i18n("URL"); blogsList->setHorizontalHeaderLabels(headers); blogsList->setColumnHidden(2, true); blogsList->setColumnHidden(3, true); for (; it != endIt; ++it) { qCDebug(BLOGILO_LOG) << it->value(QStringLiteral("title")); blogsList->insertRow(i); blogsList->setCellWidget(i, 0, new QLabel(it->value(QStringLiteral("title")))); blogsList->setCellWidget(i, 1, new QLabel(it->value(QStringLiteral("url")))); blogsList->setCellWidget(i, 2, new QLabel(it->value(QStringLiteral("id")))); blogsList->setCellWidget(i, 3, new QLabel(it->value(QStringLiteral("apiUrl")))); ++i; } QVBoxLayout *mainLayout = new QVBoxLayout; blogsDialog->setLayout(mainLayout); mainLayout->addWidget(blogsList); blogsDialog->setWindowTitle(i18n("Which blog?")); if (blogsDialog->exec()) { int row = blogsList->currentRow(); if (row == -1) { delete blogsDialog; return; } blogId = qobject_cast<QLabel *>(blogsList->cellWidget(row, 2))->text(); blogName = qobject_cast<QLabel *>(blogsList->cellWidget(row, 0))->text(); blogUrl = qobject_cast<QLabel *>(blogsList->cellWidget(row, 1))->text(); apiUrl = qobject_cast<QLabel *>(blogsList->cellWidget(row, 3))->text(); } else { delete blogsDialog; return; } delete blogsDialog; } else if (listCount > 0) { blogId = list.constBegin()->value(QStringLiteral("id")); blogName = list.constBegin()->value(QStringLiteral("title")); blogUrl = list.constBegin()->value(QStringLiteral("url")); apiUrl = list.constBegin()->value(QStringLiteral("apiUrl")); } else { KMessageBox::sorry(this, i18n("Sorry, No blog found with the specified account info.")); return; } d->ui.txtId->setText(blogId); d->ui.txtTitle->setText(blogName); d->ui.txtId->setEnabled(true); d->ui.btnFetch->setEnabled(true); d->ui.btnAutoConf->setEnabled(true); if (!apiUrl.isEmpty()) { d->ui.txtUrl->setText(apiUrl); } else { apiUrl = d->ui.txtUrl->text(); } if (!blogUrl.isEmpty()) { d->bBlog->setBlogUrl(blogUrl); } else { if (d->tmpBlogUrl.isEmpty()) { d->bBlog->setBlogUrl(apiUrl); } else { d->bBlog->setBlogUrl(d->tmpBlogUrl); } } d->bBlog->setUrl(QUrl(apiUrl)); d->bBlog->setUsername(d->ui.txtUser->text()); d->bBlog->setPassword(d->ui.txtPass->text()); d->bBlog->setBlogId(blogId); d->bBlog->setTitle(blogName); }