void RulerT::mousePressEvent(QMouseEvent *m) { QRect fpo; mousePressed = true; rulerCode = 0; if (haveInd) { fpo = QRect(static_cast<int>(firstLine+leftIndent-offset)-4, 0, 8, 12); if (fpo.contains(m->pos())) { rulerCode = 1; mouseX = m->x(); return; } fpo = QRect(static_cast<int>(leftIndent-offset)-4, 12, 8, 12); if (fpo.contains(m->pos())) { rulerCode = 2; mouseX = m->x(); return; } } if (tabValues.count() != 0) { for (int yg = 0; yg < static_cast<int>(tabValues.count()); yg++) { fpo = QRect(static_cast<int>(tabValues[yg].tabPosition-offset)-3, 15, 8, 8); if (fpo.contains(m->pos())) { rulerCode = 3; actTab = yg; mouseX = m->x(); emit tabSelected(); emit typeChanged(tabValues[actTab].tabType); emit tabMoved(tabValues[actTab].tabPosition); emit fillCharChanged(tabValues[actTab].tabFillChar); repaint(); return; } } } if ((rulerCode == 0) && (m->button() == Qt::LeftButton)) { ParagraphStyle::TabRecord tb; tb.tabPosition = static_cast<double>(m->x() + offset); tb.tabType = 0; tb.tabFillChar = QChar(); tabValues.prepend(tb); actTab = 0; rulerCode = 3; updateTabList(); repaint(); emit newTab(); emit typeChanged(tabValues[actTab].tabType); emit tabMoved(tabValues[actTab].tabPosition); emit fillCharChanged(tabValues[actTab].tabFillChar); qApp->changeOverrideCursor(QCursor(Qt::SizeHorCursor)); } mouseX = m->x(); }
void ComboTabBar::slotTabMoved(int from, int to) { if (sender() == m_pinnedTabBar) { emit tabMoved(from, to); } else { emit tabMoved(from + pinnedTabsCount(), to + pinnedTabsCount()); } }
void ChoqokTabBar::moveTab( int from , int to ) { int low , high; if( from == to ) return ; if( from > to ) { low = to; high = from; } if( from < to ) { low = from; high = to; } p->actions_list.move( from , to ); p->st_widget->move( from , to ); int shift = (from > to)*2 -1; for( int i=0; i<p->history_list.count() ; i++ ) { int index = p->history_list.at(i); if( index > low && index < high ) p->history_list[ i ] += shift; if( index == from ) p->history_list[ i ] = to; } refreshTabBar(); emit tabMoved( from , to ); }
void TabBar::mouseReleaseEvent(QMouseEvent* ev) { if (d->readOnly) return; d->autoScroll = false; if (ev->button() == Qt::LeftButton && d->targetTab != 0) { emit tabMoved(d->activeTab - 1, d->targetTab - 1); d->targetTab = 0; } }
void TabWidget::createTabTree() { m_tabTree = new TabTree(this); m_toolBarTree->addWidget(m_tabTree); m_tabTree->setObjectName("tab_tree"); connect( m_tabTree, SIGNAL(tabMenuRequested(QPoint,QString)), this, SIGNAL(tabMenuRequested(QPoint,QString)) ); connect( m_tabTree, SIGNAL(tabMoved(QString,QString,QString)), this, SIGNAL(tabMoved(QString,QString,QString)) ); connect( m_tabTree, SIGNAL(dropItems(QString,QMimeData)), this, SIGNAL(dropItems(QString,QMimeData)) ); connect( m_tabTree, SIGNAL(currentTabChanged(int)), this, SLOT(setCurrentIndex(int)) ); updateToolBar(); // Override left and right keys of tab tree. addTabAction(m_tabTree, Qt::Key_Left, this, SLOT(previousTab()), Qt::WidgetShortcut); addTabAction(m_tabTree, Qt::Key_Right, this, SLOT(nextTab()), Qt::WidgetShortcut); }
void RulerT::removeActTab() { if (actTab > -1) { tabValues.removeAt(actTab); actTab = 0; if (tabValues.count() != 0) { emit typeChanged(tabValues[actTab].tabType); emit tabMoved(tabValues[actTab].tabPosition); emit fillCharChanged(tabValues[actTab].tabFillChar); } else emit noTabs(); } repaint(); }
void RulerT::mouseReleaseEvent(QMouseEvent *m) { mousePressed = false; qApp->restoreOverrideCursor(); if ((m->y() < height()) && (m->y() > 0)) { if (rulerCode == 3) { if (m->button() == Qt::RightButton) { tabValues[actTab].tabType += 1; if (tabValues[actTab].tabType > 4) tabValues[actTab].tabType = 0; emit typeChanged(tabValues[actTab].tabType); repaint(); } } } else { if (rulerCode == 3) { tabValues.removeAt(actTab); actTab = 0; if (tabValues.count() != 0) { emit typeChanged(tabValues[actTab].tabType); emit tabMoved(tabValues[actTab].tabPosition); emit fillCharChanged(tabValues[actTab].tabFillChar); } else emit noTabs(); repaint(); } } rulerCode = 0; emit mouseReleased(); }
void TabWidget::onTabMoved(int from, int to) { m_stackedWidget->insertWidget(to, m_stackedWidget->widget(from)); emit tabMoved(from, to); }
void RulerT::mouseMoveEvent(QMouseEvent *m) { double oldInd; QRect fpo; if ((mousePressed) && (m->y() < height()) && (m->y() > 0) && (m->x() > 0) && (m->x() < width())) { qApp->changeOverrideCursor(QCursor(Qt::SizeHorCursor)); switch (rulerCode) { case 1: firstLine -= mouseX - m->x(); if (firstLine+leftIndent+offset < offset) firstLine += mouseX - m->x(); if (firstLine+leftIndent > Width) firstLine = Width-leftIndent; emit firstLineMoved(firstLine); repaint(); break; case 2: oldInd = leftIndent+firstLine; leftIndent -= mouseX - m->x(); if (leftIndent < 0) leftIndent = 0; if (leftIndent > Width-1) leftIndent = Width-1; firstLine = oldInd - leftIndent; emit leftIndentMoved(leftIndent); emit firstLineMoved(firstLine); repaint(); break; case 3: tabValues[actTab].tabPosition -= mouseX - m->x(); if (tabValues[actTab].tabPosition < 0) tabValues[actTab].tabPosition = 0; if (tabValues[actTab].tabPosition > Width-1) tabValues[actTab].tabPosition = Width-1; updateTabList(); emit tabMoved(tabValues[actTab].tabPosition); repaint(); break; default: break; } mouseX = m->x(); return; } if ((!mousePressed) && (m->y() < height()) && (m->y() > 0) && (m->x() > 0) && (m->x() < width())) { setCursor(IconManager::instance()->loadCursor("tab.png", 3)); if (haveInd) { fpo = QRect(static_cast<int>(firstLine+leftIndent-offset)-4, 0, 8, 12); if (fpo.contains(m->pos())) { setCursor(QCursor(Qt::SizeHorCursor)); return; } fpo = QRect(static_cast<int>(leftIndent-offset)-4, 12, 8, 12); if (fpo.contains(m->pos())) { setCursor(QCursor(Qt::SizeHorCursor)); return; } } if (tabValues.count() != 0) { for (int yg = 0; yg < static_cast<int>(tabValues.count()); yg++) { fpo = QRect(static_cast<int>(tabValues[yg].tabPosition-offset)-3, 15, 8, 8); if (fpo.contains(m->pos())) { setCursor(QCursor(Qt::SizeHorCursor)); return; } } } } if ((mousePressed) && ((m->y() > height()) || (m->y() < 0) || (m->x() < 0) || (m->x() > width()))) { qApp->changeOverrideCursor(IconManager::instance()->loadCursor("DelPoint.png", 1, 1)); } }