void Editor::toggleBookmark ( int line ) { QTextCursor save = m_textEdit->textCursor(); int scroll = verticalScrollBar(); gotoLine ( line, false ); m_textEdit->textCursor().movePosition ( QTextCursor::StartOfLine, QTextCursor::MoveAnchor ); m_textEdit->textCursor().movePosition ( QTextCursor::EndOfLine, QTextCursor::KeepAnchor ); QString s = m_textEdit->textCursor().block().text().simplified(); // QTextCursor cursor = m_textEdit->textCursor(); bool activate; BlockUserData *blockUserData = ( BlockUserData* ) cursor.block().userData(); if ( !blockUserData ) { blockUserData = new BlockUserData(); blockUserData->bookmark = false; blockUserData->block = cursor.block(); } blockUserData->bookmark = !blockUserData->bookmark; cursor.block().setUserData ( blockUserData ); activate = blockUserData->bookmark; // QDateTime date=extractTimeStamp(s); if ( date.isValid() ) emit markTimeStamp ( date, activate ); // m_textEdit->setTextCursor ( cursor ); // //emit bookmark(this, s, QPair<bool,QTextBlock>(activate, cursor.block())); // m_mainimpl->toggleBookmark(this, s, activate, cursor.block()); m_textEdit->setTextCursor ( save ); setVerticalScrollBar ( scroll ); m_textEdit->lineNumbers()->update(); }
TextBrowser::TextBrowser(QWidget* parent) : QTextBrowser(parent) { d.ub = -1; d.bud = 0; setVerticalScrollBar(new StyledScrollBar(this)); setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); }
void ScrollBar::onCreate(const ScrollBar * Id) { Inherited::onCreate(Id); DefaultBoundedRangeModelUnrecPtr TheModel(DefaultBoundedRangeModel::create()); setRangeModel(TheModel); if(Id != NULL) { if(Id->getVerticalMinButton() != NULL && Id->getVerticalMaxButton() != NULL && Id->getVerticalScrollBar() != NULL && Id->getVerticalScrollField() != NULL) { FieldContainerUnrecPtr TempPtr(Id->getVerticalMinButton()->shallowCopy()); setVerticalMinButton(dynamic_pointer_cast<Button>(TempPtr)); TempPtr = Id->getVerticalMaxButton()->shallowCopy(); setVerticalMaxButton(dynamic_pointer_cast<Button>(TempPtr)); TempPtr = Id->getVerticalScrollBar()->shallowCopy(); setVerticalScrollBar(dynamic_pointer_cast<Button>(TempPtr)); TempPtr = Id->getVerticalScrollField()->shallowCopy(); setVerticalScrollField(dynamic_pointer_cast<Button>(TempPtr)); } if(Id->getHorizontalMinButton() != NULL && Id->getHorizontalMaxButton() != NULL && Id->getHorizontalScrollBar() != NULL && Id->getHorizontalScrollField() != NULL) { FieldContainerUnrecPtr TempPtr(Id->getHorizontalMinButton()->shallowCopy()); setHorizontalMinButton(dynamic_pointer_cast<Button>(TempPtr)); TempPtr = Id->getHorizontalMaxButton()->shallowCopy(); setHorizontalMaxButton(dynamic_pointer_cast<Button>(TempPtr)); TempPtr = Id->getHorizontalScrollBar()->shallowCopy(); setHorizontalScrollBar(dynamic_pointer_cast<Button>(TempPtr)); TempPtr = Id->getHorizontalScrollField()->shallowCopy(); setHorizontalScrollField(dynamic_pointer_cast<Button>(TempPtr)); } } }
AbstractTableView::AbstractTableView(QWidget* parent) : QAbstractScrollArea(parent) { // Class variable initialization mTableOffset = 0; mPrevTableOffset = mTableOffset + 1; Header_t data; data.isVisible = true; data.height = 20; data.activeButtonIndex = -1; mHeader = data; // Paint cell content only when debugger is running setDrawDebugOnly(true); mRowCount = 0; mHeaderButtonSytle.setStyleSheet(" QPushButton {\n background-color: rgb(192, 192, 192);\n border-style: outset;\n border-width: 2px;\n border-color: rgb(128, 128, 128);\n }\n QPushButton:pressed {\n background-color: rgb(192, 192, 192);\n border-style: inset;\n }"); mNbrOfLineToPrint = 0; memset(&mColResizeData, 0, sizeof(mColResizeData)); mGuiState = AbstractTableView::NoState; mShouldReload = true; mAllowPainting = true; // ScrollBar Init setVerticalScrollBar(new AbstractTableScrollBar(verticalScrollBar())); setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn); memset(&mScrollBarAttributes, 0, sizeof(mScrollBarAttributes)); horizontalScrollBar()->setRange(0, 0); horizontalScrollBar()->setPageStep(650); mMouseWheelScrollDelta = 4; setMouseTracking(true); // Slots connect(verticalScrollBar(), SIGNAL(actionTriggered(int)), this, SLOT(vertSliderActionSlot(int))); connect(Config(), SIGNAL(colorsUpdated()), this, SLOT(slot_updateColors())); connect(Config(), SIGNAL(fontsUpdated()), this, SLOT(slot_updateFonts())); connect(Config(), SIGNAL(shortcutsUpdated()), this, SLOT(slot_updateShortcuts())); // todo: try Qt::QueuedConnection to init Initialize(); }
PacketList::PacketList(QWidget *parent) : QTreeView(parent), proto_tree_(NULL), byte_view_tab_(NULL), cap_file_(NULL), decode_as_(NULL), ctx_column_(-1), create_near_overlay_(true), create_far_overlay_(true), capture_in_progress_(false), tail_timer_id_(0), rows_inserted_(false) { QMenu *main_menu_item, *submenu; QAction *action; setItemsExpandable(false); setRootIsDecorated(false); setSortingEnabled(true); setUniformRowHeights(true); setAccessibleName("Packet list"); setItemDelegateForColumn(0, &related_packet_delegate_); overlay_sb_ = new OverlayScrollBar(Qt::Vertical, this); setVerticalScrollBar(overlay_sb_); overlay_timer_id_ = startTimer(overlay_update_interval_); packet_list_model_ = new PacketListModel(this, cap_file_); setModel(packet_list_model_); sortByColumn(-1, Qt::AscendingOrder); // XXX We might want to reimplement setParent() and fill in the context // menu there. ctx_menu_.addAction(window()->findChild<QAction *>("actionEditMarkPacket")); ctx_menu_.addAction(window()->findChild<QAction *>("actionEditIgnorePacket")); ctx_menu_.addAction(window()->findChild<QAction *>("actionEditSetTimeReference")); ctx_menu_.addAction(window()->findChild<QAction *>("actionEditTimeShift")); ctx_menu_.addAction(window()->findChild<QAction *>("actionEditPacketComment")); ctx_menu_.addSeparator(); ctx_menu_.addAction(window()->findChild<QAction *>("actionViewEditResolvedName")); ctx_menu_.addSeparator(); main_menu_item = window()->findChild<QMenu *>("menuApplyAsFilter"); submenu = new QMenu(main_menu_item->title()); ctx_menu_.addMenu(submenu); submenu->addAction(window()->findChild<QAction *>("actionAnalyzeAAFSelected")); submenu->addAction(window()->findChild<QAction *>("actionAnalyzeAAFNotSelected")); submenu->addAction(window()->findChild<QAction *>("actionAnalyzeAAFAndSelected")); submenu->addAction(window()->findChild<QAction *>("actionAnalyzeAAFOrSelected")); submenu->addAction(window()->findChild<QAction *>("actionAnalyzeAAFAndNotSelected")); submenu->addAction(window()->findChild<QAction *>("actionAnalyzeAAFOrNotSelected")); main_menu_item = window()->findChild<QMenu *>("menuPrepareAFilter"); submenu = new QMenu(main_menu_item->title()); ctx_menu_.addMenu(submenu); submenu->addAction(window()->findChild<QAction *>("actionAnalyzePAFSelected")); submenu->addAction(window()->findChild<QAction *>("actionAnalyzePAFNotSelected")); submenu->addAction(window()->findChild<QAction *>("actionAnalyzePAFAndSelected")); submenu->addAction(window()->findChild<QAction *>("actionAnalyzePAFOrSelected")); submenu->addAction(window()->findChild<QAction *>("actionAnalyzePAFAndNotSelected")); submenu->addAction(window()->findChild<QAction *>("actionAnalyzePAFOrNotSelected")); const char *conv_menu_name = "menuConversationFilter"; main_menu_item = window()->findChild<QMenu *>(conv_menu_name); conv_menu_.setTitle(main_menu_item->title()); conv_menu_.setObjectName(conv_menu_name); ctx_menu_.addMenu(&conv_menu_); const char *colorize_menu_name = "menuColorizeConversation"; main_menu_item = window()->findChild<QMenu *>(colorize_menu_name); colorize_menu_.setTitle(main_menu_item->title()); colorize_menu_.setObjectName(colorize_menu_name); ctx_menu_.addMenu(&colorize_menu_); main_menu_item = window()->findChild<QMenu *>("menuSCTP"); submenu = new QMenu(main_menu_item->title()); ctx_menu_.addMenu(submenu); submenu->addAction(window()->findChild<QAction *>("actionSCTPAnalyseThisAssociation")); submenu->addAction(window()->findChild<QAction *>("actionSCTPShowAllAssociations")); submenu->addAction(window()->findChild<QAction *>("actionSCTPFilterThisAssociation")); main_menu_item = window()->findChild<QMenu *>("menuFollow"); submenu = new QMenu(main_menu_item->title()); ctx_menu_.addMenu(submenu); submenu->addAction(window()->findChild<QAction *>("actionAnalyzeFollowTCPStream")); submenu->addAction(window()->findChild<QAction *>("actionAnalyzeFollowUDPStream")); submenu->addAction(window()->findChild<QAction *>("actionAnalyzeFollowSSLStream")); ctx_menu_.addSeparator(); main_menu_item = window()->findChild<QMenu *>("menuEditCopy"); submenu = new QMenu(main_menu_item->title()); ctx_menu_.addMenu(submenu); action = submenu->addAction(tr("Summary as Text")); action->setData(copy_summary_text_); connect(action, SIGNAL(triggered()), this, SLOT(copySummary())); action = submenu->addAction(tr(UTF8_HORIZONTAL_ELLIPSIS "as CSV")); action->setData(copy_summary_csv_); connect(action, SIGNAL(triggered()), this, SLOT(copySummary())); action = submenu->addAction(tr(UTF8_HORIZONTAL_ELLIPSIS "as YAML")); action->setData(copy_summary_yaml_); connect(action, SIGNAL(triggered()), this, SLOT(copySummary())); submenu->addSeparator(); submenu->addAction(window()->findChild<QAction *>("actionEditCopyAsFilter")); submenu->addSeparator(); action = window()->findChild<QAction *>("actionContextCopyBytesHexTextDump"); submenu->addAction(action); copy_actions_ << action; action = window()->findChild<QAction *>("actionContextCopyBytesHexDump"); submenu->addAction(action); copy_actions_ << action; action = window()->findChild<QAction *>("actionContextCopyBytesPrintableText"); submenu->addAction(action); copy_actions_ << action; action = window()->findChild<QAction *>("actionContextCopyBytesHexStream"); submenu->addAction(action); copy_actions_ << action; action = window()->findChild<QAction *>("actionContextCopyBytesBinary"); submenu->addAction(action); copy_actions_ << action; ctx_menu_.addSeparator(); ctx_menu_.addMenu(&proto_prefs_menu_); decode_as_ = window()->findChild<QAction *>("actionAnalyzeDecodeAs"); ctx_menu_.addAction(decode_as_); // "Print" not ported intentionally action = window()->findChild<QAction *>("actionViewShowPacketInNewWindow"); ctx_menu_.addAction(action); initHeaderContextMenu(); g_assert(gbl_cur_packet_list == NULL); gbl_cur_packet_list = this; connect(packet_list_model_, SIGNAL(goToPacket(int)), this, SLOT(goToPacket(int))); connect(packet_list_model_, SIGNAL(itemHeightChanged(const QModelIndex&)), this, SLOT(updateRowHeights(const QModelIndex&))); connect(wsApp, SIGNAL(addressResolutionChanged()), this, SLOT(redrawVisiblePackets())); header()->setContextMenuPolicy(Qt::CustomContextMenu); connect(header(), SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(showHeaderMenu(QPoint))); connect(header(), SIGNAL(sectionResized(int,int,int)), this, SLOT(sectionResized(int,int,int))); connect(header(), SIGNAL(sectionMoved(int,int,int)), this, SLOT(sectionMoved(int,int,int))); connect(verticalScrollBar(), SIGNAL(actionTriggered(int)), this, SLOT(vScrollBarActionTriggered(int))); connect(&proto_prefs_menu_, SIGNAL(showProtocolPreferences(QString)), this, SIGNAL(showProtocolPreferences(QString))); connect(&proto_prefs_menu_, SIGNAL(editProtocolPreference(preference*,pref_module*)), this, SIGNAL(editProtocolPreference(preference*,pref_module*))); }