void FancyTabBar::paintTab(QPainter *painter, int tabIndex) const { if (!validIndex(tabIndex)) { qWarning("invalid index"); return; } painter->save(); QRect rect = tabRect(tabIndex); bool selected = (tabIndex == m_currentIndex); bool enabled = isTabEnabled(tabIndex); if (selected) { //jassuncao:if (creatorTheme()->widgetStyle() == Theme::StyleFlat) { if(true) { // background color of a fancy tab that is active painter->fillRect(rect.adjusted(0, 0, 0, -1), QColor(0x90,0x90,0x90,0xFF)); } else { //background painter->save(); QLinearGradient grad(rect.topLeft(), rect.topRight()); grad.setColorAt(0, QColor(255, 255, 255, 140)); grad.setColorAt(1, QColor(255, 255, 255, 210)); painter->fillRect(rect.adjusted(0, 0, 0, -1), grad); painter->restore(); //shadows painter->setPen(QColor(0, 0, 0, 110)); painter->drawLine(rect.topLeft() + QPoint(1,-1), rect.topRight() - QPoint(0,1)); painter->drawLine(rect.bottomLeft(), rect.bottomRight()); painter->setPen(QColor(0, 0, 0, 40)); painter->drawLine(rect.topLeft(), rect.bottomLeft()); //highlights painter->setPen(QColor(255, 255, 255, 50)); painter->drawLine(rect.topLeft() + QPoint(0, -2), rect.topRight() - QPoint(0,2)); painter->drawLine(rect.bottomLeft() + QPoint(0, 1), rect.bottomRight() + QPoint(0,1)); painter->setPen(QColor(255, 255, 255, 40)); painter->drawLine(rect.topLeft() + QPoint(0, 0), rect.topRight()); painter->drawLine(rect.topRight() + QPoint(0, 1), rect.bottomRight() - QPoint(0, 1)); painter->drawLine(rect.bottomLeft() + QPoint(0,-1), rect.bottomRight()-QPoint(0,1)); } } QString tabText(this->tabText(tabIndex)); QRect tabTextRect(rect); const bool drawIcon = rect.height() > 36; QRect tabIconRect(tabTextRect); tabTextRect.translate(0, drawIcon ? -2 : 1); QFont boldFont(painter->font()); //jassuncao boldFont.setPointSizeF(StyleHelper::sidebarFontSize()); boldFont.setPointSizeF(8); boldFont.setBold(true); painter->setFont(boldFont); painter->setPen(selected ? QColor(255, 255, 255, 160) : QColor(0, 0, 0, 110)); const int textFlags = Qt::AlignCenter | (drawIcon ? Qt::AlignBottom : Qt::AlignVCenter) | Qt::TextWordWrap; #if defined(Q_OS_MAC) bool isMacHost = true; #else bool isMacHost = false; #endif if (!isMacHost && !selected && enabled) { painter->save(); int fader = int(m_tabs[tabIndex]->fader()); //jassuncaoif (creatorTheme()->widgetStyle() == Theme::StyleFlat) { if(true) { //QColor c = creatorTheme()->color(Theme::BackgroundColorHover); QColor c(0x51,0x51,0x51,0xFF); c.setAlpha(int(255 * fader/40.0)); // FIXME: hardcoded end value 40 painter->fillRect(rect, c); } else { QLinearGradient grad(rect.topLeft(), rect.topRight()); grad.setColorAt(0, Qt::transparent); grad.setColorAt(0.5, QColor(255, 255, 255, fader)); grad.setColorAt(1, Qt::transparent); painter->fillRect(rect, grad); painter->setPen(QPen(grad, 1.0)); painter->drawLine(rect.topLeft(), rect.topRight()); painter->drawLine(rect.bottomLeft(), rect.bottomRight()); } painter->restore(); } if (!enabled) painter->setOpacity(0.7); if (drawIcon) { int textHeight = painter->fontMetrics().boundingRect(QRect(0, 0, width(), height()), Qt::TextWordWrap, tabText).height(); tabIconRect.adjust(0, 4, 0, -textHeight); //jassuncao StyleHelper::drawIconWithShadow(tabIcon(tabIndex), tabIconRect, painter, enabled ? QIcon::Normal : QIcon::Disabled); drawIconWithShadow(tabIcon(tabIndex), tabIconRect, painter, enabled ? QIcon::Normal : QIcon::Disabled); } painter->setOpacity(1.0); //FIXME: was 0.7 before? /*jassuncao if (enabled) { painter->setPen(selected ? creatorTheme()->color(Theme::FancyTabWidgetEnabledSelectedTextColor) : creatorTheme()->color(Theme::FancyTabWidgetEnabledUnselectedTextColor)); } else { painter->setPen(selected ? creatorTheme()->color(Theme::FancyTabWidgetDisabledSelectedTextColor) : creatorTheme()->color(Theme::FancyTabWidgetDisabledUnselectedTextColor)); } */ if (enabled) { painter->setPen(selected ? QColor(0x3C,0x3C,0x3C,0xFF) : QColor(0xFF,0xFF,0xFF,0xFF)); } else { painter->setPen(selected ? QColor(0xFF,0xFF,0xFF,0xFF) : QColor(0xFF,0xFF,0xFF,0x78)); } painter->translate(0, -1); painter->drawText(tabTextRect, textFlags, tabText); painter->restore(); }
static int loadLocalTimeDescriptors( bsl::vector<baltzo::LocalTimeDescriptor> *descriptors, const bsl::vector<RawLocalTimeType>& localTimeDescriptors, const bsl::vector<char>& abbreviationBuffer) // Load the specified 'descriptors' with the sequence of local time // descriptors described by the specified 'localTimeDescriptors' holding // raw information read from the file, and referring to null-terminated // abbreviations in the specified 'abbreviationBuffer'. Return 0 on // success, and a non-zero value otherwise. { BALL_LOG_SET_CATEGORY(LOG_CATEGORY); for (bsl::size_t i = 0; i < localTimeDescriptors.size(); ++i) { if (!validIndex(abbreviationBuffer, localTimeDescriptors[i].d_abbreviationIndex)) { BALL_LOG_ERROR << "Invalid abbreviation buffer index " << (int)localTimeDescriptors[i].d_abbreviationIndex << " found in Zoneinfo file. Expecting [0 .. " << abbreviationBuffer.size() - 1 << "]." << BALL_LOG_END; return -20; // RETURN } const int utcOffset = decode32(localTimeDescriptors[i].d_offset); if (!baltzo::LocalTimeDescriptor::isValidUtcOffsetInSeconds( utcOffset)) { BALL_LOG_ERROR << "Invalid UTC offset " << utcOffset << " found in Zoneinfo file. Expecting " << "[-86399 .. 86399]." << BALL_LOG_END; return -21; // RETURN } const bool isDst = localTimeDescriptors[i].d_isDst; // Passing the address of the first character pointed by the index (C // string). const char *description = &abbreviationBuffer[localTimeDescriptors[i].d_abbreviationIndex]; // Check if 'description' is null-terminated. const int maxLength = abbreviationBuffer.size() - localTimeDescriptors[i].d_abbreviationIndex - 1; if (maxLength < bdlb::String::strnlen(description, maxLength + 1)) { BALL_LOG_ERROR << "Abbreviation string is not null-terminated." << BALL_LOG_END; return -22; // RETURN } descriptors->push_back(baltzo::LocalTimeDescriptor(utcOffset, isDst, description)); } return 0; }
void FancyTabBar::paintTab(QPainter *painter, int tabIndex) const { if (!validIndex(tabIndex)) { qWarning("invalid index"); return; } painter->save(); QRect rect = tabRect(tabIndex); bool selected = (tabIndex == m_currentIndex); bool enabled = isTabEnabled(tabIndex); if (selected) { //background painter->save(); QLinearGradient grad(rect.topLeft(), rect.topRight()); grad.setColorAt(0, QColor(255, 255, 255, 140)); grad.setColorAt(1, QColor(255, 255, 255, 210)); painter->fillRect(rect.adjusted(0, 0, 0, -1), grad); painter->restore(); //shadows painter->setPen(QColor(0, 0, 0, 110)); painter->drawLine(rect.topLeft() + QPoint(1,-1), rect.topRight() - QPoint(0,1)); painter->drawLine(rect.bottomLeft(), rect.bottomRight()); painter->setPen(QColor(0, 0, 0, 40)); painter->drawLine(rect.topLeft(), rect.bottomLeft()); //highlights painter->setPen(QColor(255, 255, 255, 50)); painter->drawLine(rect.topLeft() + QPoint(0, -2), rect.topRight() - QPoint(0,2)); painter->drawLine(rect.bottomLeft() + QPoint(0, 1), rect.bottomRight() + QPoint(0,1)); painter->setPen(QColor(255, 255, 255, 40)); painter->drawLine(rect.topLeft() + QPoint(0, 0), rect.topRight()); painter->drawLine(rect.topRight() + QPoint(0, 1), rect.bottomRight() - QPoint(0, 1)); painter->drawLine(rect.bottomLeft() + QPoint(0,-1), rect.bottomRight()-QPoint(0,1)); } QString tabText(this->tabText(tabIndex)); QRect tabTextRect(tabRect(tabIndex)); QRect tabIconRect(tabTextRect); tabTextRect.translate(0, -2); QFont boldFont(painter->font()); boldFont.setPointSizeF(StyleHelper::sidebarFontSize()); boldFont.setBold(true); painter->setFont(boldFont); painter->setPen(selected ? QColor(255, 255, 255, 160) : QColor(0, 0, 0, 110)); int textFlags = Qt::AlignCenter | Qt::AlignBottom | Qt::TextWordWrap; if (enabled) { painter->drawText(tabTextRect, textFlags, tabText); painter->setPen(selected ? QColor(60, 60, 60) : StyleHelper::panelTextColor()); } else { painter->setPen(selected ? StyleHelper::panelTextColor() : QColor(255, 255, 255, 120)); } #ifndef Q_WS_MAC if (!selected && enabled) { painter->save(); int fader = int(m_tabs[tabIndex]->fader()); QLinearGradient grad(rect.topLeft(), rect.topRight()); grad.setColorAt(0, Qt::transparent); grad.setColorAt(0.5, QColor(255, 255, 255, fader)); grad.setColorAt(1, Qt::transparent); painter->fillRect(rect, grad); painter->setPen(QPen(grad, 1.0)); painter->drawLine(rect.topLeft(), rect.topRight()); painter->drawLine(rect.bottomLeft(), rect.bottomRight()); painter->restore(); } #endif if (!enabled) painter->setOpacity(0.7); int textHeight = painter->fontMetrics().boundingRect(QRect(0, 0, width(), height()), Qt::TextWordWrap, tabText).height(); tabIconRect.adjust(0, 4, 0, -textHeight); StyleHelper::drawIconWithShadow(tabIcon(tabIndex), tabIconRect, painter, enabled ? QIcon::Normal : QIcon::Disabled); painter->translate(0, -1); painter->drawText(tabTextRect, textFlags, tabText); painter->restore(); }
bool Pager::remove(int index) { if (validIndex(index)) { d->images.removeAt(index); d->updateScrollBar(); d->labels.removeAt(index); d->searchHits.remove(index); d->hasAnnotation.remove(index); double oldPreModifier = d->indexPreModifiers.value(index, 0.0); double oldPostModifier = d->indexPostModifiers.value(index, 0.0); // Modify index modifiers QMap< int, double > updatedModifiers; QMutableMapIterator< int, double > iter(d->indexPreModifiers); iter.toBack(); while (iter.hasPrevious()) { iter.previous(); int targetIndex = iter.key(); if (targetIndex > index) { double modifier = iter.value(); iter.remove(); updatedModifiers[targetIndex - 1] = modifier; } else { if (targetIndex == index) { iter.remove(); } break; } } if (index != d->currentIndex - 1) updatedModifiers.insert(index, updatedModifiers.value(index, 0.0) + 1.0); d->indexPreModifiers.unite(updatedModifiers); updatedModifiers.clear(); iter = d->indexPostModifiers; iter.toBack(); while (iter.hasPrevious()) { iter.previous(); int targetIndex = iter.key(); if (targetIndex > index) { double modifier = iter.value(); iter.remove(); updatedModifiers[targetIndex - 1] = modifier; } else { if (targetIndex == index) { iter.remove(); } break; } } if (index == d->currentIndex - 1 && index > 0) updatedModifiers.insert(index - 1, updatedModifiers.value(index - 1, 0.0) + 1.0); d->indexPostModifiers.unite(updatedModifiers); // Modify Search Hits QMap< int, int > updatedSearchHits; QMutableMapIterator< int, int > iter2(d->searchHits); iter2.toBack(); while (iter2.hasPrevious()) { iter2.previous(); int targetIndex = iter2.key(); if (targetIndex > index) { int hits = iter2.value(); iter2.remove(); updatedSearchHits[targetIndex - 1] = hits; } else { if (targetIndex == index) { iter2.remove(); } break; } } d->searchHits.unite(updatedSearchHits); // Modify Annotations QMap< int, int > updatedHasAnnotation; iter2 = d->hasAnnotation; iter2.toBack(); while (iter2.hasPrevious()) { iter2.previous(); int targetIndex = iter2.key(); if (targetIndex > index) { int annotations = iter2.value(); iter2.remove(); updatedHasAnnotation[targetIndex - 1] = annotations; } else { if (targetIndex == index) { iter2.remove(); } break; } } d->hasAnnotation.unite(updatedHasAnnotation); if (!nearAsDamnIt(oldPreModifier, 0)) { d->indexPreModifiers.insert(index, d->indexPreModifiers.value(index, 0.0) + oldPreModifier); } if (!nearAsDamnIt(oldPostModifier, 0)) { if (index > 0) { d->indexPostModifiers.insert(index - 1, d->indexPostModifiers.value(index - 1, 0.0) + oldPostModifier); } else { d->indexPreModifiers.insert(index, d->indexPostModifiers.value(index, 0.0) + oldPostModifier); } } if (index < d->currentIndex || d->currentIndex == count()) // FIXME { if (d->currentIndex == count()) { previous(); } else { d->currentIndex -= 1; d->guiIndex -= 1.0; } } d->timer.start(); update(); return true; } return false; }