예제 #1
0
 void visitChar( char c ) {
     if( m_mode == None ) {
         switch( c ) {
         case ' ': return;
         case '~': m_exclusion = true; return;
         case '[': startNewMode( Tag, ++m_pos ); return;
         case '"': startNewMode( QuotedName, ++m_pos ); return;
         default: startNewMode( Name, m_pos ); break;
         }
     }
     if( m_mode == Name ) {
         if( c == ',' ) {
             addPattern( (TestSpec::NamePattern *)0 );
             addFilter();
         }
         else if( c == '[' ) {
             if( subString() == "exclude:" )
                 m_exclusion = true;
             else
                 addPattern( (TestSpec::NamePattern *)0 );
             startNewMode( Tag, ++m_pos );
         }
     }
     else if( m_mode == QuotedName && c == '"' )
         addPattern( (TestSpec::NamePattern *)0 );
     else if( m_mode == Tag && c == ']' )
         addPattern( (TestSpec::TagPattern *)0 );
 }
예제 #2
0
void CombinedURLFilters::addDomain(uint64_t actionId, const String& domain)
{
    // This is like adding (.|^)domain$ by adding two Vector<Term>'s,
    // but interpreting domain as a series of characters, not a regular expression.
    // This way a domain of "webkit.org" will match "bugs.webkit.org" and "webkit.org".
    // FIXME: Add support for matching only subdomains or no subdomains.
    Vector<Term> prependDot;
    Vector<Term> prependBeginningOfLine;
    prependDot.reserveInitialCapacity(domain.length() + 3);
    prependBeginningOfLine.reserveInitialCapacity(domain.length() + 1); // This is just no .* at the beginning.
    
    Term canonicalDotStar(Term::UniversalTransition);
    canonicalDotStar.quantify(AtomQuantifier::ZeroOrMore);
    prependDot.uncheckedAppend(canonicalDotStar);
    prependDot.uncheckedAppend(Term('.', true));
    
    for (unsigned i = 0; i < domain.length(); i++) {
        ASSERT(isASCII(domain[i]));
        ASSERT(!isASCIIUpper(domain[i]));
        prependDot.uncheckedAppend(Term(domain[i], true));
        prependBeginningOfLine.uncheckedAppend(Term(domain[i], true));
    }
    prependDot.uncheckedAppend(Term::EndOfLineAssertionTerm);
    prependBeginningOfLine.uncheckedAppend(Term::EndOfLineAssertionTerm);
    
    addPattern(actionId, prependDot);
    addPattern(actionId, prependBeginningOfLine);
}
예제 #3
0
 void processLine(lString16 & line) {
     if (line.lastChar()=='\r' || line.lastChar()=='\n')
         line.erase(line.length()-1, 1);
     if (state == 0) {
         //
         if (line.startsWith(lString16("%"))) {
             fprintf(out, "%s\n", LCSTR(line));
             return;
         }
         if (line.startsWith(lString16("\\patterns{"))) {
             start();
             return;
         }
     } else {
         lString16 word;
         for (int i=0; i<=line.length(); i++) {
             lChar16 ch = (i<line.length()) ? line[i] : 0;
             if (ch == '}')
                 break;
             if (ch==' ' || ch=='\t' || ch=='%' || ch==0) {
                 if (!word.empty()) {
                     addPattern(word);
                     word.clear();
                 }
                 if (ch!=' ' && ch!='\t')
                     break;
             } else {
                 word.append(1, ch);
             }
         }
     }
 }
BeddingTypeLegendItem::BeddingTypeLegendItem(QGraphicsItem* p, BeddingType* t, int w, int h)
: PatternLegendItem(p, w, h),
_beddingType(t) {
    ProfileLogger* app = (static_cast<ProfileLogger*> (QApplication::instance()));
    QBrush b = app->getBrushFromFileName(app->getSettings()->getLithologiesPatternPath(), t->getFileName());

    addPattern(b);
    addId(t->getId());
    addName(t->getName());
}
예제 #5
0
 TestSpecParser parse( std::string const& arg ) {
     m_mode = None;
     m_exclusion = false;
     m_start = std::string::npos;
     m_arg = arg;
     for( m_pos = 0; m_pos < m_arg.size(); ++m_pos )
         visitChar( m_arg[m_pos] );
     if( m_mode == Name )
         addPattern( (TestSpec::NamePattern *)0 );
     return *this;
 }
