void CGeneralModuleWidget::doAction(int buttonId)
{
	switch(buttonId)
	{
		case CModuleButtonBar::Add:
		{
			emit requestForm( m_pModuleInfo.key, 0);
		}
		break;
		case CModuleButtonBar::Del:
		{
			removeCurrentItem();
		}
		break;
		case CModuleButtonBar::Query:
		{
			
		}
		break;
		case CModuleButtonBar::Modify:
		{
			emit requestForm( m_pModuleInfo.key, 0, currentKey());
		}
		break;
	}
}
Example #2
0
void KAccel::changeMenuAccel ( QPopupMenu *menu, int id,
	const char *action )
{
	QString s = menu->text( id );
	if ( !s ) return;
	if (!action) return;
	
	int i = s.find('\t');
	
	QString k = keyToString( currentKey( action), true );
	if( !k ) return;
	
	if ( i >= 0 )
		s.replace( i+1, s.length()-i, k );
	else {
		s += '\t';
		s += k;
	}

	QPixmap *pp = menu->pixmap(id);
	if(pp && !pp->isNull())
	  menu->changeItem( *pp, s, id );
	else
	  menu->changeItem( s, id );
}
void TestHelpSelectingDialog::addKey(QTreeWidgetItem *root, const Key &key, const QString &title, const uint nodeId, const int role)
{
    Key rootKey(root->text(0).split(" ").at(0), ((role == Qt::UserRole) ? Key::InnerCode : Key::OuterCode));

    if (rootKey == key)
    {
        QTreeWidgetItem *newNode = new QTreeWidgetItem(root);

        newNode->setText(0, key.getKey() + " - " + title);
        newNode->setData(0, role, nodeId);

        return;
    }

    for (int i = 0; i < root->childCount(); i++)
    {
        if (root->child(i)->text(0).contains(" "))
        {
            continue;
        }
        Key currentKey(root->child(i)->text(0).split(" ").at(0), ((role == Qt::UserRole) ? Key::InnerCode : Key::OuterCode));

        if ((currentKey.isParentFor(key)) || (currentKey == key))
        {
            QTreeWidgetItem *newRoot = root->child(i);
            addKey(newRoot, key, title, nodeId, role);

            return;
        }
    }

    // иначе - среди узлов нет родителей, нужно создать свой ключ

    QList<int> rootLevels = rootKey.getLevels();
    QList<int> keyLevels = key.getLevels();


    QString newKey;
    if (!((rootLevels.length() == 1) && (rootLevels.at(0) == 0)))
    {
        newKey = rootKey.getKey();
        newKey += "." + QString::number(keyLevels.at(rootLevels.length()), 10);
    }
    else
    {
        newKey = QString::number(keyLevels.at(0), 10);
    }

    QTreeWidgetItem *newNode = new QTreeWidgetItem(root);

    newNode->setText(0, newKey);
    newNode->setData(0, role, -1);

    addKey(newNode, key, title, nodeId, role);
}
Example #4
0
	float Interpolator::interpolate(const Particle& particle,ModelParam interpolatedParam,float ratioY,float offsetX,float scaleX)
	{
		// First finds the current X of the particle
		InterpolatorEntry currentKey((this->*Interpolator::COMPUTE_X_FN[type])(particle));
		currentKey.x += offsetX; // Offsets it
		currentKey.x *= scaleX;  // Scales it

		if (loopingEnabled)
		{
			// If the graph has les than 2 entries, we cannot loop
			if (graph.size() < 2)
			{
				if (graph.empty())
					return Model::getDefaultValue(interpolatedParam);
				else
					return interpolateY(*(graph.begin()),ratioY);
			}

			// Else finds the current X in the range
			const float beginX = graph.begin()->x;
			const float rangeX = graph.rbegin()->x - beginX;
			float newX = (currentKey.x - beginX) / rangeX;
			newX -= static_cast<int>(newX);
			if (newX < 0.0f)
				newX = 1.0f + newX;
			currentKey.x = beginX + newX * rangeX;
		}

		// Gets the entry that is immediatly after the current X
		std::set<InterpolatorEntry>::const_iterator nextIt = graph.upper_bound(currentKey);

		// If the current X is higher than the one of the last entry
		if (nextIt == graph.end())
		{
			if (graph.empty())	// If the graph has no entry, sets the default value
				return Model::getDefaultValue(interpolatedParam);
			else	// Else sets the value of the last entry
				return interpolateY(*(--nextIt),ratioY);
		}
		else if (nextIt == graph.begin()) // If the current X is lower than the first entry, sets the value to the first entry
		{
			return interpolateY(*nextIt,ratioY);
		}
		else	// Else interpolated between the entries before and after the current X
		{
			const InterpolatorEntry& nextEntry = *nextIt;
			const InterpolatorEntry& previousEntry = *(--nextIt);
			float y0 = interpolateY(previousEntry,ratioY);
			float y1 = interpolateY(nextEntry,ratioY);

			float ratioX = (currentKey.x - previousEntry.x) / (nextEntry.x - previousEntry.x);
			return y0 + ratioX * (y1 - y0);
		}
	}
Example #5
0
bool
Dynamic::LastFmBias::trackMatches( int position,
                                   const Meta::TrackList& playlist,
                                   int contextCount ) const
{
    Q_UNUSED( contextCount );

    if( position <= 0 || position >= playlist.count())
        return false;

    // determine the last track and artist
    Meta::TrackPtr lastTrack = playlist[position-1];
    Meta::ArtistPtr lastArtist = lastTrack->artist();
    QString lastTrackName = lastTrack->name();
    QString lastArtistName = lastArtist ? lastArtist->name() : QString();

    Meta::TrackPtr currentTrack = playlist[position];
    Meta::ArtistPtr currentArtist = currentTrack->artist();
    QString currentTrackName = currentTrack->name();
    QString currentArtistName = currentArtist ? currentArtist->name() : QString();

    {
        QMutexLocker locker( &m_mutex );

        if( m_match == SimilarArtist )
        {
            if( lastArtistName.isEmpty() )
                return true;
            if( currentArtistName.isEmpty() )
                return false;
            if( lastArtistName == currentArtistName )
                return true;
            if( m_similarArtistMap.contains( lastArtistName ) )
                return m_similarArtistMap.value( lastArtistName ).contains( currentArtistName );
        }
        else if( m_match == SimilarTrack )
        {
            if( lastTrackName.isEmpty() )
                return true;
            if( currentTrackName.isEmpty() )
                return false;
            if( lastTrackName == currentTrackName )
                return true;
            TitleArtistPair lastKey( lastTrackName, lastArtistName );
            TitleArtistPair currentKey( currentTrackName, currentArtistName );
            if( m_similarTrackMap.contains( lastKey ) )
                return m_similarTrackMap.value( lastKey ).contains( currentKey );
        }
    }

    debug() << "didn't have a cached suggestions for track:" << lastTrackName;
    return false;
}
Example #6
0
void AlDatabase::read()
{
  for (;;) {
    const char *key = currentKey();
    if (strcmp(key, "begin")==0) {
      const char *value = currentValue();
      if (strcmp(value, "MemoryMap")==0) {
        gMemoryMap.readBlock(*this);
      } else {
        printErrValue();
      }
    } else {
      printErrKey();
    }
    if (!readNext())
      return;
  }
}