Commit 0a13e88a authored by Hans-Christian Ebke's avatar Hans-Christian Ebke

Added horizontal scroll bar to logger widget.


git-svn-id: http://www.openflipper.org/svnrepo/OpenFlipper/branches/Free@14134 383ad7c9-94d9-4d36-a494-682f7c89f535
parent ac7f0562
......@@ -62,12 +62,11 @@ LoggerWidget::LoggerWidget( QWidget *parent)
QVBoxLayout* vlayout = new QVBoxLayout();
QHBoxLayout* hlayout = new QHBoxLayout();
QHBoxLayout* hlayout2 = new QHBoxLayout();
list_ = new QListWidget();
list_->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
list_->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
list_->setHorizontalScrollBarPolicy(Qt::ScrollBarAsNeeded);
list_->setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded);
list_->setFocusPolicy(Qt::NoFocus);
list_->setSelectionMode(QAbstractItemView::ExtendedSelection);
......@@ -113,10 +112,8 @@ LoggerWidget::LoggerWidget( QWidget *parent)
// ============================
// Scrollbar
// ============================
scrollBar_ = new QScrollBar(Qt::Vertical);
blockNext_ = false;
connect (scrollBar_, SIGNAL(valueChanged(int)), this, SLOT(scrollTo(int)));
connect (list_->verticalScrollBar(), SIGNAL(valueChanged(int)), this, SLOT(mapScrollPosition(int)));
connect (&loggerUpdateTimer_, SIGNAL(timeout ()), this, SLOT(slotScrollUpdate()));
......@@ -124,9 +121,6 @@ LoggerWidget::LoggerWidget( QWidget *parent)
loggerUpdateTimer_.setSingleShot(true);
loggerUpdateTimer_.setInterval(500);
hlayout2->addWidget(list_);
hlayout2->addWidget(scrollBar_);
allButton_ = new QPushButton(QIcon(path + "status_all.png"),tr("All Messages"));
allButton_->setCheckable(true);
allButton_->setAutoExclusive(true);
......@@ -168,7 +162,7 @@ LoggerWidget::LoggerWidget( QWidget *parent)
vlayout->setSpacing(0);
vlayout->setContentsMargins (0,0,0,0);
vlayout->addLayout( hlayout2 );
vlayout->addWidget(list_);
vlayout->addLayout( hlayout );
setLayout( vlayout );
......@@ -181,44 +175,11 @@ LoggerWidget::~LoggerWidget()
delete warnButton_;
delete infoButton_;
delete allButton_;
delete scrollBar_;
delete context_;
delete list_;
}
//-------------------------------------------------------------------------------------
/// workaround for scrolling
void LoggerWidget::mapScrollPosition(int _pos){
//map list_'s internal scrollbar position to our own scrollBar position
blockNext_ = true;
scrollBar_->setValue( floor( 100 * _pos / (double) list_->verticalScrollBar()->maximum() ) );
}
//-------------------------------------------------------------------------------------
/// workaround for scrolling
void LoggerWidget::scrollTo(int _pos){
//if the scrollEvent was triggered by list_ ignore it
if (blockNext_){
blockNext_ = false;
return;
}
// now it gets ugly ;)
if (_pos < 5)
list_->scrollToTop();
else if (_pos > 95)
list_->scrollToBottom();
else
list_->scrollToItem( list_->item( floor((list_->count()-1) * (_pos / 100.0)) ) );
list_->hide();
list_->show();
}
//-------------------------------------------------------------------------------------
/// Append a new logmessage to log viewer
......
......@@ -94,9 +94,6 @@ class LoggerWidget : public QWidget
QListWidget* list_;
//scrolling with list_'s scrollbar doesn't work correctly
//use separate scrollbar as workaround
QScrollBar* scrollBar_;
bool blockNext_;
QPushButton* allButton_;
......@@ -125,10 +122,6 @@ class LoggerWidget : public QWidget
/// update the list if a button was pressed
void updateList();
/// workaround for scrolling
void scrollTo(int _pos);
/// map scroll position of list to scrollbar position
void mapScrollPosition(int _pos);
/// copy Selected rows to clipboard
void copySelected();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment