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();
}
示例#2
0
void MainWindow::OnConvertButtonClicked()
{
    QAbstractItemModel *model = ui->listView->model();
    if (!model || model->rowCount() == 0)
    {
        return;
    }

    while (model->rowCount())
    {
        QString pvrName = model->data(model->index(0, 0)).toString();
        QString pngName = pvrName;
        pngName.replace(".pvr", ".png", Qt::CaseInsensitive);

        unsigned char* data;
        unsigned long int size;
        PVRTHeader header;
        int ret = LoadPVRFromFile(pvrName.toUtf8().data(), &data, &size, &header);
        if (ret)
        {
            QFile file(pngName);
            file.open(QIODevice::WriteOnly);

            QImage image(data, header.width, header.height, QImage::Format_RGBA8888);
            QPixmap pixmap = QPixmap::fromImage(image);
            pixmap.save(&file, "PNG");

            free(data);
        }

        model->removeRow(0);
    }

    ui->statusBar->showMessage("Done!");
}
void CBBaseProviderTestSet::clonningTest(){
    QAbstractItemModel * listModel = (QAbstractItemModel *)m_current_node->listModel();
    int recordCount = listModel->rowCount();
    m_current_node->selectItemWithIndex(2);
    QVariantMap default_item = m_current_node->selectedItem();
    m_current_node->cloneItem();
    QVariantMap clonned_item = m_current_node->selectedItem();
    for (auto iter: default_item.keys()){
        if (iter == "id"){
            QVERIFY(clonned_item[iter]!=default_item[iter]);
        }
        else{
            QVERIFY(clonned_item[iter]==default_item[iter]);
        }
    }

    clonned_item["nominal"]=QVariant("Test insert");
    clonned_item["firstYear"]=QVariant(1000);

    m_current_node->applyChanges(clonned_item);

    // check that selected item was not changed after appliing changes
    QVariantMap clonned_item_after_saving = m_current_node->selectedItem();
    QVERIFY(clonned_item["id"]==clonned_item_after_saving["id"]);

    // check that we have recordCount + 1

    QCOMPARE(recordCount+1,listModel->rowCount());

}
示例#4
0
QModelIndex FindDialog::getPreIndex(QModelIndex index)
{
    QAbstractItemModel *model = m_parent->ui.tree_view->model();
    assert(NULL != model);

    // 根节点的前一个是最后一个节点
    if (!index.isValid())
    {
        QModelIndex current = model->index(0,0,QModelIndex());
        while (model->rowCount(current) > 0)
            current = current.child(model->rowCount(current) - 1, 0);
        return current;
    }

    QModelIndex parent = index.parent();
    if (!parent.isValid())
        return QModelIndex(); // 根
    int row = index.row();
    if (row == 0)
        return parent;
    QModelIndex current = parent.child(row - 1, 0);
    while (model->rowCount(current) > 0)
        current = current.child(model->rowCount(current) - 1, 0);
    return current;
}
示例#5
0
void AdminDialog::on_borrowAddBtn_clicked()
{
    QAbstractItemModel *model = ui->tv3->model();
    for(int i=0;i<model->rowCount();i++)
    {
        QModelIndex index = ui->tv3->model()->index(i,0);
        QString boid = ui->tv3->model()->data(index).toString();
        QSqlQuery query(Tool::getInstance()->getDb());
        query.exec("update borrow set overbor=overbor+1 where boid="+boid);
    }
    if(model->rowCount()>0){
        QMessageBox::about(NULL,"提示","增加续借次数成功!");
        initBorrowTableView();
    }
}
示例#6
0
文件: main.cpp 项目: Igalia/lookalike
int main(int argc, char *argv[])
{
    QCoreApplication a(argc, argv);
    MyTest *t = new MyTest();
    QImage i("/home/jasuarez/MyDocs/12020001.jpg");
    t->connect(t->recognizer, SIGNAL(facesDetected(QString,QImage,QSize,QList<QRect>)), t, SLOT(onFacesDetected(QString,QImage,QSize,QList<QRect>)));
    t->connect(t->recognizer, SIGNAL(facesRecognized(QString,QImage,QList<XQFaceRegion>)), t, SLOT(onFacesRecognized(QString,QImage,QList<XQFaceRegion>)));
    //t->recognizer->detectFaces("t1", i);
    t->recognizer->processFaces("urn:uuid:15fb1a3d-cfe7-ebb7-a110-bdc0c6968c8f", i);
    return a.exec();

    XQFaceGroup group = t->db->faceGroup("Jota");
    QAbstractItemModel *m = group.faces();
    int s = m->rowCount();
    qDebug() << s;
    QAbstractItemModel *m2 = t->db->faceGroups(XQFaceDatabase::UnnamedGroup);
    QString f = m2->index(0,0,QModelIndex()).data().toString();
    qDebug() << f;
    group = t->db->faceGroup(f);
    qDebug() << group.faceId();
    m = group.faces();
    f = m->index(0,0,QModelIndex()).data().toString();
    XQFaceRegion region = group.faceRegion(f);
    qDebug() << region.sourceId();
    qDebug() << region.faceIds().size();
    qDebug() << region.faceIds().at(0);
    s = m2->rowCount();
    qDebug() << s;
    return a.exec();
}
示例#7
0
文件: itemsync.cpp 项目: hluk/CopyQ
bool ItemSyncSaver::saveItems(const QString &tabName, const QAbstractItemModel &model, QIODevice *file)
{
    // Don't save items if path is empty.
    if (!m_watcher) {
        writeConfiguration(file, QStringList());
        return true;
    }

    const QString path = m_watcher->path();
    QStringList savedFiles;

    if ( !m_watcher->isValid() ) {
        log( tr("Failed to synchronize tab \"%1\" with directory \"%2\"!")
             .arg(tabName, path),
             LogError );
        return false;
    }

    QDir dir(path);

    for (int row = 0; row < model.rowCount(); ++row) {
        const QModelIndex index = model.index(row, 0);
        const QVariantMap itemData = index.data(contentType::data).toMap();
        const QVariantMap mimeToExtension = itemData.value(mimeExtensionMap).toMap();
        const QString baseName = FileWatcher::getBaseName(index);
        const QString filePath = dir.absoluteFilePath(baseName);

        for (const auto &ext : mimeToExtension)
            savedFiles.prepend( filePath + ext.toString() );
    }

    writeConfiguration(file, savedFiles);

    return true;
}
示例#8
0
QModelIndex ComputerManager::findNetworkObject( const NetworkObject::Uid& networkObjectUid, const QModelIndex& parent )
{
	QAbstractItemModel* model = networkObjectModel();

	int rows = model->rowCount( parent );

	for( int i = 0; i < rows; ++i )
	{
		QModelIndex entryIndex = model->index( i, 0, parent );

		auto objectType = static_cast<NetworkObject::Type>( model->data( entryIndex, NetworkObjectModel::TypeRole ).toInt() );

		if( objectType == NetworkObject::Group )
		{
			QModelIndex index = findNetworkObject( networkObjectUid, entryIndex );
			if( index.isValid() )
			{
				return index;
			}
		}
		else if( objectType == NetworkObject::Host )
		{
			if( model->data( entryIndex, NetworkObjectModel::UidRole ).toUuid() == networkObjectUid )
			{
				return entryIndex;
			}
		}
	}

	return QModelIndex();
}
QVariantMap RemoteControl::get_switchboard_incoming_calls_infos()
{
    QVariantMap result;

    Switchboard *xlet = this->get_xlet<Switchboard>("switchboard");
    QueueEntriesView * incoming = xlet->ui.incomingCallsView;
    this->assert(incoming != NULL, "widget for incoming calls is null");

    QAbstractItemModel *model = incoming->model();

    QVariantList list;

    for (int row = 0; row < model->rowCount(); row++) {
        QVariantMap incoming;
        incoming["position"] = this->getValueInModel(model, row, QueueEntriesModel::POSITION);
        incoming["cid_name"] = this->getValueInModel(model, row, QueueEntriesModel::NAME);
        incoming["cid_num"] = this->getValueInModel(model, row, QueueEntriesModel::NUMBER);
        incoming["time"] = this->getValueInModel(model, row, QueueEntriesModel::TIME);
        incoming["unique_id"] = this->getValueInModel(model, row, QueueEntriesModel::UNIQUE_ID);
        list.append(incoming);
    }

    result["incoming_calls"] = list;
    return result;
}
示例#10
0
void EditProfileDialog::colorSchemeAnimationUpdate()
{
    QAbstractItemModel* model = _ui->colorSchemeList->model();

    for ( int i = model->rowCount() ; i >= 0 ; i-- )
        _ui->colorSchemeList->update( model->index(i,0) );
}
示例#11
0
void ResultsOutput::copy()
{
  if (DEBUG)
    qDebug("ResultsOutput::copy() entered");

  QClipboard *clipboard = QApplication::clipboard();
  QAbstractItemModel *model = _table->model();
  QByteArray  bytes;
  for (int i = 0; i < model->rowCount(); i++)
  {
    for (int j = 0; j < model->columnCount(); j++)
    {
      if (j)
        bytes += ",";
      bytes += "\"" +
              model->data(model->index(i, j)).toString().replace("\"", "\"\"") +
              "\"";
    }
    bytes += "\n";
  }
  clipboard->setText(bytes);

  if (DEBUG)
    qDebug("ResultsOutput::copy() returning with bytes %s", bytes.data());
}
示例#12
0
QMatchData QCompletionEngine::filterHistory()
{
    QAbstractItemModel *source = c->proxy->sourceModel();
    if (curParts.count() <= 1 || c->proxy->showAll || !source)
        return QMatchData();
    bool isDirModel = false;
    bool isFsModel = false;
    Q_UNUSED(isDirModel)
    Q_UNUSED(isFsModel)
#ifndef QT_NO_DIRMODEL
    isDirModel = (qobject_cast<QDirModel *>(source) != 0);
#endif
#ifndef QT_NO_FILESYSTEMMODEL
    isFsModel = (qobject_cast<QFileSystemModel *>(source) != 0);
#endif
    QVector<int> v;
    QIndexMapper im(v);
    QMatchData m(im, -1, true);

    for (int i = 0; i < source->rowCount(); i++) {
        QString str = source->index(i, c->column).data().toString();
        if (str.startsWith(c->prefix, c->cs)
#if (!defined(Q_OS_WIN) || defined(Q_OS_WINCE)) && !defined(Q_OS_SYMBIAN)
            && ((!isFsModel && !isDirModel) || QDir::toNativeSeparators(str) != QDir::separator())
#endif
            )
            m.indices.append(i);
    }
    return m;
}
示例#13
0
void EmoticonViewer::addEntry()
{
    QAbstractItemModel *model = _ui->listView->model();
    int row = model->rowCount();
    model->insertRow(row);
    _ui->listView->edit(model->index(row, 0));
}
QVariant TaskContextMenuModel::data(const QModelIndex &index, int role) const
{
    if (index.row() < 0 || index.row() >= rowCount(QModelIndex()))
        return QVariant();

    if (index.row() < rowOffset())
        return staticData(static_cast<OptionType>(index.row()), role);

    const int tagRow = index.row() - rowOffset();
    QAbstractItemModel *tagModel = m_task->checkableTagModel();
    if (tagRow < 0 || tagRow >= tagModel->rowCount()) {
        qWarning() << "TaskContextMenuModel: invalid index" << tagRow;
        return QVariant();
    }

    QModelIndex tagIndex = tagModel->index(tagRow, 0);

    switch (role) {
    case TextRole:
        return tagIndex.data(CheckableTagModel::ItemTextRole);
    case IconRole:
        return "";
    case CheckableRole:
        return true;
    case DismissRole:
        return false;
    case Qt::CheckStateRole:
        return tagIndex.data(Qt::CheckStateRole);
    }

    return QVariant();
}
QSizeF HbTumbleViewItem::sizeHint(Qt::SizeHint which, const QSizeF &constraint) const
{
    HB_SDD(const HbAbstractViewItem);
    static qreal height=0;

    QSizeF sh=HbListViewItem::sizeHint(which,constraint);
    if(which == Qt::PreferredSize && sh.height()<=0) {
        //TODO:remove this check once refresh issue in DTP is solved on removeRows/insertRows
        if(height<=0) {
            //Let's create a temporary item and take the height for the size hint
            HbAbstractViewItem *tempitem = sd->mPrototype->createItem();
            if(sd->mItemView) {
                QAbstractItemModel *model = sd->mItemView->model();
                if(model) {
                    int rowCount=model->rowCount();
                    QModelIndex ind=model->index(rowCount,0);
                    if(ind.isValid()) {
                        tempitem->setModelIndex(ind);
                    }
                }
            }


            //call polish            
            QEvent polishEvent(QEvent::Polish);
            QCoreApplication::sendEvent(const_cast<HbAbstractViewItem *>(tempitem), &polishEvent);
            height=tempitem->effectiveSizeHint(which,constraint).height();
            delete tempitem;
        }
        return QSizeF(sh.width(),height);
    }
    return sh;
}
示例#16
0
int KexiRelationsTableFieldList::globalY(const QString &item)
{
    QAbstractItemModel *themodel = model();
    QModelIndex idx;
    
    for (int i = 0; i < themodel->rowCount(); ++i) {
        idx = themodel->index(i, 0);
        QVariant data = themodel->data(idx);
        if (data.toString() == item) {
            break;
        }
    }
    
    if (idx.isValid()) {
        QRect r = this->rectForIndex(idx);
        int y = r.y() + r.height()/2;
        
        //Not sure what this line is supposed to do...is it to check if the item is visible?
        if (visualRect(idx).y() > viewport()->height()){   
            y = 0;
        } else if (y == 0) {
            y = height();
        }
        return mapToGlobal(QPoint(0, y)).y();
    }
    return -1;
}
示例#17
0
QString ComputerManager::findRoomOfComputer( const QStringList& hostNames, const QList<QHostAddress>& hostAddresses, const QModelIndex& parent )
{
	QAbstractItemModel* model = networkObjectModel();

	int rows = model->rowCount( parent );

	for( int i = 0; i < rows; ++i )
	{
		QModelIndex entryIndex = model->index( i, 0, parent );

		auto objectType = static_cast<NetworkObject::Type>( model->data( entryIndex, NetworkObjectModel::TypeRole ).toInt() );

		if( objectType == NetworkObject::Group )
		{
			QString room = findRoomOfComputer( hostNames, hostAddresses, entryIndex );
			if( room.isEmpty() == false )
			{
				return room;
			}
		}
		else if( objectType == NetworkObject::Host )
		{
			QString currentHost = model->data( entryIndex, NetworkObjectModel::HostAddressRole ).toString().toLower();
			QHostAddress currentHostAddress;

			if( hostNames.contains( currentHost ) ||
					( currentHostAddress.setAddress( currentHost ) && hostAddresses.contains( currentHostAddress ) ) )
			{
				return model->data( parent, NetworkObjectModel::NameRole ).toString();
			}
		}
	}

	return QString();
}
示例#18
0
	// rebuild the internal data structure, private function
	void TreeChainsawFilter::sortWalkTree(const QModelIndex &parent)
	{
		static int rowCounter = 0;

		if (!parent.isValid())
			// root node
			rowCounter = 0;

		QAbstractItemModel* model = sourceModel();
		int childCount = model->rowCount(parent);
		if (childCount == 0)
		{
			// leaf!
			ModelIndexLink indexLink;
			indexLink.source = parent;
			indexLink.proxy = createIndex(rowCounter++, 0);
			indexList.append(indexLink);
			return;
		}

		// iterate on children
		for (int row = 0; row < childCount; row++)
		{
			//QModelIndex child = parent.child(row, 0);
			QModelIndex child = model->index(row, 0, parent);
			sortWalkTree(child);
		}
	}
