[vlc-devel] commit: Qt: messages cleanup and work around #2432 to solve the speed issues. ( Jean-Baptiste Kempf )
git version control
git at videolan.org
Sun Feb 8 03:08:19 CET 2009
vlc | branch: master | Jean-Baptiste Kempf <jb at videolan.org> | Sun Feb 8 03:07:37 2009 +0100| [b505449c011b2b190007b9dac8b37379e08e2f3e] | committer: Jean-Baptiste Kempf
Qt: messages cleanup and work around #2432 to solve the speed issues.
Patches partly by random.
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=b505449c011b2b190007b9dac8b37379e08e2f3e
---
modules/gui/qt4/dialogs/messages.cpp | 103 +++++++++++++++-------------------
modules/gui/qt4/dialogs/messages.hpp | 2 +-
2 files changed, 47 insertions(+), 58 deletions(-)
diff --git a/modules/gui/qt4/dialogs/messages.cpp b/modules/gui/qt4/dialogs/messages.cpp
index 2cd54e7..264e51c 100644
--- a/modules/gui/qt4/dialogs/messages.cpp
+++ b/modules/gui/qt4/dialogs/messages.cpp
@@ -88,6 +88,7 @@ MessagesDialog::MessagesDialog( intf_thread_t *_p_intf)
messages->setReadOnly( true );
messages->setGeometry( 0, 0, 440, 600 );
messages->setHorizontalScrollBarPolicy( Qt::ScrollBarAlwaysOff );
+ messages->setTextInteractionFlags( Qt::TextSelectableByMouse );
msgLayout->addWidget( messages, 0, 0, 1, 0 );
mainTab->addTab( msgWidget, qtr( "Messages" ) );
@@ -171,19 +172,21 @@ void MessagesDialog::updateTab( int index )
}
}
-void MessagesDialog::sinkMessage (msg_item_t *item, unsigned)
+void MessagesDialog::sinkMessage( msg_item_t *item )
{
if ((item->i_type == VLC_MSG_WARN && verbosityBox->value() < 1)
|| (item->i_type == VLC_MSG_DBG && verbosityBox->value() < 2 ))
return;
- // Saving cursor selection
- int startPos = messages->textCursor().selectionStart();
- int endPos = messages->textCursor().selectionEnd();
+ /* Copy selected text to the clipboard */
+ if( messages->textCursor().hasSelection() )
+ messages->copy();
+
+ /* Fix selected text bug */
+ if( !messages->textCursor().atEnd() ||
+ messages->textCursor().anchor() != messages->textCursor().position() )
+ messages->moveCursor( QTextCursor::End );
- messages->moveCursor( QTextCursor::End );
- if( startPos == endPos && messages->textCursor().selectionEnd() == endPos )
- endPos = 0;
messages->setFontItalic( true );
messages->setTextColor( "darkBlue" );
messages->insertPlainText( qfu( item->psz_module ) );
@@ -214,54 +217,14 @@ void MessagesDialog::sinkMessage (msg_item_t *item, unsigned)
messages->setTextColor( "black" );
messages->insertPlainText( qfu(item->psz_msg) );
messages->insertPlainText( "\n" );
- messages->ensureCursorVisible();
-
- // Restoring saved cursor selection
- // If the cursor was at this end, put it at the end,
- // so we don't need to scroll down.
- if( endPos == 0 )
- messages->moveCursor( QTextCursor::End );
- else
- {
- QTextCursor cur = messages->textCursor();
- cur.movePosition( QTextCursor::Start );
- cur.movePosition( QTextCursor::NextCharacter, QTextCursor::MoveAnchor, startPos );
- cur.movePosition( QTextCursor::NextCharacter, QTextCursor::KeepAnchor, endPos - startPos );
- messages->setTextCursor( cur );
- }
}
+
void MessagesDialog::customEvent( QEvent *event )
{
- MsgEvent *msg = dynamic_cast<MsgEvent*>(event);
+ MsgEvent *msge = static_cast<MsgEvent *>(event);
- assert( msg );
- sinkMessage( msg->msg, 0 );
-}
-
-void MessagesDialog::buildTree( QTreeWidgetItem *parentItem,
- vlc_object_t *p_obj )
-{
- QTreeWidgetItem *item;
-
- if( parentItem )
- item = new QTreeWidgetItem( parentItem );
- else
- item = new QTreeWidgetItem( modulesTree );
-
- if( p_obj->psz_object_name )
- item->setText( 0, qfu( p_obj->psz_object_type ) + " \"" +
- qfu( p_obj->psz_object_name ) + "\" (" +
- QString::number((uintptr_t)p_obj) + ")" );
- else
- item->setText( 0, qfu( p_obj->psz_object_type ) + " (" +
- QString::number((uintptr_t)p_obj) + ")" );
-
- item->setExpanded( true );
-
- vlc_list_t *l = vlc_list_children( p_obj );
- for( int i=0; i < l->i_count; i++ )
- buildTree( item, l->p_values[i].p_object );
- vlc_list_release( l );
+ assert( msge );
+ sinkMessage( msge->msg );
}
void MessagesDialog::clearOrUpdate()
@@ -272,12 +235,6 @@ void MessagesDialog::clearOrUpdate()
clear();
}
-void MessagesDialog::updateTree()
-{
- modulesTree->clear();
- buildTree( NULL, VLC_OBJECT( p_intf->p_libvlc ) );
-}
-
void MessagesDialog::clear()
{
messages->clear();
@@ -309,6 +266,38 @@ bool MessagesDialog::save()
return false;
}
+void MessagesDialog::buildTree( QTreeWidgetItem *parentItem,
+ vlc_object_t *p_obj )
+{
+ QTreeWidgetItem *item;
+
+ if( parentItem )
+ item = new QTreeWidgetItem( parentItem );
+ else
+ item = new QTreeWidgetItem( modulesTree );
+
+ if( p_obj->psz_object_name )
+ item->setText( 0, qfu( p_obj->psz_object_type ) + " \"" +
+ qfu( p_obj->psz_object_name ) + "\" (" +
+ QString::number((uintptr_t)p_obj) + ")" );
+ else
+ item->setText( 0, qfu( p_obj->psz_object_type ) + " (" +
+ QString::number((uintptr_t)p_obj) + ")" );
+
+ item->setExpanded( true );
+
+ vlc_list_t *l = vlc_list_children( p_obj );
+ for( int i=0; i < l->i_count; i++ )
+ buildTree( item, l->p_values[i].p_object );
+ vlc_list_release( l );
+}
+
+void MessagesDialog::updateTree()
+{
+ modulesTree->clear();
+ buildTree( NULL, VLC_OBJECT( p_intf->p_libvlc ) );
+}
+
static void MsgCallback( msg_cb_data_t *data, msg_item_t *item, unsigned )
{
int canc = vlc_savecancel();
diff --git a/modules/gui/qt4/dialogs/messages.hpp b/modules/gui/qt4/dialogs/messages.hpp
index a4881cb..e723505 100644
--- a/modules/gui/qt4/dialogs/messages.hpp
+++ b/modules/gui/qt4/dialogs/messages.hpp
@@ -67,7 +67,7 @@ private:
msg_cb_data_t *cbData;
static void sinkMessage( msg_cb_data_t *, msg_item_t *, unsigned );
void customEvent( QEvent * );
- void sinkMessage( msg_item_t *item, unsigned );
+ void sinkMessage( msg_item_t *item );
private slots:
void updateTab( int );
More information about the vlc-devel
mailing list