Procházet zdrojové kódy

New dialog Fb2FindDlg

Kandrashin Denis před 13 roky
rodič
revize
340fbed399
7 změnil soubory, kde provedl 227 přidání a 10 odebrání
  1. 6 5
      fb2edit.pro
  2. 22 1
      source/fb2dlgs.cpp
  3. 16 3
      source/fb2dlgs.hpp
  4. 173 0
      source/fb2find.ui
  5. 2 0
      source/fb2main.cpp
  6. 7 1
      source/fb2view.cpp
  7. 1 0
      source/fb2view.hpp

+ 6 - 5
fb2edit.pro

@@ -9,9 +9,9 @@ HEADERS = \
     source/fb2temp.hpp \
     source/fb2tree.hpp \
     source/fb2view.hpp \
-    source/fb2note.hpp \
     source/fb2utils.h \
-    source/fb2save.hpp
+    source/fb2save.hpp \
+    source/fb2dlgs.hpp
 
 SOURCES = \
     source/fb2app.cpp \
@@ -25,8 +25,8 @@ SOURCES = \
     source/fb2view.cpp \
     source/fb2xml.cpp \
     source/fb2xml2.cpp \
-    source/fb2note.cpp \
-    source/fb2utils.cpp
+    source/fb2utils.cpp \
+    source/fb2dlgs.cpp
 
 RESOURCES = \
     3rdparty/gnome/gnome.qrc \
@@ -59,4 +59,5 @@ if (unix) {
 }
 
 FORMS += \
-    source/fb2note.ui
+    source/fb2note.ui \
+    source/fb2find.ui

+ 22 - 1
source/fb2note.cpp → source/fb2dlgs.cpp

@@ -1,8 +1,29 @@
-#include "fb2note.hpp"
+#include "fb2dlgs.hpp"
 #include "fb2view.hpp"
 #include "fb2utils.h"
+#include "ui_fb2find.h"
 #include "ui_fb2note.h"
 
+//---------------------------------------------------------------------------
+//  Fb2FindDlg
+//---------------------------------------------------------------------------
+
+Fb2FindDlg::Fb2FindDlg(QWidget *parent) :
+    QDialog(parent),
+    ui(new Ui::Fb2Find)
+{
+    ui->setupUi(this);
+}
+
+Fb2FindDlg::~Fb2FindDlg()
+{
+    delete ui;
+}
+
+//---------------------------------------------------------------------------
+//  Fb2NoteDlg
+//---------------------------------------------------------------------------
+
 Fb2NoteDlg::Fb2NoteDlg(Fb2WebView &view, QWidget *parent) :
     QDialog(parent),
     ui(new Ui::Fb2Note)

+ 16 - 3
source/fb2note.hpp → source/fb2dlgs.hpp

@@ -1,5 +1,5 @@
-#ifndef FB2NOTE_H
-#define FB2NOTE_H
+#ifndef FB2DLGS_H
+#define FB2DLGS_H
 
 #include <QDialog>
 
@@ -7,6 +7,7 @@ class Fb2WebView;
 
 namespace Ui {
 class Fb2Note;
+class Fb2Find;
 }
 
 class Fb2NoteDlg : public QDialog
@@ -21,4 +22,16 @@ private:
     Ui::Fb2Note *ui;
 };
 
-#endif // FB2NOTE_H
+class Fb2FindDlg : public QDialog
+{
+    Q_OBJECT
+
+public:
+    explicit Fb2FindDlg(QWidget *parent = 0);
+    virtual ~Fb2FindDlg();
+
+private:
+    Ui::Fb2Find *ui;
+};
+
+#endif // FB2DLGS_H

+ 173 - 0
source/fb2find.ui

