/*!
 * When user selects a zip or a city this private slot is activated. It causes the line edit
 * to be populated with the selected values.
*/
void ZipCountryCompleters::onCompleterIndexActivated(const QModelIndex &index)
{
    if (!m_ZipModel || !m_CityModel)
        return;
    QAbstractItemModel *model = const_cast<QAbstractItemModel*>(index.model());
    const QString &zip = model->index(index.row(), ZipCountryModel::Zip).data().toString();
    const QString &city = model->index(index.row(), ZipCountryModel::City).data().toString();
    const QString &province = model->index(index.row(), ZipCountryModel::Province).data().toString();
    // Disconnect editors
    m_zipEdit->blockSignals(true);
    m_cityEdit->blockSignals(true);
    m_provinceCombo->blockSignals(true);
    if (m_zipEdit) {
        m_zipEdit->clearFocus();
        m_zipEdit->setText(zip.toUpper());
    }
    if (m_cityEdit) {
        m_cityEdit->clearFocus();
        m_cityEdit->setText(city.toUpper());
    }
    if (m_provinceCombo) {
        m_provinceCombo->clearFocus();
        m_provinceCombo->setCurrentIndex(m_provinceCombo->findText(province));
    }
    // Reconnect editors
    m_zipEdit->blockSignals(false);
    m_cityEdit->blockSignals(false);
    m_provinceCombo->blockSignals(false);
    checkData();
}
void PreferencesDialog::writeSettings() {
  TulipSettings::instance().setProxyEnabled(_ui->proxyCheck->isChecked());

  switch(_ui->proxyType->currentIndex()) {
  case 0:
    TulipSettings::instance().setProxyType(QNetworkProxy::Socks5Proxy);
    break;

  case 1:
    TulipSettings::instance().setProxyType(QNetworkProxy::HttpProxy);
    break;

  case 2:
    TulipSettings::instance().setProxyType(QNetworkProxy::HttpCachingProxy);
    break;

  case 3:
    TulipSettings::instance().setProxyType(QNetworkProxy::FtpCachingProxy);
    break;

  default:
    break;
  }

  TulipSettings::instance().setProxyHost(_ui->proxyAddr->text());
  TulipSettings::instance().setProxyPort(_ui->proxyPort->value());
  TulipSettings::instance().setUseProxyAuthentification(_ui->proxyAuthCheck->isChecked());
  TulipSettings::instance().setProxyUsername(_ui->proxyUser->text());
  TulipSettings::instance().setProxyPassword(_ui->proxyPassword->text());

  QAbstractItemModel* model = _ui->graphDefaultsTable->model();

  TulipSettings::instance().setDefaultColor(tlp::NODE,model->data(model->index(0,1)).value<tlp::Color>());
  TulipSettings::instance().setDefaultColor(tlp::EDGE,model->data(model->index(0,2)).value<tlp::Color>());
  TulipSettings::instance().setDefaultSize(tlp::NODE,model->data(model->index(1,1)).value<tlp::Size>());
  TulipSettings::instance().setDefaultSize(tlp::EDGE,model->data(model->index(1,2)).value<tlp::Size>());
  TulipSettings::instance().setDefaultShape(tlp::NODE,model->data(model->index(2,1)).value<NodeShape::NodeShapes>());
  TulipSettings::instance().setDefaultShape(tlp::EDGE,(int)(model->data(model->index(2,2)).value<EdgeShape::EdgeShapes>()));
  TulipSettings::instance().setDefaultSelectionColor(model->data(model->index(3,1)).value<tlp::Color>());
  TulipSettings::instance().setDefaultSelectionColor(model->data(model->index(3,2)).value<tlp::Color>());

  TulipSettings::instance().applyProxySettings();

  TulipSettings::instance().setDisplayDefaultViews(_ui->displayDefaultViews->isChecked());
  TulipSettings::instance().setAutomaticMapMetric(_ui->colorMappingCheck->isChecked());
  TulipSettings::instance().setAutomaticRatio(_ui->aspectRatioCheck->isChecked());
  TulipSettings::instance().setViewOrtho(_ui->viewOrthoCheck->isChecked());
  TulipSettings::instance().setResultPropertyStored(_ui->resultPropertyStoredCheck->isChecked());
  TulipSettings::instance().setRunningTimeComputed(_ui->runningTimeComputedCheck->isChecked());

  if (_ui->randomSeedCheck->isChecked()) {
    bool ok = true;
    unsigned int seed = _ui->randomSeedEdit->text().toUInt(&ok);
    tlp::setSeedOfRandomSequence(seed);
  }
  else
    tlp::setSeedOfRandomSequence();

  TulipSettings::instance().setSeedOfRandomSequence(tlp::getSeedOfRandomSequence());
}
void LogDetailWidget::setupModel()
{
	QAbstractItemModel *model = pieChart->model();

	model->setHeaderData(0, Qt::Horizontal, tr("Label"));
    model->setHeaderData(1, Qt::Horizontal, tr("Quantity"));

	QString colors[] = {"#ff0000", "#00ff00", "#0000ff","#ffff00", "#ff00ff", "#00ffff", "#000000", "#ffffff", "#777777", "#222222", "#aaaaaa"};

	int i=0;
	for(hash_map<string, double>::iterator it = logMan.process_stat.begin() ; it != logMan.process_stat.end(); it++)
	{
		string process = it->first;
		double duration = it->second;

		model->insertRow(i);
		model->setData(model->index(i, 0), QString::fromStdString(process));
		model->setData(model->index(i, 1), duration);

		model->setData(model->index(i, 0, QModelIndex()),
                           QColor(colors[i]), Qt::DecorationRole);
		i++;
	}

}
示例#4
0
void MainWindow::insertChild()
{
    QModelIndex index = view->selectionModel()->currentIndex();
    QAbstractItemModel *model = view->model();

    if (model->columnCount(index) == 0) {
        if (!model->insertColumn(0, index))
            return;
    }

    if (!model->insertRow(0, index))
        return;

    for (int column = 0; column < model->columnCount(index); ++column) {
        QModelIndex child = model->index(0, column, index);
        model->setData(child, QVariant("[No data]"), Qt::EditRole);
        if (!model->headerData(column, Qt::Horizontal).isValid())
            model->setHeaderData(column, Qt::Horizontal, QVariant("[No header]"),
                                 Qt::EditRole);
    }

    view->selectionModel()->setCurrentIndex(model->index(0, 0, index),
                                            QItemSelectionModel::ClearAndSelect);
    updateActions();
}
void LogDetailWidget::onCustomMenuRequested(const QPoint &pos)
{
	QModelIndex index = ui.aaView->currentIndex();
	if(index.row() <0) return;

	QAbstractItemModel* model = ui.aaView->model();
	QMenu *menu=new QMenu(this);

	QString timestamp = model->data(model->index(index.row(), 0), Qt::DisplayRole).toString();
	QString compName = model->data(model->index(index.row(), 2), Qt::DisplayRole).toString();
	QString type = model->data(model->index(index.row(), 4), Qt::DisplayRole).toString();
	QString value = model->data(model->index(index.row(), 5), Qt::DisplayRole).toString();
	int i;
	if((i=compName.indexOf(".java"))>=0 && type == "edit" && value != "")
	{
		QAction *editHistory = new QAction("See Edit History", this);
		menu->addAction(editHistory);
		connect(editHistory, SIGNAL(triggered()), this, SLOT(showEditHistory()));
	}

	QAction *showact = new QAction("Show Screenshot", this);
	
	menu->addAction(showact);
    
    menu->popup(ui.aaView->viewport()->mapToGlobal(pos));

	connect(showact, SIGNAL(triggered()), this, SLOT(showScreenshot()));

}
示例#6
0
QModelIndex TreeViewFind::prevIndex(const QModelIndex &idx, bool *wrapped) const
{
    if (wrapped)
        *wrapped = false;
    QAbstractItemModel *model = d->m_view->model();
    // if same parent has earlier columns, just move there
    if (idx.column() > 0)
        return model->index(idx.row(), idx.column() - 1, idx.parent());

    QModelIndex current = idx;
    bool checkForChildren = true;
    if (current.isValid()) {
        int row = current.row();
        if (row > 0) {
            current = model->index(row - 1, 0, current.parent());
        } else {
            current = current.parent();
            checkForChildren = !current.isValid();
            if (checkForChildren && wrapped) {
                // we start from the end
                *wrapped = true;
            }
        }
    }
    if (checkForChildren) {
        // traverse down the hierarchy
        while (int rc = model->rowCount(current)) {
            current = model->index(rc - 1, 0, current);
        }
    }
    // set to last column
    current = model->index(current.row(), model->columnCount(current.parent()) - 1, current.parent());
    return current;
}
示例#7
0
void MetaEditor::insertRow(QString code, QString contents)
{
    QModelIndex index = view->selectionModel()->currentIndex();
    QAbstractItemModel *model = view->model();

    // force all row insertions to be children of the root item
    while(index.parent() != QModelIndex()) {
        index = index.parent();
    }

    if (!model->insertRow(index.row()+1, index.parent()))
        return;


    updateActions();

    QModelIndex child = model->index(index.row()+1, 0, index.parent());
    model->setData(child, QVariant(code), Qt::EditRole);
    for (int column = 1; column < model->columnCount(index.parent()); ++column) {
        QModelIndex nchild = model->index(index.row()+1, column, index.parent());
        if (!contents.isEmpty()) {
            model->setData(nchild, QVariant(contents), Qt::EditRole);
        } else {
            model->setData(nchild, QVariant(tr("[Your value here]")), Qt::EditRole);
        }
    }

    // force newly inserted row to be the currently selected item so that any
    // follow-on insertChild calls use this as their parent.
    view->selectionModel()->setCurrentIndex(child, QItemSelectionModel::ClearAndSelect);
    updateActions();
}
示例#8
0
QModelIndex TreeViewFind::prevIndex(const QModelIndex &idx, bool *wrapped) const
{
    if (wrapped)
        *wrapped = false;
    QModelIndex current = idx;
    bool checkForChildren = true;
    QAbstractItemModel *model = d->m_view->model();
    if (current.isValid()) {
        int row = current.row();
        int column = current.column();
        if (column > 0) {
            current = model->index(row, column - 1, current.parent());
        } else {
            if (row > 0) {
                current = model->index(row - 1, model->columnCount(current.parent()) - 1,
                                       current.parent());
            } else {
                current = current.parent();
                checkForChildren = !current.isValid();
                if (checkForChildren && wrapped) {
                    // we start from the end
                    *wrapped = true;
                }
            }
        }
    }
    if (checkForChildren) {
        // traverse down the hierarchy
        while (int rc = model->rowCount(current)) {
            current = model->index(rc - 1, model->columnCount(current) - 1, current);
        }
    }
    return current;
}
void PreferencesDialog::cellChanged(int row, int column) {
  if (row == 3) {
    // force selection color to be the same for nodes & edges
    QAbstractItemModel* model = _ui->graphDefaultsTable->model();
    model->setData(model->index(3, column == 1 ? 2 : 1), model->data(model->index(3,column)));
  }
}
示例#10
0
void EditSolutionDialog::accept()
{
    QVariant bw = ui->bw->property("wine");
    QModelIndexList l = mWineModel->match(mWineModel->index(0, 0), Qt::DisplayRole, bw, -1, Qt::MatchFixedString);
    bw = l.first().data(PackageModel::IdRole);
    QVariant aw = ui->aw->property("wine");
    l = mWineModel->match(mWineModel->index(0, 0), Qt::DisplayRole, aw, -1, Qt::MatchFixedString);
    aw = l.first().data(PackageModel::IdRole);
    SolutionModel::IntList bp;
    QAbstractItemModel *bpm = ui->bp->model();
    for (int i = 0, count = bpm->rowCount(); i < count; ++i)
        bp.append(bpm->index(i, 0).data(PackageModel::IdRole).toInt());
    SolutionModel::IntList ap;
    QAbstractItemModel *apm = ui->ap->model();
    for (int i = 0, count = apm->rowCount(); i < count; ++i)
        ap.append(apm->index(i, 0).data(PackageModel::IdRole).toInt());
    QModelIndex index = mModel->index(mRow, 0);
    QMap<int, QVariant> data;
    data.insert(SolutionModel::BWRole, bw);
    data.insert(SolutionModel::AWRole, aw);
    data.insert(SolutionModel::BPRole, QVariant::fromValue(bp));
    data.insert(SolutionModel::APRole, QVariant::fromValue(ap));
    QSortFilterProxyModel *sm = static_cast<QSortFilterProxyModel *>(mModel);
    sm->sourceModel()->setItemData(sm->mapToSource(index), data);
    QDialog::accept();
}
示例#11
0
//-----------------------------------------------------------------------------
void ctkPathLineEditPrivate::_q_recomputeCompleterPopupSize()
{
  QSize lineEditSize = this->LineEdit->size();

  QAbstractItemView* view = this->LineEdit->completer()->popup();
  const QFontMetrics& fm = view->fontMetrics();

  int iconWidth = 0;
  int textWidth = 0;

  QStyleOptionFrame option;
  int frameWidth = view->style()->pixelMetric(QStyle::PM_DefaultFrameWidth, &option, view);
  int frame = 2 * frameWidth
      + view->contentsMargins().left()
      + view->contentsMargins().right();

  QAbstractItemModel* model = this->LineEdit->completer()->completionModel();
  for (int i = 0; i < model->rowCount(); ++i)
    {
    QVariant icon = model->data(model->index(i, 0), Qt::DecorationRole);
    if (icon.isValid() && icon.canConvert<QIcon>())
      {
      iconWidth = qMax(iconWidth, icon.value<QIcon>().availableSizes().front().width() + 4);
      }
    textWidth = qMax(textWidth, fm.boundingRect(model->data(model->index(i, 0)).toString()).width());
    }

  view->setMinimumWidth(qMax(frame + iconWidth + textWidth, lineEditSize.width()));
}
/** Submit the current editing class/interactor to the model and submit the model to the database */
void InteractorEditorWidget::save()
{
    if (d->m_EditingIndex.isValid()) {
        QAbstractItemModel *model = ddiCore()->drugInteractorTableModel();

        // Manage ATC
        QModelIndex atc = model->index(d->m_EditingIndex.row(), DrugInteractorTableModel::ATCCodeStringList, d->m_EditingIndex.parent());
        model->setData(atc, d->_atcCodesStringListModel->stringList().join(";"));

        // Manage class children
        QModelIndex children = model->index(d->m_EditingIndex.row(), DrugInteractorTableModel::ChildrenUuid, d->m_EditingIndex.parent());
        model->setData(children, d->_childrenInteractorsStringListModel->stringList().join(";"));

        // Manage PMIDs
        QModelIndex pmids = model->index(d->m_EditingIndex.row(), DrugInteractorTableModel::PMIDStringList, d->m_EditingIndex.parent());
        model->setData(pmids, d->_pmidStringListModel->stringList().join(";"));

        // Submit mapper at the end as the model will be resetted on submit
        if (!d->_mapper->submit())
            LOG_ERROR("Unable to submit mapper");
    }

    setEditorsEnabled(false);
    d->aSave->setEnabled(false);
    d->aRevert->setEnabled(false);
    d->_proxyMoleculeModel->invalidate();
    d->_proxyMoleculeModel->setFilterFixedString(d->ui->searchLine->text());
    updateCounts();
}
示例#13
0
void tst_QDataWidgetMapper::setData()
{
    QDataWidgetMapper mapper;
    QAbstractItemModel *model = testModel(&mapper);
    mapper.setModel(model);

    QLineEdit edit1;
    QLineEdit edit2;
    QLineEdit edit3;

    mapper.addMapping(&edit1, 0);
    mapper.addMapping(&edit2, 1);
    mapper.addMapping(&edit3, 0, "text");
    mapper.toFirst();
    QCOMPARE(edit1.text(), QString("item 0 0"));
    QCOMPARE(edit2.text(), QString("item 0 1"));
    QCOMPARE(edit3.text(), QString("item 0 0"));

    edit1.setText("new text");

    mapper.submit();
    QCOMPARE(model->data(model->index(0, 0)).toString(), QString("new text"));

    edit3.setText("more text");

    mapper.submit();
    QCOMPARE(model->data(model->index(0, 0)).toString(), QString("more text"));
}
示例#14
0
/*
void AdjustNames::resizeEvent( QResizeEvent * event )
{
    int w = event->size().width();
    int h = event->size().height();
    BackFrame->resize(event->size());
    if( w > 300 && h > 150 )
    {
        Cancel->setGeometry(w-85,h-36,77,26);
        Next->setGeometry(w-168,h-36,77,26);
        line->setGeometry(14,h-53,w-21,16);
        title->setGeometry(220,21,w-299,18);
        instructions->setGeometry(220,h-79,w-229,18);
        tableWidget->setGeometry(220, 45, w-229, h-130);
    }
}
*/
void AdjustNames::show()
{
    QDialog::show();

    scenarioName->setText(QString(     "Scenario Name:       ") + extractor->setup->scenarioName->text());
    scenarioDirectory->setText(QString("Scenario Directory:  ") + extractor->setup->scenarioDirectory->text());

    tableWidget->clearContents();
    tableWidget->setRowCount(0);

    tableWidget->horizontalHeaderItem(0)->setToolTip("This is the node id used by the EXata/QualNet simulator and GUI");
    tableWidget->horizontalHeaderItem(1)->setToolTip("This is the name used by the HLA federate that published the entity");
    tableWidget->horizontalHeaderItem(2)->setToolTip("Enter text to change the name that will be used by the EXata/QualNet simulator and GUI");
    tableWidget->horizontalHeaderItem(3)->setToolTip("Enter an icon file name or browse to change the icon used by the EXata/QualNet simulator and GUI");

    QAbstractItemModel* model = tableWidget->model();
    SNT_HLA::NodeSet::iterator it = extractor->ns->begin();
    //QFontMetrics fontMetrics = tableWidget->fontMetrics();
    //int iconWidth = 0;
    while( it != extractor->ns->end() )
    {
        QApplication::processEvents();
        if( extractor == 0 )
            break;
        if( (*it)->entity )
        {
            QString name((*it)->getNodeName());
            int id = (*it)->NodeId;
            QString iconName((*it)->getIconName().c_str());
            QIcon icon(iconName);
            QFileInfo iconInfo(iconName);
            int row = tableWidget->rowCount();
            tableWidget->insertRow(row);
            QModelIndex index = model->index(row, 1, QModelIndex());
            model->setData(index, name);
            index = model->index(row, 2, QModelIndex());
            model->setData(index, name);
            index = model->index(row, 0, QModelIndex());
            model->setData(index, id);
            tableWidget->item(row, 0)->setFlags(0);
            tableWidget->item(row, 1)->setFlags(0);
            FileNameWidget* wid = new FileNameWidget("Open Icon File", extractor->exeHome+"/gui/icons", getImageFilter(),tableWidget);
            wid->setText(iconName);
            wid->setToolTip("Enter an icon file name or browse to change the icon used by the EXata/QualNet simulator and GUI");
            tableWidget->setCellWidget(row, 3, wid);
            tableWidget->item(row,0)->setToolTip("This is the node id used by the EXata/QualNet simulator and GUI");
            tableWidget->item(row,1)->setToolTip("This is the name used by the HLA federate that published the entity");
            tableWidget->item(row,2)->setToolTip("Enter text to change the name that will be used by the EXata/QualNet simulator and GUI");
            tableWidget->resizeColumnToContents(0);
            tableWidget->resizeColumnToContents(1);
            tableWidget->resizeColumnToContents(2);
        }
        //tableWidget->setColumnWidth(3, iconWidth);
        it++;
    }
}
示例#15
0
void CSVRender::Object::apply (CSMWorld::CommandMacro& commands)
{
    const CSMWorld::RefCollection& collection = mData.getReferences();
    QAbstractItemModel *model = mData.getTableModel (CSMWorld::UniversalId::Type_References);

    int recordIndex = collection.getIndex (mReferenceId);

    if (mOverrideFlags & Override_Position)
    {
        for (int i=0; i<3; ++i)
        {
            int column = collection.findColumnIndex (static_cast<CSMWorld::Columns::ColumnId> (
                CSMWorld::Columns::ColumnId_PositionXPos+i));

            commands.push (new CSMWorld::ModifyCommand (*model,
                model->index (recordIndex, column), mPositionOverride.pos[i]));
        }

        int column = collection.findColumnIndex (static_cast<CSMWorld::Columns::ColumnId> (
            CSMWorld::Columns::ColumnId_Cell));

        if (CSMWorld::CellCoordinates::isExteriorCell(collection.getRecord (recordIndex).get().mCell))
        {
            std::pair<int, int> cellIndex = collection.getRecord (recordIndex).get().getCellIndex();

            /// \todo figure out worldspace (not important until multiple worldspaces are supported)
            std::string cellId = CSMWorld::CellCoordinates (cellIndex).getId ("");

            commands.push (new CSMWorld::ModifyCommand (*model,
                model->index (recordIndex, column), QString::fromUtf8 (cellId.c_str())));
        }
    }

    if (mOverrideFlags & Override_Rotation)
    {
        for (int i=0; i<3; ++i)
        {
            int column = collection.findColumnIndex (static_cast<CSMWorld::Columns::ColumnId> (
                CSMWorld::Columns::ColumnId_PositionXRot+i));

            commands.push (new CSMWorld::ModifyCommand (*model,
                model->index (recordIndex, column), mPositionOverride.rot[i]));
        }
    }

    if (mOverrideFlags & Override_Scale)
    {
        int column = collection.findColumnIndex (CSMWorld::Columns::ColumnId_Scale);

        commands.push (new CSMWorld::ModifyCommand (*model,
            model->index (recordIndex, column), mScaleOverride));
    }

    mOverrideFlags = 0;
}
示例#16
0
//! [9] //! [10]
void AddressView::itemSelected(const QModelIndex &index)
{
    if (!index.isValid())
	return;

    QAbstractItemModel *model = treeView->model();
    iFirstName->setText(model->data(model->index(index.row(), 0)).toString());
    iLastName->setText(model->data(model->index(index.row(), 1)).toString());
    iAddress->setText(model->data(model->index(index.row(), 2)).toString());
    iEMail->setText(model->data(model->index(index.row(), 3)).toString());
}
    void PathPlanningWidget::pointPosUpdated_slot(const tf::Transform& point_pos, const char* marker_name)
    {
        /*! When the user updates the position of the Way-Point or the User Interactive Marker, the information in the TreeView also needs to be updated to correspond to the current pose of the InteractiveMarkers.

        */
        QAbstractItemModel *model = ui_.treeView->model();

        ROS_INFO_STREAM("Updating marker name:"<<marker_name);

        tf::Vector3 p = point_pos.getOrigin();
        tfScalar rx,ry,rz;
        point_pos.getBasis().getRPY(rx,ry,rz,1);

        rx = RAD2DEG(rx);
        ry = RAD2DEG(ry);
        rz = RAD2DEG(rz);

      if((strcmp(marker_name,"add_point_button") == 0) || (atoi(marker_name)==0))
      {
          QString pos_s;
          pos_s = QString::number(p.x()) + "; " + QString::number(p.y()) + "; " + QString::number(p.z()) + ";";
          QString orient_s;
          orient_s = QString::number(rx) + "; " + QString::number(ry) + "; " + QString::number(rz) + ";";

          model->setData(model->index(0,0),QVariant("add_point_button"),Qt::EditRole);
          model->setData(model->index(0,1),QVariant(pos_s),Qt::EditRole);
          model->setData(model->index(0,2),QVariant(orient_s),Qt::EditRole);
      }
      else
      {

          int changed_marker = atoi(marker_name);
    //**********************update the positions and orientations of the children as well***********************************************************************************************
          QModelIndex ind = model->index(changed_marker, 0);
          QModelIndex chldind_pos = model->index(0, 0, ind);
          QModelIndex chldind_orient = model->index(1, 0, ind);

          //set the strings of each axis of the position
          QString pos_x = QString::number(p.x());
          QString pos_y = QString::number(p.y());
          QString pos_z = QString::number(p.z());

          //repeat that with the orientation
          QString orient_x = QString::number(rx);
          QString orient_y = QString::number(ry);
          QString orient_z = QString::number(rz);

          //second we add the current position information, for each position axis separately
          model->setData(model->index(0, 1, chldind_pos), QVariant(pos_x), Qt::EditRole);
          model->setData(model->index(1, 1, chldind_pos), QVariant(pos_y), Qt::EditRole);
          model->setData(model->index(2, 1, chldind_pos), QVariant(pos_z), Qt::EditRole);

          //second we add the current position information, for each position axis separately
          model->setData(model->index(0, 2, chldind_orient), QVariant(orient_x), Qt::EditRole);
          model->setData(model->index(1, 2, chldind_orient), QVariant(orient_y), Qt::EditRole);
          model->setData(model->index(2, 2, chldind_orient), QVariant(orient_z), Qt::EditRole);
//*****************************************************************************************************************************************************************************************
      }
    }
