Browse Source

Images list view

Kandrashin Denis 13 years ago
parent
commit
e9520c4e3b
7 changed files with 113 additions and 7 deletions
  1. 41 3
      source/fb2main.cpp
  2. 12 1
      source/fb2main.hpp
  3. 18 0
      source/fb2temp.cpp
  4. 17 1
      source/fb2temp.hpp
  5. 0 1
      source/fb2tree.cpp
  6. BIN
      source/ts/ru.qm
  7. 25 1
      source/ts/ru.ts

+ 41 - 3
source/fb2main.cpp

@@ -12,6 +12,21 @@
 #include "fb2head.hpp"
 #include "fb2head.hpp"
 #include "fb2utils.h"
 #include "fb2utils.h"
 
 
+//---------------------------------------------------------------------------
+//  FbDockWidget
+//---------------------------------------------------------------------------
+
+FbDockWidget::FbDockWidget(const QString &title, QWidget *parent, Qt::WindowFlags flags)
+    : QDockWidget(title, parent, flags)
+{
+    setFeatures(QDockWidget::AllDockWidgetFeatures);
+    setAttribute(Qt::WA_DeleteOnClose);
+}
+
+//---------------------------------------------------------------------------
+//  FbMainWindow
+//---------------------------------------------------------------------------
+
 FbMainWindow::FbMainWindow(const QString &filename, ViewMode mode)
 FbMainWindow::FbMainWindow(const QString &filename, ViewMode mode)
     : QMainWindow()
     : QMainWindow()
     , textFrame(0)
     , textFrame(0)
@@ -20,6 +35,7 @@ FbMainWindow::FbMainWindow(const QString &filename, ViewMode mode)
     , noteEdit(0)
     , noteEdit(0)
     , toolEdit(0)
     , toolEdit(0)
     , dockTree(0)
     , dockTree(0)
+    , dockImgs(0)
     , inspector(0)
     , inspector(0)
     , messageEdit(0)
     , messageEdit(0)
     , isSwitched(false)
     , isSwitched(false)
@@ -75,6 +91,11 @@ void FbMainWindow::treeDestroyed()
     dockTree = NULL;
     dockTree = NULL;
 }
 }
 
 