@@ -0,0 +1,173 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>Fb2Find</class>
+ <widget class="QDialog" name="Fb2Find">
+  <property name="geometry">
+   <rect>
+    <x>0</x>
+    <y>0</y>
+    <width>347</width>
+    <height>122</height>
+   </rect>
+  </property>
+  <property name="sizePolicy">
+   <sizepolicy hsizetype="Minimum" vsizetype="Minimum">
+    <horstretch>0</horstretch>
+    <verstretch>0</verstretch>
+   </sizepolicy>
+  </property>
+  <property name="windowTitle">
+   <string>Find</string>
+  </property>
+  <layout class="QGridLayout" name="gridLayout" rowstretch="0,0,0,1" columnstretch="0,0,1,0">
+   <property name="sizeConstraint">
+    <enum>QLayout::SetMinimumSize</enum>
+   </property>
+   <item row="0" column="0" colspan="3">
+    <layout class="QHBoxLayout" name="horizontalLayout1">
+     <property name="sizeConstraint">
+      <enum>QLayout::SetMinimumSize</enum>
+     </property>
+     <item>
+      <widget class="QLabel" name="label">
+       <property name="sizePolicy">
+        <sizepolicy hsizetype="Preferred" vsizetype="Expanding">
+         <horstretch>0</horstretch>
+         <verstretch>0</verstretch>
+        </sizepolicy>
+       </property>
+       <property name="text">
+        <string>Find what:</string>
+       </property>
+      </widget>
+     </item>
+     <item>
+      <widget class="QLineEdit" name="editText"/>
+     </item>
+    </layout>
+   </item>
+   <item row="0" column="3" rowspan="4">
+    <layout class="QVBoxLayout" name="verticalLayout2">
+     <item>
+      <widget class="QPushButton" name="btnFind">
+       <property name="text">
+        <string>Find Next</string>
+       </property>
+       <property name="default">
+        <bool>true</bool>
+       </property>
+      </widget>
+     </item>
+     <item>
+      <widget class="QPushButton" name="btnClose">
+       <property name="text">
+        <string>Close</string>
+       </property>
+      </widget>
+     </item>
+     <item>
+      <spacer name="verticallSpacer">
+       <property name="orientation">
+        <enum>Qt::Vertical</enum>
+       </property>
+       <property name="sizeType">
+        <enum>QSizePolicy::Expanding</enum>
+       </property>
+       <property name="sizeHint" stdset="0">
+        <size>
+         <width>20</width>
+         <height>40</height>
+        </size>
+       </property>
+      </spacer>
+     </item>
+    </layout>
+   </item>
+   <item row="2" column="1">
+    <widget class="QGroupBox" name="groupDirect">
+     <property name="title">
+      <string>&amp;Direction</string>
+     </property>
+     <layout class="QHBoxLayout" name="horizontalLayout3">
+      <item>
+       <widget class="QRadioButton" name="radioUp">
+        <property name="text">
+         <string>&amp;Up</string>
+        </property>
+       </widget>
+      </item>
+      <item>
+       <widget class="QRadioButton" name="radioDown">
+        <property name="text">
+         <string>&amp;Down</string>
+        </property>
+       </widget>
+      </item>
+     </layout>
+    </widget>
+   </item>
+   <item row="2" column="0">
+    <layout class="QVBoxLayout" name="verticalLayout">
+     <item>
+      <widget class="QCheckBox" name="checkCase">
+       <property name="text">
+        <string>&amp;Case sensitive </string>
+       </property>
+      </widget>
+     </item>
+     <item>
+      <widget class="QCheckBox" name="checkHigh">
+       <property name="text">
+        <string>&amp;Highlights all</string>
+       </property>
+      </widget>
+     </item>
+    </layout>
+   </item>
+   <item row="2" column="2">
+    <spacer name="horizontalSpacer">
+     <property name="orientation">
+      <enum>Qt::Horizontal</enum>
+     </property>
+     <property name="sizeType">
+      <enum>QSizePolicy::Expanding</enum>
+     </property>
+     <property name="sizeHint" stdset="0">
+      <size>
+       <width>20</width>
+       <height>40</height>
+      </size>
+     </property>
+    </spacer>
+   </item>
+  </layout>
+ </widget>
+ <tabstops>
+  <tabstop>editText</tabstop>
+  <tabstop>checkCase</tabstop>
+  <tabstop>checkHigh</tabstop>
+  <tabstop>radioUp</tabstop>
+  <tabstop>radioDown</tabstop>
+  <tabstop>btnFind</tabstop>
+  <tabstop>btnClose</tabstop>
+ </tabstops>
+ <resources/>
+ <connections>
+  <connection>
+   <sender>btnClose</sender>
+   <signal>clicked()</signal>
+   <receiver>Fb2Find</receiver>
+   <slot>close()</slot>
+   <hints>
+    <hint type="sourcelabel">
+     <x>298</x>
+     <y>53</y>
+    </hint>
+    <hint type="destinationlabel">
+     <x>173</x>
+     <y>60</y>
+    </hint>
+   </hints>
+  </connection>
+ </connections>
+</ui>

+ 2 - 0
source/fb2main.cpp

@@ -666,6 +666,8 @@ void Fb2MainWindow::viewText()
     connect(actionCopy, SIGNAL(triggered()), textEdit->pageAction(QWebPage::Copy), SIGNAL(triggered()));
     connect(actionPaste, SIGNAL(triggered()), textEdit->pageAction(QWebPage::Paste), SIGNAL(triggered()));
 
+    connect(actionFind, SIGNAL(triggered()), textEdit, SLOT(findText()));
+
     connect(actionTextBold, SIGNAL(triggered()), textEdit->pageAction(QWebPage::ToggleBold), SIGNAL(triggered()));
     connect(actionTextItalic, SIGNAL(triggered()), textEdit->pageAction(QWebPage::ToggleItalic), SIGNAL(triggered()));
     connect(actionTextStrike, SIGNAL(triggered()), textEdit->pageAction(QWebPage::ToggleStrikethrough), SIGNAL(triggered()));

+ 7 - 1
source/fb2view.cpp

@@ -1,5 +1,5 @@
 #include "fb2view.hpp"
-#include "fb2note.hpp"
+#include "fb2dlgs.hpp"
 #include "fb2read.hpp"
 #include "fb2save.hpp"
 #include "fb2utils.h"
@@ -272,6 +272,12 @@ bool Fb2WebView::SupChecked()
     return pageAction(QWebPage::ToggleSuperscript)->isChecked();
 }
 
+void Fb2WebView::findText()
+{
+    Fb2FindDlg dlg(this);
+    dlg.exec();
+}
+
 void Fb2WebView::insertImage()
 {
     QString filters;

+ 1 - 0
source/fb2view.hpp

@@ -91,6 +91,7 @@ public slots:
     void data(QString name, QByteArray data);
     void html(QString name, QString html);
     void linkHovered(const QString &link, const QString &title, const QString &textContent);
+    void findText();
     void showInspector();
     void insertImage();
     void insertNote();