LithologyLegendItem::LithologyLegendItem(QGraphicsItem* parent, Lithology* l, int width, int height)
: PatternLegendItem(parent, width, height),
_lithology(l) {

    ProfileLogger* app = (static_cast<ProfileLogger*> (QApplication::instance()));
    QBrush b = app->getBrushFromFileName(app->getSettings()->getLithologiesPatternPath(), l->getFileName());

    addPattern(b);
    addId(l->getId());
    addName(l->getName());
}
void Settings::setupGui() {
    ui.setupUi(this);

    connect(ui.buttonBox, SIGNAL(accepted()), this, SLOT(saveSettings()));
    connect(ui.patternEdit, SIGNAL(textChanged(QString)), this, SLOT(changeAddPatternButtonState(QString)));

    connect(ui.patternAddButton, SIGNAL(clicked()), this, SLOT(addPattern()));
    connect(ui.patternDeleteButton, SIGNAL(clicked()), this, SLOT(deletePattern()));

    connect(ui.directoryOpenButton, SIGNAL(clicked()), this, SLOT(addDirectory()));
    connect(ui.directoryDeleteButton, SIGNAL(clicked()), this, SLOT(deleteDirectory()));
}
예제 #8
0
    void Channel::processEvents()
    {
        Pattern newPattern;
        while(patternQueue_.pop_front(newPattern) )
        {
            addPattern(newPattern);
        }

        if(currentPattern_ < patterns_.size() )
        {
            Pattern &currentPattern = patterns_[currentPattern_];
            auto events = currentPattern.getEvents();
            for(auto &event : events)
            {
                switch(event.type)
                {
                    case NOTE_ON:
                        moduleChain_.input(ModuleChain::NOTE_NUMBER) = event.note;
                        moduleChain_.input(ModuleChain::NOTE_FREQ) = FREQ_TABLE[event.note];
                        moduleChain_.input(ModuleChain::GATE_IN) = event.value;
                        moduleChain_.input(ModuleChain::NEW_NOTE) = 1;
                        break;
                    case NOTE_OFF:
                        moduleChain_.input(ModuleChain::GATE_IN) = 0;
                        break;
                    case PARAM_CHANGE:
                        moduleChain_.setParameter(event.paramID, event.value);
                        break;
                }
            }
            currentPattern.nextTick();
            if(currentPattern.finished() )
            {
                if(consumePatterns_)
                {
                    removePattern(currentPattern_);
                }
                else
                {
                    currentPattern.restart();
                    currentPattern_++;
                }
                if(currentPattern_ >= patterns_.size())
                {
                    if(loop_)
                    {
                        currentPattern_ = loopStart_;
                    }
                }
            }
        }
    }
예제 #9
0
int lg_add_pattern(LG_HFSM hFsm,
                   LG_HPATTERNMAP hMap,
                   LG_HPATTERN hPattern,
                   const char* encoding,
                   LG_Error** err)
{
  return trapWithRetval(
    [hFsm,hMap,hPattern,encoding]() {
      return addPattern(hFsm, hMap, hPattern, encoding);
    },
    -1,
    err
  );
}
예제 #10
0
void FileMgr::initilize(int argc, char* argv[]){
	try{
		if (argc >= 2){
			int temp_int = 1, flag_d = 0, flag_f = 0;
			std::string temp, test_store;
			++argv;
			temp = *argv;
			if (temp.find('/') != 0 && (temp.find('*') == -1)){									 //to know if path is present at the starting
				path_ = temp;
				++argv;
				++temp_int;
			}
			for (int j = temp_int; j < argc; j++){												//looping through the extensions and filenames
				temp = *argv;
				if (temp.find('/') == -1 && temp.find('.') != -1){ addPattern(temp); }	        //saving the pattern
				else{
					if (temp == "/s" || temp == "/S"){ flag_fm = 1; }
					else if (temp == "/d" || temp == "/D"){ flag_d = 1; }						//identifing options
					else if ((temp == "/f" || temp == "/F") && j != argc - 1){
						++argv;
						test_store = (*argv);
						flag_f = 1;
						++j;
					}
					else{																	//ignoring invalid option
					}
				}
				++argv;
			}
			search();																			//building catalog
			Display dis(DataStore1);
			dis.display(0);
			if (flag_d == 1){ dis.display(1); }									 //to display duplicates flag_d is set when /d option is given
			if (flag_f == 1){
				Catalog cat(DataStore1);														//to check for /f optoin 
				cat.search_text(test_store, 0);
			}
		}
		else{
			path_ = ".";
			search();
			Display dis(DataStore1);
			dis.display(3);																	//if no command line argument was given
		}
 }
	catch (std::exception e) {
		std::cout << e.what();
	}
}
예제 #11
0
/**
 * Load a predefined set of double-click gestures patterns.
 * Theses patterns are manualy recorded @ 20FPS
 * If the framerate changes the patterns wont be relevant anymore.
 */
