Move find dialog layout code into separate ui file
authorRafał Długołęcki <rafal@dlugolecki.net.pl>
Thu, 28 Jan 2016 22:38:37 +0000 (23:38 +0100)
committerRafał Długołęcki <rafal@dlugolecki.net.pl>
Thu, 28 Jan 2016 22:38:37 +0000 (23:38 +0100)
Makefile.am
src/edit/FindDialog.cpp [new file with mode: 0644]
src/edit/FindDialog.h [new file with mode: 0644]
src/edit/editor.cpp
src/edit/ui/dialogs/FindDialog.ui [new file with mode: 0644]

index a47ee0d06130b4ff3ea781528d2343b84814c4ba..9aa17e31a933e02e1a7ebd86597149c2fdb5438f 100644 (file)
@@ -165,7 +165,8 @@ bin_logedit_SOURCES = \
        src/edit/editor.moc.cpp \
        src/edit/ProgramStructureDialog.cpp \
        src/edit/UnitStructureDialog.cpp \
-       src/edit/PreferencesDialog.cpp
+       src/edit/PreferencesDialog.cpp \
+       src/edit/FindDialog.cpp
 bin_logedit_CPPFLAGS = $(bin_logedit_CFLAGS)
 bin_logedit_LDADD = $(bin_logedit_LIBS)
 bin_logeditdir = src/edit
@@ -177,14 +178,17 @@ bin_logedit_HEADERS =\
        src/edit/UnitStructureDialog.h \
        src/edit/ui/dialogs/UnitStructureDialog.h \
        src/edit/PreferencesDialog.h \
-       src/edit/ui/dialogs/PreferencesDialog.h
+       src/edit/ui/dialogs/PreferencesDialog.h \
+       src/edit/FindDialog.h \
+       src/edit/ui/dialogs/FindDialog.h
 
 src/edit/editor.moc.cpp: \
                src/edit/editor.h \
                src/edit/ui/editor.h \
                src/edit/ui/dialogs/ProgramStructureDialog.h \
                src/edit/ui/dialogs/UnitStructureDialog.h \
-               src/edit/ui/dialogs/PreferencesDialog.h
+               src/edit/ui/dialogs/PreferencesDialog.h \
+               src/edit/ui/dialogs/FindDialog.h
        moc-qt4 src/edit/editor.h -o src/edit/editor.moc.cpp
 #      $(MOC) src/edit/editor.h -o src/edit/editor.moc.cpp
 
@@ -200,6 +204,9 @@ src/edit/ui/dialogs/UnitStructureDialog.h:
 src/edit/ui/dialogs/PreferencesDialog.h:
        uic src/edit/ui/dialogs/PreferencesDialog.ui -o src/edit/ui/dialogs/PreferencesDialog.h
 
+src/edit/ui/dialogs/FindDialog.h:
+       uic src/edit/ui/dialogs/FindDialog.ui -o src/edit/ui/dialogs/FindDialog.h
+
 
 clean-logedit-extra:
        rm -f src/edit/ui/dialogs/*.h
diff --git a/src/edit/FindDialog.cpp b/src/edit/FindDialog.cpp
new file mode 100644 (file)
index 0000000..267ae24
--- /dev/null
@@ -0,0 +1,33 @@
+#include "FindDialog.h"
+
+namespace loglan {
+namespace vlp {
+namespace dialog {
+
+
+FindDialog::FindDialog(QWidget * parent)
+       : QDialog(parent)
+{
+       setupUi(this);
+       
+       connect(buttonBox, SIGNAL(accepted()), this, SLOT(accept()));
+       connect(buttonBox, SIGNAL(rejected()), this, SLOT(reject()));
+}
+
+FindDialog::~FindDialog()
+{
+}
+
+bool FindDialog::isCaseSensitive()
+{
+       return caseSensitive->isChecked();
+}
+
+QString FindDialog::getSearchText()
+{
+       return lineEdit->text();
+}
+
+}
+}
+}
diff --git a/src/edit/FindDialog.h b/src/edit/FindDialog.h
new file mode 100644 (file)
index 0000000..b0c6d5e
--- /dev/null
@@ -0,0 +1,49 @@
+#ifndef _VLP_EDITOR_FINDEDIALOG_H
+#define _VLP_EDITOR_FINDEDIALOG_H
+
+#include <QtGui/QDialog>
+#include <QtCore/QString>
+
+
+#include "ui/dialogs/FindDialog.h"
+
+namespace loglan {
+namespace vlp {
+namespace dialog {
+
+/**
+ * Find Dialog class
+ * Displays dialog for findinf text in source code
+ */
+class FindDialog : public QDialog, private Ui::FindDialog {
+public:
+       /**
+        * Class constructor
+        */
+       FindDialog(QWidget * parent = 0);
+
+       /**
+        * Class destuctor
+        */
+       ~FindDialog();
+
+       /**
+        * Gets user-passed program name
+        * 
+        * @return program name entered in dialog
+        */
+       bool isCaseSensitive();
+
+       /**
+        * Gets program code template
+        * 
+        * @return program code template with program name
+        */
+       QString getSearchText();
+};
+
+}
+}
+}
+
+#endif /* _VLP_EDITOR_FINDEDIALOG_H */
index a64d42d58bebb304ab6e964ca6f2fdeb52328c70..c697a32827bf4261e67f7394a9cc2ce3ca982f09 100644 (file)
@@ -17,6 +17,7 @@
 #include "ProgramStructureDialog.h"
 #include "UnitStructureDialog.h"
 #include "PreferencesDialog.h"