示例#18
0
QString LookAlikeMainPrivate::urnFromUrl(QUrl url)
{
    QAbstractItemModel *model = m_trackerProvider->model();
    QString urlString = url.toString();
    for (int i = 0; i < model->rowCount(); i++) {
        if (model->index(i, GalleryContentProvider::UrlColumn).data().toString() == urlString) {
            return model->index(i, GalleryContentProvider::UrnColumn).data().toString();
        }
    }
    return QString();
}
示例#19
0
void ActsDialog::view()
{
  QAbstractItemModel *model = tableView_->model();
  QString lim = model->data(model->index(tableView_->currentIndex().row(),
					 Act_Text)).toString();
  // QString customer = model->data(model->index(tableView_->currentIndex().row(),
  // 					 Limit_Customer)).toString();
  QString limDate = model->data(model->index(tableView_->currentIndex().row(),
					 Act_Date)).toString();
  

  QSqlQuery query;
  query.prepare("SELECT 1 "
		",d.catNum "
		",d.text "
		",'' "
		",m.n "
		",strftime('%d.%m.%Y',date_) "
		",d.qty "
		",m.n*d.qty "
		"FROM tb_moves m"
		" ,tb_details d "
		"WHERE 1=1 "
		"AND m.detailId=d.uid "
		"AND m.document=:document "
		"AND strftime('%d.%m.%Y',date_)=:date "
		"ORDER BY d.text");
  query.bindValue(":document", lim);
  query.bindValue(":date", limDate);
  query.exec();

  QFile file("./txt/acts.txt");
  if(file.open(QIODevice::WriteOnly | QIODevice::Truncate)) {
    
    QTextStream fout(&file);
    fout.setCodec("Windows-1251");
    
    while(query.next()) {
      for(qint8 i=0; i < 8; ++i) {
	if(i == 6 || i == 7)
	  fout << query.value(i).toString().replace('.',',') << ";";
	else
	  fout << query.value(i).toString() << ";";
      }
      fout << "\n";
    }
    file.close();
    QMessageBox::information(0, trUtf8("Информация"), trUtf8("Выполнено.."));
  }
  
  // QProcess proc;
  // proc.startDetached("./txt/acts.txt");
}
示例#20
0
void LineEdit::keyReleaseEvent(QKeyEvent *ke)
{
    if (!m_historyEnabled || completer()->completionMode() == QCompleter::UnfilteredPopupCompletion ||
        !(ke->key() == Qt::Key_Up || ke->key() == Qt::Key_Down)) {
        // irrelevant events -> ignore
        QLineEdit::keyReleaseEvent(ke);
        return;
    }

    // this manages the shell-a-like history and
    // triggers a popdown (when pressing "down" arrow from current entry)

    QAbstractItemModel *m = completer()->model();
    int historyCount = m->rowCount();

    if (ke->key() == Qt::Key_Up) {
        // shell-a-like history navigation
        if (m_historyPosition == historyCount) {
            m_currentText = text();
            if (historyCount && m->index(m_historyPosition - 1,0).data().toString() == m_currentText) {
                // user still sees entry he entered (into history) last - skip that one.
                --m_historyPosition;
            }
        }
        if (--m_historyPosition < 0) {
            m_historyPosition = historyCount;
            setText(m_currentText);
        } else {
            setText(m->index(m_historyPosition,0).data().toString());
        }
    } else if (ke->key() == Qt::Key_Down) {
        if (m_historyPosition + 1 < historyCount && m->index(m_historyPosition + 1,0).data().toString() == m_currentText) {
            // user still sees entry he entered (into history) last - skip that one.
            ++m_historyPosition;
        }
        if (++m_historyPosition == historyCount) {
            // returning from shell-a-like journey
            setText(m_currentText);
        } else if (m_historyPosition > historyCount) {
            // trigger pop...down ;-)
            completer()->setCompletionMode(QCompleter::UnfilteredPopupCompletion);
            completer()->complete(); // make a popup
            completer()->popup()->removeEventFilter(this); // protected against accidental double filtering
            completer()->popup()->installEventFilter(this); // to restore inline completion when it closes
            m_historyPosition = historyCount; // fix value to "current" (it's usually historyCount + 1 now)
        } else {
            // shell-a-like history navigation
            setText(m->index(m_historyPosition,0).data().toString());
        }
    }
    QLineEdit::keyReleaseEvent(ke);
}
示例#21
0
/*================================================================
*  函 数 名: ProcessTreeView::setNowSelectProcess
*
*  功能描述: 设置当前选中的进程名到内部变量(内部接口)
*
*  参    数: 选中的索引
*			  
*  返 回 值:无
*
*  作    者:刘欢 2013/8
================================================================*/
void ProcessTreeView::setNowSelectProcess(const QModelIndex &index)
{
	nowSelectIndex = index;
	QAbstractItemModel *model = (QAbstractItemModel *)index.model();
	QModelIndex nowSelectProcessName = model->index(index.row(), 0);
	strNowProcess = nowSelectProcessName.data().toString();

	QModelIndex nowSelectProcessPID = model->index(index.row(), 1);
	strNowPid = nowSelectProcessPID.data().toString(); 
	
	qDebug() << "当前选择进程:" << index.row() << strNowProcess 
					<<"PID:" << strNowPid << "\r\n";
}
示例#22
0
void ListProxyModel::update()
{
	QAbstractItemModel *sourceModel = QAbstractProxyModel::sourceModel();
	indexList.clear();
	// add all nodes to the list
	int column = 0;
	for (int row = 0; sourceModel->index(row, column).isValid(); row++)
	{
		QModelIndex aIndex = sourceModel->index(row, column);
		indexList.append(aIndex);
		addIndexes(&aIndex);
	}
}
示例#23
0
void DlgFilletEdges::on_filletEndRadius_valueChanged(double radius)
{
    QAbstractItemModel* model = ui->treeView->model();
    QString text = QLocale::system().toString(radius,'f',2);
    for (int i=0; i<model->rowCount(); ++i) {
        QVariant value = model->index(i,0).data(Qt::CheckStateRole);
        Qt::CheckState checkState = static_cast<Qt::CheckState>(value.toInt());

        // is item checked
        if (checkState & Qt::Checked) {
            model->setData(model->index(i, 2), QVariant(text));
        }
    }
}
示例#24
0
    void ICatInvestigation::onSelectAllFiles()
    {
      QItemSelectionModel* selectionModel = m_uiForm.invsttableWidget->selectionModel();
      QAbstractItemModel *model = m_uiForm.invsttableWidget->model();
      int rowCount = model->rowCount();
      int colCount = model->columnCount();

      QModelIndex topLeft = model->index(0,0,QModelIndex());
      QModelIndex bottomRight = model->index(rowCount-1,colCount-1,QModelIndex());

      QItemSelection selection(topLeft, bottomRight);
      selectionModel->select(selection, QItemSelectionModel::Select);


    }