void DoubleClickFilter::loadDoubleClickPatterns()
{
    cv::Mat p1( sizeof(doubleClickPattern_1)/sizeof(float), 1, CV_32F, doubleClickPattern_1 );
    cv::Mat p2( sizeof(doubleClickPattern_2)/sizeof(float), 1, CV_32F, doubleClickPattern_2 );
    cv::Mat p3( sizeof(doubleClickPattern_3)/sizeof(float), 1, CV_32F, doubleClickPattern_3 );
    cv::Mat p4( sizeof(doubleClickPattern_4)/sizeof(float), 1, CV_32F, doubleClickPattern_4 );
    cv::Mat p5( sizeof(doubleClickPattern_5)/sizeof(float), 1, CV_32F, doubleClickPattern_5 );
    cv::Mat p6( sizeof(doubleClickPattern_6)/sizeof(float), 1, CV_32F, doubleClickPattern_6 );
    cv::Mat p7( sizeof(doubleClickPattern_7)/sizeof(float), 1, CV_32F, doubleClickPattern_7 );
    cv::Mat p8( sizeof(doubleClickPattern_8)/sizeof(float), 1, CV_32F, doubleClickPattern_8 );

    addPattern( p1 );
    addPattern( p2 );
    addPattern( p3 );
    addPattern( p4 );
    addPattern( p5 );
    addPattern( p6 );
    addPattern( p7 );
    addPattern( p8 );
}
AhoCorasickPlus::EnumReturnStatus AhoCorasickPlus::addPattern 
    (const char pattern[], PatternId id)
{
    std::string tmpString = pattern;
    return addPattern (tmpString, id);
}
예제 #13
0
bool TexHyph::load( LVStreamRef stream )
{
    int w = isCorrectHyphFile(stream.get());
    int patternCount = 0;
    if (w) {
        _hash = stream->crc32();
        int        i;
        lvsize_t   dw;

        lvByteOrderConv cnv;

        int hyph_count = w;
        thyph hyph;

        lvpos_t p = 78 + (hyph_count * 8 + 2);
        stream->SetPos(p);
        if ( stream->SetPos(p)!=p )
            return false;
        lChar16 charMap[256];
        unsigned char buf[0x10000];
        memset( charMap, 0, sizeof( charMap ) );
        // make char map table
        for (i=0; i<hyph_count; i++)
        {
            if ( stream->Read( &hyph, 522, &dw )!=LVERR_OK || dw!=522 ) 
                return false;
            cnv.msf( &hyph.len ); //rword(_main_hyph[i].len);
            lvpos_t newPos;
            if ( stream->Seek( hyph.len, LVSEEK_CUR, &newPos )!=LVERR_OK )
                return false;

            cnv.msf( hyph.wl );
            cnv.msf( hyph.wu );
            charMap[ (unsigned char)hyph.al ] = hyph.wl;
            charMap[ (unsigned char)hyph.au ] = hyph.wu;
//            lChar16 ch = hyph.wl;
//            CRLog::debug("wl=%s mask=%c%c", LCSTR(lString16(&ch, 1)), hyph.mask0[0], hyph.mask0[1]);
            if (hyph.mask0[0]!='0'||hyph.mask0[1]!='0') {
                unsigned char pat[4];
                pat[0] = hyph.al;
                pat[1] = hyph.mask0[0];
                pat[2] = hyph.mask0[1];
                pat[3] = 0;
                TexPattern * pattern = new TexPattern(pat, 1, charMap);
#if DUMP_PATTERNS==1
                CRLog::debug("Pattern: '%s' - %s", LCSTR(lString16(pattern->word)), pattern->attr );
#endif
                addPattern( pattern );
                patternCount++;
            }
        }

        if ( stream->SetPos(p)!=p )
            return false;

        for (i=0; i<hyph_count; i++)
        {
            stream->Read( &hyph, 522, &dw );
            if (dw!=522) 
                return false;
            cnv.msf( &hyph.len );

            stream->Read(buf, hyph.len, &dw); 
            if (dw!=hyph.len)
                return false;

            unsigned char * p = buf;
            unsigned char * end_p = p + hyph.len;
            while ( p < end_p ) {
                lUInt8 sz = *p++;
                if ( p + sz > end_p )
                    break;
                TexPattern * pattern = new TexPattern( p, sz, charMap );
#if DUMP_PATTERNS==1
                CRLog::debug("Pattern: '%s' - %s", LCSTR(lString16(pattern->word)), pattern->attr);
#endif
                addPattern( pattern );
                patternCount++;
                p += sz + sz + 1;
            }
        }

        return patternCount>0;
    } else {
        // tex xml format as for FBReader
        lString16Collection data;
        HyphPatternReader reader( data );
        LVXMLParser parser( stream, &reader );
        if ( !parser.CheckFormat() )
            return false;
        if ( !parser.Parse() )
            return false;
        if ( !data.length() )
            return false;
        for ( int i=0; i<(int)data.length(); i++ ) {
            data[i].lowercase();
            TexPattern * pattern = new TexPattern( data[i] );
#if DUMP_PATTERNS==1
            CRLog::debug("Pattern: (%s) '%s' - %s", LCSTR(data[i]), LCSTR(lString16(pattern->word)), pattern->attr);
#endif
            addPattern( pattern );
            patternCount++;
        }
        return patternCount>0;
    }
}
예제 #14
0
파일: pattern.cpp 프로젝트: alinelena/aten
// Create default pattern
Pattern* Model::createDefaultPattern()
{
	clearPatterns();
	Pattern* p = addPattern("Default", 1, atoms_.nItems());
	return p;
}
예제 #15
0
파일: pattern.cpp 프로젝트: alinelena/aten
// Autocreate patterns
bool Model::createPatterns()
{
	// Determine the pattern (molecule) layout of the model
	Messenger::enter("Model::createPatterns");
	int n, atomid, nsel2, nmols, idi, idj, idoff, count;
	bool same;
	QString empirical;
	Clipboard patclip;
	Pattern* p;
	RefListItem<Bond,int>* rb;
	Atom* i, *selectSource;
	ClipAtom* clipi;
	RefListItem<Atom,int>* isel;
	
	// Check current pattern first...
	if (arePatternsValid())
	{
		Messenger::exit("Model::createPatterns");
		return true;
	}
	
	// Delete all old nodes first.
	Messenger::print("Autodetecting patterns for model '%s'..", qPrintable(name_));
	patterns_.clear();
	// If there are no atoms in the molecule, exit here.
	if (atoms_.nItems() == 0)
	{
		Messenger::print("No patterns defined for model '%s' - no atoms present.", qPrintable(name_));
		patternsPoint_ = log(Log::Structure);
		Messenger::exit("Model::createPatterns");
		return true;
	}
	
	// To autodetect, we start off at the first atom in the model, tree-select this atom and copy the selection to the clipboard. Use the clipboard to check subsequent selections, and if its the same just increase the nmols counter by one. If it's different, assume its the start of a new type of molecule and reset the counters.
	atomid = 0;
	nmols = 0;
	i = atoms_.first();
	while (atomid != atoms_.nItems())
	{
		selectNone(true);
		
		// Select molecule starting at atom 'i' and calculate fingerprint
		selectTree(i, true);
		selectSource = i;
		
		// We insist that the molecule consists of consecutively ordered atoms, otherwise we can't proceed, so count the number of selected
		// atoms in those that we now skip (if != nselected then we must force a 1*N pattern)
		nsel2 = 0;
		atomid += marked_.nItems();
		//selectionGetEmpirical(emp);
		for (n=0; n<marked_.nItems(); n++)
		{
			if (i->isSelected(true)) nsel2 ++;
			i = i->next;
		}
		if (nsel2 != marked_.nItems())
		{
			Messenger::error("Pattern creation failed because of bad atom ordering or the presence of additional bonds.");
			Messenger::error("Problem occurred in pattern %i whilst selecting from atom %i.", patterns_.nItems()+1, selectSource->id()+1);

			// Remove any patterns added so far
			patterns_.clear();
			nmols = 0;

			Messenger::exit("Model::createPatterns");
			return false;
		}
		// If this is the first pass (molecule), copy the selection. If not, compare it
		if (nmols == 0)
		{
			patclip.copyMarked(this);
			empirical = selectionEmpirical(true);
			nmols = 1;
		}
		else
		{
			// Compare clipboard contents with current selection
			same = true;
			// Check number of atoms first....
			if (marked_.nItems() != patclip.nAtoms()) same = false;
			else
			{
				// Atoms
				clipi = patclip.atoms();
				for (isel = marked_.first(); isel != NULL; isel = isel->next)
				{
					count++;
					
					// Element check
					if (clipi->atom().element() != isel->item->element())
					{
						same = false;
						break;
					}
					
					// Fixed position
					if (clipi->atom().isPositionFixed() != isel->item->isPositionFixed())
					{
						same = false;
						break;
					}

					// Fixed forcefield type check
					if (clipi->atom().hasFixedType() != isel->item->hasFixedType())
					{
						same = false;
						break;
					}
					else if (clipi->atom().hasFixedType())
					{
						// Both have fixed type - make sure types are the same
						if (clipi->atom().type() != isel->item->type())
						{
							same = false;
							break;
						}
					}
					clipi = clipi->next;
				}
				
				// Bonding between atoms (but only if atoms themselves check out)...
				if (same)
				{
					idoff = selection(true)->item->id();
					count = 0;
					for (isel = marked_.first(); isel != NULL; isel = isel->next)
					{
						// Convert IDs so they start at zero (i.e. subtract ID of current atom 'i')
						idi = isel->item->id() - idoff;
						for (rb = isel->item->bonds(); rb != NULL; rb = rb->next)
						{
							idj = rb->item->partner(isel->item)->id() - idoff;
							if (idi < idj) continue;
							++count;
							if (!patclip.hasBond(idi,idj))
							{
								same = false;
								break;
							}
						}
						if (!same) break;
					}
					// Check for difference between number of bonds between marked atoms and clipboard atoms
					if (count != patclip.nBonds()) same = false;
				}
			}

			// If we get to here with same == true then we increase nmols. Otherwise, we create a new pattern.
			if (same) ++nmols;
			else
			{
				// Not the same as the last stored pattern, so store old data and start a new one
				Messenger::print(Messenger::Verbose, "New pattern found: %s", qPrintable(empirical));
				p = addPattern(qPrintable(empirical), nmols, patclip.nAtoms());
				patclip.copyMarked(this);
				empirical = selectionEmpirical(true);
				nmols = 1;
			}
		}
	}
	// Store last pattern data 
	if (nmols != 0)
	{
		Messenger::print(Messenger::Verbose, "New pattern found: %s", qPrintable(empirical));
		p = addPattern(qPrintable(empirical), nmols, patclip.nAtoms());
	}

	// Describe the atoms / rings in the patterns
	describeAtoms();

	// Patterns depend only on the properties / relation of the atoms, and not the positions..
	patternsPoint_ = log(Log::Structure);

	Messenger::exit("Model::createPatterns");
	return true;
}
예제 #16
0
void Character::loadPatternsXML()
{
	if(directory=="chars/Iguro/")
	{
		addPattern(sonido,painter,receiver,
					/*name*/"o",
					/*velocity*/0,
					/*max_velocity*/99999,
					/*acceleration*/10,
					/*a_frequency*/0,
					/*angle*/0,
					/*angle_change*/0,
					/*stop_ac_at*/99999,
					/*ac_frequency*/0,
					/*animation_velocity*/2,
					/*bullet*/"lazor",
					/*offset_x*/65,
					/*offset_y*/-44,
					/*startup*/0,
					/*cooldown*/11,
					/*duration*/99999,
					/*random_angle*/0,
					/*aim_player*/false,
					/*bullet_rotation*/0,
					/*br_change*/0,
					/*independent_br*/false);

		addPattern(sonido,painter,receiver,
					/*name*/"o",
					/*velocity*/40,
					/*max_velocity*/120,
					/*acceleration*/1,
					/*a_frequency*/0,
					/*angle*/0,
					/*angle_change*/0,
					/*stop_ac_at*/99999,
					/*ac_frequency*/0,
					/*animation_velocity*/2,
					/*bullet*/"machinegun",
					/*offset_x*/85,
					/*offset_y*/4,
					/*startup*/0,
					/*cooldown*/2,
					/*duration*/99999,
					/*random_angle*/0,
					/*aim_player*/false,
					/*bullet_rotation*/0,
					/*br_change*/0,
					/*independent_br*/false);

		addPattern(sonido,painter,receiver,
					/*name*/"o",
					/*velocity*/40,
					/*max_velocity*/90,
					/*acceleration*/2,
					/*a_frequency*/0,
					/*angle*/0,
					/*angle_change*/0,
					/*stop_ac_at*/99999,
					/*ac_frequency*/0,
					/*animation_velocity*/2,
					/*bullet*/"machinegun",
					/*offset_x*/75,
					/*offset_y*/-4,
					/*startup*/0,
					/*cooldown*/2,
					/*duration*/99999,
					/*random_angle*/0,
					/*aim_player*/false,
					/*bullet_rotation*/0,
					/*br_change*/0,
					/*independent_br*/false);

////////////////////////////////////U////////////////////////////////////
if(false)
{
		addPattern(sonido,painter,receiver,
					/*name*/"u",
					/*velocity*/0,
					/*max_velocity*/99999,
					/*acceleration*/10,
					/*a_frequency*/0,
					/*angle*/0,
					/*angle_change*/0,
					/*stop_ac_at*/99999,
					/*ac_frequency*/0,
					/*animation_velocity*/2,
					/*bullet*/"lazor",
					/*offset_x*/65,
					/*offset_y*/-44,
					/*startup*/0,
					/*cooldown*/11,
					/*duration*/99999,
					/*random_angle*/0,
					/*aim_player*/false,
					/*bullet_rotation*/0,
					/*br_change*/0,
					/*independent_br*/false);
}
		addPattern(sonido,painter,receiver,
					/*name*/"u",
					/*velocity*/20,
					/*max_velocity*/120,
					/*acceleration*/1,
					/*a_frequency*/1,
					/*angle*/-30,
					/*angle_change*/0,
					/*stop_ac_at*/99999,
					/*ac_frequency*/0,
					/*animation_velocity*/2,
					/*bullet*/"machinegun",
					/*offset_x*/85,
					/*offset_y*/4,
					/*startup*/0,
					/*cooldown*/2,
					/*duration*/99999,
					/*random_angle*/60,
					/*aim_player*/false,
					/*bullet_rotation*/0,
					/*br_change*/0,
					/*independent_br*/false);

		addPattern(sonido,painter,receiver,
					/*name*/"u",
					/*velocity*/20,
					/*max_velocity*/90,
					/*acceleration*/2,
					/*a_frequency*/1,
					/*angle*/-30,
					/*angle_change*/0,
					/*stop_ac_at*/99999,
					/*ac_frequency*/0,
					/*animation_velocity*/2,
					/*bullet*/"machinegun",
					/*offset_x*/75,
					/*offset_y*/-4,
					/*startup*/0,
					/*cooldown*/2,
					/*duration*/99999,
					/*random_angle*/60,
					/*aim_player*/false,
					/*bullet_rotation*/0,
					/*br_change*/0,
					/*independent_br*/false);
		//addModifier("u",2,20, "aim_player", "yes");

////////////////////////////////////Y////////////////////////////////////

		addPattern(sonido,painter,receiver,
					/*name*/"y",
					/*velocity*/70,
					/*max_velocity*/99999,
					/*acceleration*/0,
					/*a_frequency*/0,
					/*angle*/0,
					/*angle_change*/0,
					/*stop_ac_at*/99999,
					/*ac_frequency*/0,
					/*animation_velocity*/2,
					/*bullet*/"lazor",
					/*offset_x*/65,
					/*offset_y*/-44,
					/*startup*/0,
					/*cooldown*/4,
					/*duration*/99999,
					/*random_angle*/0,
					/*aim_player*/false,
					/*bullet_rotation*/0,
					/*br_change*/0,
					/*independent_br*/false);

////////////////////////////////////A////////////////////////////////////

		addPattern(sonido,painter,receiver,
					/*name*/"a",
					/*velocity*/0,
					/*max_velocity*/99999,
					/*acceleration*/10,
					/*a_frequency*/0,
					/*angle*/0,
					/*angle_change*/0,
					/*stop_ac_at*/99999,
					/*ac_frequency*/0,
					/*animation_velocity*/4,
					/*bullet*/"lazor",
					/*offset_x*/65,
					/*offset_y*/-44,
					/*startup*/0,
					/*cooldown*/22,
					/*duration*/99999,
					/*random_angle*/0,
					/*aim_player*/false,
					/*bullet_rotation*/0,
					/*br_change*/0,
					/*independent_br*/false);

		addPattern(sonido,painter,receiver,
					/*name*/"a",
					/*velocity*/20,
					/*max_velocity*/120,
					/*acceleration*/1,
					/*a_frequency*/1,
					/*angle*/-45,
					/*angle_change*/2,
					/*stop_ac_at*/99999,
					/*ac_frequency*/0,
					/*animation_velocity*/4,
					/*bullet*/"machinegun",
					/*offset_x*/85,
					/*offset_y*/4,
					/*startup*/0,
					/*cooldown*/4,
					/*duration*/99999,
					/*random_angle*/0,
					/*aim_player*/false,
					/*bullet_rotation*/0,
					/*br_change*/0,
					/*independent_br*/false);

		addPattern(sonido,painter,receiver,
					/*name*/"a",
					/*velocity*/20,
					/*max_velocity*/90,
					/*acceleration*/2,
					/*a_frequency*/1,
					/*angle*/45,
					/*angle_change*/-2,
					/*stop_ac_at*/99999,
					/*ac_frequency*/0,
					/*animation_velocity*/3,
					/*bullet*/"machinegun",
					/*offset_x*/75,
					/*offset_y*/-4,
					/*startup*/0,
					/*cooldown*/4,
					/*duration*/99999,
					/*random_angle*/0,
					/*aim_player*/false,
					/*bullet_rotation*/0,
					/*br_change*/0,
					/*independent_br*/false);
	}else
	{
	}
}
OpenWithManagerDialog::OpenWithManagerDialog(QWidget *parentObject) :
  QDialog(parentObject),
  ui(new Ui::OpenWithManagerDialog),
  m_factoryModel(new OpenWithExecutableModel(this)),
  m_patternModel(new OpenWithPatternModel(this)),
  m_patternMapper(new QDataWidgetMapper(this)),
  m_handlerMapper(new QDataWidgetMapper(this)),
  m_patternTypeDelegate(new PatternTypeDelegate(this)),
  m_dirty(false)
{
  // Setup ui:
  ui->setupUi(this);

  // Setup MVC:
  ui->tableFactories->setModel(m_factoryModel);

  ui->tablePattern->setModel(m_patternModel);
  ui->tablePattern->setItemDelegate(m_patternTypeDelegate);

  ui->comboMatch->setModel(m_patternTypeDelegate->patternTypeModel());

  m_handlerMapper->setModel(m_factoryModel);
  m_handlerMapper->setSubmitPolicy(QDataWidgetMapper::AutoSubmit);
  m_handlerMapper->addMapping(ui->editName, 0);
  m_handlerMapper->addMapping(ui->comboType, 1, "currentIndex");
  m_handlerMapper->addMapping(ui->editExec, 2);

  m_patternMapper->setModel(m_patternModel);
  m_patternMapper->setSubmitPolicy(QDataWidgetMapper::ManualSubmit);
  m_patternMapper->setItemDelegate(m_patternTypeDelegate);
  m_patternMapper->addMapping(ui->editPattern,
                              OpenWithPatternModel::PatternCol);
  m_patternMapper->addMapping(ui->comboMatch,
                              OpenWithPatternModel::PatternTypeCol);
  m_patternMapper->addMapping(ui->checkCaseSensitive,
                              OpenWithPatternModel::CaseSensitivityCol);

  // Setup executable completion
  QFileSystemModel *fsModel = new QFileSystemModel(this);
  fsModel->setFilter(QDir::Files | QDir::Dirs | QDir::NoDot);
  fsModel->setRootPath(QDir::rootPath());
  QCompleter *fsCompleter = new QCompleter(fsModel, this);
  ui->editExec->setCompleter(fsCompleter);

  // Factory GUI:
  connect(ui->pushAddFactory, SIGNAL(clicked()),
          this, SLOT(addFactory()));
  connect(ui->pushRemoveFactory, SIGNAL(clicked()),
          this, SLOT(removeFactory()));
  connect(ui->comboType, SIGNAL(currentIndexChanged(int)),
          this, SLOT(factoryTypeChanged(int)));
  connect(ui->tableFactories->selectionModel(),
          SIGNAL(selectionChanged(QItemSelection,QItemSelection)),
          this, SLOT(factorySelectionChanged()));

  // Executable GUI:
  connect(ui->pushExec, SIGNAL(clicked()), SLOT(browseExecutable()));
  connect(ui->editExec, SIGNAL(textChanged(QString)), SLOT(testExecutable()));

  // Pattern GUI:
  connect(ui->pushAddPattern, SIGNAL(clicked()),
          this, SLOT(addPattern()));
  connect(ui->pushRemovePattern, SIGNAL(clicked()),
          this, SLOT(removePattern()));
  connect(ui->tablePattern->selectionModel(),
          SIGNAL(selectionChanged(QItemSelection,QItemSelection)),
          this, SLOT(patternSelectionChanged()));
  connect(ui->pushApplyPattern, SIGNAL(clicked()),
          m_patternMapper, SLOT(submit()));
  connect(ui->pushRevertPattern, SIGNAL(clicked()),
          m_patternMapper, SLOT(revert()));
  connect(m_patternModel, SIGNAL(rowsInserted(QModelIndex, int, int)),
          this, SLOT(patternDimensionsChanged()));
  connect(m_patternModel, SIGNAL(rowsRemoved(QModelIndex, int, int)),
          this, SLOT(patternDimensionsChanged()));
  connect(m_patternModel, SIGNAL(modelReset()),
          this, SLOT(patternDimensionsChanged()));

  // Test updates:
  connect(ui->editTest, SIGNAL(textChanged(QString)),
          this, SLOT(checkTestText()));
  connect(m_patternModel, SIGNAL(dataChanged(QModelIndex,QModelIndex)),
          this, SLOT(checkTestText()));
  connect(m_patternModel, SIGNAL(layoutChanged()),
          this, SLOT(checkTestText()));
  connect(ui->tableFactories->selectionModel(),
          SIGNAL(selectionChanged(QItemSelection,QItemSelection)),
          this, SLOT(checkTestText()));

  // handle apply button:
  connect(ui->buttonBox, SIGNAL(clicked(QAbstractButton*)),
          SLOT(buttonBoxClicked(QAbstractButton*)));

  // Mark dirty when the data changes.
  connect(m_factoryModel, SIGNAL(dataChanged(QModelIndex,QModelIndex)),
          SLOT(markDirty()));
  connect(m_factoryModel, SIGNAL(rowsInserted(QModelIndex, int, int)),
          SLOT(markDirty()));
  connect(m_factoryModel, SIGNAL(rowsRemoved(QModelIndex, int, int)),
          SLOT(markDirty()));
  connect(m_patternModel, SIGNAL(dataChanged(QModelIndex,QModelIndex)),
          SLOT(markDirty()));
  connect(m_patternModel, SIGNAL(rowsInserted(QModelIndex, int, int)),
          SLOT(markDirty()));
  connect(m_patternModel, SIGNAL(rowsRemoved(QModelIndex, int, int)),
          SLOT(markDirty()));
}