Ejemplo n.º 1
0
void ReplaceTests::caseSensitiveTest() {
    const int itemsToGenerate = 10;
    DECLARE_MODELS_AND_GENERATE(itemsToGenerate);

    QString replaceFrom = "rePLace";
    QString replaceTo = "Replaced";
    QString initString = "ReplaceMe";
    QString finalString = "ReplacedMe";

    auto flags = Common::SearchFlags::Description |
            Common::SearchFlags::Title |
            Common::SearchFlags::Keywords;

    for (int i = 0; i < itemsToGenerate; i++) {
        Models::ArtworkMetadata *metadata = artItemsModelMock.getArtwork(i);
        metadata->initialize(initString, initString, QStringList() << initString);
    }

    auto artWorksInfo = filteredItemsModel.getSearchablePreviewOriginalItems(replaceFrom, flags);
    std::shared_ptr<Commands::FindAndReplaceCommand> replaceCommand(
                new Commands::FindAndReplaceCommand(artWorksInfo, replaceFrom, replaceTo, flags));
    auto result = commandManagerMock.processCommand(replaceCommand);

    for (int i = 0; i < itemsToGenerate; i++) {
        Models::ArtworkMetadata *metadata = artItemsModelMock.getArtwork(i);
        QCOMPARE(metadata->getDescription(), finalString);
        QCOMPARE(metadata->getTitle(), finalString);
        QCOMPARE(metadata->getKeywords()[0], finalString);
        QVERIFY(metadata->isModified());
    }
}
Ejemplo n.º 2
0
void luConsoleEdit::pasteCommand(int move)
{
	if (move == 0) 
	{
		m_lastCmdIndex = -1;
		return;
	}

	int last = m_commands.GetCount() - 1;

	if (last < 0) return;

	if (move < 0)	//up
	{ 
		if (m_lastCmdIndex == 0) 
			return;
		 else if (m_lastCmdIndex < 0) 
			m_lastCmdIndex = last;
		 else 
			m_lastCmdIndex--;
		
	} 
	else			//down
	{ 
		if (m_lastCmdIndex == last) 
			return;
		else if (m_lastCmdIndex < 0)
			return;
		else
			m_lastCmdIndex++;		
	}

	replaceCommand(m_commands[m_lastCmdIndex]);
}
Ejemplo n.º 3
0
void ReplaceTests::replaceKeywordsTest() {
    const int itemsToGenerate = 10;
    DECLARE_MODELS_AND_GENERATE(itemsToGenerate);

    QString replaceFrom = "keywordOld";
    QString replaceTo = "keywordNew";
    QString replaceToLower = replaceTo.toLower();

    auto flags = Common::SearchFlags::CaseSensitive |
                Common::SearchFlags::Description |
                Common::SearchFlags::Title |
                Common::SearchFlags::Keywords;

    for (int i = 0; i < itemsToGenerate; i++) {
        Models::ArtworkMetadata *metadata = artItemsModelMock.getArtwork(i);
        metadata->initialize(QString("title"), QString("description"),
                             QStringList() << replaceToLower << "dummyKey" << replaceFrom);
    }

    auto artWorksInfo = filteredItemsModel.getSearchablePreviewOriginalItems(replaceFrom, flags);
    std::shared_ptr<Commands::FindAndReplaceCommand> replaceCommand(
                new Commands::FindAndReplaceCommand(artWorksInfo, replaceFrom, replaceTo, flags));
    auto result = commandManagerMock.processCommand(replaceCommand);

    for (int i = 0; i < itemsToGenerate; i++) {
        Models::ArtworkMetadata *metadata = artItemsModelMock.getArtwork(i);
        QCOMPARE(metadata->getDescription(), QString("description"));
        QCOMPARE(metadata->getTitle(), QString("title"));

        QStringList test = metadata->getKeywords();
        QStringList gold;

        gold << replaceToLower << "dummyKey";
        qSort(gold.begin(), gold.end());
        qSort(test.begin(), test.end());

        QCOMPARE(gold, test);
        QVERIFY(metadata->isModified());
    }
}
Ejemplo n.º 4
0
void
KGpgSignKey::replaceCmd(const QString &cmd)
{
	replaceCommand(cmd);
}
Ejemplo n.º 5
0
void luConsoleEdit::OnKeyDown(wxKeyEvent& event)
{
	int ch = event.GetKeyCode();
	wxString str;
	
	if (ch == WXK_UP) 
	{
		pasteCommand(-1);
		return;
	} 
	else if (ch == WXK_DOWN) 
	{
		pasteCommand(+1);
		return;
	} 
	else if (ch == WXK_ESCAPE) 
	{
		pasteCommand(0);
		replaceCommand("");
		return;
	} 
	else if (ch == WXK_LEFT || ch == WXK_BACK) 
	{
		long x = 0, y = 0;
		if (PositionToXY(GetInsertionPoint(), &x, &y))
		{
			if (x <= (int)m_prompt.Length()) 
				return;
		}		
	} 
	else if (ch == WXK_HOME) 
	{
		long x = 0, y = 0;
		if (PositionToXY(GetInsertionPoint(), &x, &y))
		{
			x = m_prompt.Length();
			long pos = XYToPosition(x, y);
			SetSelection(pos, pos);
		}

		return;
	} 
	
	
	if (ch == WXK_RETURN) 
	{
		str = GetLineText(GetNumberOfLines() - 1);
		str.Replace(m_prompt, "");
	}
	else
	{
		event.Skip();
	}

	if (ch == WXK_RETURN) 
	{
		writeLine("\n");

		str.Trim().Trim(false);

		if (!str.IsEmpty()) 
		{
			runCmd(str, false, false);
			addCommand(str);
		} 
				
		writeLine(m_prompt);
		pasteCommand(0);
	}
}