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 ) ; }
QWidget * Table::createQtWidget(Proxy *proxy, UIProxy *uiproxy, QWidget *parent) { QTableWidget *tablewidget = new TableWidget(this, parent); tablewidget->setEnabled(enabled); tablewidget->setVisible(visible); tablewidget->setStyleSheet(QString::fromStdString(style)); size_t rowcount = rows.size(), columncount = 0; for(size_t i = 0; i < rowcount; i++) columncount = std::max(columncount, rows[i].size()); tablewidget->setRowCount(rowcount); tablewidget->setColumnCount(columncount); tablewidget->horizontalHeader()->setVisible(show_horizontal_header); tablewidget->verticalHeader()->setVisible(show_vertical_header); tablewidget->setShowGrid(show_grid); QStringList qtHorizontalHeader; for(size_t i = 0; i < horizontalHeader.size(); i++) qtHorizontalHeader << QString::fromStdString(horizontalHeader[i]); tablewidget->setHorizontalHeaderLabels(qtHorizontalHeader); QStringList qtVerticalHeader; for(size_t i = 0; i < verticalHeader.size(); i++) qtVerticalHeader << QString::fromStdString(verticalHeader[i]); tablewidget->setVerticalHeaderLabels(qtVerticalHeader); if(autosize_horizontal_header) tablewidget->horizontalHeader()->setSectionResizeMode(QHeaderView::ResizeToContents); if(autosize_vertical_header) tablewidget->verticalHeader()->setSectionResizeMode(QHeaderView::ResizeToContents); if(sortable) tablewidget->setSortingEnabled(true); for(size_t row = 0; row < rowcount; row++) { for(size_t column = 0; column < rows[row].size(); column++) { TableItem &item = rows[row][column]; QTableWidgetItem *qtwitem = new QTableWidgetItem(QString::fromStdString(item.text)); if(item.editable) qtwitem->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled | Qt::ItemIsEditable); else qtwitem->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled); tablewidget->setItem(row, column, qtwitem); } } tablewidget->setSelectionBehavior(selectionBehavior); tablewidget->setSelectionMode(selectionMode); QObject::connect(tablewidget, &QTableWidget::cellActivated, uiproxy, &UIProxy::onCellActivate); QObject::connect(tablewidget, &QTableWidget::cellChanged, uiproxy, &UIProxy::onCellActivate); QObject::connect(tablewidget, &QTableWidget::itemSelectionChanged, uiproxy, &UIProxy::onTableSelectionChange); setQWidget(tablewidget); setEditable(editable); setProxy(proxy); return tablewidget; }
Test::Test(QWidget *parent) : QWidget(parent), ui(new Ui::Test) { ui->setupUi(this); QTableWidget *tableWidget = ui->tableWidget; //tableWidget->setRowCount(10); tableWidget->setEnabled(false); search_title = new QList<QString>(); search_href = new QList<QString>(); bugs = new QList<Bug*>(); manager = new QNetworkAccessManager(this); connect(manager,SIGNAL(finished(QNetworkReply*)),this,SLOT(finished(QNetworkReply*))); }