#include <LegendTable.h>
Public Types | |
| enum | Column { ColumnNull, ColumnPenColor, ColumnPenWidth, ColumnPenStyle, ColumnSymbolType, ColumnSymbolSize, ColumnSymbolPenColor, ColumnSymbolPenWidth, ColumnSymbolPenStyle, ColumnSymbolBrushColor, ColumnSymbolBrushStyle, ColumnTextColor, ColumnText } |
| enum | PropertySection { All = 0x3F, Text = 0x01, Pen = 0x02, SymbolAll = 0x1C, SymbolType = 0x04, SymbolPen = 0x08, SymbolBrush = 0x10, TextColor = 0x20, TextAll = 0x21 } |
Signals | |
| void | changed () |
Public Member Functions | |
| LegendTable (QWidget *parent=0) | |
| bool | oneColor () const |
| bool | readOnlyText () const |
| void | setConstant (bool c) |
| void | setLegend (Legend *legend) |
| void | setOneColor (bool oc) |
| void | setPropertySections (PropertySections s=All) |
| void | setReadOnlyText (bool ro) |
Static Public Member Functions | |
| static int | brushItem (Qt::BrushStyle b) |
| static Qt::BrushStyle | brushStyle (int index) |
| static void | initBrushStyles (QComboBox *w) |
| static void | initPenStyles (QComboBox *w) |
| static void | initSymbolTypes (QComboBox *w) |
| static int | penItem (Qt::PenStyle p) |
| static Qt::PenStyle | penStyle (int index) |
| static int | symbolItem (Symbol::Type t) |
| static Symbol::Type | symbolType (int index) |
GUI table for Legend.
{All=0x3F, Text=0x01, Pen=0x02, SymbolAll=0x1C,
SymbolType=0x04, SymbolPen=0x08, SymbolBrush=0x10, TextColor=0x20, TextAll=0x21};
| SciFigs::LegendTable::LegendTable | ( | QWidget * | parent = 0 | ) |
References changed(), and TRACE.
: QTableView(parent)
{
TRACE;
LegendTableItem * model=new LegendTableItem(this);
connect(model, SIGNAL(dataChanged (const QModelIndex &, const QModelIndex &)),
this, SIGNAL(changed()));
setModel(model);
LegendTableDelegate * delegate=new LegendTableDelegate(this);
setItemDelegate(delegate);
connect(delegate, SIGNAL(dataChanged()), this, SLOT(applyAllSelected()));
setSelectionBehavior(QAbstractItemView::SelectRows);
setSelectionMode(QAbstractItemView::ExtendedSelection);
setEditTriggers(QAbstractItemView::AllEditTriggers);
horizontalHeader()->setStretchLastSection(true);
horizontalHeader()->hide();
verticalHeader()->hide();
connect(this, SIGNAL(clicked(const QModelIndex&)), delegate, SLOT(colorClicked(QModelIndex)));
}
| int SciFigs::LegendTable::brushItem | ( | Qt::BrushStyle | b | ) | [static] |
Referenced by SciFigs::LegendTableItem::data().
{
switch (b) {
case Qt::LinearGradientPattern:
case Qt::RadialGradientPattern:
case Qt::ConicalGradientPattern:
case Qt::TexturePattern:
case Qt::NoBrush:
break;
case Qt::SolidPattern: return 1;
case Qt::Dense1Pattern: return 2;
case Qt::Dense2Pattern: return 3;
case Qt::Dense3Pattern: return 4;
case Qt::Dense4Pattern: return 5;
case Qt::Dense5Pattern: return 6;
case Qt::Dense6Pattern: return 7;
case Qt::Dense7Pattern: return 8;
case Qt::HorPattern: return 9;
case Qt::VerPattern: return 10;
case Qt::CrossPattern: return 11;
case Qt::BDiagPattern: return 12;
case Qt::FDiagPattern: return 13;
case Qt::DiagCrossPattern: return 14;
}
return 0;
}
| Qt::BrushStyle SciFigs::LegendTable::brushStyle | ( | int | index | ) | [static] |
Referenced by SciFigs::LegendTableItem::setData().
{
switch (index) {
default: return Qt::NoBrush;
case 1: return Qt::SolidPattern;
case 2: return Qt::Dense1Pattern;
case 3: return Qt::Dense2Pattern;
case 4: return Qt::Dense3Pattern;
case 5: return Qt::Dense4Pattern;
case 6: return Qt::Dense5Pattern;
case 7: return Qt::Dense6Pattern;
case 8: return Qt::Dense7Pattern;
case 9: return Qt::HorPattern;
case 10: return Qt::VerPattern;
case 11: return Qt::CrossPattern;
case 12: return Qt::BDiagPattern;
case 13: return Qt::FDiagPattern;
case 14: return Qt::DiagCrossPattern;
}
}
| void SciFigs::LegendTable::changed | ( | ) | [signal] |
Referenced by LegendTable(), and setLegend().
| void SciFigs::LegendTable::initBrushStyles | ( | QComboBox * | w | ) | [static] |
Referenced by SciFigs::LegendTableDelegate::createEditor().
{
w->setIconSize (QSize(16, 16));
w->addItem(brushStylePixmap(Qt::NoBrush), "");
w->addItem(brushStylePixmap(Qt::SolidPattern), "");
w->addItem(brushStylePixmap(Qt::Dense1Pattern), "");
w->addItem(brushStylePixmap(Qt::Dense2Pattern), "");
w->addItem(brushStylePixmap(Qt::Dense3Pattern), "");
w->addItem(brushStylePixmap(Qt::Dense4Pattern), "");
w->addItem(brushStylePixmap(Qt::Dense5Pattern), "");
w->addItem(brushStylePixmap(Qt::Dense6Pattern), "");
w->addItem(brushStylePixmap(Qt::Dense7Pattern), "");
w->addItem(brushStylePixmap(Qt::HorPattern), "");
w->addItem(brushStylePixmap(Qt::VerPattern), "");
w->addItem(brushStylePixmap(Qt::CrossPattern), "");
w->addItem(brushStylePixmap(Qt::BDiagPattern), "");
w->addItem(brushStylePixmap(Qt::FDiagPattern), "");
w->addItem(brushStylePixmap(Qt::DiagCrossPattern), "");
}
| void SciFigs::LegendTable::initPenStyles | ( | QComboBox * | w | ) | [static] |
Referenced by SciFigs::LegendTableDelegate::createEditor().
{
w->setIconSize (QSize(32, 16));
w->addItem(penStylePixmap(Qt::NoPen), "");
w->addItem(penStylePixmap(Qt::SolidLine), "");
w->addItem(penStylePixmap(Qt::DashLine), "");
w->addItem(penStylePixmap(Qt::DotLine), "");
w->addItem(penStylePixmap(Qt::DashDotLine), "");
w->addItem(penStylePixmap(Qt::DashDotDotLine), "");
}
| void SciFigs::LegendTable::initSymbolTypes | ( | QComboBox * | w | ) | [static] |
References SciFigs::Symbol::Circle, SciFigs::Symbol::Cross, SciFigs::Symbol::Losange, SciFigs::Symbol::NoSymbol, SciFigs::Symbol::Square, SciFigs::Symbol::Star, SciFigs::Symbol::TriangleDown, and SciFigs::Symbol::TriangleUp.
Referenced by SciFigs::LegendTableDelegate::createEditor(), and SciFigs::XYPlotProperties::XYPlotProperties().
{
w->setIconSize(QSize(16, 16));
w->addItem(symbolTypePixmap(Symbol::NoSymbol), "");
w->addItem(symbolTypePixmap(Symbol::Cross), "");
w->addItem(symbolTypePixmap(Symbol::Square), "");
w->addItem(symbolTypePixmap(Symbol::Circle), "");
w->addItem(symbolTypePixmap(Symbol::TriangleUp), "");
w->addItem(symbolTypePixmap(Symbol::TriangleDown), "");
w->addItem(symbolTypePixmap(Symbol::Losange), "");
w->addItem(symbolTypePixmap(Symbol::Star), "");
}
| bool SciFigs::LegendTable::oneColor | ( | ) | const |
{
return static_cast<LegendTableItem *>(model())->oneColor();
}
| int SciFigs::LegendTable::penItem | ( | Qt::PenStyle | p | ) | [static] |
Referenced by SciFigs::LegendTableItem::data().
{
switch (p) {
case Qt::CustomDashLine:
case Qt::MPenStyle:
case Qt::NoPen:
break;
case Qt::SolidLine: return 1;
case Qt::DashLine: return 2;
case Qt::DotLine: return 3;
case Qt::DashDotLine: return 4;
case Qt::DashDotDotLine: return 5;
}
return 0;
}
| Qt::PenStyle SciFigs::LegendTable::penStyle | ( | int | index | ) | [static] |
Referenced by SciFigs::LegendTableItem::setData().
{
switch (index) {
default: return Qt::NoPen;
case 1: return Qt::SolidLine;
case 2: return Qt::DashLine;
case 3: return Qt::DotLine;
case 4: return Qt::DashDotLine;
case 5: return Qt::DashDotDotLine;
}
}
| bool SciFigs::LegendTable::readOnlyText | ( | ) | const |
{
return static_cast<LegendTableItem *>(model())->readOnlyText();
}
| void SciFigs::LegendTable::setConstant | ( | bool | c | ) |
Linked to properties: if c is true, the legend is the same for all legend widgets controled by this table. This is just a visual effect.
TODO: check whether it works.
{
printf("Legend table constant %s\n",c ? "true" : "false");
QPalette palette;
palette.setColor(QPalette::Window, c ? Qt::gray : QColor(164,112,128));
viewport()->setPalette(palette);
}
| void SciFigs::LegendTable::setLegend | ( | Legend * | legend | ) |
| void SciFigs::LegendTable::setOneColor | ( | bool | oc | ) |
{
static_cast<LegendTableItem *>(model())->setOneColor(oc);
}
| void SciFigs::LegendTable::setPropertySections | ( | PropertySections | s = All | ) |
References ColumnPenColor, ColumnPenStyle, ColumnPenWidth, ColumnSymbolBrushColor, ColumnSymbolBrushStyle, ColumnSymbolPenColor, ColumnSymbolPenStyle, ColumnSymbolPenWidth, ColumnSymbolSize, ColumnSymbolType, ColumnText, ColumnTextColor, SymbolBrush, SymbolPen, SymbolType, Text, TextColor, and TRACE.
{
TRACE;
int columnIndex =0;
_columnIndexes.clear();
if(s & Pen) {
setSpan(0, columnIndex, 1, 3);
_columnIndexes.insert(columnIndex++, ColumnPenColor);
_columnIndexes.insert(columnIndex++, ColumnPenWidth);
_columnIndexes.insert(columnIndex++, ColumnPenStyle);
}
if(s & SymbolType) {
setSpan(0, columnIndex, 1, 2);
_columnIndexes.insert(columnIndex++, ColumnSymbolType);
_columnIndexes.insert(columnIndex++, ColumnSymbolSize);
}
if(s & SymbolPen) {
setSpan(0, columnIndex, 1, 3);
_columnIndexes.insert(columnIndex++, ColumnSymbolPenColor);
_columnIndexes.insert(columnIndex++, ColumnSymbolPenWidth);
_columnIndexes.insert(columnIndex++, ColumnSymbolPenStyle);
}
if(s & SymbolBrush) {
setSpan(0, columnIndex, 1, 2);
_columnIndexes.insert(columnIndex++, ColumnSymbolBrushColor);
_columnIndexes.insert(columnIndex++, ColumnSymbolBrushStyle);
}
if(s & Text) {
if(s & TextColor) {
setSpan(0, columnIndex, 1, 2);
_columnIndexes.insert(columnIndex++, ColumnTextColor);
_columnIndexes.insert(columnIndex++, ColumnText);
} else {
setSpan(0, columnIndex, 2, 1);
_columnIndexes.insert(columnIndex++, ColumnText);
}
} else if(s & TextColor) {
setSpan(0, columnIndex, 2, 1);
_columnIndexes.insert(columnIndex++, ColumnTextColor);
}
static_cast<LegendTableItem *>(model())->setColumnIndexes(&_columnIndexes);
static_cast<LegendTableDelegate *>(itemDelegate())->setColumnIndexes(&_columnIndexes);
}
| void SciFigs::LegendTable::setReadOnlyText | ( | bool | ro | ) |
{
static_cast<LegendTableItem *>(model())->setReadOnlyText(ro);
}
| int SciFigs::LegendTable::symbolItem | ( | Symbol::Type | t | ) | [static] |
References SciFigs::Symbol::Circle, SciFigs::Symbol::Cross, SciFigs::Symbol::Losange, SciFigs::Symbol::NoSymbol, SciFigs::Symbol::Square, SciFigs::Symbol::Star, SciFigs::Symbol::TriangleDown, and SciFigs::Symbol::TriangleUp.
Referenced by SciFigs::LegendTableItem::data(), and SciFigs::XYPlot::properties().
{
switch (t) {
case Symbol::NoSymbol: break;
case Symbol::Cross: return 1;
case Symbol::Square: return 2;
case Symbol::Circle: return 3;
case Symbol::TriangleUp: return 4;
case Symbol::TriangleDown: return 5;
case Symbol::Losange: return 6;
case Symbol::Star: return 7;
}
return 0;
}
| Symbol::Type SciFigs::LegendTable::symbolType | ( | int | index | ) | [static] |
References SciFigs::Symbol::Circle, SciFigs::Symbol::Cross, SciFigs::Symbol::Losange, SciFigs::Symbol::NoSymbol, SciFigs::Symbol::Square, SciFigs::Symbol::Star, SciFigs::Symbol::TriangleDown, and SciFigs::Symbol::TriangleUp.
Referenced by SciFigs::LegendTableItem::setData(), and SciFigs::XYPlot::setProperty().
{
switch (index) {
default: return Symbol::NoSymbol;
case 1: return Symbol::Cross;
case 2: return Symbol::Square;
case 3: return Symbol::Circle;
case 4: return Symbol::TriangleUp;
case 5: return Symbol::TriangleDown;
case 6: return Symbol::Losange;
case 7: return Symbol::Star;
}
}