示例#1
0
// Add Pattern Node
Pattern* Model::addPattern(QString patternName, int nMols, int nAtomsPerMol)
{
	Messenger::enter("Model::addPattern");
	// Determine starting atom...
	Pattern* lastp = patterns_.last();
	int start = (lastp == NULL ? 0 : lastp->startAtom() + lastp->nMolecules() * lastp->nAtoms());
	Pattern* newpnode = patterns_.add();
	newpnode->setParent(this);
	newpnode->setName(patternName);
	newpnode->initialise(patterns_.nItems()-1, start, nMols, nAtomsPerMol);
	Messenger::print("New pattern '%s' added - startatom %i, %i mols, %i atoms per mol.", qPrintable(patternName) , start+1, nMols, nAtomsPerMol);
	if ((start + nMols*nAtomsPerMol) == atoms_.nItems())
	{
		Messenger::print("Pattern description completed (spans %i atoms).", atoms_.nItems());
		energy.resize(patterns_.nItems());
		Messenger::print("Done.");
		// Patterns depend only on the properties / relation of the atoms, and not the positions..
		patternsPoint_ = log(Log::Structure);
	}
	else if ((start + nMols*nAtomsPerMol) > atoms_.nItems())
	{
		Messenger::print("New pattern '%s' extends %i atoms past number of atoms in owner model.", qPrintable(patternName), (start + nMols*nAtomsPerMol) - atoms_.nItems());
		Messenger::print("Not added.");
		patterns_.remove(newpnode);
		newpnode = NULL;
	}
	Messenger::exit("Model::addPattern");
	return newpnode;
}
示例#2
0
void PatternLoader::__setNewPattern(QString line) {
  QStringList strList = QStringList::split('\t', line);
  if(strList.count() != 2) { return; }
  if(pCurrentPatternGroup == NULL) { return; }
  Pattern* pPat = patternDefault.clone();
  pPat->setData(strList[0].stripWhiteSpace());
  pPat->setName(strList[1].stripWhiteSpace());
  pPat->setStyle(pCurrentStyle->getName());
  pCurrentPatternGroup->addPattern(pPat);
  return;
}
void InstrumentTrack::setName( const QString & _new_name )
{
	// when changing name of track, also change name of those patterns,
	// which have the same name as the instrument-track
	for( int i = 0; i < numOfTCOs(); ++i )
	{
		Pattern* p = dynamic_cast<Pattern*>( getTCO( i ) );
		if( ( p != NULL && p->name() == name() ) || p->name() == "" )
		{
			p->setName( _new_name );
		}
	}

	Track::setName( _new_name );
	m_midiPort.setName( name() );
	m_audioPort.setName( name() );

	emit nameChanged();
}
示例#4
0
void CustomPatternsModel::loadFromDB()
{
    layoutAboutToBeChanged();
    QSqlQuery query;
    myData.clear();
    query.exec("SELECT * from custompatterns ORDER BY name");
    while (query.next())
    {
        Pattern pattern;
        pattern.setName(query.value("name").toString());
        pattern.setArtistRegex(query.value("artistregex").toString());
        pattern.setArtistCaptureGrp(query.value("artistcapturegrp").toInt());
        pattern.setTitleRegex(query.value("titleregex").toString());
        pattern.setTitleCaptureGrp(query.value("titlecapturegrp").toInt());
        pattern.setDiscIdRegex(query.value("discidregex").toString());
        pattern.setDiscIdCaptureGrp(query.value("discidcapturegrp").toInt());
        myData.append(pattern);
    }
    layoutChanged();
}