From: Rafał Długołęcki Date: Thu, 28 Jan 2016 22:38:37 +0000 (+0100) Subject: Move find dialog layout code into separate ui file X-Git-Tag: 3.4-b1~23 X-Git-Url: https://git.dlugolecki.net.pl/?a=commitdiff_plain;h=b74545f199d4cf52c1b40a3dab7be65b20f68a26;p=vlp.git Move find dialog layout code into separate ui file --- diff --git a/Makefile.am b/Makefile.am index a47ee0d..9aa17e3 100644 --- a/Makefile.am +++ b/Makefile.am @@ -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 index 0000000..267ae24 --- /dev/null +++ b/src/edit/FindDialog.cpp @@ -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 index 0000000..b0c6d5e --- /dev/null +++ b/src/edit/FindDialog.h @@ -0,0 +1,49 @@ +#ifndef _VLP_EDITOR_FINDEDIALOG_H +#define _VLP_EDITOR_FINDEDIALOG_H + +#include +#include + + +#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 */ diff --git a/src/edit/editor.cpp b/src/edit/editor.cpp index a64d42d..c697a32 100644 --- a/src/edit/editor.cpp +++ b/src/edit/editor.cpp @@ -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 index 0000000..2c7da0d --- /dev/null +++ b/src/edit/ui/dialogs/FindDialog.ui @@ -0,0 +1,111 @@ + + + FindDialog + + + + 0 + 0 + 355 + 80 + + + + Dialog + + + + + + 7 + + + 6 + + + 6 + + + 6 + + + + + 10 + + + + + Text + + + + + + + + 200 + 0 + + + + + + + + + + Case sensitive + + + + + + + + + Qt::Vertical + + + QDialogButtonBox::Close|QDialogButtonBox::Ok + + + + + + + + + buttonBox + accepted() + FindDialog + accept() + + + 248 + 254 + + + 157 + 274 + + + + + buttonBox + rejected() + FindDialog + reject() + + + 316 + 260 + + + 286 + 274 + + + + +