From 25e07587af51258e1a90af4953aab8f2cafba1f5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C4=83t=C4=83lin=20Badea?= Date: Thu, 9 Aug 2012 21:53:26 +0300 Subject: Fix highlighting and disable scrollToBottom in the history dialog. diff --git a/Swift/QtUI/QtChatView.cpp b/Swift/QtUI/QtChatView.cpp index 5ade8d6..1feb8eb 100644 --- a/Swift/QtUI/QtChatView.cpp +++ b/Swift/QtUI/QtChatView.cpp @@ -28,7 +28,7 @@ namespace Swift { -QtChatView::QtChatView(QtChatTheme* theme, QWidget* parent, bool disableAutoScroll) : QWidget(parent), fontSizeSteps_(0) { +QtChatView::QtChatView(QtChatTheme* theme, QWidget* parent, bool disableAutoScroll) : QWidget(parent), fontSizeSteps_(0), disableAutoScroll_(disableAutoScroll) { theme_ = theme; QVBoxLayout* mainLayout = new QVBoxLayout(this); @@ -291,11 +291,9 @@ void QtChatView::handleFrameSizeChanged() { topMessageAdded_ = false; } - if (isAtBottom_) { + if (isAtBottom_ && !disableAutoScroll_) { scrollToBottom(); } - - emit contentSizeChanged(); } void QtChatView::handleLinkClicked(const QUrl& url) { @@ -468,8 +466,4 @@ void QtChatView::resetTopInsertPoint() { firstElement_ = QWebElement(); } -bool QtChatView::findText(const QString& text, QWebPage::FindFlags options) { - return webPage_->findText(text, options); -} - } diff --git a/Swift/QtUI/QtChatView.h b/Swift/QtUI/QtChatView.h index 6b5d21f..118f14b 100644 --- a/Swift/QtUI/QtChatView.h +++ b/Swift/QtUI/QtChatView.h @@ -11,7 +11,6 @@ #include #include #include -#include #include @@ -48,7 +47,6 @@ namespace Swift { void setMUCInvitationJoined(QString id); void showEmoticons(bool show); int getSnippetPositionByDate(const QDate& date); - bool findText(const QString& text, QWebPage::FindFlags options); signals: void gotFocus(); @@ -57,7 +55,6 @@ namespace Swift { void scrollRequested(int pos); void scrollReachedTop(); void scrollReachedBottom(); - void contentSizeChanged(); public slots: void copySelectionToClipboard(); @@ -96,6 +93,7 @@ namespace Swift { QWebElement lastElement_; QWebElement firstElement_; QWebElement document_; + bool disableAutoScroll_; }; } diff --git a/Swift/QtUI/QtHistoryWindow.cpp b/Swift/QtUI/QtHistoryWindow.cpp index c2dcbcb..932922e 100644 --- a/Swift/QtUI/QtHistoryWindow.cpp +++ b/Swift/QtUI/QtHistoryWindow.cpp @@ -61,7 +61,6 @@ QtHistoryWindow::QtHistoryWindow(SettingsProvider* settings, UIEventStream* even connect(conversation_, SIGNAL(scrollReachedTop()), this, SLOT(handleScrollReachedTop())); connect(conversation_, SIGNAL(scrollReachedBottom()), this, SLOT(handleScrollReachedBottom())); connect(conversation_, SIGNAL(fontResized(int)), this, SLOT(handleFontResized(int))); - connect(conversation_, SIGNAL(contentSizeChanged()), this, SLOT(handleContentSizeChanged())); connect(ui_.searchBox_->lineEdit(), SIGNAL(returnPressed()), this, SLOT(handleReturnPressed())); connect(ui_.calendarWidget_, SIGNAL(clicked(const QDate&)), this, SLOT(handleCalendarClicked(const QDate&))); connect(ui_.calendarWidget_, SIGNAL(activated(const QDate&)), this, SLOT(handleCalendarClicked(const QDate&))); @@ -74,7 +73,6 @@ QtHistoryWindow::~QtHistoryWindow() { disconnect(conversation_, SIGNAL(scrollReachedTop()), this, SLOT(handleScrollReachedTop())); disconnect(conversation_, SIGNAL(scrollReachedBottom()), this, SLOT(handleScrollReachedBottom())); disconnect(conversation_, SIGNAL(fontResized(int)), this, SLOT(handleFontResized(int))); - disconnect(conversation_, SIGNAL(contentSizeChanged()), this, SLOT(handleContentSizeChanged())); disconnect(ui_.searchBox_->lineEdit(), SIGNAL(returnPressed()), this, SLOT(handleReturnPressed())); disconnect(ui_.calendarWidget_, SIGNAL(clicked(const QDate&)), this, SLOT(handleCalendarClicked(const QDate&))); disconnect(ui_.calendarWidget_, SIGNAL(activated(const QDate&)), this, SLOT(handleCalendarClicked(const QDate&))); @@ -110,6 +108,10 @@ void QtHistoryWindow::addMessage(const std::string &message, const std::string & QString messageHTML(P2QSTRING(message)); messageHTML = Qt::escape(messageHTML); + QString searchTerm = ui_.searchBox_->lineEdit()->text(); + if (searchTerm.length()) { + messageHTML.replace(searchTerm, "" + searchTerm + ""); + } // note: time uses localtime QDate date = QDate(time.date().year(), time.date().month(), time.date().day()); @@ -235,8 +237,4 @@ boost::gregorian::date QtHistoryWindow::getLastVisibleDate() { return boost::gregorian::date(boost::gregorian::not_a_date_time); } -void QtHistoryWindow::handleContentSizeChanged() { - conversation_->findText(ui_.searchBox_->lineEdit()->text(), QWebPage::HighlightAllOccurrences); -} - } diff --git a/Swift/QtUI/QtHistoryWindow.h b/Swift/QtUI/QtHistoryWindow.h index 79449bd..49de098 100644 --- a/Swift/QtUI/QtHistoryWindow.h +++ b/Swift/QtUI/QtHistoryWindow.h @@ -48,7 +48,6 @@ namespace Swift { void handleCalendarClicked(const QDate& date); void handlePreviousButtonClicked(); void handleNextButtonClicked(); - void handleContentSizeChanged(); private: void handleSomethingSelectedChanged(RosterItem* item); -- cgit v0.10.2-6-g49f6