Ejemplo n.º 1
0
	void RegexpMatcherUi::on_ModifyRegexpButton__released ()
	{
		QModelIndex index = Ui_.Regexps_->selectionModel ()->currentIndex ();
		if (!index.isValid ())
			return;
	
		bool success = false;
		RegexpMatcherManager::titlebody_t pair = RegexpMatcherManager::Instance ().GetTitleBody (index);
		QString title = pair.first,
				body = pair.second;
		do
		{
			success = true;
			SingleRegexp srx (title, body, true, this);
			if (srx.exec () == QDialog::Rejected)
				return;
	
			body = srx.GetBody ();
	
			try
			{
				RegexpMatcherManager::Instance ().Modify (title, body);
			}
			catch (const RegexpMatcherManager::AlreadyExists&)
			{
				QMessageBox::critical (this,
						tr ("LeechCraft"),
						tr ("This title "
							"matcher regexp already exists. Specify another "
							"one or modify existing title matcher regexp's "
							"body extractor."));
				success = false;
			}
			catch (const RegexpMatcherManager::Malformed&)
			{
				QMessageBox::critical (this,
						tr ("LeechCraft"),
						tr ("Either title"
							" matcher or body extractor is malformed."));
				success = false;
			}
		}
		while (!success);
	}
Ejemplo n.º 2
0
	void RegexpMatcherUi::on_AddRegexpButton__released ()
	{
		bool success = false;
		QString title, body;
		do
		{
			success = true;
			SingleRegexp srx (title, body, false, this);
			if (srx.exec () == QDialog::Rejected)
				return;
	
			title = srx.GetTitle ();
			body = srx.GetBody ();
	
			try
			{
				RegexpMatcherManager::Instance ().Add (title, body);
			}
			catch (const RegexpMatcherManager::AlreadyExists&)
			{
				QMessageBox::critical (this,
						tr ("LeechCraft"),
						tr ("This title "
							"matcher regexp already exists. Specify another "
							"one or modify existing title matcher regexp's "
							"body extractor."));
				success = false;
			}
			catch (const RegexpMatcherManager::Malformed&)
			{
				QMessageBox::critical (this,
						tr ("LeechCraft"),
						tr ("Either title"
							" matcher or body extractor is malformed."));
				success = false;
			}
		}
		while (!success);
	}