.
This commit is contained in:
+67
-261
@@ -4,289 +4,95 @@
|
||||
#include "ctextdocument.h"
|
||||
#include "cdocumentreader.h"
|
||||
|
||||
#include "cstructurewindow.h"
|
||||
#include "cwidget.h"
|
||||
|
||||
#include <QTextDocument>
|
||||
#include <QTextBlockFormat>
|
||||
#include <QTextCharFormat>
|
||||
|
||||
#include <QTextDocumentWriter>
|
||||
#include <QByteArray>
|
||||
#include <QTextCodec>
|
||||
#include <QFile>
|
||||
|
||||
|
||||
//#define WITH_ZIP
|
||||
|
||||
|
||||
cTextDocument* g_lpInputDocument = 0;
|
||||
cTextDocument* g_lpOutputDocument = 0;
|
||||
|
||||
|
||||
QTextBlockFormat createTextBlockFormat(Qt::Alignment alignment, qreal leftMargin, qreal topMargin, qreal rightMargin, qreal bottomMargin, int indent, qreal lineHeight, int lineHeightType,
|
||||
bool nonBreakableLines, QTextBlockFormat::PageBreakFlags pageBreakPolicy, const QList<QTextOption::Tab>& tabPositions, qreal textIndent,
|
||||
QBrush background, QBrush foreground, Qt::LayoutDirection layoutDirection, int objectIndex, int objectType /* property*/)
|
||||
{
|
||||
QTextBlockFormat format;
|
||||
|
||||
format.setAlignment(alignment);
|
||||
format.setLeftMargin(leftMargin);
|
||||
format.setTopMargin(topMargin);
|
||||
format.setRightMargin(rightMargin);
|
||||
format.setBottomMargin(bottomMargin);
|
||||
format.setIndent(indent);
|
||||
format.setLineHeight(lineHeight, lineHeightType);
|
||||
format.setNonBreakableLines(nonBreakableLines);
|
||||
format.setPageBreakPolicy(pageBreakPolicy);
|
||||
format.setTabPositions(tabPositions);
|
||||
format.setTextIndent(textIndent);
|
||||
|
||||
format.setBackground(background);
|
||||
format.setForeground(foreground);
|
||||
format.setLayoutDirection(layoutDirection);
|
||||
format.setObjectIndex(objectIndex);
|
||||
format.setObjectType(objectType);
|
||||
//property
|
||||
|
||||
return(format);
|
||||
}
|
||||
|
||||
QTextCharFormat createTextCharFormat(bool anchor, const QString& anchorHref, const QStringList& anchorNames, const QFont& font, QTextCharFormat::FontPropertiesInheritanceBehavior behavior,
|
||||
const QPen& textOutline, const QString& toolTip, const QColor& underlineColor, QTextCharFormat::UnderlineStyle underlineStyle, QTextCharFormat::VerticalAlignment verticalAlignment,
|
||||
QBrush background, QBrush foreground, Qt::LayoutDirection layoutDirection, int objectIndex, int objectType /* property*/)
|
||||
{
|
||||
QTextCharFormat format;
|
||||
|
||||
format.setAnchor(anchor);
|
||||
format.setAnchorHref(anchorHref);
|
||||
format.setAnchorNames(anchorNames);
|
||||
format.setFont(font, behavior);
|
||||
format.setTextOutline(textOutline);
|
||||
format.setToolTip(toolTip);
|
||||
format.setUnderlineColor(underlineColor);
|
||||
format.setUnderlineStyle(underlineStyle);
|
||||
format.setVerticalAlignment(verticalAlignment);
|
||||
|
||||
format.setBackground(background);
|
||||
format.setForeground(foreground);
|
||||
format.setLayoutDirection(layoutDirection);
|
||||
format.setObjectIndex(objectIndex);
|
||||
format.setObjectType(objectType);
|
||||
//property
|
||||
|
||||
return(format);
|
||||
}
|
||||
|
||||
void readWriteTest1()
|
||||
{
|
||||
if(!QFile::exists(":/example.html"))
|
||||
return;
|
||||
QFile file(":/example.html");
|
||||
|
||||
if(!file.open(QFile::ReadOnly))
|
||||
return;
|
||||
|
||||
QByteArray data = file.readAll();
|
||||
QTextCodec* codec = Qt::codecForHtml(data);
|
||||
QString str = codec->toUnicode(data);
|
||||
if(Qt::mightBeRichText(str))
|
||||
{
|
||||
g_lpInputDocument->setHtml(str);
|
||||
}
|
||||
else
|
||||
{
|
||||
str = QString::fromLocal8Bit(data);
|
||||
g_lpInputDocument->setPlainText(str);
|
||||
}
|
||||
|
||||
file.close();
|
||||
}
|
||||
|
||||
void readWriteTest2()
|
||||
{
|
||||
QTextCursor cursor(g_lpInputDocument);
|
||||
|
||||
// TEXT BLOCK FORMAT
|
||||
Qt::Alignment alignment = Qt::AlignCenter;
|
||||
qreal leftMargin = 0;
|
||||
qreal topMargin = 0;
|
||||
qreal rightMargin = 0;
|
||||
qreal bottomMargin = 0;
|
||||
int indent = 0;
|
||||
qreal lineHeight = 1;
|
||||
int lineHeightType = QTextBlockFormat::SingleHeight; // QTextBlockFormat::SingleHeight 0 This is the default line height: single spacing.
|
||||
// QTextBlockFormat::ProportionalHeight 1 This sets the spacing proportional to the line (in percentage). For example, set to 200 for double spacing.
|
||||
// QTextBlockFormat::FixedHeight 2 This sets the line height to a fixed line height (in pixels).
|
||||
// QTextBlockFormat::MinimumHeight 3 This sets the minimum line height (in pixels).
|
||||
// QTextBlockFormat::LineDistanceHeight 4 This adds the specified height between lines (in pixels).
|
||||
bool nonBreakableLines = false;
|
||||
QTextBlockFormat::PageBreakFlags pageBreakPolicy = QTextFormat::PageBreak_Auto; // QTextFormat::PageBreak_Auto 0 The page break is determined automatically depending on the available space on the current page
|
||||
// QTextFormat::PageBreak_AlwaysBefore 0x001 The page is always broken before the paragraph/table
|
||||
// QTextFormat::PageBreak_AlwaysAfter 0x010 A new page is always started after the paragraph/table
|
||||
const QList<QTextOption::Tab> tabPositions;
|
||||
qreal textIndent = 0;
|
||||
QBrush background = QBrush(QColor("lightGray"));
|
||||
QBrush foreground = QBrush(QColor("black"));
|
||||
Qt::LayoutDirection layoutDirection = Qt::LeftToRight; // Qt::LeftToRight 0 Left-to-right layout.
|
||||
// Qt::RightToLeft 1 Right-to-left layout.
|
||||
// Qt::LayoutDirectionAuto 2 Automatic layout.
|
||||
int objectIndex = 0;
|
||||
int objectType = QTextFormat::NoObject; // QTextFormat::NoObject 0
|
||||
// QTextFormat::ImageObject 1
|
||||
// QTextFormat::TableObject 2
|
||||
// QTextFormat::TableCellObject 3
|
||||
// QTextFormat::UserObject 0x1000 The first object that can be used for application-specific purposes.
|
||||
//property
|
||||
|
||||
|
||||
// TEXT CHAR FORMAT
|
||||
bool anchor = false;
|
||||
QString anchorHref = "";
|
||||
QStringList anchorNames;
|
||||
QFont font = QFont("Arial");
|
||||
QTextCharFormat::FontPropertiesInheritanceBehavior behavior = QTextCharFormat::FontPropertiesAll;// QTextCharFormat::FontPropertiesSpecifiedOnly 0 If a property is not explicitly set, do not change the text format's property value.
|
||||
// QTextCharFormat::FontPropertiesAll 1 If a property is not explicitly set, override the text format's property with a default value.
|
||||
QPen textOutline = QPen(QColor("blue"));
|
||||
QString toolTip = "toolTip";
|
||||
QColor underlineColor = QColor("yellow");
|
||||
QTextCharFormat::UnderlineStyle underlineStyle = QTextCharFormat::NoUnderline; // QTextCharFormat::NoUnderline 0 Text is draw without any underlining decoration.
|
||||
// QTextCharFormat::SingleUnderline 1 A line is drawn using Qt::SolidLine.
|
||||
// QTextCharFormat::DashUnderline 2 Dashes are drawn using Qt::DashLine.
|
||||
// QTextCharFormat::DotLine 3 Dots are drawn using Qt::DotLine;
|
||||
// QTextCharFormat::DashDotLine 4 Dashs and dots are drawn using Qt::DashDotLine.
|
||||
// QTextCharFormat::DashDotDotLine 5 Underlines draw drawn using Qt::DashDotDotLine.
|
||||
// QTextCharFormat::WaveUnderline 6 The text is underlined using a wave shaped line.
|
||||
// QTextCharFormat::SpellCheckUnderline 7 The underline is drawn depending on the SpellCheckUnderlineStyle theme hint of QPlatformTheme. By default this is mapped to WaveUnderline, on macOS it is mapped to DotLine.
|
||||
QTextCharFormat::VerticalAlignment verticalAlignment = QTextCharFormat::AlignNormal; // QTextCharFormat::AlignNormal 0 Adjacent characters are positioned in the standard way for text in the writing system in use.
|
||||
// QTextCharFormat::AlignSuperScript 1 Characters are placed above the base line for normal text.
|
||||
// QTextCharFormat::AlignSubScript 2 Characters are placed below the base line for normal text.
|
||||
// QTextCharFormat::AlignMiddle 3 The center of the object is vertically aligned with the base line. Currently, this is only implemented for inline objects.
|
||||
// QTextCharFormat::AlignBottom 5 The bottom edge of the object is vertically aligned with the base line.
|
||||
// QTextCharFormat::AlignTop 4 The top edge of the object is vertically aligned with the base line.
|
||||
// QTextCharFormat::AlignBaseline 6 The base lines of the characters are aligned.
|
||||
QBrush background1 = QBrush(QColor("red"));
|
||||
QBrush foreground1 = QBrush(QColor("green"));
|
||||
Qt::LayoutDirection layoutDirection1 = Qt::LeftToRight; // Qt::LeftToRight 0 Left-to-right layout.
|
||||
// Qt::RightToLeft 1 Right-to-left layout.
|
||||
// Qt::LayoutDirectionAuto 2 Automatic layout.
|
||||
int objectIndex1 = 0;
|
||||
int objectType1 = QTextFormat::NoObject; // QTextFormat::NoObject 0
|
||||
// QTextFormat::ImageObject 1
|
||||
// QTextFormat::TableObject 2
|
||||
// QTextFormat::TableCellObject 3
|
||||
// QTextFormat::UserObject 0x1000 The first object that can be used for application-specific purposes.
|
||||
//property
|
||||
|
||||
QTextBlockFormat blockFormat1 = createTextBlockFormat(alignment, leftMargin, topMargin, rightMargin, bottomMargin, indent, lineHeight, lineHeightType, nonBreakableLines, pageBreakPolicy, tabPositions, textIndent, background, foreground, layoutDirection, objectIndex, objectType);
|
||||
QTextCharFormat charFormat1 = createTextCharFormat(anchor, anchorHref, anchorNames, font, behavior, textOutline, toolTip, underlineColor, underlineStyle, verticalAlignment, background1, foreground1, layoutDirection1, objectIndex1, objectType1); // property);
|
||||
|
||||
cursor.setBlockFormat(blockFormat1);
|
||||
cursor.setBlockCharFormat(charFormat1);
|
||||
|
||||
cursor.insertText("TestText");
|
||||
}
|
||||
|
||||
#include <QTextList>
|
||||
|
||||
void readWriteTest3()
|
||||
{
|
||||
QTextCursor cursor(g_lpInputDocument);
|
||||
|
||||
QTextListFormat* lpFormat = new QTextListFormat;
|
||||
QString numberSuffix = lpFormat->numberSuffix();
|
||||
|
||||
lpFormat->setNumberSuffix(".");
|
||||
numberSuffix = lpFormat->numberSuffix();
|
||||
|
||||
delete lpFormat;
|
||||
|
||||
QTextList* list1;
|
||||
QTextList* list2;
|
||||
QTextList* list3;
|
||||
QTextBlock textBlock;
|
||||
|
||||
QTextListFormat format1;
|
||||
QTextListFormat format2;
|
||||
QTextListFormat format3;
|
||||
format1.setStyle(QTextListFormat::ListDecimal);
|
||||
format1.setIndent(1);
|
||||
format2.setStyle(QTextListFormat::ListLowerAlpha);
|
||||
format2.setIndent(2);
|
||||
format3.setStyle(QTextListFormat::ListUpperAlpha);
|
||||
format3.setIndent(3);
|
||||
|
||||
list1 = cursor.insertList(format1);
|
||||
textBlock = cursor.block(); cursor.insertText("Introduction"); list1->add(textBlock);
|
||||
cursor.insertBlock(); textBlock = cursor.block(); cursor.insertText("Tools"); list1->add(textBlock);
|
||||
|
||||
list2 = cursor.insertList(format2);
|
||||
textBlock = cursor.block(); cursor.insertText("Assistant"); list2->add(textBlock);
|
||||
cursor.insertBlock(); textBlock = cursor.block(); cursor.insertText("Designer"); list2->add(textBlock);
|
||||
|
||||
list3 = cursor.insertList(format3);
|
||||
textBlock = cursor.block(); cursor.insertText("Form Editor"); list3->add(textBlock);
|
||||
cursor.insertBlock(); textBlock = cursor.block(); cursor.insertText("Component Architecture"); list3->add(textBlock);
|
||||
|
||||
cursor.insertBlock(); textBlock = cursor.block(); cursor.insertText("Qt Linguist"); list2->add(textBlock);
|
||||
}
|
||||
|
||||
cMainWindow::cMainWindow(QWidget *parent) :
|
||||
QMainWindow(parent),
|
||||
ui(new Ui::cMainWindow)
|
||||
ui(new Ui::cMainWindow),
|
||||
m_bUpdatingTab(false)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
ui->m_lpTabWidget->setCurrentIndex(0);
|
||||
|
||||
g_lpInputDocument = new cTextDocument(ui->m_lpInput);
|
||||
g_lpOutputDocument = new cTextDocument(ui->m_lpOutput);
|
||||
cStructureWindow* lpStructureWindow = new cStructureWindow(this);
|
||||
cWidget* lpWidget1 = new cWidget(lpStructureWindow);
|
||||
lpWidget1->setWindow(ui->m_lpMdiArea->addSubWindow(lpStructureWindow));
|
||||
|
||||
ui->m_lpInput->setDocument(g_lpInputDocument);
|
||||
QMainWindow* lpMainWindow = new QMainWindow(this);
|
||||
lpMainWindow->setWindowTitle("Bla");
|
||||
cWidget* lpWidget2 = new cWidget(lpMainWindow);
|
||||
lpWidget2->setWindow(ui->m_lpMdiArea->addSubWindow(lpMainWindow));
|
||||
|
||||
readWriteTest1();
|
||||
// readWriteTest2();
|
||||
// readWriteTest3();
|
||||
ui->m_lpMainTab->addTab((QWidget*)lpWidget1, "Structure");
|
||||
ui->m_lpMainTab->addTab((QWidget*)lpWidget2, "Bla");
|
||||
|
||||
// g_lpInputDocument = new cTextDocument(ui->m_lpInput);
|
||||
// g_lpOutputDocument = new cTextDocument(ui->m_lpOutput);
|
||||
|
||||
// ui->m_lpInput->setDocument(g_lpInputDocument);
|
||||
}
|
||||
|
||||
cMainWindow::~cMainWindow()
|
||||
{
|
||||
delete ui;
|
||||
|
||||
if(g_lpInputDocument)
|
||||
delete g_lpInputDocument;
|
||||
|
||||
if(g_lpOutputDocument)
|
||||
delete g_lpOutputDocument;
|
||||
}
|
||||
|
||||
void cMainWindow::on_actionTest1_triggered()
|
||||
//void cMainWindow::on_actionSave_triggered()
|
||||
//{
|
||||
//#ifdef __linux__
|
||||
// #ifdef WITH_ZIP
|
||||
// g_lpInputDocument->saveAs("/tmp/qtStoryWriter/documentText.zip", false);
|
||||
// cDocumentReader reader("/tmp/qtStoryWriter/documentText.zip", false);
|
||||
// #else
|
||||
// g_lpInputDocument->saveAs("/tmp/qtStoryWriter/documentText.xml", false);
|
||||
// cDocumentReader reader("/tmp/qtStoryWriter/documentText.xml", false);
|
||||
// #endif
|
||||
//#elif _WIN32
|
||||
// #ifdef WITH_ZIP
|
||||
// g_lpInputDocument->saveAs("C:/Temp/qtStoryWriter/documentText.zip", false);
|
||||
// cDocumentReader reader("C:/Temp/qtStoryWriter/documentText.zip", false);
|
||||
// #else
|
||||
// g_lpInputDocument->saveAs("C:/Temp/qtStoryWriter/documentText.xml", false);
|
||||
// cDocumentReader reader("C:/Temp/qtStoryWriter/documentText.xml", false);
|
||||
// #endif
|
||||
// g_lpOutputDocument = reader.readDocument();
|
||||
// ui->m_lpOutput->setDocument(g_lpOutputDocument);
|
||||
//#endif
|
||||
//}
|
||||
|
||||
void cMainWindow::on_m_lpMainTab_currentChanged(int index)
|
||||
{
|
||||
QTextBlockFormat blockFormatStyle;
|
||||
blockFormatStyle.setBackground(QColor("red"));
|
||||
|
||||
QTextCursor cursor(g_lpInputDocument);
|
||||
cursor.setBlockFormat(blockFormatStyle);
|
||||
|
||||
QTextCharFormat charFormatStyle;
|
||||
if(m_bUpdatingTab)
|
||||
return;
|
||||
|
||||
m_bUpdatingTab = true;
|
||||
cWidget* lpWidget = (cWidget*)ui->m_lpMainTab->currentWidget();
|
||||
QMdiSubWindow* lpWindow = lpWidget->window();
|
||||
ui->m_lpMdiArea->setActiveSubWindow(lpWindow);
|
||||
m_bUpdatingTab = false;
|
||||
}
|
||||
|
||||
void cMainWindow::on_actionSave_triggered()
|
||||
void cMainWindow::on_m_lpMdiArea_subWindowActivated(QMdiSubWindow *arg1)
|
||||
{
|
||||
#ifdef __linux__
|
||||
#ifdef WITH_ZIP
|
||||
g_lpInputDocument->saveAs("/tmp/qtStoryWriter/documentText.zip", false);
|
||||
cDocumentReader reader("/tmp/qtStoryWriter/documentText.zip", false);
|
||||
#else
|
||||
g_lpInputDocument->saveAs("/tmp/qtStoryWriter/documentText.xml", false);
|
||||
cDocumentReader reader("/tmp/qtStoryWriter/documentText.xml", false);
|
||||
#endif
|
||||
#elif _WIN32
|
||||
#ifdef WITH_ZIP
|
||||
g_lpInputDocument->saveAs("C:/Temp/qtStoryWriter/documentText.zip", false);
|
||||
cDocumentReader reader("C:/Temp/qtStoryWriter/documentText.zip", false);
|
||||
#else
|
||||
g_lpInputDocument->saveAs("C:/Temp/qtStoryWriter/documentText.xml", false);
|
||||
cDocumentReader reader("C:/Temp/qtStoryWriter/documentText.xml", false);
|
||||
#endif
|
||||
g_lpOutputDocument = reader.readDocument();
|
||||
ui->m_lpOutput->setDocument(g_lpOutputDocument);
|
||||
#endif
|
||||
if(m_bUpdatingTab)
|
||||
return;
|
||||
|
||||
m_bUpdatingTab = true;
|
||||
|
||||
for(int x = 0;x < ui->m_lpMainTab->count();x++)
|
||||
{
|
||||
cWidget* lpWidget = (cWidget*)ui->m_lpMainTab->widget(x);
|
||||
if(lpWidget->window() == arg1)
|
||||
{
|
||||
ui->m_lpMainTab->setCurrentIndex(x);
|
||||
m_bUpdatingTab = false;
|
||||
return;
|
||||
}
|
||||
}
|
||||
m_bUpdatingTab = false;
|
||||
}
|
||||
|
||||
+7
-3
@@ -2,6 +2,8 @@
|
||||
#define CMAINWINDOW_H
|
||||
|
||||
#include <QMainWindow>
|
||||
#include <QMdiSubWindow>
|
||||
|
||||
|
||||
namespace Ui {
|
||||
class cMainWindow;
|
||||
@@ -16,12 +18,14 @@ public:
|
||||
~cMainWindow();
|
||||
|
||||
private slots:
|
||||
void on_actionTest1_triggered();
|
||||
|
||||
void on_actionSave_triggered();
|
||||
void on_m_lpMainTab_currentChanged(int index);
|
||||
void on_m_lpMdiArea_subWindowActivated(QMdiSubWindow *arg1);
|
||||
|
||||
private:
|
||||
Ui::cMainWindow *ui;
|
||||
Ui::cMainWindow* ui;
|
||||
|
||||
bool m_bUpdatingTab;
|
||||
};
|
||||
|
||||
#endif // CMAINWINDOW_H
|
||||
|
||||
+57
-42
@@ -14,37 +14,55 @@
|
||||
<string>cMainWindow</string>
|
||||
</property>
|
||||
<widget class="QWidget" name="centralWidget">
|
||||
<layout class="QGridLayout" name="gridLayout_2">
|
||||
<item row="0" column="0">
|
||||
<widget class="QTabWidget" name="m_lpTabWidget">
|
||||
<property name="currentIndex">
|
||||
<number>1</number>
|
||||
</property>
|
||||
<widget class="QWidget" name="m_lpInputTab">
|
||||
<attribute name="title">
|
||||
<string>Input</string>
|
||||
</attribute>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="0" column="0">
|
||||
<widget class="cTextEdit" name="m_lpInput"/>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QWidget" name="m_lpOutputTab">
|
||||
<attribute name="title">
|
||||
<string>Output</string>
|
||||
</attribute>
|
||||
<layout class="QGridLayout" name="gridLayout_3">
|
||||
<item row="0" column="0">
|
||||
<widget class="cTextEdit" name="m_lpOutput"/>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="1" column="0">
|
||||
<layout class="QVBoxLayout" name="verticalLayout" stretch="0,99999">
|
||||
<item>
|
||||
<widget class="QTabWidget" name="m_lpMainTab">
|
||||
<property name="currentIndex">
|
||||
<number>-1</number>
|
||||
</property>
|
||||
<property name="documentMode">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="tabsClosable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="movable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QMdiArea" name="m_lpMdiArea">
|
||||
<property name="verticalScrollBarPolicy">
|
||||
<enum>Qt::ScrollBarAsNeeded</enum>
|
||||
</property>
|
||||
<property name="horizontalScrollBarPolicy">
|
||||
<enum>Qt::ScrollBarAsNeeded</enum>
|
||||
</property>
|
||||
<property name="viewMode">
|
||||
<enum>QMdiArea::SubWindowView</enum>
|
||||
</property>
|
||||
<property name="documentMode">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="tabsClosable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="tabsMovable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="tabPosition">
|
||||
<enum>QTabWidget::South</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QMenuBar" name="menuBar">
|
||||
<widget class="QMenuBar" name="m_lpMainMenu">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
@@ -53,16 +71,15 @@
|
||||
<height>21</height>
|
||||
</rect>
|
||||
</property>
|
||||
<widget class="QMenu" name="menuTest">
|
||||
<widget class="QMenu" name="menu_File">
|
||||
<property name="title">
|
||||
<string>Test</string>
|
||||
<string>&File</string>
|
||||
</property>
|
||||
<addaction name="actionTest1"/>
|
||||
<addaction name="actionSave"/>
|
||||
<addaction name="action_Close"/>
|
||||
</widget>
|
||||
<addaction name="menuTest"/>
|
||||
<addaction name="menu_File"/>
|
||||
</widget>
|
||||
<widget class="QToolBar" name="mainToolBar">
|
||||
<widget class="QToolBar" name="m_lpMainToolBar">
|
||||
<attribute name="toolBarArea">
|
||||
<enum>TopToolBarArea</enum>
|
||||
</attribute>
|
||||
@@ -70,7 +87,7 @@
|
||||
<bool>false</bool>
|
||||
</attribute>
|
||||
</widget>
|
||||
<widget class="QStatusBar" name="statusBar"/>
|
||||
<widget class="QStatusBar" name="m_lpStatusBar"/>
|
||||
<action name="actionTest1">
|
||||
<property name="text">
|
||||
<string>Test1</string>
|
||||
@@ -81,15 +98,13 @@
|
||||
<string>Save</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="action_Close">
|
||||
<property name="text">
|
||||
<string>&Close</string>
|
||||
</property>
|
||||
</action>
|
||||
</widget>
|
||||
<layoutdefault spacing="6" margin="11"/>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>cTextEdit</class>
|
||||
<extends>QTextEdit</extends>
|
||||
<header>ctextedit.h</header>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
#include "cstructurewindow.h"
|
||||
#include "ui_cstructurewindow.h"
|
||||
|
||||
#include <QCloseEvent>
|
||||
|
||||
|
||||
cStructureWindow::cStructureWindow(QWidget *parent) :
|
||||
QMainWindow(parent),
|
||||
ui(new Ui::cStructureWindow)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
}
|
||||
|
||||
cStructureWindow::~cStructureWindow()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
|
||||
void cStructureWindow::closeEvent(QCloseEvent *event)
|
||||
{
|
||||
event->ignore();
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
#ifndef CSTRUCTUREWINDOW_H
|
||||
#define CSTRUCTUREWINDOW_H
|
||||
|
||||
#include <QMainWindow>
|
||||
|
||||
namespace Ui {
|
||||
class cStructureWindow;
|
||||
}
|
||||
|
||||
class cStructureWindow : public QMainWindow
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit cStructureWindow(QWidget *parent = 0);
|
||||
~cStructureWindow();
|
||||
|
||||
protected:
|
||||
void closeEvent(QCloseEvent *event) override;
|
||||
|
||||
private:
|
||||
Ui::cStructureWindow* ui;
|
||||
};
|
||||
|
||||
#endif // CSTRUCTUREWINDOW_H
|
||||
@@ -0,0 +1,49 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>cStructureWindow</class>
|
||||
<widget class="QMainWindow" name="cStructureWindow">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>800</width>
|
||||
<height>600</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Structure</string>
|
||||
</property>
|
||||
<widget class="QWidget" name="centralwidget">
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="0" column="0">
|
||||
<widget class="QTreeView" name="treeView"/>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QMenuBar" name="m_lpStructureMenu">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>800</width>
|
||||
<height>21</height>
|
||||
</rect>
|
||||
</property>
|
||||
<widget class="QMenu" name="menuTest">
|
||||
<property name="title">
|
||||
<string>Test</string>
|
||||
</property>
|
||||
<addaction name="actionTest"/>
|
||||
</widget>
|
||||
<addaction name="menuTest"/>
|
||||
</widget>
|
||||
<widget class="QStatusBar" name="m_lpStructureStatusBar"/>
|
||||
<action name="actionTest">
|
||||
<property name="text">
|
||||
<string>Test</string>
|
||||
</property>
|
||||
</action>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
#include "cwidget.h"
|
||||
|
||||
|
||||
cWidget::cWidget(QWidget *parent) :
|
||||
QWidget(parent),
|
||||
m_lpWindow(0)
|
||||
{
|
||||
}
|
||||
|
||||
void cWidget::setWindow(QMdiSubWindow* lpWindow)
|
||||
{
|
||||
m_lpWindow = lpWindow;
|
||||
}
|
||||
|
||||
QMdiSubWindow *cWidget::window()
|
||||
{
|
||||
return(m_lpWindow);
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
#ifndef CWIDGET_H
|
||||
#define CWIDGET_H
|
||||
|
||||
#include <QWidget>
|
||||
#include <QMdiSubWindow>
|
||||
|
||||
|
||||
class cWidget : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit cWidget(QWidget *parent = nullptr);
|
||||
void setWindow(QMdiSubWindow* lpWindow);
|
||||
QMdiSubWindow* window();
|
||||
|
||||
signals:
|
||||
|
||||
public slots:
|
||||
|
||||
private:
|
||||
QMdiSubWindow* m_lpWindow;
|
||||
};
|
||||
|
||||
#endif // CWIDGET_H
|
||||
@@ -1,79 +0,0 @@
|
||||
<html><head><meta name="qrichtext" content="1" /><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><title>QTextEdit Example</title><style type="text/css">
|
||||
p, li { white-space: pre-wrap; }
|
||||
</style></head><body style=" font-size:9pt; font-weight:400; font-style:normal; text-decoration:none;">
|
||||
<p align="center" style=" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:20pt; font-weight:600;">QTextEdit</span></p>
|
||||
<p align="justify" style=" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:11pt;">The QTextEdit widget is an advanced editor that supports formatted rich text. It can be used to display HTML and other rich document formats. Internally, QTextEdit uses the QTextDocument class to describe both the high-level structure of each document and the low-level formatting of paragraphs.</span></p>
|
||||
<p align="justify" style=" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:11pt;">If you are viewing this document in the <span style=" font-style:italic;">textedit</span> example, you can edit this document to explore Qt's rich text editing features. We have included some comments in each of the following sections to encourage you to experiment. </p>
|
||||
<p style=" margin-top:16px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:18pt; font-weight:600;"><span style=" font-size:16pt;">Font and Paragraph Styles</span></p>
|
||||
<p align="justify" style=" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:11pt;">QTextEdit supports </span><span style=" font-size:11pt; font-weight:600;">bold</span><span style=" font-size:11pt;">, </span><span style=" font-size:11pt; font-style:italic;">italic</span><span style=" font-size:11pt;">, and </span><span style=" font-size:11pt; text-decoration: underline;">underlined</span><span style=" font-size:11pt;"> font styles, and can display </span><span style=" font-size:11pt; font-weight:600; color:#00007f;">multicolored</span><span style=" font-size:11pt;"> </span><span style=" font-size:11pt; font-weight:600; color:#aa0000;">text</span><span style=" font-size:11pt;">. Font families such as </span><span style=" font-family:'Times New Roman'; font-size:11pt; font-weight:600;">Times New Roman</span><span style=" font-size:11pt;"> and </span><span style=" font-family:'Courier'; font-size:11pt; font-weight:600;">Courier</span><span style=" font-size:11pt;"> can also be used directly. </span><span style=" font-size:11pt; font-style:italic;">If you place the cursor in a region of styled text, the controls in the tool bars will change to reflect the current style.</span></p>
|
||||
<p align="justify" style=" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:11pt;">Paragraphs can be formatted so that the text is left-aligned, right-aligned, centered, or fully justified.</p>
|
||||
<p align="center" style=" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:11pt;"><span style=" font-style:italic;">Try changing the alignment of some text and resize the editor to see how the text layout changes.</span> </p>
|
||||
<p align="justify" style=" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:16pt; font-weight:600;">Lists</span></p>
|
||||
<p align="justify" style=" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:16pt; font-weight:600;"><span style=" font-size:11pt; font-weight:400;">Different kinds of lists can be included in rich text documents. Standard bullet lists can be nested, using different symbols for each level of the list: </span></p>
|
||||
<ul style="-qt-list-indent: 1;"><li style=" font-size:11pt;" style=" margin-top:0px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Disc symbols are typically used for top-level list items. </li></ul>
|
||||
<ul type=circle style="-qt-list-indent: 2;"><li style=" font-size:11pt;" style=" margin-top:0px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Circle symbols can be used to distinguish between items in lower-level lists.</li></ul>
|
||||
<ul type=square style="-qt-list-indent: 3;"><li style=" font-size:11pt;" style=" margin-top:0px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Square symbols provide a reasonable alternative to discs and circles. </li></ul>
|
||||
<p style=" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:11pt;">Ordered lists can be created that can be used for tables of contents. Different characters can be used to enumerate items, and we can use both Roman and Arabic numerals in the same list structure: </p>
|
||||
<ol style="-qt-list-indent: 1;"><li style=" font-size:11pt;" style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Introduction</li>
|
||||
<li style=" font-size:11pt;" style=" margin-top:0px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Qt Tools </li></ol>
|
||||
<ol type=a style="-qt-list-indent: 2;"><li style=" font-size:11pt;" style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Qt Assistant</li>
|
||||
<li style=" font-size:11pt;" style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Qt Designer</li>
|
||||
<ol type=A style="-qt-list-indent: 3;"><li style=" font-size:11pt;" style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Form Editor</li>
|
||||
<li style=" font-size:11pt;" style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Component Architecture</li></ol>
|
||||
<li style=" font-size:11pt;" style=" margin-top:0px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Qt Linguist</li></ol>
|
||||
<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:11pt;"></p>
|
||||
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:11pt;">The list will automatically be renumbered if you add or remove items. <span style=" font-style:italic;">Try adding new sections to the above list or removing existing item to see the numbers change.</span> </p>
|
||||
<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:11pt;"></p>
|
||||
<p style=" margin-top:0px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:11pt;"><span style=" font-size:16pt; font-weight:600;">Images</span></p>
|
||||
<p style=" margin-top:0px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:16pt; font-weight:600;"><span style=" font-size:11pt; font-weight:400;">Inline images are treated like ordinary ranges of characters in the text editor, so they flow with the surrounding text. Images can also be selected in the same way as text, making it easy to cut, copy, and paste them. </span></p>
|
||||
<p align="justify" style=" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:11pt;"><img src=":/images/logo32.png" /><span style=" font-style:italic;"> Try to select this image by clicking and dragging over it with the mouse, or use the text cursor to select it by holding down Shift and using the arrow keys. You can then cut or copy it, and paste it into different parts of this document.</span></p>
|
||||
<p align="justify" style=" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:11pt;"><span style=" font-size:16pt; font-weight:600;">Tables</span></p>
|
||||
<p align="justify" style=" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:16pt; font-weight:600;"><span style=" font-size:11pt; font-weight:400;">QTextEdit can arrange and format tables, supporting features such as row and column spans, text formatting within cells, and size constraints for columns. </span></p>
|
||||
<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:11pt;"></p>
|
||||
<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:11pt;"></p>
|
||||
<table border="1" align="center" width="90%" cellspacing="0" cellpadding="4">
|
||||
<tr>
|
||||
<td>
|
||||
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"> </p></td>
|
||||
<td>
|
||||
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-weight:600;">Development Tools </span></p></td>
|
||||
<td>
|
||||
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-weight:600;">Programming Techniques </span></p></td>
|
||||
<td>
|
||||
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-weight:600;">Graphical User Interfaces </span></p></td></tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-weight:600;">9:00 - 11:00 </span></p></td>
|
||||
<td colspan="3">
|
||||
<p align="center" style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Introduction to <span style=" font-style:italic;">Qt </span></p></td></tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-weight:600;">11:00 - 13:00 </span></p></td>
|
||||
<td>
|
||||
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Using <span style=" font-style:italic;">qmake</span> </p></td>
|
||||
<td>
|
||||
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Object-oriented Programming </p></td>
|
||||
<td>
|
||||
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Layouts in <span style=" font-style:italic;">Qt</span> </p></td></tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-weight:600;">13:00 - 15:00 </span></p></td>
|
||||
<td>
|
||||
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-style:italic;">Qt Designer</span> Tutorial </p></td>
|
||||
<td rowspan="2">
|
||||
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Extreme Programming </p></td>
|
||||
<td>
|
||||
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Writing Custom Styles </p></td></tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-weight:600;">15:00 - 17:00 </span></p></td>
|
||||
<td>
|
||||
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-style:italic;">Qt Linguist</span> and Internationalization </p></td>
|
||||
<td></td></tr></table>
|
||||
<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:11pt;"></p>
|
||||
<p style=" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:11pt; font-style:italic;">Try adding text to the cells in the table and experiment with the alignment of the paragraphs.</p>
|
||||
<p style=" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:11pt;"><span style=" font-size:16pt; font-weight:600;">Hyperlinks</span></p>
|
||||
<p style=" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:11pt;">QTextEdit is designed to support hyperlinks between documents, and this feature is used extensively in </span><span style=" font-size:11pt; font-style:italic;">Qt Assistant</span><span style=" font-size:11pt;">. Hyperlinks are automatically created when an HTML file is imported into an editor. Since the rich text framework supports hyperlinks natively, they can also be created programatically.</span></p>
|
||||
<p style=" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:11pt;"><span style=" font-size:16pt; font-weight:600;">Undo and Redo</span></p>
|
||||
<p style=" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:11pt;">Full support for undo and redo operations is built into QTextEdit and the underlying rich text framework. Operations on a document can be packaged together to make editing a more comfortable experience for the user.</p>
|
||||
<p style=" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:11pt;"><span style=" font-style:italic;">Try making changes to this document and press Ctrl+Z to undo them. You can always recover the original contents of the document.</span> </p></body></html>
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 1.4 KiB |
+9
-5
@@ -59,7 +59,9 @@ SOURCES += \
|
||||
cdocumentwriter.cpp \
|
||||
ctextdocument.cpp \
|
||||
common.cpp \
|
||||
ctextedit.cpp
|
||||
ctextedit.cpp \
|
||||
cstructurewindow.cpp \
|
||||
cwidget.cpp
|
||||
|
||||
HEADERS += \
|
||||
cmainwindow.h \
|
||||
@@ -67,13 +69,15 @@ HEADERS += \
|
||||
cdocumentwriter.h \
|
||||
ctextdocument.h \
|
||||
common.h \
|
||||
ctextedit.h
|
||||
ctextedit.h \
|
||||
cstructurewindow.h \
|
||||
cwidget.h
|
||||
|
||||
FORMS += \
|
||||
cmainwindow.ui
|
||||
cmainwindow.ui \
|
||||
cstructurewindow.ui
|
||||
|
||||
DISTFILES += \
|
||||
example.html
|
||||
DISTFILES +=
|
||||
|
||||
RESOURCES += \
|
||||
qtstorywriter.qrc
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
<RCC>
|
||||
<qresource prefix="/">
|
||||
<file>example.html</file>
|
||||
<file>images/logo32.png</file>
|
||||
<file>images/mac/editcopy.png</file>
|
||||
<file>images/mac/editcut.png</file>
|
||||
<file>images/mac/editpaste.png</file>
|
||||
|
||||
Reference in New Issue
Block a user