|
From: <cn...@us...> - 2020-10-28 14:22:54
|
Revision: 1085
http://sourceforge.net/p/seq/svn/1085
Author: cn187
Date: 2020-10-28 14:22:52 +0000 (Wed, 28 Oct 2020)
Log Message:
-----------
Replace Q3MultiLineEdit/Q3TextEdit with QTextEdit
Modified Paths:
--------------
showeq/branches/pre_6_0_beta/src/editor.cpp
showeq/branches/pre_6_0_beta/src/editor.h
showeq/branches/pre_6_0_beta/src/messagewindow.cpp
showeq/branches/pre_6_0_beta/src/messagewindow.h
Modified: showeq/branches/pre_6_0_beta/src/editor.cpp
===================================================================
--- showeq/branches/pre_6_0_beta/src/editor.cpp 2020-10-28 00:32:56 UTC (rev 1084)
+++ showeq/branches/pre_6_0_beta/src/editor.cpp 2020-10-28 14:22:52 UTC (rev 1085)
@@ -38,7 +38,7 @@
#include <Q3TextStream>
#include <QPaintDevice>
#include <QObject>
-#include <Q3MultiLineEdit>
+#include <QTextEdit>
#include <QMessageBox>
#include <QPixmap>
#include <QCloseEvent>
@@ -124,7 +124,7 @@
file->insertSeparator();
file->insertItem( "&Close Editor", this, SLOT(close()), Qt::CTRL+Qt::Key_W );
- e = new Q3MultiLineEdit( this, "editor" );
+ e = new QTextEdit( this, "editor" );
e->setFocus();
setCentralWidget( e );
@@ -154,7 +154,6 @@
if ( !f.open( QIODevice::ReadOnly ) )
return;
- e->setAutoUpdate( FALSE );
e->clear();
Q3TextStream t(&f);
@@ -164,9 +163,8 @@
}
f.close();
- e->setAutoUpdate( TRUE );
e->repaint();
- e->setEdited( FALSE );
+ e->setModified( FALSE );
setCaption( fileName );
QString s;
s.sprintf( "Opened %s", fileName );
@@ -192,7 +190,7 @@
t << text;
f.close();
- e->setEdited( FALSE );
+ e->setModified( FALSE );
setCaption( filename );
@@ -212,7 +210,7 @@
void EditorWindow::closeEvent( QCloseEvent* ce )
{
- if ( !e->edited() ) {
+ if ( !e->isModified() ) {
ce->accept();
return;
}
Modified: showeq/branches/pre_6_0_beta/src/editor.h
===================================================================
--- showeq/branches/pre_6_0_beta/src/editor.h 2020-10-28 00:32:56 UTC (rev 1084)
+++ showeq/branches/pre_6_0_beta/src/editor.h 2020-10-28 14:22:52 UTC (rev 1085)
@@ -27,7 +27,7 @@
#include <QCloseEvent>
#include <QMenu>
-class Q3MultiLineEdit;
+class QTextEdit;
class Q3ToolBar;
class QMenu;
@@ -49,7 +49,7 @@
void saveAs();
private:
- Q3MultiLineEdit *e;
+ QTextEdit *e;
Q3ToolBar *fileTools;
QString filename;
};
Modified: showeq/branches/pre_6_0_beta/src/messagewindow.cpp
===================================================================
--- showeq/branches/pre_6_0_beta/src/messagewindow.cpp 2020-10-28 00:32:56 UTC (rev 1084)
+++ showeq/branches/pre_6_0_beta/src/messagewindow.cpp 2020-10-28 14:22:52 UTC (rev 1085)
@@ -51,7 +51,7 @@
//----------------------------------------------------------------------
// MessageBrowser
MessageBrowser::MessageBrowser(QWidget* parent, const char* name)
- : Q3TextEdit(parent, name)
+ : QTextEdit(parent, name)
{
}
@@ -65,7 +65,7 @@
}
#endif // ZBTEPM
if (e->type() != QEvent::MouseButtonPress)
- return Q3TextEdit::eventFilter(o, e);
+ return QTextEdit::eventFilter(o, e);
QMouseEvent* m = (QMouseEvent*)e;
@@ -76,7 +76,7 @@
return true;
}
- return Q3TextEdit::eventFilter(o, e);
+ return QTextEdit::eventFilter(o, e);
}
void MessageBrowser::keyPressEvent(QKeyEvent* e)
@@ -104,7 +104,7 @@
}
};
- Q3TextEdit::keyPressEvent(e);
+ QTextEdit::keyPressEvent(e);
}
//----------------------------------------------------------------------
@@ -163,11 +163,11 @@
{
// perform a find in the message window, starting at the current position
// using the settings from the checkboxes.
- m_messageWindow->find(m_findText->text(),
- m_matchCase->isChecked(),
- m_wholeWords->isChecked(),
- !m_findBackwards->isChecked(),
- 0, 0);
+ QTextDocument::FindFlags options = 0;
+ if (m_matchCase->isChecked()) options |= QTextDocument::FindCaseSensitively;
+ if (m_wholeWords->isChecked()) options |= QTextDocument::FindWholeWords;
+ if (m_findBackwards->isChecked()) options |= QTextDocument::FindBackward;
+ m_messageWindow->find(m_findText->text(), options);
}
void MessageFindDialog::close()
@@ -480,11 +480,12 @@
m_messageWindow->setCurrentFont(font());
// set the colors
- m_messageWindow->setColor(m_defaultColor);
- m_messageWindow->setPaper(m_defaultBGColor);
+ QPalette p = m_messageWindow->palette();
+ p.setColor(QPalette::Base, m_defaultBGColor);
+ p.setColor(QPalette::Text, m_defaultColor);
+ m_messageWindow->setPalette(p);
// make sure history isn't kept
- m_messageWindow->setUndoDepth(0);
m_messageWindow->setUndoRedoEnabled(false);
m_messageWindow->setTextFormat(Qt::PlainText);
@@ -492,12 +493,12 @@
// set it to read only
m_messageWindow->setReadOnly(true);
- // set the word wrap
- m_messageWindow->setWordWrap(m_wrapText ?
- Q3TextEdit::WidgetWidth : Q3TextEdit::NoWrap);
+ // set the word wrap
+ m_messageWindow->setLineWrapMode(m_wrapText ?
+ QTextEdit::WidgetWidth : QTextEdit::NoWrap);
// set the wrap policy to break at space
- m_messageWindow->setWrapPolicy(Q3TextEdit::AtWhiteSpace);
+ m_messageWindow->setWordWrapMode(QTextOption::WordWrap);
// connect to the Messages signal(s)
connect(m_messages, SIGNAL(newMessage(const MessageEntry&)),
@@ -716,15 +717,25 @@
text.replace(m_itemPattern, "\\2 (#\\1)");
+ //Set the fg/bg colors
+ if (m_typeStyles[type].bgColor().isValid() &&
+ m_typeStyles[type].color().isValid())
+ {
+ QTextCharFormat format = m_messageWindow->currentCharFormat();
+ format.setForeground(m_typeStyles[type].color());
+ format.setBackground(m_typeStyles[type].bgColor());
+ m_messageWindow->setCurrentCharFormat(format);
+ }
+
// now append the message text to the buffer
m_messageWindow->append(text);
- int para = m_messageWindow->paragraphs() - 1;
- if (m_typeStyles[type].bgColor().isValid())
- m_messageWindow->setParagraphBackgroundColor(para,
- m_typeStyles[type].bgColor());
- else
- m_messageWindow->setParagraphBackgroundColor(para, m_defaultBGColor);
+ //Reset the fg/bg colors
+ QTextCharFormat format = m_messageWindow->currentCharFormat();
+ format.setForeground(m_defaultColor);
+ format.setBackground(m_defaultBGColor);
+ m_messageWindow->setCurrentCharFormat(format);
+
}
void MessageWindow::newMessage(const MessageEntry& message)
@@ -758,10 +769,10 @@
m_messageWindow->append(" ");
// set the cursor to the beginning of the document
- m_messageWindow->setCursorPosition(0, 0);
+ //m_messageWindow->moveCursor(QTextCursor::Start, QTextCursor::MoveAnchor);
// move the cursor to the end of the document
- m_messageWindow->moveCursor(Q3TextEdit::MoveEnd, false);
+ m_messageWindow->moveCursor(QTextEdit::MoveEnd, QTextCursor::MoveAnchor);
// iterate over the message list and add the messages
MessageList::const_iterator it;
@@ -785,7 +796,7 @@
m_messageWindow->unsetCursor();
// move the cursor to the end of the document
- m_messageWindow->moveCursor(Q3TextEdit::MoveEnd, false);
+ m_messageWindow->moveCursor(QTextEdit::MoveEnd, QTextCursor::MoveAnchor);
// move the cursor to the end of the document
m_messageWindow->ensureCursorVisible();
@@ -827,10 +838,7 @@
{
Q3TextStream stream( &file );
- // save all the paragraphs
- // ZBNOTE: unfortunately just using ->text() doesn't work.
- for (int i = 0; i < m_messageWindow->paragraphs(); i++)
- stream << m_messageWindow->text(i) << endl;
+ stream << m_messageWindow->toPlainText() << endl;
}
}
@@ -1052,8 +1060,8 @@
pSEQPrefs->setPrefBool("WrapText", preferenceName(), m_wrapText);
// set the wrap policy according to the setting
- m_messageWindow->setWordWrap(m_wrapText ?
- Q3TextEdit::WidgetWidth : Q3TextEdit::NoWrap);
+ m_messageWindow->setLineWrapMode(m_wrapText ?
+ QTextEdit::WidgetWidth : QTextEdit::NoWrap);
}
void MessageWindow::setTypeStyle(int id)
@@ -1108,7 +1116,9 @@
if (color.isValid())
{
m_defaultBGColor = color;
- m_messageWindow->setPaper(m_defaultBGColor);
+ QPalette p = m_messageWindow->palette();
+ p.setColor(QPalette::Base, m_defaultBGColor);
+ m_messageWindow->setPalette(p);
pSEQPrefs->setPrefColor("DefaultBGColor", preferenceName(),
m_defaultBGColor);
Modified: showeq/branches/pre_6_0_beta/src/messagewindow.h
===================================================================
--- showeq/branches/pre_6_0_beta/src/messagewindow.h 2020-10-28 00:32:56 UTC (rev 1084)
+++ showeq/branches/pre_6_0_beta/src/messagewindow.h 2020-10-28 14:22:52 UTC (rev 1085)
@@ -27,7 +27,7 @@
#include <cstdint>
-#include <Q3TextEdit>
+#include <QTextEdit>
#include <QRegExp>
#include <QDialog>
#include <QLabel>
@@ -51,7 +51,7 @@
//----------------------------------------------------------------------
// MessageBrowser
-class MessageBrowser : public Q3TextEdit
+class MessageBrowser : public QTextEdit
{
Q_OBJECT
public:
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|