Пример #1
0
QPair<QList<QNetworkRequest>, QStringList> Cache::createRequests(const QList<QUrl> &in,
																 bool refreshAll)
{
	QList<QUrl> urlsIn = in;
	QList<QNetworkRequest> requests;
	{
		QList<QUrl> urls = refreshAll ? in : getStaleUrls(in);
		requests.reserve(urls.size());
		for (const auto url : urls) {
			urlsIn.removeAll(url);
			QNetworkRequest request(url);
			const auto entryIt = findEntry(url);
			if (entryIt != m_entries.end()) {
				const auto entry = *entryIt;
				// TODO add the md5 as a header
			}
			requests.append(request);
		}
	}
	QStringList localfiles;
	{
		// loop through all urls that didn't get made into network requests
		for (const auto url : urlsIn) {
			localfiles.append(absoluteFilename(*findEntry(url)));
		}
	}
	return qMakePair(requests, localfiles);
}
Пример #2
0
void GpxTreeWidget::splitTrack() {
    assert(_gpx!=0);
    assert(selectedItems().size()==1);

    QList<QTreeWidgetItem*> tracks = selectedItems();
    tracks.removeAll(root);
    if (tracks.size()==0) return;

    QString newFileName = QFileDialog::getSaveFileName(this,
                          tr("Choose a file to save to"),
                          tr("."),
                          tr("GPX Files (*.gpx)"));
    if (newFileName == tr("")) return;
    GpxTrackSegment s = _gpx->segmentByName(selectedItems()[0]->text(1));
    GpxFile *newGpx = new GpxFile(s);
    QString strValue;
    newGpx->toXml(strValue);

    QFile file( newFileName );
    if (file.open(QIODevice::WriteOnly)) {
        QTextStream out(&file);
        out << strValue;
    }
    delete newGpx;
}
Пример #3
0
QList<QVector3D> ControlPlan2D::controlLed(const QString & valeur,Cube cubeMotif,int NumeroPlan,QList<QVector3D>  liste_vecteur3D,Ui::MainWindow *ui,QPushButton* buttons[90]){
        QString strlig=valeur[0];
        QString strcol=valeur[1];
        int lig=strlig.toInt(0,10);
        int col=strcol.toInt(0,10);
        Led l;
        l=cubeMotif.getList1()->value(NumeroPlan).getLed(lig,col);
        l.modifierEtat();
        Plan p1=cubeMotif.getList1()->value(NumeroPlan);
        p1.updatePlan(l,lig,col);
        cubeMotif.updateCube(p1,NumeroPlan);
        QVector3D v;
        v=QVector3D(abs(8-col),NumeroPlan,abs(8-lig));
        liste_vecteur3D.append(v);
        QString s ;
        s=QString::number(liste_vecteur3D.size());
        qDebug()<<"la taille de la liste est "+s;
        ui->widget->setListPoints(liste_vecteur3D);
        if(cubeMotif.getList1()->value(NumeroPlan).getLed(lig,col).getEtat()==1){
            liste_vecteur3D.append(v);
           ui->widget->setListPoints(liste_vecteur3D);
        }
        else {
            liste_vecteur3D.removeAll(v);
            ui->widget->setListPoints(liste_vecteur3D);
        }
        afficheLed(buttons,lig,col,l.getEtat());
        return liste_vecteur3D;
}
bool MenuNavigation::canObjectBeRemoved(QPoint location)
{
	QList<QPoint> locations = menuObjects.keys();
	QList<QPoint> checkedLocations;
	locations.removeAll(location);
	if (locations.size() == 0)
		return true;
	checkedLocations.append(locations.first());
	for (int i = 0; i < checkedLocations.size(); ++i)
	{
		QPoint loc = QPoint(checkedLocations[i]);
		QPoint loc2;
		loc2 = QPoint(loc.x(), loc.y() - 1);
		if (locations.contains(loc2) && !checkedLocations.contains(loc2))
			checkedLocations.append(loc2);
		loc2 = QPoint(loc.x() - 1, loc.y());
		if (locations.contains(loc2) && !checkedLocations.contains(loc2))
			checkedLocations.append(loc2);
		loc2 = QPoint(loc.x() + 1, loc.y());
		if (locations.contains(loc2) && !checkedLocations.contains(loc2))
			checkedLocations.append(loc2);
		loc2 = QPoint(loc.x(), loc.y() + 1);
		if (locations.contains(loc2) && !checkedLocations.contains(loc2))
			checkedLocations.append(loc2);
	}
	if (checkedLocations.size() != locations.size())
		return false;
	return true;
}
Пример #5
0
/**
 * @brief Returns all items that intersect the rectangle drawn by the user
 * except selected items.
 * @return The items thet intersect the drawn rectangle.
 */
