/*
Copyright (C) 2006 - 2009 Evan Teran
                   eteran@alum.rit.edu

This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
*/

#include "BinarySearcher.h"
#include "DialogBinaryString.h"
#include "DialogASCIIString.h"
#include "Debugger.h"
#include <QMenu>

//------------------------------------------------------------------------------
// Name: 
// Desc: 
//------------------------------------------------------------------------------
BinarySearcher::BinarySearcher() : m_Menu(0) {
}

//------------------------------------------------------------------------------
// Name: 
// Desc: 
//------------------------------------------------------------------------------
BinarySearcher::~BinarySearcher() {
}

//------------------------------------------------------------------------------
// Name: 
// Desc: 
//------------------------------------------------------------------------------
QMenu *BinarySearcher::menu(QWidget *parent) {
	if(m_Menu == 0) {
		m_Menu = new QMenu(tr("BinarySearcher"), parent);
		m_Menu->addAction(tr("&Binary String Search"), this, SLOT(doMenu()), QKeySequence(tr("Ctrl+F")));
	}
	
	return m_Menu;
}

//------------------------------------------------------------------------------
// Name: 
// Desc: 
//------------------------------------------------------------------------------
QList<QAction *> BinarySearcher::stackViewContextMenu() {
	
	QList<QAction *> ret;
	
	QAction *const actFind = new QAction(tr("&Find ASCII String"), this);
	connect(actFind, SIGNAL(triggered()), this, SLOT(mnuStackFindASCII()));
	ret << actFind;

	return ret;
}

//------------------------------------------------------------------------------
// Name: 
// Desc: 
//------------------------------------------------------------------------------
void BinarySearcher::doMenu() {
	static QDialog *const dialog = new DialogBinaryString(edb::v1::debuggerUI);
	dialog->show();
}

//------------------------------------------------------------------------------
// Name: 
// Desc: 
//------------------------------------------------------------------------------
void BinarySearcher::mnuStackFindASCII() {
	static QDialog *const dialog = new DialogASCIIString(edb::v1::debuggerUI);
	dialog->show();
}

Q_EXPORT_PLUGIN2(BinarySearcher, BinarySearcher)
