Example #1
0
void MyCertListPage::selectionChanged()
{
    // Set button states based on selected tab and selection
    QTableView *table = ui->tableView;
    if(!table->selectionModel())
        return;

    if(table->selectionModel()->hasSelection())
    {
        ui->copyCert->setEnabled(true);
		ui->sellCertButton->setEnabled(true);
		ui->editButton->setEnabled(true);
		ui->transferButton->setEnabled(true);
    }
    else
    {
        ui->copyCert->setEnabled(false);
		ui->sellCertButton->setEnabled(false);
		ui->editButton->setEnabled(false);
		ui->transferButton->setEnabled(false);
    }
}
void AddressBookPage::selectionChanged()
{
    // Set button states based on selected tab and selection
    QTableView *table = ui->tableView;
    if(!table->selectionModel())
        return;

    if(table->selectionModel()->hasSelection())
    {
        switch(tab)
        {
        case SendingTab:
            // In sending tab, allow deletion of selection
            ui->deleteButton->setEnabled(true);
            ui->deleteButton->setVisible(true);
            deleteAction->setEnabled(true);
            ui->signMessage->setEnabled(false);
            ui->signMessage->setVisible(false);
            break;
        case ReceivingTab:
            // Deleting receiving addresses, however, is not allowed
            ui->deleteButton->setEnabled(false);
            ui->deleteButton->setVisible(false);
            deleteAction->setEnabled(false);
            ui->signMessage->setEnabled(true);
            ui->signMessage->setVisible(true);
            break;
        }
        ui->copyToClipboard->setEnabled(true);
        ui->showQRCode->setEnabled(true);
    }
    else
    {
        ui->deleteButton->setEnabled(false);
        ui->showQRCode->setEnabled(false);
        ui->copyToClipboard->setEnabled(false);
        ui->signMessage->setEnabled(false);
    }
}
Example #3
0
//! [4a]
void AddressWidget::editEntry()
{
    QTableView *temp = static_cast<QTableView*>(currentWidget());
    QSortFilterProxyModel *proxy = static_cast<QSortFilterProxyModel*>(temp->model());
    QItemSelectionModel *selectionModel = temp->selectionModel();

    QModelIndexList indexes = selectionModel->selectedRows();
    QModelIndex index, i;        
    QString name;
    QString address;
    int row = -1;

    foreach (index, indexes) {
        row = proxy->mapToSource(index).row();
        i = table->index(row, 0, QModelIndex());
        QVariant varName = table->data(i, Qt::DisplayRole);
        name = varName.toString();
    
        i = table->index(row, 1, QModelIndex());
        QVariant varAddr = table->data(i, Qt::DisplayRole);
        address = varAddr.toString();
    }
Example #4
0
void MainWindow::on_actShowStat_triggered()
{
  QString query = QString("call p_showStat_admin('%1', '%2', 0);")
      .arg(_model->dateA_dbformat())
      .arg(_model->dateZ_dbformat());
  qDebug() << query;
  QSqlQueryModel *m = App::theApp()->db_model(query);

  QDialog *dlgStat = new QDialog();
  dlgStat->setWindowTitle("Статистика");
  dlgStat->setGeometry(200, 200, 400, 200);

  QTableView* view = new QTableView();
  view->setModel(m);
  view->resizeColumnsToContents();
  view->resizeRowsToContents();

  QVBoxLayout* lay = new QVBoxLayout(dlgStat);
  lay->addWidget(view);

  dlgStat->exec();
}
Example #5
0
void MainWindow::setupViews()
{
    QSplitter *splitter = new QSplitter;
    QTableView *table = new QTableView;
    pieChart = new PieView;
    splitter->addWidget(table);
    splitter->addWidget(pieChart);
    splitter->setStretchFactor(0, 0);
    splitter->setStretchFactor(1, 1);

    table->setModel(model);
    pieChart->setModel(model);

    QItemSelectionModel *selectionModel = new QItemSelectionModel(model);
    table->setSelectionModel(selectionModel);
    pieChart->setSelectionModel(selectionModel);

    QHeaderView *headerView = table->horizontalHeader();
    headerView->setStretchLastSection(true);

    setCentralWidget(splitter);
}
Example #6
0
void MainWindow::do_copyPathName_Clipboard()
{
    QTableView *tab = ui->tableView_result;
    QString t;

    QItemSelectionModel *selections = tab->selectionModel();
    QList<QModelIndex> list= selections->selectedRows();
    for(int i=0; i<list.size(); i++)
    {
        //修改时间
        QString filename=
                modelResult->item(list.at(i).row(),1)->text().trimmed()
                +QDir::separator()
                +modelResult->item(list.at(i).row(),0)->text().trimmed();
        t += tr("文件名:") + filename + tr("\n");
        //行号信息
        QString lineno = modelResult->item(list.at(i).row(),2)->text().trimmed();
        if(!lineno.isEmpty())
        {
            t += tr("行号:") + lineno + tr("\n");
        }
        //行内容
        QString linestr = modelResult->item(list.at(i).row(),3)->text().trimmed();
        if(!linestr.isEmpty())
        {
            t += tr("行内容:") + linestr + tr("\n");
        }
        //修改时间
        QString modftime = modelResult->item(list.at(i).row(),4)->text().trimmed();
        if(!modftime.isEmpty())
        {
            t += tr("修改时间:") + modftime + tr("\n");
        }
        //换行
        t += "\n\n";
    }
    QClipboard *board = QApplication::clipboard();
    board->setText(t);
}
Example #7
0
void AddressBookPage::done(int retval)
{
    QTableView *table = ui->tableView;
    if(!table->selectionModel() || !table->model())
        return;

    // Figure out which address was selected, and return it
    QModelIndexList indexes = table->selectionModel()->selectedRows(AddressTableModel::Address);

    for (const QModelIndex& index : indexes) {
        QVariant address = table->model()->data(index);
        returnValue = address.toString();
    }

    if(returnValue.isEmpty())
    {
        // If no address entry selected, return rejected
        retval = Rejected;
    }

    QDialog::done(retval);
}
/*! Constructor */
StateBasedPhiWidget::StateBasedPhiWidget(QWidget *parent) : AbstractAnalysisWidget(parent){
	QVBoxLayout *mainVerticalBox = new QVBoxLayout(this);

	//Create a state based phi analysis dao to be used by this class
	stateDao = new StateBasedPhiAnalysisDao(Globals::getAnalysisDao()->getDBInfo());

	//Initialize analysis parameters and other variables
	initializeAnalysisInfo();

	//Set up analysis runner with function to create threads to analyze for state-based phi
	analysisRunner->setTimeStepThreadCreationFunction(&createAnalysisTimeStepThread);

	//Add tool bar to top of widget
	toolBar = getDefaultToolBar();
	checkToolBarEnabled();//Can only carry out analysis if a network and archive are loaded
	mainVerticalBox->addWidget(toolBar);

	//Create a tabbed widget to hold progress and results
	QTabWidget* tabWidget = new QTabWidget(this);

	//Add the model and view displaying the current analysis
	fullResultsModel = new FullResultsModel(&analysisInfo, stateDao);
	QTableView* fullResultsTableView = new FullResultsTableView(this, fullResultsModel);
	fullResultsTableView->setMinimumSize(500, 500);
	tabWidget->addTab(fullResultsTableView, "Results");

	//Add widget displaying progress
	progressWidget = new ProgressWidget(this);
	connect(analysisRunner, SIGNAL(progress(const QString&, unsigned int, unsigned int, unsigned int)), progressWidget, SLOT(updateProgress(const QString&, unsigned int, unsigned int, unsigned int)), Qt::QueuedConnection);
	connect(analysisRunner, SIGNAL(timeStepComplete(unsigned int)), progressWidget, SLOT(timeStepComplete(unsigned int)), Qt::QueuedConnection);
	progressWidget->setMinimumSize(500, 500);
	QScrollArea* progressScrollArea = new QScrollArea(this);
	progressScrollArea->setWidget(progressWidget);
	tabWidget->addTab(progressScrollArea, "Progress");
	mainVerticalBox->addWidget(tabWidget);

	mainVerticalBox->addStretch(5);
}
void InvoicePage::selectionChanged()
{
    // Set button states based on selected tab and selection
    QTableView *table = ui->tableView;
    if(!table->selectionModel())
        return;

    if(table->selectionModel()->hasSelection())
    {
        replyAction->setEnabled(true);
        copyFromAddressAction->setEnabled(true);
        copyToAddressAction->setEnabled(true);
        deleteAction->setEnabled(true);

        ui->copyFromAddressButton->setEnabled(true);
        ui->copyToAddressButton->setEnabled(true);
        ui->replyButton->setEnabled(true);
        ui->deleteButton->setEnabled(true);

        // Figure out which message was selected, and return it
        QModelIndexList typeColumn = table->selectionModel()->selectedRows(InvoiceTableModel::Type);

        foreach (QModelIndex index, typeColumn)
        {
            bool sent = (table->model()->data(index).toString() == MessageModel::Sent);

            resendAction->setEnabled(sent);
            ui->resendButton->setEnabled(sent);
            ui->resendButton->setVisible(sent);

            receiptAction->setEnabled(sent);
            ui->receiptButton->setEnabled(sent);
            ui->receiptButton->setVisible(sent);

            //payAction->setEnabled(!sent);
            //ui->payButton->setEnabled(!sent);
            //ui->payButton->setVisible(!sent);
        }
Example #10
0
void ShoppingPage::selectionChanged()
{
    // Set button states based on selected tab and selection
    QTableView *table = ui->tableView;
    if(!table->selectionModel())
        return;

    if(table->selectionModel()->hasSelection())
    {
        switch(tab)
        {
        case SendingTab:
            // In sending tab, allow deletion of selection
            deleteAction->setEnabled(true);
            break;
        case ReceivingTab:
            // Deleting receiving addresses, however, is not allowed
            deleteAction->setEnabled(false);
            break;
        }
    }

}
Example #11
0
int main(int argc, char ** argv)
{
	std::vector<test_entity> data =
	{
	    {"first", 1},
	    {"second", 2},
	    {"opla", 3},
	    {"123", 4},
	};

	test_model model;

	QApplication qapp {argc, argv};

	QTableView view;
	view.setModel(&model);

	view.show();

	model.assign(std::move(data));

	return qapp.exec();
}
Example #12
0
int main(int argc, char ** argv) {
    QApplication app{argc, argv};
    QSqlDatabase db = QSqlDatabase::addDatabase("QSQLITE");
    db.setDatabaseName(":memory:");
    if (! db.open()) return 1;
    db.exec("create table example (name text, inuse numeric);");
    db.exec("insert into example (name, inuse) values "
            "('Zaphod', 0), ('Beeblebrox', 1);");

    QSqlTableModel model;
    model.setTable("example");
    model.select();

    BoolProxy proxy{1};
    proxy.setSourceModel(&model);

    QTableView ui;
    YesNoDelegate delegate;
    ui.setItemDelegateForColumn(1, &delegate);
    ui.setModel(&proxy);
    ui.show();
    return app.exec();
}
Example #13
0
void MainWindow::on_pushButton_clicked()
{
    int current_tab = this->ui->tabWidget->currentIndex();

    QPrinter printer;
    QTableView *myWidget;

    switch(current_tab)
    {
    case TABLE::StudentsTableTab:
        myWidget = this->ui->StudentsTableView;
        break;

    case TABLE::TeachersTableTab:
        myWidget = this->ui->TeachersTableView;
        break;
    default:
        return;
    }

    QPixmap pix = myWidget->grab();
    QPainter painter;
    printer.setResolution(QPrinter::HighResolution);

    printer.setPageMargins (15,15,15,15,QPrinter::Millimeter);
    painter.begin(&printer);
    double xscale = printer.pageRect().width()/double(myWidget->width() + 50);
    double yscale = printer.pageRect().height()/double(myWidget->height() + 50);
    double scale = qMin(xscale, yscale);
    painter.scale(scale, scale);

    painter.drawPixmap(0, 0, pix);
    painter.end();

    myWidget->render(&painter);

}
ColorMatrixEffectConfigWidget::ColorMatrixEffectConfigWidget(QWidget *parent)
        : KFilterEffectConfigWidgetBase(parent), m_effect(0)
{
    QGridLayout * g = new QGridLayout(this);

    m_type = new KComboBox(this);
    m_type->addItem(i18n("Apply color matrix"));
    m_type->addItem(i18n("Saturate colors"));
    m_type->addItem(i18n("Rotate hue"));
    m_type->addItem(i18n("Luminance to alpha"));
    g->addWidget(m_type, 0, 0);

    m_stack = new QStackedWidget(this);
    m_stack->setContentsMargins(0, 0, 0, 0);
    g->addWidget(m_stack, 1, 0);

    m_matrixModel = new MatrixDataModel(this);

    QTableView * matrixWidget = new QTableView(m_stack);
    matrixWidget->setModel(m_matrixModel);
    matrixWidget->horizontalHeader()->hide();
    matrixWidget->horizontalHeader()->setResizeMode(QHeaderView::Stretch);
    matrixWidget->verticalHeader()->hide();
    matrixWidget->verticalHeader()->setResizeMode(QHeaderView::ResizeToContents);
    m_stack->addWidget(matrixWidget);

    QWidget * saturateWidget = new QWidget(m_stack);
    QGridLayout * saturateLayout = new QGridLayout(saturateWidget);
    saturateLayout->addWidget(new QLabel(i18n("Saturate value"), saturateWidget), 0, 0);
    m_saturate = new KDoubleNumInput(saturateWidget);
    m_saturate->setRange(0.0, 1.0, 0.05, false);
    saturateLayout->addWidget(m_saturate, 0, 1);
    saturateLayout->addItem(new QSpacerItem(0, 1, QSizePolicy::Minimum, QSizePolicy::MinimumExpanding), 1, 0);
    saturateWidget->setLayout(saturateLayout);
    m_stack->addWidget(saturateWidget);

    QWidget * hueRotateWidget = new QWidget(m_stack);
    QGridLayout * hueRotateLayout = new QGridLayout(hueRotateWidget);
    hueRotateLayout->addWidget(new QLabel(i18n("Angle"), hueRotateWidget), 0, 0);
    m_hueRotate = new KDoubleNumInput(hueRotateWidget);
    m_hueRotate->setRange(0.0, 360.0, 1.0, false);
    hueRotateLayout->addWidget(m_hueRotate, 0, 1);
    hueRotateLayout->addItem(new QSpacerItem(0, 1, QSizePolicy::Minimum, QSizePolicy::MinimumExpanding), 1, 0);
    hueRotateWidget->setLayout(hueRotateLayout);
    m_stack->addWidget(hueRotateWidget);

    QWidget * luminanceWidget = new QWidget(m_stack);
    m_stack->addWidget(luminanceWidget);

    setLayout(g);

    connect(m_type, SIGNAL(currentIndexChanged(int)), m_stack, SLOT(setCurrentIndex(int)));
    connect(m_type, SIGNAL(currentIndexChanged(int)), this, SLOT(typeChanged(int)));
    connect(m_saturate, SIGNAL(valueChanged(double)), this, SLOT(saturateChanged(double)));
    connect(m_hueRotate, SIGNAL(valueChanged(double)), this, SLOT(hueRotateChanged(double)));
    connect(m_matrixModel, SIGNAL(dataChanged(QModelIndex,QModelIndex)), this, SLOT(matrixChanged()));
}
Example #15
0
QtTutorial::QtTutorial(QWidget *parent)
	: QMainWindow(parent)
{
	QTableView *tableView = new QTableView();
	tableView->show();

	QTableView *tableView2 = new QTableView();
	tableView2->show();

	// RGBA
	QColor red = QColor(255, 0, 0, 255);
	QColor green = QColor(0, 255, 0, 255);
	QColor blue = QColor(0, 0, 255, 255);
	QColor grey = QColor(155, 155, 155, 255);

	QList<QColor> colors;
	colors.append(red);
	colors.append(green);
	colors.append(blue);
	colors.append(grey);

	QList<QList<QColor>> items;
	for(int i = 0; i < 5; i++)
	{
		items.append(colors);
	}

	PaletteTableModel *model = new PaletteTableModel(items);
	tableView->setModel(model);
	tableView2->setModel(model);

	//model->removeColumns(1, 1);
	//model->removeRows(0,1);

	//model->insertRows(0, 5);
	//model->insertColumns(0, 2);
}
Example #16
0
void AddressOverviewWindow::editEntry()
{
    QTableView *temp = static_cast<QTableView*>(ui->AddressesTableView);
    QSortFilterProxyModel *proxy = static_cast<QSortFilterProxyModel*>(temp->model());
    QItemSelectionModel *selectionModel = temp->selectionModel();
    QModelIndexList indexes = selectionModel->selectedRows();
    QModelIndex index, i;
    QString firstName;
    QString lastName;
    QString address;
    QString city;
    QString zipCode;
    int row = -1;

    foreach (index, indexes) {
        row = proxy->mapToSource(index).row();
        i = model->index(row, 0, QModelIndex());
        QVariant varFirstName = model->data(i, Qt::DisplayRole);
        firstName = varFirstName.toString();

        i = model->index(row, 1, QModelIndex());
        QVariant varLastName = model->data(i, Qt::DisplayRole);
        lastName = varLastName.toString();

        i = model->index(row, 2, QModelIndex());
        QVariant varAddr = model->data(i, Qt::DisplayRole);
        address = varAddr.toString();

        i = model->index(row, 3, QModelIndex());
        QVariant varCity = model->data(i, Qt::DisplayRole);
        city = varCity.toString();

        i = model->index(row, 4, QModelIndex());
        QVariant varZip = model->data(i, Qt::DisplayRole);
        zipCode = varZip.toString();
    }
Example #17
0
int main( int argc, char** argv ) {
    QApplication app( argc, argv );


    CityEngine *engine = new CityEngine(QCoreApplication::instance());
    CityTableModel *model = new CityTableModel(QCoreApplication::instance());
    model->setInput(engine);
    QListView* list = new QListView;
    list->setModel( model );
    list->setWindowTitle( "QListView" );
    list->show();

    QTreeView* tree = new QTreeView;
    tree->setModel( model );
    tree->setWindowTitle( "QTreeView" );
    tree->show();

    QTableView* table = new QTableView;
    table->setModel( model );
    table->setWindowTitle( "QTableView" );
    table->show();

    return app.exec();
}
Example #18
0
void QSqlTableModel_snippets()
{
//! [24]
    QSqlTableModel *model = new QSqlTableModel(parentObject, database);
    model->setTable("employee");
    model->setEditStrategy(QSqlTableModel::OnManualSubmit);
    model->select();
    model->setHeaderData(0, Qt::Horizontal, tr("Name"));
    model->setHeaderData(1, Qt::Horizontal, tr("Salary"));

    QTableView *view = new QTableView;
    view->setModel(model);
    view->hideColumn(0); // don't show the ID
    view->show();
//! [24]

    {
//! [25]
    QSqlTableModel model;
    model.setTable("employee");
    QString name = model.record(4).value("name").toString();
//! [25]
    }
}
Example #19
0
int main(int argc, char *argv[])
{
    QApplication a(argc, argv);

      QDirModel mainModel;
      QTreeView  *treeView     = new QTreeView;
      QTableView *tableView    = new QTableView;
      QSplitter  *mainSplitter = new QSplitter;

        treeView->setModel(&mainModel);
        tableView->setModel(&mainModel);

      QObject::connect(treeView,SIGNAL(clicked(QModelIndex)),tableView,SLOT(setRootIndex(QModelIndex)));
      QObject::connect(tableView,SIGNAL(activated(QModelIndex)),treeView,SLOT(setCurrentIndex(QModelIndex)));
      QObject::connect(tableView,SIGNAL(activated(QModelIndex)),tableView,SLOT(setRootIndex(QModelIndex)));


        mainSplitter->addWidget(treeView);
        mainSplitter->addWidget(tableView);
        mainSplitter->setGeometry(430,340,400,400);
       mainSplitter->show();

    return a.exec();
}
Example #20
0
void MainWindow::setupView()
{
    QSplitter *splitter = new QSplitter;
    splitter->setOrientation(Qt::Vertical);
    QTableView *table = new QTableView;
    HistogramView *histogram = new HistogramView(splitter);
    
    table->setModel(model);
    histogram->setModel(model);

    QItemSelectionModel *selectionModel = new QItemSelectionModel(model);
    table->setSelectionModel(selectionModel);
    histogram->setSelectionModel(selectionModel);

    connect(selectionModel,SIGNAL(selectionChanged(const QItemSelection, const QItemSelection)),
    		histogram,SLOT(selectionChanged(const QItemSelection, const QItemSelection)));
    connect(selectionModel,SIGNAL(selectionChanged(const QItemSelection, const QItemSelection)),
    		table,SLOT(selectionChanged(const QItemSelection, const QItemSelection)));
    
    splitter->addWidget(table);
    splitter->addWidget(histogram);
    
    setCentralWidget(splitter);
}
Example #21
0
int main( int argc, char **argv )
{
  QApplication app( argc, argv );
  
  QTableView table;

  QStandardItemModel model( 10, 2 ); 
  for( int r=0; r<10; ++r )
  {
    QStandardItem *item = new QStandardItem( QString("Row %1").arg(r+1) );
    item->setEditable( false ); 
    model.setItem( r, 0, item );
    
    model.setItem( r, 1, new QStandardItem( QString::number((r*30)%100 )) );  
  }
  table.setModel( &model );
  
  BarDelegate delegate;
  table.setItemDelegateForColumn( 1, &delegate );

  table.show();
  
  return app.exec();
}
StaticView::StaticView(QWidget *parent) : QMainWindow(parent){
	QWidget *cwg= new QWidget(this);
	QVBoxLayout *vbox = new QVBoxLayout(cwg);
{
	QHBoxLayout *hbox = new QHBoxLayout();
	QTableView *view = new QTableView(cwg);
		view->setEditTriggers(QAbstractItemView::NoEditTriggers);
		hbox->addWidget(view);

		vbox->addLayout(hbox);
}
{
		QHBoxLayout *hbox = new QHBoxLayout();
		hbox->addStretch();
		{
			QPushButton *ppb = new QPushButton("&Refresh",cwg);
			hbox->addWidget(ppb);
		}
		vbox->addLayout(hbox);
	}
	this->setCentralWidget(cwg);
	setWindowIcon(QIcon(":image/tomatoicon.ico"));
    setWindowTitle("Pomidorka Static");
}
Example #23
0
 Widget() {
    m_layout.addWidget(&m_view, 0, 0, 1, 1);
    m_layout.addWidget(&m_button, 1, 0, 1, 1);
    connect(&m_button, SIGNAL(clicked()), &m_dialog, SLOT(open()));
    m_model.append({"Volvo", "240", "SQL8941"});
    m_model.append({"Volvo", "850", {}});
    m_model.append({"Volvo", "940", "QRZ1321"});
    m_model.append({"Volvo", "960", "QRZ1628"});
    m_proxy.setSourceModel(&m_model);
    m_proxy.setFilterKeyColumn(2);
    m_view.setModel(&m_proxy);
    m_dialog.setLabelText("Enter registration number fragment to filter on. Leave empty to clear filter.");
    m_dialog.setInputMode(QInputDialog::TextInput);
    connect(&m_dialog, SIGNAL(textValueSelected(QString)),
            &m_proxy, SLOT(setFilterFixedString(QString)));
 }
Example #24
0
void KinectCalibration::init(QTableView &kinectCalibrationTableView) {
    if (mongo_helper_->is_connected() == false) {
        return;
    }

    if (ros::master::check())
    {
        initialising_ = true;

        CheckBoxDelegate *checkbox_delegate = new CheckBoxDelegate(&kinectCalibrationTableView);
        kinectCalibrationTableView.setItemDelegateForColumn(0, checkbox_delegate);

        std::vector<struct NodeRowData> gridData;

        Query query;
        query.sort("node.row");

        std::unique_ptr<DBClientCursor> cursor = mongo_helper_->find("KinectCalibrationFunction", query);
        while (cursor->more()) {
            BSONElement node = cursor->next()["node"];
            NodeRowData nodeRowData;

            if (node["selected"].ok())
                node["selected"].Val(nodeRowData.selected);
            else
                nodeRowData.selected = false;

            if (node["friendlyName"].ok())
                node["friendlyName"].Val(nodeRowData.friendlyName);

            if (node["nodePath"].ok())
                node["nodePath"].Val(nodeRowData.nodePath);

            nodeRowData.running = false;
            gridData.push_back(nodeRowData);
        }

        kinect_calibration_table_model_ = std::make_shared<NodeTableModel>(this, mongo_helper_, &gridData);
        kinectCalibrationTableView.setModel(kinect_calibration_table_model_.get());
        kinectCalibrationTableView.setColumnWidth(0, 100);
        kinectCalibrationTableView.setColumnWidth(1, 300);
        kinectCalibrationTableView.horizontalHeader()->setResizeMode(2, QHeaderView::Stretch);
        //kinectCalibrationTableView.setSelectionBehavior(QAbstractItemView::SelectRows);
        //kinectCalibrationTableView.setAutoFillBackground(true);
        kinectCalibrationTableView.verticalHeader()->setMovable(true);
        kinectCalibrationTableView.show();

        initialising_ = false;
    }
}
Example #25
0
void DkFileAssociationsPreference::createLayout() {
	
	QStringList fileFilters = Settings::param().app().openFilters;

	mModel = new QStandardItemModel(this);
	mModel->setObjectName("fileModel");
	for (int rIdx = 1; rIdx < fileFilters.size(); rIdx++)
		mModel->appendRow(getItems(fileFilters.at(rIdx), checkFilter(fileFilters.at(rIdx), Settings::param().app().browseFilters), checkFilter(fileFilters.at(rIdx), Settings::param().app().registerFilters)));

	mModel->setHeaderData(0, Qt::Horizontal, tr("Filter"));
	mModel->setHeaderData(1, Qt::Horizontal, tr("Browse"));
	mModel->setHeaderData(2, Qt::Horizontal, tr("Register"));

	QTableView* filterTableView = new QTableView(this);
	filterTableView->setModel(mModel);
	filterTableView->setSelectionBehavior(QAbstractItemView::SelectRows);
	filterTableView->verticalHeader()->hide();
	//filterTableView->horizontalHeader()->hide();
	filterTableView->setShowGrid(false);
	filterTableView->resizeColumnsToContents();
	filterTableView->resizeRowsToContents();
	filterTableView->setWordWrap(false);

	QPushButton* openDefault = new QPushButton(tr("Set as Default Viewer"), this);
	openDefault->setObjectName("openDefault");

	// now the final widgets
	QVBoxLayout* layout = new QVBoxLayout(this);
	layout->addWidget(filterTableView);

#ifdef Q_OS_WIN
	layout->addWidget(openDefault);
#else
	openDefault->hide();
#endif

}
Example #26
0
void tst_QItemDelegate::QTBUG4435_keepSelectionOnCheck()
{
    QStandardItemModel model(3, 1);
    for (int i = 0; i < 3; ++i) {
        QStandardItem *item = new QStandardItem(QLatin1String("Item ") + QString::number(i));
        item->setCheckable(true);
        item->setFlags(Qt::ItemIsSelectable | Qt::ItemIsUserCheckable | Qt::ItemIsEnabled);
        model.setItem(i, item);
    }
    QTableView view;
    view.setModel(&model);
    view.setItemDelegate(new TestItemDelegate);
    view.show();
    view.selectAll();
    QTest::qWaitForWindowShown(&view);
    QStyleOptionViewItem option;
    option.rect = view.visualRect(model.index(0, 0));
    const int checkMargin = qApp->style()->pixelMetric(QStyle::PM_FocusFrameHMargin, 0, 0) + 1;
    QPoint pos = qApp->style()->subElementRect(QStyle::SE_ViewItemCheckIndicator, &option, 0).center()
                 + QPoint(checkMargin, 0);
    QTest::mouseClick(view.viewport(), Qt::LeftButton, Qt::ControlModifier, pos);
    QTRY_VERIFY(view.selectionModel()->isColumnSelected(0, QModelIndex()));
    QCOMPARE(model.item(0)->checkState(), Qt::Checked);
}
bool DatabaseHandler::getSpeciesList(QString type, QComboBox * cmb_box) {
	qDebug() << "Populating species list for " << type;
    QString qstr = "SELECT name_de, name_lat, euring_id, length FROM taxa LEFT JOIN "
    		"(SELECT id_code, to_char(avg(length), 'FM99.99') as length FROM census WHERE tp='%1' GROUP BY id_code) as lt ON taxa.euring_id = lt.id_code "
    		"WHERE type='%1' ORDER BY seaflag DESC, name_de";
	QSqlQueryModel * model = new QSqlQueryModel;
	model->setQuery(qstr.arg(type));
	qDebug() << qstr.arg(type);
	model->setHeaderData(0, Qt::Horizontal, "Deutscher Name");
	model->setHeaderData(1, Qt::Horizontal, "Wissenschaftlicher Name");
	model->setHeaderData(2, Qt::Horizontal, "EURING Code");
	model->setHeaderData(3, Qt::Horizontal, QString::fromUtf8("Länge"));
	cmb_box->setModel(model);
	QTableView * view = new QTableView;
	cmb_box->setView(view);
	view->verticalHeader()->hide();
	view->hideColumn(2);
	view->resizeColumnsToContents();
	view->setSelectionMode(QAbstractItemView::SingleSelection);
	view->setSelectionBehavior(QAbstractItemView::SelectRows);
	view->setMinimumWidth(view->horizontalHeader()->length());

	return true;
}
Example #28
0
Widget::Widget(QWidget *parent)
    : QWidget(parent)
{
    resize(400,300);
    if(connect())
    {
        QTableView *view = new QTableView(this);
        QSqlRelationalTableModel *model = new QSqlRelationalTableModel;//要先有数据才能创建model,也就是先连接数据库局
        view->setGeometry(0,0,400,300);

        view->setModel(model);
        model->setTable("student");
        model->setSort(0,Qt::AscendingOrder);
//        model->setHeaderData(0,Qt::Horizontal,"Name");//from 0
//        model->setHeaderData(1,Qt::Horizontal,"Age");
//        model->setHeaderData(2,Qt::Horizontal,"likes");
        model->setRelation(3,QSqlRelation("city","id","name"));
        model->select();


//        view->setModel(model);

        view->setSelectionMode(QAbstractItemView::SingleSelection);//设置选择模式
        view->setSelectionBehavior(QAbstractItemView::SelectRows);//选择行
//        view->resizeColumnsToContents();//tiaozhengziti
        view->setEditTriggers(QAbstractItemView::DoubleClicked);//不可编辑?

        QHeaderView *header =  view->horizontalHeader();
        header->setStretchLastSection(true);
        view->setItemDelegate(new QSqlRelationalDelegate(view));
//        QHeaderView *head = view->verticalHeader();
//        head->setStretchLastSection(true);
//        view->show();
//        this?->show();
    }
}
Example #29
0
File: main.cpp Project: maxxant/qt
int main(int argc, char *argv[])
{
    Q_INIT_RESOURCE(interview);

    QApplication app(argc, argv);
    QSplitter page;

    QAbstractItemModel *data = new Model(1000, 10, &page);
    QItemSelectionModel *selections = new QItemSelectionModel(data);

    QTableView *table = new QTableView;
    table->setModel(data);
    table->setSelectionModel(selections);
    table->horizontalHeader()->setMovable(true);
    table->verticalHeader()->setMovable(true);
    // Set StaticContents to enable minimal repaints on resizes.
    table->viewport()->setAttribute(Qt::WA_StaticContents);
    page.addWidget(table);

    QTreeView *tree = new QTreeView;
    tree->setModel(data);
    tree->setSelectionModel(selections);
    tree->setUniformRowHeights(true);
    tree->header()->setStretchLastSection(false);
    tree->viewport()->setAttribute(Qt::WA_StaticContents);
    // Disable the focus rect to get minimal repaints when scrolling on Mac.
    tree->setAttribute(Qt::WA_MacShowFocusRect, false);
    page.addWidget(tree);

    QListView *list = new QListView;
    list->setModel(data);
    list->setSelectionModel(selections);
    list->setViewMode(QListView::IconMode);
    list->setSelectionMode(QAbstractItemView::ExtendedSelection);
    list->setAlternatingRowColors(false);
    list->viewport()->setAttribute(Qt::WA_StaticContents);
    list->setAttribute(Qt::WA_MacShowFocusRect, false);
    page.addWidget(list);

    page.setWindowIcon(QPixmap(":/images/interview.png"));
    page.setWindowTitle("Interview");
    page.show();

    return app.exec();
}
Example #30
-1
int main(int argc, char *argv[])
{
    QApplication a(argc, argv);

    QStandardItemModel model(4,4);
    QTableView tableView;
    tableView.setModel(&model);
    DateDelegate dateDelegate;
    tableView.setItemDelegateForColumn(1,&dateDelegate);
    ComboDelegate comboDelegate;
    tableView.setItemDelegateForColumn(2,&comboDelegate);
    SpinDelegate spinDelegate;
    tableView.setItemDelegateForColumn(3,&spinDelegate);

    model.setHeaderData(0,Qt::Horizontal,QObject::tr("姓名"));
    model.setHeaderData(1,Qt::Horizontal,QObject::tr("生日"));
    model.setHeaderData(2,Qt::Horizontal,QObject::tr("职业"));
    model.setHeaderData(3,Qt::Horizontal,QObject::tr("收入"));

    QFile file("test.txt");
    if(file.open(QFile::ReadOnly|QFile::Text))
    {
        QTextStream stream(&file);
        QString line;

        model.removeRows(0,model.rowCount(QModelIndex()),QModelIndex());
        int row =0;
        do{
               line = stream.readLine();
               if(!line.isEmpty())
               {
                   model.insertRows(row,1,QModelIndex());
                   QStringList pieces = line.split(",",QString::SkipEmptyParts);
                   model.setData(model.index(row,0,QModelIndex()),pieces.value(0));
                   model.setData(model.index(row,1,QModelIndex()),pieces.value(1));
                   model.setData(model.index(row,2,QModelIndex()),pieces.value(2));
                   model.setData(model.index(row,3,QModelIndex()),pieces.value(3));
                   row++;
               }
        }while(!line.isEmpty());

        file.close();
    }
    tableView.setWindowTitle(QObject::tr("Delegate"));
    tableView.show();
    
    return a.exec();
}