示例#25
0
void LineEdit::learnEntry()
{
    QAbstractItemModel *m = completer()->model();
    int rows = m->rowCount();
    for (int i = 0; i < rows; ++i) {
        if (m->index(i,0).data() == text()) {
            m->removeRow(i);
            --rows;
            break;
        }
    }
    m->insertRows(rows, 1);
    m->setData(m->index(rows, 0), text(), Qt::DisplayRole);
    m_historyPosition = rows + 1;
}
示例#26
0
QgsVectorJoinInfo QgsJoinDialog::joinInfo() const
{
  QgsVectorJoinInfo info;
  info.joinLayerId = mJoinLayerComboBox->currentLayer()->id();
  info.joinFieldName = mJoinFieldComboBox->currentField();
  info.targetFieldName = mTargetFieldComboBox->currentField();
  info.memoryCache = mCacheInMemoryCheckBox->isChecked();
  info.targetFieldIndex = -1;
  info.joinFieldIndex = -1;

  if ( mUseCustomPrefix->isChecked() )
    info.prefix = mCustomPrefix->text();
  else
    info.prefix = QString::null;

  if ( mUseJoinFieldsSubset->isChecked() )
  {
    QStringList lst;
    QAbstractItemModel* model = mJoinFieldsSubsetView->model();
    if ( model )
    {
      for ( int i = 0; i < model->rowCount(); ++i )
      {
        QModelIndex index = model->index( i, 0 );
        if ( model->data( index, Qt::CheckStateRole ).toInt() == Qt::Checked )
          lst << model->data( index ).toString();
      }
    }
    info.setJoinFieldNamesSubset( new QStringList( lst ) );
  }

  return info;
}
示例#27
0
void QgsJoinDialog::setJoinInfo( const QgsVectorJoinInfo& joinInfo )
{
  mJoinLayerComboBox->setLayer( QgsMapLayerRegistry::instance()->mapLayer( joinInfo.joinLayerId ) );
  mJoinFieldComboBox->setField( joinInfo.joinFieldName );
  mTargetFieldComboBox->setField( joinInfo.targetFieldName );
  mCacheInMemoryCheckBox->setChecked( joinInfo.memoryCache );
  if ( joinInfo.prefix.isNull() )
  {
    mUseCustomPrefix->setChecked( false );
  }
  else
  {
    mUseCustomPrefix->setChecked( true );
    mCustomPrefix->setText( joinInfo.prefix );
  }

  QStringList* lst = joinInfo.joinFieldNamesSubset();
  mUseJoinFieldsSubset->setChecked( lst && !lst->isEmpty() );
  QAbstractItemModel* model = mJoinFieldsSubsetView->model();
  if ( model )
  {
    for ( int i = 0; i < model->rowCount(); ++i )
    {
      QModelIndex index = model->index( i, 0 );
      if ( lst && lst->contains( model->data( index, Qt::DisplayRole ).toString() ) )
      {
        model->setData( index, Qt::Checked, Qt::CheckStateRole );
      }
      else
      {
        model->setData( index, Qt::Unchecked, Qt::CheckStateRole );
      }
    }
  }
}
示例#28
0
QModelIndex Utils::ModelListModel::index(int row, int column, const QModelIndex& parent) const
{
	//read parent modelindex
	Utils::ModelListModel::SubModelIndex smi = mapToSource(parent);
	//create SubModelIndex for child
	Utils::ModelListModel::SubModelIndex newSmi;
	if (smi.first == m_metaModel && smi.second.isValid())
	{
		QAbstractItemModel* subModel = m_subModels.value(smi.second.row());
		if (subModel)
		{
			newSmi.first = subModel;
			newSmi.second = subModel->index(row, column);
		}
		else
		{
			newSmi.first = smi.first;
			newSmi.second = smi.first->index(row, column, smi.second);
		}
	}
	else
	{
		newSmi.first = smi.first;
		newSmi.second = smi.first->index(row, column, smi.second);
	}
	//collapse into modelindex
	return mapFromSource(newSmi);
}
void MainWindow::on_find_exe_clicked()
{
	QAbstractItemModel *model = ui->tableView->model();

    bool bFind=false;

	for (int i = 0;i < model->rowCount();i++) {
		QVariant data = model->data(model->index(i, 0));

		QString fileName = data.toString();

		if (fileName.endsWith(".exe")) {
            QString yes_file_name=QString("是否将 %1 设置为主程序Exe文件").arg(fileName);
            //qDebug() << fileName;
            QMessageBox::StandardButton sb=QMessageBox::question(this,"确认",yes_file_name,QMessageBox::Yes | QMessageBox::No,QMessageBox::Yes);
            if(sb==QMessageBox::Yes){
                ui->le_ExeFile->setText(fileName);
                bFind=true;
                return;
            }
		}
	}

    if(!bFind){
        QMessageBox::information(this,"警告","无法找到或者设置Exe文件",QMessageBox::Yes);
    }
}
示例#30
0
QModelIndexList
PartitionLabelsView::getIndexesToDraw( const QModelIndex& parent ) const
{
    QModelIndexList list;

    QAbstractItemModel* modl = model();
    if ( !modl )
        return list;

    for ( int row = 0; row < modl->rowCount( parent ); ++row )
    {
        QModelIndex index = modl->index( row, 0, parent );

        //HACK: horrible special casing follows.
        //      To save vertical space, we choose to hide short instances of free space.
        //      Arbitrary limit: 10MB.
        const qint64 maxHiddenB = 10'000'000;
        if ( index.data( PartitionModel::IsFreeSpaceRole ).toBool() &&
             index.data( PartitionModel::SizeRole ).toLongLong() <  maxHiddenB )
            continue;

        list.append( index );
        if ( modl->hasChildren( index ) )
            list.append( getIndexesToDraw( index ) );
    }
    return list;
}