QVariant qtractorMidiEventListModel::headerData ( int section, Qt::Orientation orient, int role ) const { // qDebug("headerData(%d, %d, %d)", section, int(orient), int(role)); if (orient == Qt::Horizontal) { switch (role) { case Qt::DisplayRole: #if 0 if (section == 0) { switch ((m_pEditor->timeScale())->displayFormat()) { case qtractorTimeScale::Frames: return tr("Frame"); case qtractorTimeScale::Time: return tr("Time"); case qtractorTimeScale::BBT: return tr("BBT"); } } #endif return m_headers.at(section); case Qt::TextAlignmentRole: return columnAlignment(section); default: break; } } return QVariant(); }
void MSTableColumn::columnAlignment(MSAlignment alignment_) { if (columnAlignment()!=alignment_) { _columnAlignment=alignment_; redraw(); } }
unsigned long MSTableColumn::style(void) const { unsigned long aStyle=_style!=0?_style:reportTable()->style(); if ((aStyle&(MSLeft|MSRight|MSCenter))==0) { aStyle|=columnAlignment(); } return aStyle; }
QVariant drumkv1widget_elements_model::data ( const QModelIndex& index, int role ) const { switch (role) { case Qt::DisplayRole: return itemDisplay(index); case Qt::TextAlignmentRole: return columnAlignment(index.column()); case Qt::ToolTipRole: return itemToolTip(index); default: break; } return QVariant(); }
QVariant drumkv1widget_elements_model::headerData ( int section, Qt::Orientation orient, int role ) const { if (orient == Qt::Horizontal) { switch (role) { case Qt::DisplayRole: return m_headers.at(section); case Qt::TextAlignmentRole: return columnAlignment(section); default: break; } } return QVariant(); }
QVariant qtractorMidiEventListModel::data ( const QModelIndex& index, int role ) const { // qDebug("data(%d, %d, %d)", index.row(), index.column(), int(role)); switch (role) { case Qt::DisplayRole: return itemDisplay(index); case Qt::TextAlignmentRole: return columnAlignment(index.column()); case Qt::ToolTipRole: return itemToolTip(index); default: break; } return QVariant(); }
MSAttrValueList& MSTableColumn::get(MSAttrValueList& avList_) { MSStringVector aBoolVector("MSFalse\nMSTrue"); avList_<<MSAttrValue("tag",tag().symbolName(),MSAttrValue::Control|MSAttrValue::String); avList_<<MSAttrValue("heading",MSAttrValue::stringVectorToString(heading()),MSAttrValue::String); avList_<<MSAttrValue("headingForeground",server()->colorName(headingForeground()),MSAttrValue::Color); avList_<<MSAttrValue("headingFont",server()->fontName(headingFont()),MSAttrValue::Font); MSStringVector alignmentVector("MSNone\nMSCenter\nMSTop\nMSBottom\nMSLeft\nMSRight"); avList_<<MSAttrValue("headingAlignment",MSAttrValue::alignmentToString(headingAlignment()), alignmentVector, MSAttrValue::List); avList_<<MSAttrValue("cycleColors",MSAttrValue::colorVectorToString(cycleColors(),server()), MSAttrValue::Color|MSAttrValue::List|MSAttrValue::StringVector); const char *value; switch (cycleColorMode()) { case MSBackground: value="MSBackground"; break; case MSReverseVideo: value="MSReverseVideo"; break; case MSForeground: default: value="MSForeground"; break; } avList_<<MSAttrValue("cycleColorMode",value, MSStringVector("MSBackground\nMSForeground\nMSReverseVideo")); switch (columnAlignment()) { case MSCenter: value="MSCenter"; break; case MSLeft: value="MSLeft"; break; case MSRight: default: value="MSRight"; break; } avList_<<MSAttrValue("columnAlignment",value,MSStringVector("MSLeft\nMSRight\nMSCenter")); MSStringVector clipModeVector("MSNoClipping\nMSClipStars"); if(clipMode()==MSClipStars) value="MSClipStars"; else value="MSNoClipping"; avList_<<MSAttrValue("clipMode",value,clipModeVector); avList_<<MSAttrValue("columnWidth",MSString(columnWidth())); avList_<<MSAttrValue("editWidth",MSString(editWidth())); avList_<<MSAttrValue("resizable",resizable()==MSTrue?"MSTrue":"MSFalse",aBoolVector); avList_<<MSAttrValue("format",format().asString(),format().formats(),MSAttrValue::String); avList_<<MSAttrValue("breakOn",breakOn()==MSTrue?"MSTrue":"MSFalse",aBoolVector); MSStringVector modes="MSP::Total\nMSP::Minimum\nMSP::Maximum\nMSP::Average"; MSUnsignedLongVector modeValues; modeValues.append(MSP::Total); modeValues.append(MSP::Minimum); modeValues.append(MSP::Maximum); modeValues.append(MSP::Average); MSString result=MSAttrValue::enumToString(breakProcessMode(),modes,modeValues,modes(0),MSTrue); avList_<<MSAttrValue("breakProcessMode",result,modes); avList_<<MSAttrValue("breakProcessOn",breakProcessOn()==MSTrue?"MSTrue":"MSFalse",aBoolVector); avList_<<MSAttrValue("breakBg",server()->colorName(breakBgPixel()),MSAttrValue::Color); avList_<<MSAttrValue("breakFg",server()->colorName(breakFgPixel()),MSAttrValue::Color); // avList_<<MSAttrValue("breakFont",server()->fontName(breakFont()),MSAttrValue::Font); avList_<<MSAttrValue("suppressDuplicate",suppressDuplicate()==MSTrue?"MSTrue":"MSFalse",aBoolVector); avList_<<MSAttrValue("columnresize","",MSAttrValue::Callback); avList_<<MSAttrValue("valueQuoted",valueQuoted()==MSTrue?"MSTrue":"MSFalse",aBoolVector); avList_<<MSAttrValue("choices",MSAttrValue::stringVectorToString(choices()),MSAttrValue::StringVector); return MSWidget::get(avList_); }
void MSTableColumn::set(MSAttrValueList& avList_) { MSWidget::set(avList_); MSIndexVector index; for (unsigned i=0;i<avList_.length();i++) { if (avList_[i].attribute()=="breakOn") { breakOn(avList_[i].value().asBoolean()); index<<i; } else if (avList_[i].attribute()=="suppressDuplicate") { suppressDuplicate(avList_[i].value().asBoolean()); index<<i; } /* else if (avList_[i].attribute()=="breakFont") { breakFont(avList_[i].value()); index<<i; } */ else if (avList_[i].attribute()=="breakFg") { if(avList_[i].value().length()!=0) breakFg(avList_[i].value()); index<<i; } else if (avList_[i].attribute()=="breakBg") { if(avList_[i].value().length()!=0) breakBg(avList_[i].value()); index<<i; } else if (avList_[i].attribute()=="breakProcessOn") { breakProcessOn(avList_[i].value().asBoolean()); index<<i; } else if (avList_[i].attribute()=="breakProcessMode") { MSStringVector modes="MSP::Total\nMSP::Minimum\nMSP::Maximum\nMSP::Average"; MSUnsignedLongVector modeValues; modeValues.append(MSP::Total); modeValues.append(MSP::Minimum); modeValues.append(MSP::Maximum); modeValues.append(MSP::Average); unsigned long mode=MSAttrValue::stringToEnum(avList_[i].value(),modes,modeValues,MSP::Total,MSTrue); breakProcessMode((MSP::BreakProcessMode)mode); index<<i; } else if (avList_[i].attribute()=="heading") { heading(MSAttrValue::stringToStringVector(avList_[i].value())); index<<i; } else if (avList_[i].attribute()=="headingForeground") { headingForeground(avList_[i].value()); index<<i; } else if (avList_[i].attribute()=="headingFont") { headingFont(avList_[i].value()); index<<i; } else if (avList_[i].attribute()=="headingAlignment") { headingAlignment(MSAttrValue::stringToAlignment(avList_[i].value())); index<<i; } else if (avList_[i].attribute()=="cycleColors") { cycleColors(MSAttrValue::stringToStringVector(avList_[i].value())); index<<i; } else if (avList_[i].attribute()=="cycleColorMode") { if (avList_[i].value()=="MSBackground") cycleColorMode(MSBackground); else if (avList_[i].value()=="MSReverseVideo") cycleColorMode(MSReverseVideo); else cycleColorMode(MSForeground); index<<i; } else if (avList_[i].attribute()=="clipMode") { if (avList_[i].value()=="MSClipStars") clipMode(MSClipStars); else clipMode(MSNoClipping); index<<i; } else if (avList_[i].attribute()=="columnAlignment") { if (avList_[i].value()=="MSRight") columnAlignment(MSRight); else if (avList_[i].value()=="MSLeft") columnAlignment(MSLeft); else columnAlignment(MSCenter); index<<i; } else if (avList_[i].attribute()=="columnWidth") { columnWidth(avList_[i].value().asInt()); index<<i; } else if (avList_[i].attribute()=="editWidth") { editWidth(avList_[i].value().asInt()); index<<i; } else if (avList_[i].attribute()=="resizable") { resizable(avList_[i].value().asBoolean()); index<<i; } else if (avList_[i].attribute()=="format") { format(MSFormat(avList_[i].value())); index<<i; } else if(avList_[i].attribute()=="tag") { if(avList_[i].value().length()==0) tag(MSSymbol::nullSymbol()); else tag(MSSymbol(avList_[i].value())); index<<i; } else if (avList_[i].attribute()=="valueQuoted") { valueQuoted(avList_[i].value().asBoolean()); index<<i; } else if (avList_[i].attribute()=="choices") { choices(MSAttrValue::stringToStringVector(avList_[i].value())); index<<i; } } avList_.remove(index); }
MSAlignment MSTableColumn::cellAlignment(unsigned) { return columnAlignment(); }
toTreeWidgetItem *toListView::printPage(TOPrinter *printer, QPainter *painter, toTreeWidgetItem *top, int &column, int &level, int pageNo, bool paint) { Q3PaintDeviceMetrics wmetr(this); Q3PaintDeviceMetrics metrics(printer); double wpscalex = (double(metrics.width()) * wmetr.widthMM() / metrics.widthMM() / wmetr.width()); double wpscaley = (double(metrics.height()) * wmetr.heightMM() / metrics.heightMM() / wmetr.height()); painter->save(); QFont font = painter->font(); font.setPointSizeFloat(font.pointSizeFloat() / std::max(wpscalex, wpscaley)); painter->setFont(font); painter->scale(wpscalex, wpscaley); double mwidth = metrics.width() / wpscalex; double mheight = metrics.height() / wpscaley; double x = 0; if (paint) { QString numPage(tr("Page: %1").arg(pageNo)); painter->drawText(0, int(metrics.height() / wpscaley) - header()->height(), int(metrics.width() / wpscalex), header()->height(), Qt::SingleLine | Qt::AlignRight | Qt::AlignVCenter, numPage); painter->drawText(0, int(metrics.height() / wpscaley) - header()->height(), int(metrics.width() / wpscalex), header()->height(), Qt::SingleLine | Qt::AlignHCenter | Qt::AlignVCenter, middleString()); painter->drawText(0, int(metrics.height() / wpscaley) - header()->height(), int(metrics.width() / wpscalex), header()->height(), Qt::SingleLine | Qt::AlignLeft | Qt::AlignVCenter, sqlName()); painter->drawLine(0, header()->height() - 1, int(mwidth), header()->height() - 1); } font = toListView::font(); font.setPointSizeFloat(font.pointSizeFloat() / std::max(wpscalex, wpscaley)); painter->setFont(font); for (int i = column; i < columns(); i++) { double width = columnWidth(i); if (width + x >= mwidth) { if (i == column) width = mwidth - x - 1; else break; } if (paint) painter->drawText(int(x), 0, int(width), header()->height(), Qt::SingleLine | Qt::AlignLeft | Qt::AlignVCenter, header()->label(i)); x += width; } if (paint) painter->translate(0, header()->height()); double y = (header()->height() + 1) + header()->height(); int curLevel = level; int tree = rootIsDecorated() ? treeStepSize() : 0; int newCol = -1; toTreeWidgetItem *item = top; while (item && (y < mheight || item == top)) { if (column == 0) x = curLevel; else x = 0; painter->translate(x, 0); for (int i = column; i < columns(); i++) { double width = columnWidth(i); if (width + x >= mwidth) { if (i == column) width = mwidth - x - 1; else { newCol = i; break; } } if (i == 0) width -= curLevel; if (paint) { item->setSelected(false); item->paintCell(painter, qApp->palette().active(), i, int(width), columnAlignment(i)); painter->translate(width, 0); } x += width; } if (paint) painter->translate(-x, item->height()); y += item->height(); if (item->firstChild()) { item = item->firstChild(); curLevel += tree; } else if (item->nextSibling()) item = item->nextSibling(); else { do { item = item->parent(); curLevel -= tree; } while (item && !item->nextSibling()); if (item) item = item->nextSibling(); } } if (paint) painter->drawLine(0, 0, int(mwidth), 0); painter->restore(); if (newCol >= 0) { column = newCol; return top; } column = 0; level = curLevel; return item; }