+void FbMainWindow::imgsDestroyed()
+{
+    dockImgs = NULL;
+}
+
 bool FbMainWindow::loadXML(const QString &filename)
 bool FbMainWindow::loadXML(const QString &filename)
 {
 {
     if (!filename.isEmpty()) {
     if (!filename.isEmpty()) {
@@ -417,6 +438,10 @@ void FbMainWindow::createActions()
     connect(act, SIGNAL(triggered()), this, SLOT(viewTree()));
     connect(act, SIGNAL(triggered()), this, SLOT(viewTree()));
     menu->addAction(act);
     menu->addAction(act);
 
 
+    act = new QAction(tr("&Pictures"), this);
+    connect(act, SIGNAL(triggered()), this, SLOT(viewImgs()));
+    menu->addAction(act);
+
     actionInspect = act = new QAction(tr("&Web inspector"), this);
     actionInspect = act = new QAction(tr("&Web inspector"), this);
     menu->addAction(act);
     menu->addAction(act);
 
 
@@ -443,15 +468,23 @@ void FbMainWindow::openSettings()
 void FbMainWindow::createTree()
 void FbMainWindow::createTree()
 {
 {
     if (textFrame && centralWidget() == textFrame) {
     if (textFrame && centralWidget() == textFrame) {
-        dockTree = new QDockWidget(tr("Contents"), this);
-        dockTree->setAttribute(Qt::WA_DeleteOnClose);
-        dockTree->setFeatures(QDockWidget::AllDockWidgetFeatures);
+        dockTree = new FbDockWidget(tr("Contents"), this);
         dockTree->setWidget(new FbTreeWidget(textFrame->view, this));
         dockTree->setWidget(new FbTreeWidget(textFrame->view, this));
         connect(dockTree, SIGNAL(destroyed()), SLOT(treeDestroyed()));
         connect(dockTree, SIGNAL(destroyed()), SLOT(treeDestroyed()));
         addDockWidget(Qt::LeftDockWidgetArea, dockTree);
         addDockWidget(Qt::LeftDockWidgetArea, dockTree);
     }
     }
 }
 }
 
 
+void FbMainWindow::createImgs()
+{
+    if (textFrame && centralWidget() == textFrame) {
+        dockImgs = new FbDockWidget(tr("Pictures"), this);
+        dockImgs->setWidget(new FbListWidget(textFrame->view, this));
+        connect(dockImgs, SIGNAL(destroyed()), SLOT(imgsDestroyed()));
+        addDockWidget(Qt::RightDockWidgetArea, dockImgs);
+    }
+}
+
 void FbMainWindow::selectionChanged()
 void FbMainWindow::selectionChanged()
 {
 {
     actionCut->setEnabled(textFrame->view.CutEnabled());
     actionCut->setEnabled(textFrame->view.CutEnabled());
@@ -790,6 +823,11 @@ void FbMainWindow::viewTree()
     if (dockTree) dockTree->deleteLater(); else createTree();
     if (dockTree) dockTree->deleteLater(); else createTree();
 }
 }
 
 
+void FbMainWindow::viewImgs()
+{
+    if (dockImgs) dockImgs->deleteLater(); else createImgs();
+}
+
 void FbMainWindow::clipboardDataChanged()
 void FbMainWindow::clipboardDataChanged()
 {
 {
     if (const QMimeData *md = QApplication::clipboard()->mimeData()) {
     if (const QMimeData *md = QApplication::clipboard()->mimeData()) {

+ 12 - 1
source/fb2main.hpp

@@ -2,10 +2,10 @@
 #define FB2MAIN_H
 #define FB2MAIN_H
 
 
 #include <QMainWindow>
 #include <QMainWindow>
+#include <QDockWidget>
 
 
 QT_BEGIN_NAMESPACE
 QT_BEGIN_NAMESPACE
 class QAction;
 class QAction;
-class QDockWidget;
 class QFile;
 class QFile;
 class QMenu;
 class QMenu;
 class QModelIndex;
 class QModelIndex;
@@ -20,6 +20,13 @@ class FbHeadView;
 class FbTextFrame;
 class FbTextFrame;
 class FbTextEdit;
 class FbTextEdit;
 
 
+class FbDockWidget : public QDockWidget
+{
+    Q_OBJECT
+public:
+    explicit FbDockWidget(const QString &title, QWidget *parent = 0, Qt::WindowFlags flags = 0);
+};
+
 class FbMainWindow : public QMainWindow
 class FbMainWindow : public QMainWindow
 {
 {
     Q_OBJECT
     Q_OBJECT
@@ -44,12 +51,14 @@ private slots:
     void documentWasModified();
     void documentWasModified();
     void checkScintillaUndo();
     void checkScintillaUndo();
     void treeDestroyed();
     void treeDestroyed();
+    void imgsDestroyed();
     void logDestroyed();
     void logDestroyed();
     void logShowed();
     void logShowed();
     void viewCode();
     void viewCode();
     void viewText();
     void viewText();
     void viewHead();
     void viewHead();
     void viewTree();
     void viewTree();
+    void viewImgs();
 
 
     void cleanChanged(bool clean);
     void cleanChanged(bool clean);
     void canUndoChanged(bool canUndo);
     void canUndoChanged(bool canUndo);
@@ -68,6 +77,7 @@ private:
 private:
 private:
     void createHead();
     void createHead();
     void createTree();
     void createTree();
+    void createImgs();
     void createActions();
     void createActions();
     void createStatusBar();
     void createStatusBar();
     void readSettings();
     void readSettings();
@@ -84,6 +94,7 @@ private:
     QTextEdit *noteEdit;
     QTextEdit *noteEdit;
     QToolBar *toolEdit;
     QToolBar *toolEdit;
     QDockWidget *dockTree;
     QDockWidget *dockTree;
+    QDockWidget *dockImgs;
     QWebInspector *inspector;
     QWebInspector *inspector;
     QTextEdit *messageEdit;
     QTextEdit *messageEdit;
     QString curFile;
     QString curFile;

+ 18 - 0
source/fb2temp.cpp

@@ -4,6 +4,7 @@
 #include <QFileInfo>
 #include <QFileInfo>
 #include <QImageReader>
 #include <QImageReader>
 #include <QUrl>
 #include <QUrl>
+#include <QVBoxLayout>
 #include <QtDebug>
 #include <QtDebug>
 
 
 #include "fb2text.hpp"
 #include "fb2text.hpp"
@@ -205,3 +206,20 @@ QNetworkReply * FbNetworkAccessManager::imageRequest(Operation op, const QNetwor
     QByteArray data = m_view.files().data(name);
     QByteArray data = m_view.files().data(name);
     return new FbImageReply(op, request, data);
     return new FbImageReply(op, request, data);
 }
 }
+
+//---------------------------------------------------------------------------
+//  FbListWidget
+//---------------------------------------------------------------------------
+
+FbListWidget::FbListWidget(FbTextEdit &view, QWidget* parent)
+{
+    QVBoxLayout * layout = new QVBoxLayout(this);
+    layout->setSpacing(0);
+    layout->setContentsMargins(0, 0, 0, 0);
+
+    m_list = new QListView(this);
+    layout->addWidget(m_list);
+
+    m_tool = new QToolBar(this);
+    layout->addWidget(m_tool);
+}

+ 17 - 1
source/fb2temp.hpp

@@ -2,11 +2,14 @@
 #define FB2TEMP_H
 #define FB2TEMP_H
 
 
 #include <QByteArray>
 #include <QByteArray>
+#include <QLabel>
 #include <QList>
 #include <QList>
+#include <QNetworkAccessManager>
 #include <QNetworkReply>
 #include <QNetworkReply>
 #include <QString>
 #include <QString>
 #include <QTemporaryFile>
 #include <QTemporaryFile>
-#include <QNetworkAccessManager>
+#include <QToolBar>
+#include <QListView>
 
 
 class FbTextEdit;
 class FbTextEdit;
 
 
@@ -91,4 +94,17 @@ private:
     QString m_path;
     QString m_path;
 };
 };
 
 
+class FbListWidget : public QWidget
+{
+    Q_OBJECT
+
+public:
+    explicit FbListWidget(FbTextEdit &view, QWidget* parent = 0);
+
+protected:
+    QToolBar * m_tool;
+    QListView * m_list;
+    QLabel * m_label;
+};
+
 #endif // FB2TEMP_H
 #endif // FB2TEMP_H

+ 0 - 1
source/fb2tree.cpp

@@ -753,7 +753,6 @@ FbTreeWidget::FbTreeWidget(FbTextEdit &view, QWidget* parent)
     QVBoxLayout * layout = new QVBoxLayout(this);
     QVBoxLayout * layout = new QVBoxLayout(this);
     layout->setSpacing(0);
     layout->setSpacing(0);
     layout->setContentsMargins(0, 0, 0, 0);
     layout->setContentsMargins(0, 0, 0, 0);
-    layout->setObjectName(QString::fromUtf8("verticalLayout"));
 
 
     m_tree = new FbTreeView(view, this);
     m_tree = new FbTreeView(view, this);
     layout->addWidget(m_tree);
     layout->addWidget(m_tree);

BIN
source/ts/ru.qm


+ 25 - 1
source/ts/ru.ts

@@ -428,7 +428,7 @@
     </message>
     </message>
     <message>
     <message>
         <source>Settings</source>
         <source>Settings</source>
-        <translation type="unfinished"></translation>
+        <translation>Настройки</translation>
     </message>
     </message>
     <message>
     <message>
         <source>&amp;Bold</source>
         <source>&amp;Bold</source>
@@ -498,6 +498,18 @@
         <source>&amp;Code</source>
         <source>&amp;Code</source>
         <translation>&amp;Код</translation>
         <translation>&amp;Код</translation>
     </message>
     </message>
+    <message>
+        <source>&amp;Date</source>
+        <translation>&amp;Дата</translation>
+    </message>
+    <message>
+        <source>&amp;Pictures</source>
+        <translation>&amp;Иллюстрации</translation>
+    </message>
+    <message>
+        <source>Pictures</source>
+        <translation>Иллюстрации</translation>
+    </message>
 </context>
 </context>
 <context>
 <context>
     <name>FbNodeDlg</name>
     <name>FbNodeDlg</name>
@@ -585,6 +597,14 @@
         <source>Insert image...</source>
         <source>Insert image...</source>
         <translation type="unfinished"></translation>
         <translation type="unfinished"></translation>
     </message>
     </message>
+    <message>
+        <source>Insert hyperlink</source>
+        <translation type="unfinished"></translation>
+    </message>
+    <message>
+        <source>URL:</source>
+        <translation type="unfinished"></translation>
+    </message>
 </context>
 </context>
 <context>
 <context>
     <name>FbTextFrame</name>
     <name>FbTextFrame</name>
@@ -619,6 +639,10 @@
         <source>Append stanza</source>
         <source>Append stanza</source>
         <translation type="unfinished"></translation>
         <translation type="unfinished"></translation>
     </message>
     </message>
+    <message>
+        <source>Insert epigraph</source>
+        <translation type="unfinished"></translation>
+    </message>
 </context>
 </context>
 <context>
 <context>
     <name>FbTreeModel</name>
     <name>FbTreeModel</name>