QList<QGraphicsItem*> TilesetView::get_items_intersecting_current_area() const {

  QRect area = current_area_item->rect().toRect();
  area = QRect(
      area.topLeft() + QPoint(1, 1),
      area.size() - QSize(2, 2));
  QList<QGraphicsItem*> items = scene->items(area, Qt::IntersectsItemBoundingRect);
  items.removeAll(current_area_item);  // Ignore the drawn rectangle itself.

  // Ignore selected items.
  for (QGraphicsItem* item : scene->selectedItems()) {
    items.removeAll(item);
  }

  return items;
}
Пример #6
0
void MainSettingsDialog::openEditAutoProfileDialog()
{
    int selectedRow = ui->autoProfileTableWidget->currentRow();
    if (selectedRow >= 0)
    {
        QTableWidgetItem *item = ui->autoProfileTableWidget->item(selectedRow, 5);
        //QTableWidgetItem *itemDefault = ui->autoProfileTableWidget->item(selectedRow, 4);
        AutoProfileInfo *info = item->data(Qt::UserRole).value<AutoProfileInfo*>();
        if (info != allDefaultProfile)
        {
            QList<QString> reservedGUIDs = defaultAutoProfiles.keys();
            if (info->getGUID() != "all")
            {
                AutoProfileInfo *temp = defaultAutoProfiles.value(info->getGUID());
                if (info == temp)
                {
                    reservedGUIDs.removeAll(info->getGUID());
                }
            }
            AddEditAutoProfileDialog *dialog = new AddEditAutoProfileDialog(info, settings, connectedDevices, reservedGUIDs, true, this);
            connect(dialog, SIGNAL(accepted()), this, SLOT(transferEditsToCurrentTableRow()));
            dialog->show();
        }
        else
        {
            EditAllDefaultAutoProfileDialog *dialog = new EditAllDefaultAutoProfileDialog(info, settings, this);
            dialog->show();
            connect(dialog, SIGNAL(accepted()), this, SLOT(transferEditsToCurrentTableRow()));
        }
    }
}
Пример #7
0
QAudioFormat QAudioDeviceInfo::nearestFormat(const QAudioFormat &settings) const
{
    if (isFormatSupported(settings))
        return settings;

    QAudioFormat nearest = settings;

    nearest.setCodec(QLatin1String("audio/pcm"));

    if (nearest.sampleType() == QAudioFormat::Unknown) {
        QAudioFormat preferred = preferredFormat();
        nearest.setSampleType(preferred.sampleType());
    }

    QMap<int,int> testFrequencies;
    QList<int> frequenciesAvailable = supportedFrequencies();
    QMap<int,int> testSampleSizes;
    QList<int> sampleSizesAvailable = supportedSampleSizes();

    // Get sorted sampleSizes (equal to and ascending values only)
    if (sampleSizesAvailable.contains(settings.sampleSize()))
        testSampleSizes.insert(0,settings.sampleSize());
    sampleSizesAvailable.removeAll(settings.sampleSize());
    foreach (int size, sampleSizesAvailable) {
        int larger  = (size > settings.sampleSize()) ? size : settings.sampleSize();
        int smaller = (size > settings.sampleSize()) ? settings.sampleSize() : size;
        if (size >= settings.sampleSize()) {
            int diff = larger - smaller;
            testSampleSizes.insert(diff, size);
        }
    }
Пример #8
0
void CStudentManage::slotDelStudentClicked()
{
    //开始事务
    m_Model->database().transaction();
    //获取被选中的model
    QItemSelectionModel *selectModel = m_View->selectionModel();

    //通过被选中的model, 获取被选中的格子
    QModelIndexList selectList = selectModel->selectedIndexes();

    QList<int> delRow;

    //遍历格子,获得行
    for (int i = 0; i < selectList.size(); ++i)
    {
        delRow << selectList.at(i).row();
    }

    //去除重复的行
    while (delRow.size() > 0)
    {
        int row = delRow.at(0);
        //去重
        delRow.removeAll(row);

        //删除行
        m_Model->removeRow(row);
    }
    //提交
    QString msg = "删除成功!";
    SubmitData(msg);
}
Пример #9
0
void tst_QList::prepend() const
{
    QList<QString *> list;
    QString *str1 = new QString;
    list.prepend(str1);
    QVERIFY(list.size() == 1);
    QVERIFY(list.at(0) == str1);
    QString *str2 = new QString;
    list.prepend(str2);
    QVERIFY(list.size() == 2);
    QVERIFY(list.at(0) == str2);
    QVERIFY(list.at(1) == str1);
    QString *str3 = new QString;
    list.prepend(str3);
    QVERIFY(list.size() == 3);
    QVERIFY(list.at(0) == str3);
    QVERIFY(list.at(1) == str2);
    QVERIFY(list.at(2) == str1);
    list.removeAll(str2);
    delete str2;
    QVERIFY(list.size() == 2);
    QVERIFY(list.at(0) == str3);
    QVERIFY(list.at(1) == str1);
    QString *str4 = new QString;
    list.prepend(str4);
    QVERIFY(list.size() == 3);
    QVERIFY(list.at(0) == str4);
    QVERIFY(list.at(1) == str3);
    QVERIFY(list.at(2) == str1);
    qDeleteAll(list);
    list.clear();
}
Пример #10
0
QList<int> YaEventNotifier::unskippedIds() const
{
	QList<int> ids = GlobalEventQueue::instance()->ids();
	foreach(int id, skipped_ids_)
		ids.removeAll(id);
	return ids;
}
Пример #11
0
ChatClient::~ChatClient()
{
    qDebug("ChatClient 0x%llx destroyed", reinterpret_cast<qint64>(this));
    chatClients.removeAll(this);
    theClientObserver()->clientDestroyed(this);
    delete d;
}
QList<ViewLayer::ViewIdentifier> MismatchingConnectorWidget::views() {
	QList<ViewLayer::ViewIdentifier> list = AllViews;
	for(int i=0; i < m_missingViews.size(); i++) {
		list.removeAll(m_missingViews[i]);
	}
	return list;
}
Пример #13
0
ChatEditBox::~ChatEditBox()
{
// 	disconnect(m_chatWidgetActions->colorSelector(), 0, this, 0);
	disconnect(InputBox, 0, this, 0);

	chatEditBoxes.removeAll(this);
}
Пример #14
0
/*!
 * This function loads sort columns from the given display descriptor. Columns
 * that are not in the descriptor's s_columns field are still added, but they
 * are initially "disabled" and in an arbitrary order.
 *
 * \param d The display descriptor to process.
 */
void CSDDSelectorModel::loadSortColumns(
	const CSAbstractCollection::DisplayDescriptor *d)
{
	items.clear();

	QList<CSAbstractCollection::Column> colsList;
	colsList.append(CSAbstractCollection::Artist);
	colsList.append(CSAbstractCollection::Album);
	colsList.append(CSAbstractCollection::Title);
	colsList.append(CSAbstractCollection::DiscNumber);
	colsList.append(CSAbstractCollection::TrackNumber);
	colsList.append(CSAbstractCollection::TrackCount);
	colsList.append(CSAbstractCollection::Length);
	colsList.append(CSAbstractCollection::Year);

	for(int i = 0; i < d->s_columns.count(); ++i)
	{
		CSAbstractCollection::Column col = d->s_columns.at(i);
		colsList.removeAll(col);

		items.append( {col, true} );
	}

	while(!colsList.isEmpty())
		items.append( {colsList.takeFirst(), false} );

	Q_EMIT dataChanged(index(0, 0), index(rowCount() - 1, 0));
}
Пример #15
0
QList<T> Utilities::listSubtract(const QList<T>& l1, const QList<T>& l2)
{
    QList<T> r = l1;
    Q_FOREACH(const T& x, l2)
        r.removeAll(x);
    return r;
}
Пример #16
0
/*!
    Returns the closest QAudioFormat to the supplied \a settings that the system supports.

    These settings are provided by the platform/audio plugin being used.

    They are also dependent on the \l {QAudio}::Mode being used.
*/
QAudioFormat QAudioDeviceInfo::nearestFormat(const QAudioFormat &settings) const
{
    if (isFormatSupported(settings))
        return settings;

    QAudioFormat nearest = settings;

    QList<QString> testCodecs = supportedCodecs();
    QList<int> testChannels = supportedChannelCounts();
    QList<QAudioFormat::Endian> testByteOrders = supportedByteOrders();
    QList<QAudioFormat::SampleType> testSampleTypes;
    QList<QAudioFormat::SampleType> sampleTypesAvailable = supportedSampleTypes();
    QMap<int,int> testSampleRates;
    QList<int> sampleRatesAvailable = supportedSampleRates();
    QMap<int,int> testSampleSizes;
    QList<int> sampleSizesAvailable = supportedSampleSizes();

    // Get sorted lists for checking
    if (testCodecs.contains(settings.codec())) {
        testCodecs.removeAll(settings.codec());
        testCodecs.insert(0, settings.codec());
    }
    testChannels.removeAll(settings.channelCount());
    testChannels.insert(0, settings.channelCount());
    testByteOrders.removeAll(settings.byteOrder());
    testByteOrders.insert(0, settings.byteOrder());

    if (sampleTypesAvailable.contains(settings.sampleType()))
        testSampleTypes.append(settings.sampleType());
    if (sampleTypesAvailable.contains(QAudioFormat::SignedInt))
        testSampleTypes.append(QAudioFormat::SignedInt);
    if (sampleTypesAvailable.contains(QAudioFormat::UnSignedInt))
        testSampleTypes.append(QAudioFormat::UnSignedInt);
    if (sampleTypesAvailable.contains(QAudioFormat::Float))
        testSampleTypes.append(QAudioFormat::Float);

    if (sampleSizesAvailable.contains(settings.sampleSize()))
        testSampleSizes.insert(0,settings.sampleSize());
    sampleSizesAvailable.removeAll(settings.sampleSize());
    foreach (int size, sampleSizesAvailable) {
        int larger  = (size > settings.sampleSize()) ? size : settings.sampleSize();
        int smaller = (size > settings.sampleSize()) ? settings.sampleSize() : size;
        bool isMultiple = ( 0 == (larger % smaller));
        int diff = larger - smaller;
        testSampleSizes.insert((isMultiple ? diff : diff+100000), size);
    }
Пример #17
0
void KoTextDocument::removeList(KoList *list)
{
    QList<KoList *> l = lists();
    if (l.contains(list)) {
        l.removeAll(list);
        setLists(l);
    }
}
Пример #18
0
void FrameScroller::unregisterFrameScroller()
{
	if (frameScrollers.contains(this)) {
		frameScrollers.removeAll(this);
		for (int i = 0; i < frameScrollers.size(); i++)
			disconnectScroller(frameScrollers[i]);
	}
}
void ViewItemManager::removeViewItem(ViewItem *viewItem) {
  if (!_viewItemLists.contains(viewItem->view()))
    return;

  QList<ViewItem*> list = _viewItemLists.value(viewItem->view());
  list.removeAll(viewItem);
  _viewItemLists.insert(viewItem->view(), list);
}
/**
 * Delete a BluetoothManager.
 */
BluetoothManager::~BluetoothManager() {
	QMutexLocker locker(&managersMutex);
	--bluetoothInitCount;
	if (bluetoothInitCount == 0) {
		bt_device_deinit();
	}
	managers.removeAll(this);
}
void PlotItemManager::removeTiedZoomViewItem(ViewItem *viewItem) {
  if (_tiedZoomViewItemLists.contains(viewItem->view())) {
    QList<ViewItem*> list = _tiedZoomViewItemLists.value(viewItem->view());
    list.removeAll(viewItem);
    _tiedZoomViewItemLists.insert(viewItem->view(), list);
    emit tiedZoomRemoved();
  }
}
Пример #22
0
void Nepomuk2::Resource::removeProperty( const QUrl& uri, const Variant& value )
{
    QList<Variant> vl = property( uri ).toVariantList();
    foreach( const Variant& v, value.toVariantList() ) {
        vl.removeAll( v );
    }
    setProperty( uri, Variant( vl ) );
}
Пример #23
0
    // Loads a form and create its collection, creates duplicates too
    bool loadFormCollection(const QString &uid, FormType type)
    {
        if (uid.isEmpty()) {
            LOG_ERROR_FOR(q, "No uid to load...");
            return false;
        }

        // Check from cache
        if (isCollectionLoaded(uid, type))
            return true;

        // Not in cache -> ask IFormIO plugins
        QList<Form::IFormIO *> list = pluginManager()->getObjects<Form::IFormIO>();
        if (list.isEmpty()) {
            LOG_ERROR_FOR(q, "No IFormIO loaded...");
            return false;
        }

        // Load forms
        foreach(Form::IFormIO *io, list) {
            if (io->canReadForms(uid)) {
                // Load the forms once (for the main collection)
                QList<Form::FormMain *> list = io->loadAllRootForms(uid);

                // Check list for identity form
                if (!_identityForm) {
                    FormCollection *collection = new FormCollection;
                    collection->setEmptyRootForms(list);
                    _identityForm = collection->identityForm();
                    if (_identityForm) {
                        LOG_FOR(q, "Identity form detected: " + _identityForm->uuid());
                        // Reparent identity form and delete all other Form::FormMain
                        _identityForm->setParent(q);
                        list.removeAll(_identityForm);
                        qDeleteAll(list);
                        // Re-load the forms once (for the main collection)
                        list.clear();
                        list = io->loadAllRootForms(uid);
                    }
                    collection->setEmptyRootForms(QList<Form::FormMain *>());
                    delete collection;
                }

                // Create the main collection
                createModeFormCollections(list, type, false);
                list.clear();

                // Create its duplicate
                list = io->loadAllRootForms(uid);
                createModeFormCollections(list, type, true);
                LOG_FOR(q, QString("Form %1 loaded from reader %2")
                        .arg(uid)
                        .arg(io->name()));
                return true;
            }
        }
        return false;
    }
Пример #24
0
QT_BEGIN_NAMESPACE

static QFontDatabase::WritingSystem writingSystemForFont(const QFont &font, bool *hasLatin)
{
    *hasLatin = true;

    QList<QFontDatabase::WritingSystem> writingSystems = QFontDatabase().writingSystems(font.family());
//     qDebug() << font.family() << writingSystems;

    // this just confuses the algorithm below. Vietnamese is Latin with lots of special chars
    writingSystems.removeAll(QFontDatabase::Vietnamese);

    QFontDatabase::WritingSystem system = QFontDatabase::Any;

    if (!writingSystems.contains(QFontDatabase::Latin)) {
        *hasLatin = false;
        // we need to show something
        if (writingSystems.count())
            system = writingSystems.last();
    } else {
        writingSystems.removeAll(QFontDatabase::Latin);
    }

    if (writingSystems.isEmpty())
        return system;

    if (writingSystems.count() == 1 && writingSystems.at(0) > QFontDatabase::Cyrillic) {
        system = writingSystems.at(0);
        return system;
    }

    if (writingSystems.count() <= 2
        && writingSystems.last() > QFontDatabase::Armenian
        && writingSystems.last() < QFontDatabase::Vietnamese) {
        system = writingSystems.last();
        return system;
    }

    if (writingSystems.count() <= 5
        && writingSystems.last() >= QFontDatabase::SimplifiedChinese
        && writingSystems.last() <= QFontDatabase::Korean)
        system = writingSystems.last();

    return system;
}
Пример #25
0
void
ActionCollection::removeAction( QAction* action, ActionCollection::ActionDestination category )
{
    QList< QAction* > actions = m_categoryActions.value( category );
    actions.removeAll( action );
    m_categoryActions[ category ] = actions;

    m_actionNotifiers.remove( action );
}
Пример #26
0
void
AlbumInfoWidget::gotAlbums( const QList<Tomahawk::album_ptr>& albums )
{
    QList<Tomahawk::album_ptr> al = albums;
    if ( al.contains( m_album ) )
        al.removeAll( m_album );

    m_albumsModel->appendAlbums( al );
}
Пример #27
0
void FocusChain::moveAfterClientInChain(Client *client, Client *reference, QList<Client *> &chain)
{
    if (!chain.contains(reference)) {
        return;
    }
    if (Client::belongToSameApplication(reference, client)) {
        chain.removeAll(client);
        chain.insert(chain.indexOf(reference), client);
    } else {
        chain.removeAll(client);
        for (int i = chain.size() - 1; i >= 0; --i) {
            if (Client::belongToSameApplication(reference, chain.at(i))) {
                chain.insert(i, client);
                break;
            }
        }
    }
}
Пример #28
0
int main ()
{
    QList<QString> list;
    list << "sun" << "cloud" << "sun" << "rain";
    list.removeAll("sun");
    assert(list.size() == 2);
    // list: ["cloud", "rain"]
  return 0;
}
Пример #29
0
void SimpleStatementIteratorTest::testIteration()
{
    QList<Statement> sl = createStatements( 5 );
    SimpleStatementIterator it( sl );
    while ( it.next() ) {
        sl.removeAll( *it );
    }
    QCOMPARE( 0, sl.count() );
}
void SelectProfileWidget::updateProfiles()
{
	IDiscoIdentity identity;
	identity.category = "gateway";
	identity.type = FDescriptor.type;

	QList<Jid> nativeGates;
	if (FDescriptor.id == GSID_RAMBLER)
		nativeGates.append(streamJid());

	QList<Jid> gates = FGateways->gateDescriptorServices(streamJid(),FDescriptor,FDescriptor.needLogin);
	for (QList<Jid>::iterator it=gates.begin(); it!=gates.end(); )
	{
		if (!(FGateways->serviceRestrictions(streamJid(),*it) & GSR_ADD_CONTACT))
		{
			IGateServiceDescriptor descriptor = FGateways->serviceDescriptor(streamJid(),*it);
			if (FDescriptor.id == descriptor.id)
				nativeGates.append(*it);
			it++;
		}
		else
		{
			it = gates.erase(it);
		}
	}

	Jid oldSelected = selectedProfile();
	QList<Jid> newProfiles = (gates.toSet() - FProfiles.keys().toSet()).toList();
	QList<Jid> oldProfiles = (FProfiles.keys().toSet() - gates.toSet()).toList();

	qSort(newProfiles);
	if (!FDescriptor.needGate && !FProfiles.contains(streamJid()))
		newProfiles.prepend(streamJid());
	else if (FDescriptor.needGate && FProfiles.contains(streamJid()))
		oldProfiles.prepend(streamJid());
	else
		oldProfiles.removeAll(streamJid());

	foreach(Jid serviceJid, newProfiles)
	{
		QRadioButton *button = new QRadioButton(ui.wdtProfiles);
		button->setAutoExclusive(true);
		connect(button,SIGNAL(toggled(bool)),SLOT(onProfileButtonToggled(bool)));
		FProfiles.insert(serviceJid,button);

		QLabel *label = new QLabel(ui.wdtProfiles);
		connect(label,SIGNAL(linkActivated(const QString &)),SLOT(onProfileLabelLinkActivated(const QString &)));
		FProfileLabels.insert(serviceJid,label);

		QHBoxLayout *layout = new QHBoxLayout();
		layout->setMargin(0);
		layout->setSpacing(0);
		layout->addWidget(button);
		layout->addWidget(label);
		layout->addStretch();
		qobject_cast<QVBoxLayout *>(ui.wdtProfiles->layout())->addLayout(layout);
	}