示例#19
0
ComputerList ComputerManager::getComputersInRoom( const QString& roomName, const QModelIndex& parent )
{
	QAbstractItemModel* model = computerTreeModel();

	int rows = model->rowCount( parent );

	ComputerList computers;

	for( int i = 0; i < rows; ++i )
	{
		QModelIndex entryIndex = model->index( i, 0, parent );

		auto objectType = static_cast<NetworkObject::Type>( model->data( entryIndex, NetworkObjectModel::TypeRole ).toInt() );

		switch( objectType )
		{
		case NetworkObject::Group:
			if( model->data( entryIndex, NetworkObjectModel::NameRole ).toString() == roomName )
			{
				computers += getComputersInRoom( roomName, entryIndex );
			}
			break;
		case NetworkObject::Host:
			computers += Computer( model->data( entryIndex, NetworkObjectModel::UidRole ).toUuid(),
								   model->data( entryIndex, NetworkObjectModel::NameRole ).toString(),
								   model->data( entryIndex, NetworkObjectModel::HostAddressRole ).toString(),
								   model->data( entryIndex, NetworkObjectModel::MacAddressRole ).toString() );
			break;
		default: break;
		}
	}

	return computers;
}
示例#20
0
void WLibraryTableView::moveSelection(int delta) {
    QAbstractItemModel* pModel = model();

    if (pModel == nullptr) {
        return;
    }

    while(delta != 0) {
        // TODO(rryan) what happens if there is nothing selected?
        QModelIndex current = currentIndex();
        if(delta > 0) {
            // i is positive, so we want to move the highlight down
            int row = current.row();
            if (row + 1 < pModel->rowCount()) {
                selectRow(row + 1);
            }

            delta--;
        } else {
            // i is negative, so we want to move the highlight up
            int row = current.row();
            if (row - 1 >= 0) {
                selectRow(row - 1);
            }

            delta++;
        }
    }
}
示例#21
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;
}
示例#22
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;
}
示例#23
0
void UUpdateWidget::slot_installUpdates()
{
    qDebug() << __FUNCTION__;
    m_toolBarActions.at(eCHECK_UPDATES_ACTION)->setEnabled(true);

    m_stackedWidget->setCurrentIndex(0);
    m_toolBarActions.at(eINSTALL_UPDATES_ACTION)->setEnabled(false);
    m_toolBarActions.at(eCHECK_UPDATES_ACTION)->setEnabled(true);

    QMessageBox::information(this, tr("Nanomite updater"),
                                    tr("The update is completed"));

    //here need to start update.exe for install updates
    QProcess process;
    QAbstractItemModel *model = m_updatesTableView->model();
    QStringList paramList;
    QModelIndex index;

    QDir dir(QDir::current());
    dir.cdUp();
    QDir::setCurrent(dir.path());

    for (int i = 0; i < model->rowCount(); i++) {
        index = model->index(i,  UUpdatesModel::ePACKAGE);
        paramList << model->data(index).toString();
    }

    process.start(QString("%1%2").arg(QDir::currentPath()).arg("/updater.exe"), paramList);
	process.waitForStarted();

	exit(0);
}
示例#24
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()));
}
示例#25
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 );
      }
    }
  }
}
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);
    }
}
示例#27
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;
}
示例#28
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;
}
示例#29
0
void
walkTree(QAbstractItemModel &model,
         QModelIndex const &idx,
         std::function<void(QModelIndex const &)> const &worker) {
    if (!idx.isValid()) {
        for (auto row = 0, numRows = model.rowCount(); row < numRows; ++row)
            walkTree(model, model.index(row, 0), worker);

        return;
    }

    worker(idx);

    for (auto row = 0, numRows = model.rowCount(idx); row < numRows; ++row)
        walkTree(model, model.index(row, 0, idx), worker);
}
示例#30
0
			void PackagesDelegate::invalidateWidgetPositions ()
			{
				QTreeView *view = qobject_cast<QTreeView*> (parent ());
				QAbstractItemModel *model = view->model ();
				for (int i = 0, rows = model->rowCount ();
						i < rows; ++i)
					emit sizeHintChanged (model->index (i, 0));
			}