Exemplo n.º 1
0
QList<Point> ChartLine::getPoints()
{
    if (numberOfPoints == 0)
        return QList<Point>();

    QList<Point> points;
    //points.reserve(numberOfPoints);

    if (fabs(angle) < EPS_ZERO)
    {
        double dx = (end.x - start.x) / (numberOfPoints - 1);
        double dy = (end.y - start.y) / (numberOfPoints - 1);

        for (int i = 0; i < numberOfPoints; i++)
            if (reverse)
                points.insert(0, Point(start.x + i*dx, start.y + i*dy));
            else
                points.append(Point(start.x + i*dx, start.y + i*dy));
    }
    else
    {
        Point center = centerPoint(start, end, angle);
        double radius = (start - center).magnitude();
        double startAngle = atan2(center.y - start.y, center.x - start.x) / M_PI*180 - 180;
        double theta = angle / double(numberOfPoints - 1);

        for (int i = 0; i < numberOfPoints; i++)
        {
            double arc = (startAngle + i*theta)/180.0*M_PI;

            double x = radius * cos(arc);
            double y = radius * sin(arc);

            if (reverse)
                points.insert(0, Point(center.x + x, center.y + y));
            else
                points.append(Point(center.x + x, center.y + y));
        }
    }

    return points;
}
Exemplo n.º 2
0
/**
 * @brief Draw the function list and decide whether to load the default selection configuration or not.
 * @param new_  A flag indicating whether to load the default selection configuration or not. Default value is `0`.
 * 0    Use user config.
 * 1    Use default config.
 */
void QDialogUI::set_func_list(int new_)
{
    ui->Functionlist->clear();
    ui->FunctionsBox->setTitle(QApplication::translate("Util", "Functions"));

    //if new,the data will be load from database,or we just use data from class member
    if(new_){
        for(int ip=0; ip<2; ip++){
            QList<QList<QVariant> > choice;
            std::map<int, QList<int> > defaults;
            QList<int> slices;
            redata_->get_choice(ip?true:false, choice, defaults, slices);
            if(QFile::exists(custom_)){
                QList<QVariant> a;
                a.append(4);
                a.append(1);
                a.append(0);
                a.append("customize");
                choice.insert(0, a);
                QList<int> b;
                b.push_back(1);
                defaults[0x04] = b;
                for(int i=0; i<slices.size(); i++){
                    slices[i] += 1;
                }
                slices.insert(0, 0);
            }
            this->choice_[ip] = choice;
            this->slices_[ip] = slices;
            QList<int> funcs;
            for(int i=0; i<choice.size(); i++){
                int id = (choice[i][0].toInt());
                if(defaults[id].indexOf(choice[i][1].toInt()) >= 0){
                    funcs.append(1);
                }else{
                    funcs.append(0);
                }
            }
            funcs_[ip] = funcs;
        }
    }
}
QTreeWidgetItem* ProgressTree2::findItem(Job* job, bool create)
{
    QList<Job*> path;
    Job* v = job;
    while (v) {
        path.insert(0, v);
        v = v->parentJob;
    }

    QTreeWidgetItem* c = 0;
    for (int i = 0; i < path.count(); i++) {
        Job* toFind = path.at(i);
        QTreeWidgetItem* found = 0;
        if (i == 0) {
            for (int j = 0; j < this->topLevelItemCount(); j++) {
                QTreeWidgetItem* item = this->topLevelItem(j);
                Job* v = getJob(*item);
                if (v == toFind) {
                    found = item;
                    break;
                }
            }
        } else {
            for (int j = 0; j < c->childCount(); j++) {
                QTreeWidgetItem* item = c->child(j);
                Job* v = getJob(*item);
                if (v == toFind) {
                    found = item;
                    break;
                }
            }
        }
        if (found)
            c = found;
        else {
            if (create) {
                if (!toFind->parentJob)
                    c = addJob(toFind);
                else {
                    QTreeWidgetItem* subItem = new QTreeWidgetItem(c);
                    fillItem(subItem, toFind);
                    if (autoExpandNodes)
                        c->setExpanded(true);
                    c = subItem;
                }
            } else {
                c = 0;
                break;
            }
        }
    }

    return c;
}
Exemplo n.º 4
0
void RelationItem::insertHandle(int beforeIndex, const QPointF &pos)
{
    if (beforeIndex >= 1 && beforeIndex <= m_relation->intermediatePoints().size() + 1) {
        QList<DRelation::IntermediatePoint> intermediatePoints = m_relation->intermediatePoints();
        intermediatePoints.insert(beforeIndex - 1, DRelation::IntermediatePoint(pos));

        m_diagramSceneModel->diagramController()->startUpdateElement(m_relation, m_diagramSceneModel->diagram(), DiagramController::UpdateMajor);
        m_relation->setIntermediatePoints(intermediatePoints);
        m_diagramSceneModel->diagramController()->finishUpdateElement(m_relation, m_diagramSceneModel->diagram(), false);
    }
}
Exemplo n.º 5
0
void Widget::aggregationMenuAboutToShow()
{
  KMenu * menu = dynamic_cast< KMenu * >( sender() );
  if ( !menu )
    return;

  menu->clear();

  menu->addTitle( i18n( "Aggregation" ) );

  QActionGroup * grp = new QActionGroup( menu );

  const QHash< QString, Aggregation * > & aggregations = Manager::instance()->aggregations();

  QAction * act;

  QList< const Aggregation * > sortedAggregations;

  for ( QHash< QString, Aggregation * >::ConstIterator ci = aggregations.constBegin(); ci != aggregations.constEnd(); ++ci )
  {
    int idx = 0;
    int cnt = sortedAggregations.count();
    while ( idx < cnt )
    {
      if ( sortedAggregations.at( idx )->name() > ( *ci )->name() )
      {
        sortedAggregations.insert( idx, *ci );
        break;
      }
      idx++;
    }

    if ( idx == cnt )
      sortedAggregations.append( *ci );
  }

  for ( QList< const Aggregation * >::ConstIterator it = sortedAggregations.constBegin(); it != sortedAggregations.constEnd(); ++it )
  {
    act = menu->addAction( ( *it )->name() );
    act->setCheckable( true );
    grp->addAction( act );
    act->setChecked( d->mLastAggregationId == ( *it )->id() );
    act->setData( QVariant( ( *it )->id() ) );
    connect( act, SIGNAL( triggered( bool ) ),
             SLOT( aggregationSelected( bool ) ) );
  }

  menu->addSeparator();

  act = menu->addAction( i18n( "Configure..." ) );
  act->setData( QVariant( QString() ) );
  connect( act, SIGNAL( triggered( bool ) ),
           SLOT( aggregationSelected( bool ) ) );
}
Exemplo n.º 6
0
    ZVariant insert(const QList<ZVariant> &args)
    {
        if (args.count() > 2) {
            QList<ZVariant> list = args.first().toList();

            list.insert(args.at(1).toInt(), args.at(2));
            args.first().depthCopyAssign(list);
        }

        return ZVariant();
    }
