Commits

Zenchreal committed a087e40

Added new checkboxes to find dialog

Comments (0)

Files changed (5)

src/forms/FindDialog.ui

     <x>0</x>
     <y>0</y>
     <width>388</width>
-    <height>198</height>
+    <height>236</height>
    </rect>
   </property>
   <property name="windowTitle">
       <widget class="HexEditorWidget" name="bytesEdit"/>
      </item>
      <item>
-      <widget class="QCheckBox" name="checkBox">
+      <widget class="QCheckBox" name="backwardsCheckBox">
        <property name="text">
-        <string>CheckBox</string>
+        <string>Search backwards</string>
+       </property>
+      </widget>
+     </item>
+     <item>
+      <widget class="QCheckBox" name="caseInsensitiveCheckBox">
+       <property name="text">
+        <string>Case insensitive</string>
        </property>
       </widget>
      </item>

src/ui/FindDialog.cpp

 
 FindDialog::FindDialog(QWidget* parent) :
     QDialog(parent),
-    ui(new Ui::FindDialog)
+    ui(new Ui::FindDialog),
+    backwardsResult(false),
+    caseInsensitiveResult(false)
 {
 	ui->setupUi(this);
 
 	delete ui;
 }
 
+void FindDialog::setBackwards(bool flag)
+{
+	ui->backwardsCheckBox->setChecked(flag);
+}
+
+void FindDialog::setCaseInsensitive(bool flag)
+{
+	ui->caseInsensitiveCheckBox->setChecked(flag);
+}
+
 void FindDialog::setBytes(const QByteArray& data)
 {
 	// Toss out the old Document and create a new one
 	ui->bytesEdit->putBytes(data);
 }
 
-QByteArray FindDialog::result() const
+bool FindDialog::backwards() const
+{
+	return backwardsResult;
+}
+
+bool FindDialog::caseInsensitive() const
+{
+	return caseInsensitiveResult;
+}
+
+QByteArray FindDialog::bytes() const
 {
 	return resultBytes;
 }
 
 void FindDialog::saveResult()
 {
+	backwardsResult = ui->backwardsCheckBox->isChecked();
+	caseInsensitiveResult = ui->caseInsensitiveCheckBox->isChecked();
+	
 	resultBytes = ui->bytesEdit->getBytes(0, ui->bytesEdit->document()->size());
 }

src/ui/FindDialog.hpp

 public:
 	explicit FindDialog(QWidget* parent = nullptr);
 	virtual ~FindDialog();
-	void setBytes(const QByteArray& data); // This function is slightly bugged
-	QByteArray result() const;
+	void setBackwards(bool flag);
+	void setCaseInsensitive(bool flag);
+	void setBytes(const QByteArray& data);
+	bool backwards() const;
+	bool caseInsensitive() const;
+	QByteArray bytes() const;
     
 protected slots:
 	void saveResult();
 
 private:
 	Ui::FindDialog* ui;
+	bool backwardsResult;
+	bool caseInsensitiveResult;
 	QByteArray resultBytes;
 };

src/ui/MainWindow.cpp

 MainWindow::MainWindow():
 	app(nullptr),
 	editor(nullptr),
+	findBackwards(false),
+	findCaseInsensitive(false),
 	inspector(nullptr),
 	marksWindow(nullptr)
 {
 		dlg.setBytes(preFind);
 	}
 
+	dlg.setBackwards(findBackwards);
+	dlg.setCaseInsensitive(findCaseInsensitive);
+
 	if (dlg.exec() == QDialog::Accepted)
 	{
-		findPattern = dlg.result();
+		findBackwards = dlg.backwards();
+		findCaseInsensitive = dlg.caseInsensitive();
+		
+		findPattern = dlg.bytes();
 		if (findPattern.size() < 1)
 		{
 			//statusMessage(tr("empty string"));

src/ui/MainWindow.hpp

 
 	// Current find options (for find next/previous);
 	QByteArray findPattern;
+	bool findBackwards;
+	bool findCaseInsensitive;
 	
 	// Other windows
 	InspectorWindow* inspector;