+#include "FindDialog.h"
 
 #include "editor.h"
 
@@ -248,44 +249,18 @@ void Editor::on_actionClear_all_triggered()
  */
 void Editor::on_actionFind_triggered()
 {
-       QDialog dlg(this, Qt::Dialog);
+       dialog::FindDialog dialog(this);
 
-       QLineEdit *tmpQLineEdit;
-       tmpQLineEdit = new QLineEdit("", &dlg);
-       tmpQLineEdit->setGeometry(60, 10, 180, 30);
-
-       QLabel *tmpQLabel;
-       tmpQLabel = new QLabel(&dlg);
-       tmpQLabel->setGeometry(10, 10, 50, 30);
-
-       tmpQLabel->setText("Text:");
-
-       QCheckBox *tmpQRadioButton;
-       tmpQRadioButton = new QCheckBox("Case sensitive", &dlg);
-       tmpQRadioButton->setGeometry(70, 50, 150, 30);
-       tmpQRadioButton->setAutoRepeat(FALSE);
-
-       QPushButton *okbtn, *cbtn;
-       okbtn = new QPushButton("Find", &dlg);
-       okbtn->setGeometry(260, 10, 100, 30);
-       okbtn->setDefault(TRUE);
-       connect(okbtn,SIGNAL(clicked()), &dlg, SLOT(accept()));
-
-       cbtn = new QPushButton("Close", &dlg);
-       cbtn->setGeometry(260, 50, 100, 30);
-       connect(cbtn, SIGNAL(clicked()), &dlg, SLOT(reject()));
-
-       dlg.resize(380, 90);
-
-       if (dlg.exec()) {
-               sensitive = tmpQRadioButton->isChecked();
-               find_text = tmpQLineEdit->text();
+       if (dialog.exec()) {
+               sensitive = dialog.isCaseSensitive();
+               find_text = dialog.getSearchText();
                
                QTextDocument::FindFlags flags = 0;
                
                if (sensitive) {
                        flags |= QTextDocument::FindCaseSensitively;
                }
+
                editor->find(find_text, flags);
        }
 }
diff --git a/src/edit/ui/dialogs/FindDialog.ui b/src/edit/ui/dialogs/FindDialog.ui
new file mode 100644 (file)
index 0000000..2c7da0d
--- /dev/null
@@ -0,0 +1,111 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>FindDialog</class>
+ <widget class="QDialog" name="FindDialog">
+  <property name="geometry">
+   <rect>
+    <x>0</x>
+    <y>0</y>
+    <width>355</width>
+    <height>80</height>
+   </rect>
+  </property>
+  <property name="windowTitle">
+   <string>Dialog</string>
+  </property>
+  <layout class="QHBoxLayout" name="horizontalLayout_2">
+   <item>
+    <layout class="QVBoxLayout" name="verticalLayout">
+     <property name="leftMargin">
+      <number>7</number>
+     </property>
+     <property name="topMargin">
+      <number>6</number>
+     </property>
+     <property name="rightMargin">
+      <number>6</number>
+     </property>
+     <property name="bottomMargin">
+      <number>6</number>
+     </property>
+     <item>
+      <layout class="QHBoxLayout" name="horizontalLayout">
+       <property name="spacing">
+        <number>10</number>
+       </property>
+       <item>
+        <widget class="QLabel" name="label">
+         <property name="text">
+          <string>Text</string>
+         </property>
+        </widget>
+       </item>
+       <item>
+        <widget class="QLineEdit" name="lineEdit">
+         <property name="minimumSize">
+          <size>
+           <width>200</width>
+           <height>0</height>
+          </size>
+         </property>
+        </widget>
+       </item>
+      </layout>
+     </item>
+     <item>
+      <widget class="QCheckBox" name="caseSensitive">
+       <property name="text">
+        <string>Case sensitive</string>
+       </property>
+      </widget>
+     </item>
+    </layout>
+   </item>
+   <item>
+    <widget class="QDialogButtonBox" name="buttonBox">
+     <property name="orientation">
+      <enum>Qt::Vertical</enum>
+     </property>
+     <property name="standardButtons">
+      <set>QDialogButtonBox::Close|QDialogButtonBox::Ok</set>
+     </property>
+    </widget>
+   </item>
+  </layout>
+ </widget>
+ <resources/>
+ <connections>
+  <connection>
+   <sender>buttonBox</sender>
+   <signal>accepted()</signal>
+   <receiver>FindDialog</receiver>
+   <slot>accept()</slot>
+   <hints>
+    <hint type="sourcelabel">
+     <x>248</x>
+     <y>254</y>
+    </hint>
+    <hint type="destinationlabel">
+     <x>157</x>
+     <y>274</y>
+    </hint>
+   </hints>
+  </connection>
+  <connection>
+   <sender>buttonBox</sender>
+   <signal>rejected()</signal>
+   <receiver>FindDialog</receiver>
+   <slot>reject()</slot>
+   <hints>
+    <hint type="sourcelabel">
+     <x>316</x>
+     <y>260</y>
+    </hint>
+    <hint type="destinationlabel">
+     <x>286</x>
+     <y>274</y>
+    </hint>
+   </hints>
+  </connection>
+ </connections>
+</ui>