Exemplo n.º 7
0
QList<QString> KoHistogramProducerFactoryRegistry::keysCompatibleWith(const KoColorSpace* colorSpace) const
{
    QList<QString> list;
    QList<float> preferredList;
    foreach(const QString &id, keys()) {
        KoHistogramProducerFactory *f = value(id);
        if (f->isCompatibleWith(colorSpace)) {
            float preferred = f->preferrednessLevelWith(colorSpace);
            QList<float>::iterator pit = preferredList.begin();
            QList<float>::iterator pend = preferredList.end();
            QList<QString>::iterator lit = list.begin();

            while (pit != pend && preferred <= *pit) {
                ++pit;
                ++lit;
            }

            list.insert(lit, id);
            preferredList.insert(pit, preferred);
        }
    }
Exemplo n.º 8
0
void QListGuiErrorCheckfromScriptValue(const QScriptValue &obj, QList<GuiErrorCheck> &list)
{
  list = QList<GuiErrorCheck>();
  QScriptValueIterator it(obj);

  while (it.hasNext()) {
    it.next();
    if (it.flags() & QScriptValue::SkipInEnumeration)
      continue;
    GuiErrorCheck item = qscriptvalue_cast<GuiErrorCheck>(it.value());
    list.insert(it.name().toInt(), item);
  }
}
Exemplo n.º 9
0
    void updateEntry(const QString &address, const QString &label, bool isMine, int status)
    {
        // Find address / label in model
        QList<AddressTableEntry>::iterator lower = qLowerBound(
            cachedAddressTable.begin(), cachedAddressTable.end(), address, AddressTableEntryLessThan());
        QList<AddressTableEntry>::iterator upper = qUpperBound(
            cachedAddressTable.begin(), cachedAddressTable.end(), address, AddressTableEntryLessThan());
        int lowerIndex = (lower - cachedAddressTable.begin());
        int upperIndex = (upper - cachedAddressTable.begin());
        bool inModel = (lower != upper);
        AddressTableEntry::Type newEntryType = isMine ? AddressTableEntry::Receiving : AddressTableEntry::Sending;

        switch(status)
        {
        case CT_NEW:
            if(inModel)
            {
                OutputDebugStringF("Warning: AddressTablePriv::updateEntry: Got CT_NOW, but entry is already in model\n");
                break;
            }
            {
                CBitcoinAddress addr(address.toStdString());
                AddressTableEntry::Category cate = IsMyShare(*wallet, addr.Get()) ? AddressTableEntry::MultiSig : AddressTableEntry::Normal;

                parent->beginInsertRows(QModelIndex(), lowerIndex, lowerIndex);
                cachedAddressTable.insert(lowerIndex, AddressTableEntry(newEntryType, label, address, cate));
                parent->endInsertRows();
            }
            break;
        case CT_UPDATED:
            if(!inModel)
            {
                OutputDebugStringF("Warning: AddressTablePriv::updateEntry: Got CT_UPDATED, but entry is not in model\n");
                break;
            }
            lower->type = newEntryType;
            lower->label = label;
            parent->emitDataChanged(lowerIndex);
            break;
        case CT_DELETED:
            if(!inModel)
            {
                OutputDebugStringF("Warning: AddressTablePriv::updateEntry: Got CT_DELETED, but entry is not in model\n");
                break;
            }
            parent->beginRemoveRows(QModelIndex(), lowerIndex, upperIndex-1);
            cachedAddressTable.erase(lower, upper);
            parent->endRemoveRows();
            break;
        }
    }
//---------------------------------------------------------------------
// PosSettingsPluginsLoader::loadPlugins
// 
//---------------------------------------------------------------------
QList<PosSettingsAdvInterface*> PosSettingsPluginsLoader::loadPlugins()
    {
    qDebug() << "+ PosSettingsPluginsLoader::loadPlugins()";
    // parse the default cen rep key value which is used to determine
    // the order of loading the default positioning settings plugins
    ParseCenRepKey();
    // List containing the plugins implementing the PositioningSettingsAdvancedInterface
    QList<PosSettingsAdvInterface*> pluginsList;
    // Check for the files under the positioningsettings directory
    QDir pluginsDir(PLUGIN_PATH + QDir::separator());
    QFileInfoList fileInfoList = pluginsDir.entryInfoList();
    // check each file in this directory,only if its a dll give it to the
    // plugin loader
    foreach ( const QFileInfo &fileInfo, fileInfoList )
            {
            QString fileName = fileInfo.absoluteFilePath();
						qDebug() << "Filename: " <<  fileName;
						
            if (!QLibrary::isLibrary(fileName))
                {
                continue;
                }
            // load the dlls using QPluginLoader
            QPluginLoader pluginLoader(pluginsDir.absoluteFilePath(fileName));
            qDebug() << "Plugin Filename: " <<  pluginsDir.absoluteFilePath(fileName);
            QObject *plugin = pluginLoader.instance();
            // Check if the plugin found is an implementation of the
            // PosSettingsAdvInterface,if yes add it to the plugins list

            if (plugin)
                {
                PosSettingsAdvInterface* advancedInterface = qobject_cast<
                        PosSettingsAdvInterface *> (plugin);

                if (advancedInterface)
                    {
                    
                    QString dllName = fileInfo.baseName();
                    // check the position into which the plugin needs to be
                    // inserted if it is one of the default plugins
                    for (int i = 0; i < mDllNameList.count(); i++)
                        {
                        if (dllName.compare(mDllNameList[i],Qt::CaseInsensitive) == KErrNone)
                            {
                            pluginsList.insert(i, advancedInterface);
                            break;
                            }
                        }
                    }
                }
            }
Exemplo n.º 11
0
void tst_QList::testSTLIterators() const
{
    QList<QString> list;

    // create a list
    list << "foo" << "bar" << "baz";
    QList<QString>::iterator it = list.begin();
    QCOMPARE(*it, QLatin1String("foo")); it++;
    QCOMPARE(*it, QLatin1String("bar")); it++;
    QCOMPARE(*it, QLatin1String("baz")); it++;
    QCOMPARE(it, list.end()); it--;

    // walk backwards
    QCOMPARE(*it, QLatin1String("baz")); it--;
    QCOMPARE(*it, QLatin1String("bar")); it--;
    QCOMPARE(*it, QLatin1String("foo"));

    // test erase
    it = list.erase(it);
    QVERIFY(list.size() == 2);
    QCOMPARE(*it, QLatin1String("bar"));

    // test multiple erase
    it = list.erase(it, it + 2);
    QVERIFY(list.size() == 0);
    QCOMPARE(it, list.end());

    // insert again
    it = list.insert(it, QLatin1String("foo"));
    QVERIFY(list.size() == 1);
    QCOMPARE(*it, QLatin1String("foo"));

    // insert again
    it = list.insert(it, QLatin1String("bar"));
    QVERIFY(list.size() == 2);
    QCOMPARE(*it++, QLatin1String("bar"));
    QCOMPARE(*it, QLatin1String("foo"));
}
Exemplo n.º 12
0
void FocusChain::insertClientIntoChain(Client *client, QList< Client * >& chain)
{
    if (chain.contains(client)) {
        return;
    }
    if (m_activeClient && m_activeClient != client &&
            !chain.empty() && chain.last() == m_activeClient) {
        // Add it after the active client
        chain.insert(chain.size() - 1, client);
    } else {
        // Otherwise add as the first one
        chain.append(client);
    }
}
void SelectableTextEditorWidget::setSelections(const QMap<int, QList<DiffSelection> > &selections)
{
    m_diffSelections.clear();
    QMapIterator<int, QList<DiffSelection> > itBlock(selections);
    while (itBlock.hasNext()) {
        itBlock.next();

        const QList<DiffSelection> diffSelections = itBlock.value();
        QList<DiffSelection> workingList;
        for (int i = 0; i < diffSelections.count(); i++) {
            const DiffSelection &diffSelection = diffSelections.at(i);

            if (diffSelection.start == -1 && diffSelection.end == 0)
                continue;

            if (diffSelection.start == diffSelection.end && diffSelection.start >= 0)
                continue;

            int j = 0;
            while (j < workingList.count()) {
                const DiffSelection existingSelection = workingList.takeAt(j);
                const QList<DiffSelection> newSelection = subtractSelection(existingSelection, diffSelection);
                for (int k = 0; k < newSelection.count(); k++)
                    workingList.insert(j + k, newSelection.at(k));
                j += newSelection.count();
            }
            workingList.append(diffSelection);
        }
        const int blockNumber = itBlock.key();
        QVector<QTextLayout::FormatRange> selList;
        for (int i = 0; i < workingList.count(); i++) {
            const DiffSelection &diffSelection = workingList.at(i);
            if (diffSelection.format) {
                QTextLayout::FormatRange formatRange;
                formatRange.start = diffSelection.start;
                if (formatRange.start < 0)
                    formatRange.start = 0;
                formatRange.length = diffSelection.end < 0
                        ? INT_MAX
                        : diffSelection.end - diffSelection.start;
                formatRange.format = *diffSelection.format;
                if (diffSelection.end < 0)
                    formatRange.format.setProperty(QTextFormat::FullWidthSelection, true);
                selList.append(formatRange);
            }
        }
        m_diffSelections.insert(blockNumber, workingList);
    }
}
Exemplo n.º 14
0
    void setTwoColumns(const bool twoColumns)
    {
        if(twoColumns == m_twoColumns)
            return;

        Q_Q(SimpleListView);
        m_twoColumns = twoColumns;

#if (QT_VERSION >= 0x040600)
        bool cache = q->listItemCaching();
        q->setListItemCaching(false);
#endif
        QList<QGraphicsLayoutItem *> moveditems;
        if(twoColumns) {
            int half = m_layout->count()/2;
            for (int i = m_layout->count()-1; i>=half; --i) {
                QGraphicsLayoutItem *item = m_layout->itemAt(i);
                m_layout->removeAt(i);
                moveditems.append(item);
            }            
            for ( int i = 0; i < moveditems.count(); ++i)
                m_layout->addItem(moveditems.at(i), i, 1);

            m_layout->setColumnSpacing(0,0);
            m_layout->setColumnSpacing(1,0);
            m_layout->setRowSpacing(0,0);
            m_layout->setRowSpacing(1,0);
        }
        else {
            int count = m_layout->count()/2;
            for (int i = m_layout->count()-1;  i>=0; --i) {
                if (i >= count)
                    moveditems.append(m_layout->itemAt(i));
                else
                    moveditems.insert(moveditems.begin(), m_layout->itemAt(i));
                m_layout->removeAt(i);                
            }
            for (int i = 0; i<moveditems.count(); ++i) {
                m_layout->addItem(moveditems.at(i), m_layout->count(), 0);
            }
        }

        resizeContents(q->size());
        resizeScrollBars();

#if (QT_VERSION >= 0x040600)
        q->setListItemCaching(cache);
#endif
    }
Exemplo n.º 15
0
// inserts tid&crc value into an ordered list
// returns true if item is inserted
static bool insert_crc(QList<uint64_t> &seen_crc, const PSIPTable &psip)
{
    uint64_t key = (((uint64_t)psip.TableID()) << 32) | psip.CRC();

    QList<uint64_t>::iterator it =
        lower_bound(seen_crc.begin(), seen_crc.end(), key);

    if ((it == seen_crc.end()) || (*it != key))
    {
        seen_crc.insert(it, key);
        return true;
    }

    return false;
}
Exemplo n.º 16
0
 void addMessageEntry(const MessageTableEntry & message, const bool & append)
 {
     if(append)
     {
         cachedMessageTable.append(message);
     } else
     {
         int index = qLowerBound(cachedMessageTable.begin(), cachedMessageTable.end(), message.received_datetime, MessageTableEntryLessThan()) - cachedMessageTable.begin();
         parent->beginInsertRows(QModelIndex(), index, index);
         cachedMessageTable.insert(
                     index,
                     message);
         parent->endInsertRows();
     }
 }
Exemplo n.º 17
0
void ToolButton::dropEvent(QDropEvent *event)
{
    int numeroActuel = event->mimeData()->data( "number" ).toInt();
    int numeroCible = numeroDansLaListe;

    QList<int> liste = Settings::getBoutonList();

    int memoire = liste.at( numeroActuel );
    liste.removeAt( numeroActuel );
    liste.insert( numeroCible, memoire );

    Settings::setBoutonList( liste );

    event->acceptProposedAction();
}
Exemplo n.º 18
0
// returns the vhdl parsed types at line xxx
QList<Entry>* getEntryAtLine(const Entry* ce,int line)
{
  EntryListIterator eli(*ce->children());
  Entry *rt;
  for (;(rt=eli.current());++eli)
  {
    if (rt->bodyLine==line)
    {
      lineEntry.insert(0,rt);
    }

    getEntryAtLine(rt,line);
  }
  return &lineEntry;
}
Exemplo n.º 19
0
QList<QWidget *> KoPABackgroundTool::createOptionWidgets()
{
    KoPABackgroundToolWidget * widget = new KoPABackgroundToolWidget( this );
    QList<QWidget *> widgets;
    const QString title =
        (m_view->kopaDocument()->pageType() == KoPageApp::Page) ? QObject::tr("Page Background") : QObject::tr("Slide Background");
    widget->setWindowTitle(title);
    widgets.append(widget );
#if 0
    KoPAMasterPageDocker *masterPageDocker = new KoPAMasterPageDocker();
    masterPageDocker->setView( static_cast<KoPACanvas *>(m_canvas)->koPAView() );
    widgets.insert( QObject::tr("Master Page"), masterPageDocker );
#endif
    return widgets;
}
Exemplo n.º 20
0
static QList<QByteArray> interpretControlCodes(const QList<PrintLine> &lines, const ReceiptsPrinterOptions &printer_options)
{
	QList<QByteArray> ret;
	int line_length = printer_options.characterPrinterLineLength();
	bool include_escapes = printer_options.isCharacterPrinterGenerateControlCodes();
	const int cmd_length = sizeof(epson_commands) / sizeof(char*);
	for(const PrintLine line : lines) {
		QByteArray ba;
		int line_text_len = 0;
		for(const PrintData &pd : line) {
			if(pd.command == PrintData::Command::Text) {
				ba += pd.data;
				line_text_len += pd.data.length();
			}
			else if(pd.command == PrintData::Command::HorizontalLine) {
				QByteArray hr_data(line_length, pd.data[0]);
				if(line_text_len == 0) {
					ret.insert(ret.length(), ba + hr_data);
					ba.clear();
				}
				else {
					ret.insert(ret.length(), ba);
					ba = hr_data;
					line_text_len = hr_data.length();
				}
			}
			else if(include_escapes) {
				int ix = (int)pd.command;
				QF_ASSERT(ix < cmd_length, QString("%1 - Bad command index!").arg(ix), continue);
				ba += epson_commands[ix];
			}
		}
		ret.insert(ret.length(), ba);
	}
	return ret;
}
Exemplo n.º 21
0
void FocusChain::makeFirstInChain(Client *client, QList< Client * >& chain)
{
    chain.removeAll(client);
    if (client->isMinimized()) { // add it before the first minimized ...
        for (int i = chain.count()-1; i >= 0; --i) {
            if (chain.at(i)->isMinimized()) {
                chain.insert(i+1, client);
                return;
            }
        }
        chain.prepend(client); // ... or at end of chain
    } else {
        chain.append(client);
    }
}
Exemplo n.º 22
0
/** Maps to what groups the source row belongs by returning the data of those groups.
  *
  * @returns a list of data for the rows the argument belongs to. In common cases this list will
  * contain only one entry. An empty list means that the source item will be placed in the root of
  * this proxyModel. There is no support for hiding source items.
  *
  * Group data can be pre-loaded in the return value so it's added to the cache maintained by this
  * class. This is required if you want to have data that is not present in the source model.
  */
QList<RowData>
QtGroupingProxy::belongsTo( const QModelIndex &idx )
{
    //qDebug() << __FILE__ << __FUNCTION__;
    QList<RowData> rowDataList;

    //get all the data for this index from the model
    ItemData itemData = sourceModel()->itemData( idx );
    QMapIterator<int, QVariant> i( itemData );
    while( i.hasNext() )
    {
        i.next();
        int role = i.key();
        QVariant variant = i.value();
        // qDebug() << "role " << role << " : (" << variant.typeName() << ") : "<< variant;
        if( variant.type() == QVariant::List )
        {
            //a list of variants get's expanded to multiple rows
            QVariantList list = variant.toList();
            for( int i = 0; i < list.length(); i++ )
            {
                //take an existing row data or create a new one
                RowData rowData = (rowDataList.count() > i) ?  rowDataList.takeAt( i )
                                       : RowData();

                //we only gather data for the first column
                ItemData indexData = rowData.contains( 0 ) ? rowData.take( 0 ) : ItemData();
                indexData.insert( role, list.value( i ) );
                rowData.insert( 0, indexData );
                //for the grouped column the data should not be gathered from the children
                //this will allow filtering on the content of this column with a
                //QSortFilterProxyModel
                rowData.insert( m_groupedColumn, indexData );
                rowDataList.insert( i, rowData );
            }
        }
        else if( !variant.isNull() )
        {
            //it's just a normal item. Copy all the data and break this loop.
            RowData rowData;
            rowData.insert( 0, itemData );
            rowDataList << rowData;
            break;
        }
    }

    return rowDataList;
}
Exemplo n.º 23
0
// expects an unset cell with at least one option in its domain
QQueue<char> Grid::getSafestValues(Cell *target)
{
	QList<QPair<char, int> > options;
	QSet<char> originalDomain = target->domain();

	// loop over each possible value of target cell
	for( auto i=originalDomain.constBegin(); i!=originalDomain.constEnd(); ++i )
	{
		// assign the value to the cell and rebalance
		target->setValue(*i);
		auto diff = fixArcConsistency(target);
		int counter = 0;
		for( auto j=diff.begin(); j!=diff.end(); ++j ){
			QSet<char> diffDomain = j.value();
			counter += diffDomain.size();
		}

		// insert into the sorted options list
		for( auto j=options.begin(); j!=options.end(); ++j ){
			QPair<char,int> pair = *j;
			if( counter < pair.second ){
				options.insert(j, QPair<char,int>(*i,counter));
			}
		}
		if( !options.contains( QPair<char,int>(*i,counter) ) ){
			options.append( QPair<char,int>(*i,counter) );
		}

		// reset grid to pre-check levels
		unfixArcConsistency(diff);
	}
	target->setValue(Cell::UNKNOWN);
	target->setDomain(originalDomain);

	QQueue<char> retQueue;
	for( auto i=options.constBegin(); i!=options.constEnd(); ++i ){
		QPair<char,int> pair = *i;
		retQueue.enqueue( pair.first );
	}
	return retQueue;

	// dummy list returns unordered options
	/*QQueue<char> retQueue;
	for( auto i=target->domain().begin(); i!=target->domain().end(); ++i ){
		retQueue << *i;
	}
	return retQueue;*/
}
Exemplo n.º 24
0
void Library::updateTrackMetadata(Track track) {
	Track ntrack = track;
	if (track.id() > 0) {
		ntrack = _library_storage->updateTrack(track);
	}
	// update all playlists
	QList<QString> playlists = getPlaylistsNames();
	foreach (QString name, playlists) {
		Playlist pl = getPlaylist(name);
		QList<Track> tracks = pl.tracks();
		int pos = tracks.indexOf(ntrack); // comparing using source
		tracks.removeOne(ntrack); // comparing using source
		tracks.insert(pos, ntrack);
		pl.setTracks(tracks);
		savePlaylist(pl);
	}
Exemplo n.º 25
0
QList< GeoGraphicsItem* > GeoGraphicsScene::items( const Marble::GeoDataLatLonAltBox& box, int maxZoomLevel ) const
{
    QList< GeoGraphicsItem* > result;
    QRect rect;
    qreal north, south, east, west;
    box.boundaries( north, south, east, west );
    TileId key;
    int zoomLevel = maxZoomLevel < s_tileZoomLevel ? maxZoomLevel : s_tileZoomLevel;

    key = d->coordToTileId( GeoDataCoordinates(west, north, 0), zoomLevel );
    rect.setLeft( key.x() );
    rect.setTop( key.y() );

    key = d->coordToTileId( GeoDataCoordinates(east, south, 0), zoomLevel );
    rect.setRight( key.x() );
    rect.setBottom( key.y() );
    
    TileCoordsPyramid pyramid( 0, zoomLevel );
    pyramid.setBottomLevelCoords( rect );

    for ( int level = pyramid.topLevel(); level <= pyramid.bottomLevel(); ++level ) {
        QRect const coords = pyramid.coords( level );
        int x1, y1, x2, y2;
        coords.getCoords( &x1, &y1, &x2, &y2 );
        for ( int x = x1; x <= x2; ++x ) {
            for ( int y = y1; y <= y2; ++y ) {
                TileId const tileId( "", level, x, y );
                const QList< GeoGraphicsItem* > &objects = d->m_items.value(tileId);
                QList< GeoGraphicsItem* >::iterator before = result.begin();
                QList< GeoGraphicsItem* >::const_iterator currentItem = objects.constBegin();
                while( currentItem != objects.end() )
                {  
                    while( ( currentItem != objects.end() )
                      && ( ( before == result.end() ) || ( (*currentItem)->zValue() < (*before)->zValue() ) ) )
                    {
                        if( (*currentItem)->minZoomLevel() <= maxZoomLevel )
                            before = result.insert( before, *currentItem );
                        currentItem++;
                    }
                    if ( before != result.end() )
                        before++;
                }
            }
        }
    }
    return result;
}
Exemplo n.º 26
0
    void updateEntry(const QString &address, const QString &label, bool isMine, const QString &purpose, int status)
    {
        // Find address / label in model
        QList<AddressTableEntry>::iterator lower = qLowerBound(
            cachedAddressTable.begin(), cachedAddressTable.end(), address, AddressTableEntryLessThan());
        QList<AddressTableEntry>::iterator upper = qUpperBound(
            cachedAddressTable.begin(), cachedAddressTable.end(), address, AddressTableEntryLessThan());
        int lowerIndex = (lower - cachedAddressTable.begin());
        int upperIndex = (upper - cachedAddressTable.begin());
        bool inModel = (lower != upper);
        AddressTableEntry::Type newEntryType = translateTransactionType(purpose, isMine);

        switch(status)
        {
        case CT_NEW:
            if(inModel)
            {
                qWarning() << "AddressTablePriv::updateEntry : Warning: Got CT_NEW, but entry is already in model";
                break;
            }
            parent->beginInsertRows(QModelIndex(), lowerIndex, lowerIndex);
            cachedAddressTable.insert(lowerIndex, AddressTableEntry(newEntryType, label, address));
            parent->endInsertRows();
            break;
        case CT_UPDATED:
            if(!inModel)
            {
                qWarning() << "AddressTablePriv::updateEntry : Warning: Got CT_UPDATED, but entry is not in model";
                break;
            }
            lower->type = newEntryType;
            lower->label = label;
            parent->emitDataChanged(lowerIndex);
            break;
        case CT_DELETED:
            if(!inModel)
            {
                qWarning() << "AddressTablePriv::updateEntry : Warning: Got CT_DELETED, but entry is not in model";
                break;
            }
            parent->beginRemoveRows(QModelIndex(), lowerIndex, upperIndex-1);
            cachedAddressTable.erase(lower, upper);
            parent->endRemoveRows();
            break;
        }
    }
Exemplo n.º 27
0
void Server :: buildLocalPackages( Server *local )
{
    Package *curr;
    QListIterator<Package> it( packageList );

    QList<Package> *locallist = &local->getPackageList();

    for ( ; it.current(); ++it )
    {
        curr = it.current();
        QString name = curr->getPackageName();

        // If the package name is an ipk name, then convert the filename to a package name
        if ( name.find( ".ipk" ) != -1 )
            name = Utils::getPackageNameFromIpkFilename( curr->getFilename() );

        if ( local )
        {
            Package *p = local->getPackage( name );
            curr->setLocalPackage( p );
            if ( p )
            {
                // Replace local version
                if ( curr->getVersion() > p->getVersion() )
                {
                    int pos = locallist->at();
                    locallist->remove( p );
                    locallist->insert( pos, curr );
                }

                // Set some default stuff like size and things
                if ( p->getInstalledVersion() == curr->getVersion() )
                {
                    p->setPackageSize( curr->getPackageSize() );
                    p->setSection( curr->getSection() );
                    p->setDescription( curr->getDescription() );
                }
            }

        }
        else
            curr->setLocalPackage( 0 );
    }

}
Exemplo n.º 28
0
    void updateEntry(const QString &address, const QString &label, const QString &nation, int status)
    {
        // Find address / label in model
        QList<VotingTableEntry>::iterator lower = qLowerBound(
            cachedVotingTable.begin(), cachedVotingTable.end(), address, VotingTableEntryLessThan());
        QList<VotingTableEntry>::iterator upper = qUpperBound(
            cachedVotingTable.begin(), cachedVotingTable.end(), address, VotingTableEntryLessThan());
        int lowerIndex = (lower - cachedVotingTable.begin());
        int upperIndex = (upper - cachedVotingTable.begin());
        bool inModel = (lower != upper);

        switch(status)
        {
        case CT_NEW:
            if(inModel)
            {
                OutputDebugStringF("Warning: VotingTablePriv::updateEntry: Got CT_NOW, but entry is already in model\n");
                break;
            }
            parent->beginInsertRows(QModelIndex(), lowerIndex, lowerIndex);
            cachedVotingTable.insert(lowerIndex, VotingTableEntry(label, address, nation));
            parent->endInsertRows();
            break;
        case CT_UPDATED:
            if(!inModel)
            {
                OutputDebugStringF("Warning: VotingTablePriv::updateEntry: Got CT_UPDATED, but entry is not in model\n");
                break;
            }
            lower->label = label;
            lower->nation = nation;
            parent->emitDataChanged(lowerIndex);
            break;
        case CT_DELETED:
            if(!inModel)
            {
                OutputDebugStringF("Warning: VotingTablePriv::updateEntry: Got CT_DELETED, but entry is not in model\n");
                break;
            }
            parent->beginRemoveRows(QModelIndex(), lowerIndex, upperIndex-1);
            cachedVotingTable.erase(lower, upper);
            parent->endRemoveRows();
            break;
        }
    }
Exemplo n.º 29
0
bool FilterManager::insert(Filter *filter, QList<Filter *> &filters, int pos)
{
    int p = pos;
    if (p < 0)
        p += filters.size();
    if (p < 0)
        p = 0;
    if (p > filters.size())
        p = filters.size();
    const int index = filters.indexOf(filter);
    // already installed at desired position
    if (p == index)
        return false;
    if (p >= 0)
        filters.removeAt(p);
    filters.insert(p, filter);
    return true;
}
Exemplo n.º 30
0
// public
void kpToolTextEnterCommand::addEnter ()
{
    QList <QString> textLines = textSelection ()->textLines ();

    const QString rightHalf = textLines [m_row].mid (m_col);

    textLines [m_row].truncate (m_col);
    textLines.insert (textLines.begin () + m_row + 1, rightHalf);

    textSelection ()->setTextLines (textLines);

    m_row++;
    m_col = 0;

    viewManager ()->setTextCursorPosition (m_row, m_col);

    m_numEnters++;
}