QVariant SpawnModel::data(const QModelIndex& index, int role) const { if (!index.isValid()) return QVariant(); const Item* item = m_items.at(index.row()); const Spawn* spawn = NULL; if (item->type() == tSpawn || item->type() == tPlayer) spawn = (const Spawn*)item; if (role == Qt::DisplayRole) { switch (index.column()) { case tSpawnColName: { QString name = showeq_params->showRealName ? item->name() : item->transformedName(); if (spawn != NULL) { if (!spawn->lastName().isEmpty()) name += QString(" (%2)").arg(spawn->lastName()); if (spawn->gm()) name += " *GM*"; } return name; } case tSpawnColLevel: if (spawn != NULL) return spawn->level(); return QVariant(); case tSpawnColHP: if (spawn != NULL) return spawn->HP(); return QVariant(); case tSpawnColMaxHP: if (spawn != NULL) return spawn->maxHP(); return QVariant(); case tSpawnColXPos: return showeq_params->retarded_coords ? (int)item->y() : (int)item->x(); case tSpawnColYPos: return showeq_params->retarded_coords ? (int)item->x() : (int)item->y(); case tSpawnColZPos: return (int)item->z(); case tSpawnColID: return (int)item->id(); case tSpawnColDist: return showeq_params->fast_machine ? item->calcDist( m_player->x(), m_player->y(), m_player->z()) : item->calcDist2DInt( m_player->x(), m_player->y()); case tSpawnColRace: return item->raceString(); case tSpawnColClass: return item->classString(); case tSpawnColInfo: return item->info(); case tSpawnColSpawnTime: return item->spawnTimeStr(); case tSpawnColDeity: return spawn != NULL ? spawn->deityName() : QVariant(); case tSpawnColBodyType: return spawn != NULL ? spawn->typeString() : QVariant(); case tSpawnColGuildID: if (spawn != NULL) { if (spawn->guildID() < MAX_GUILDS) return spawn->guildTag().isEmpty() ? QVariant(spawn->guildID()) : QVariant(spawn->guildTag()); } return QVariant(); default: Q_ASSERT(false); } } else if (role == Qt::ForegroundRole) { return QBrush(pickTextColor(item, m_player)); } else if (role == Qt::FontRole) { // TODO: Change me QFont font; font.setPointSize(8); return font; } return QVariant(); }
formatButtons = new TextFormatButtons(textEditBox); formatButtons->toggleCurveButton(textType == TextDialog::TextMarker); setFocusPolicy(Qt::StrongFocus); setFocusProxy(textEditBox); // put everything together QVBoxLayout* mainLayout = new QVBoxLayout(); mainLayout->addWidget(groupBox1); mainLayout->addWidget(formatButtons); mainLayout->addWidget(textEditBox); setLayout( mainLayout ); // signals and slots connections connect( colorBtn, SIGNAL( clicked() ), this, SLOT( pickTextColor() ) ); connect( buttonOk, SIGNAL( clicked() ), this, SLOT( accept() ) ); connect( buttonApply, SIGNAL( clicked() ), this, SLOT( apply() ) ); connect( buttonCancel, SIGNAL( clicked() ), this, SLOT( reject() ) ); connect( buttonFont, SIGNAL( clicked() ), this, SLOT(customFont() ) ); } void TextDialog::apply() { if (textType == TextDialog::AxisTitle) { emit changeAlignment(alignment()); emit changeText(textEditBox->toPlainText()); emit changeColor(colorBtn->color()); } else
TextDialog::TextDialog(TextType type, QWidget* parent, const char* name, bool modal, WFlags fl ) : QDialog( parent, name, modal, fl ) { if ( !name ) setName( "TextDialog" ); setCaption( tr( "QtiPlot - Text options" ) ); setSizeGripEnabled( true ); text_type = type; GroupBox1 = new QButtonGroup(3,QGroupBox::Horizontal, QString::null, this); new QLabel(tr( "Color" ), GroupBox1); colorBox = new ColorButton(GroupBox1); buttonOk = new QPushButton( GroupBox1); buttonOk->setText( tr( "&OK" ) ); buttonOk->setAutoDefault( TRUE ); buttonOk->setDefault( TRUE ); new QLabel(tr( "Font" ),GroupBox1); buttonFont = new QPushButton( GroupBox1, "buttonFont" ); buttonFont->setText( tr( "&Font" ) ); buttonApply = new QPushButton( GroupBox1, "buttonApply" ); buttonApply->setText( tr( "&Apply" ) ); buttonApply->setDefault( TRUE ); if (text_type) { new QLabel(tr( "Alignement" ),GroupBox1, "TextLabel1_22",0); alignementBox = new QComboBox( FALSE, GroupBox1, "alignementBox" ); alignementBox->insertItem( tr( "Center" ) ); alignementBox->insertItem( tr( "Left" ) ); alignementBox->insertItem( tr( "Right" ) ); } else { new QLabel(tr( "Frame" ), GroupBox1, "TextLabel1",0 ); backgroundBox = new QComboBox( FALSE, GroupBox1, "backgroundBox" ); backgroundBox->insertItem( tr( "None" ) ); backgroundBox->insertItem( tr( "Rectangle" ) ); backgroundBox->insertItem( tr( "Shadow" ) ); } buttonCancel = new QPushButton( GroupBox1, "buttonCancel" ); buttonCancel->setText( tr( "&Cancel" ) ); if (text_type == TextMarker) { new QLabel(tr("Background"), GroupBox1, "TextLabel2",0 ); backgroundBtn = new ColorButton(GroupBox1); connect(backgroundBtn, SIGNAL(clicked()), this, SLOT(pickBackgroundColor())); buttonDefault = new QPushButton( GroupBox1); buttonDefault->setText( tr( "Set &Default" ) ); connect(buttonDefault, SIGNAL(clicked()), this, SLOT(setDefaultValues())); } QLabel* rotate=new QLabel(tr( "Rotate (deg.)" ),GroupBox1, "TextLabel1_2",0); rotate->hide(); rotateBox = new QComboBox( FALSE, GroupBox1, "rotateBox" ); rotateBox->insertItem( tr( "0" ) ); rotateBox->insertItem( tr( "45" ) ); rotateBox->insertItem( tr( "90" ) ); rotateBox->insertItem( tr( "135" ) ); rotateBox->insertItem( tr( "180" ) ); rotateBox->insertItem( tr( "225" ) ); rotateBox->insertItem( tr( "270" ) ); rotateBox->insertItem( tr( "315" ) ); rotateBox->setEditable (TRUE); rotateBox->setCurrentItem(0); rotateBox->hide(); GroupBox2= new QButtonGroup(8, QGroupBox::Horizontal, QString::null,this, "GroupBox2" ); if (text_type == TextMarker) { buttonCurve = new QPushButton( GroupBox2, "buttonCurve" ); buttonCurve->setPixmap (QPixmap(lineSymbol_xpm)); connect( buttonCurve, SIGNAL( clicked() ), this, SLOT(addCurve() ) ); } buttonIndice = new QPushButton( GroupBox2, "buttonIndice" ); buttonIndice->setPixmap (QPixmap(index_xpm)); buttonExp = new QPushButton( GroupBox2, "buttonExp" ); buttonExp->setPixmap (QPixmap(exp_xpm)); buttonMinGreek = new QPushButton(QChar(0x3B1), GroupBox2, "buttonMinGreek" ); buttonMinGreek->setMaximumWidth(40); buttonMajGreek = new QPushButton(QChar(0x393), GroupBox2, "buttonMajGreek" ); buttonMajGreek->setMaximumWidth(40); QFont font = this->font(); font.setBold(true); buttonB = new QPushButton(tr("B"), GroupBox2, "buttonB" ); buttonB->setFont(font); buttonB->setMaximumWidth(40); font = this->font(); font.setItalic(true); buttonI = new QPushButton(tr("It"), GroupBox2, "buttonI" ); buttonI->setFont(font); buttonI->setMaximumWidth(40); font = this->font(); font.setUnderline(true); buttonU = new QPushButton(tr("U"), GroupBox2, "buttonU" ); buttonU->setFont(font); buttonU->setMaximumWidth(40); textEditBox = new QTextEdit( this); textEditBox->setTextFormat(QTextEdit::PlainText); setFocusPolicy(QWidget::StrongFocus); setFocusProxy(textEditBox); QVBoxLayout* vlayout = new QVBoxLayout(this,5,5, "vlayout"); vlayout->addWidget(GroupBox1); vlayout->addWidget(GroupBox2); vlayout->addWidget(textEditBox); // signals and slots connections connect( colorBox, SIGNAL( clicked() ), this, SLOT( pickTextColor() ) ); connect( buttonOk, SIGNAL( clicked() ), this, SLOT( accept() ) ); connect( buttonApply, SIGNAL( clicked() ), this, SLOT( apply() ) ); connect( buttonCancel, SIGNAL( clicked() ), this, SLOT( reject() ) ); connect( buttonFont, SIGNAL( clicked() ), this, SLOT(customFont() ) ); connect( buttonExp, SIGNAL( clicked() ), this, SLOT(addExp() ) ); connect( buttonIndice, SIGNAL( clicked() ), this, SLOT(addIndex() ) ); connect( buttonU, SIGNAL( clicked() ), this, SLOT(addUnderline() ) ); connect( buttonI, SIGNAL( clicked() ), this, SLOT(addItalic() ) ); connect( buttonB, SIGNAL( clicked() ), this, SLOT(addBold() ) ); connect( buttonMinGreek, SIGNAL(clicked()), this, SLOT(showMinGreek())); connect( buttonMajGreek, SIGNAL(clicked()), this, SLOT(showMajGreek())); }
configDialog::configDialog( QWidget* parent, const char* name, bool modal, WFlags fl ) : QDialog( parent, name, modal, fl ) { ApplicationWindow *app = (ApplicationWindow *)parentWidget(); plot3DColors = app->plot3DColors; plot3DTitleFont = app->plot3DTitleFont; plot3DNumbersFont = app->plot3DNumbersFont; plot3DAxesFont = app->plot3DAxesFont; textFont = app->tableTextFont; headerFont = app->tableHeaderFont; appFont = app->appFont; axesFont = app->plotAxesFont; numbersFont = app->plotNumbersFont; legendFont = app->plotLegendFont; titleFont = app->plotTitleFont; if ( !name ) setName( "configDialog" ); setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)0, (QSizePolicy::SizeType)0, 0, 0, sizePolicy().hasHeightForWidth() ) ); setMouseTracking( TRUE ); setSizeGripEnabled( FALSE ); QHBox *box = new QHBox (this); box->setSpacing (5); box->setMargin(5); itemsList = new QListBox (box); QVBox *vbox = new QVBox (box); vbox->setSpacing (10); lblPageHeader = new QLabel (vbox); QFont fnt = this->font(); fnt.setPointSize(fnt.pointSize() + 3); fnt.setBold(true); lblPageHeader->setFont(fnt); lblPageHeader->setFrameStyle(QFrame::StyledPanel | QFrame::Sunken); lblPageHeader->setBackgroundColor(app->panelsColor); generalDialog = new QWidgetStack(vbox); initAppPage(); initTablesPage(); initPlotsPage(); initPlots3DPage(); initFittingPage(); generalDialog->addWidget(appTabWidget, 0); generalDialog->addWidget(tables, 1); generalDialog->addWidget(plotsTabWidget, 2); generalDialog->addWidget(plots3D, 3); generalDialog->addWidget(fitPage, 4); GroupBox2 = new QButtonGroup( 3,QGroupBox::Horizontal, QString::null,this); GroupBox2->setFlat(TRUE); GroupBox2->setLineWidth(0); buttonApply = new QPushButton(GroupBox2); buttonOk = new QPushButton(GroupBox2); buttonOk->setDefault( TRUE ); buttonCancel = new QPushButton(GroupBox2); QVBoxLayout* hlayout = new QVBoxLayout(this, 0, 0); hlayout->addWidget(box); hlayout->addWidget(GroupBox2); languageChange(); // signals and slots connections connect( itemsList, SIGNAL(highlighted(int)), this, SLOT(update())); connect( itemsList, SIGNAL(highlighted(int)), this, SLOT(setCurrentPage(int))); connect( buttonOk, SIGNAL( clicked() ), this, SLOT( accept() ) ); connect( buttonApply, SIGNAL( clicked() ), this, SLOT( update() ) ); connect( buttonCancel, SIGNAL( clicked() ), this, SLOT( reject() ) ); connect( buttonBackground, SIGNAL( clicked() ), this, SLOT( pickBgColor() ) ); connect( buttonText, SIGNAL( clicked() ), this, SLOT( pickTextColor() ) ); connect( buttonHeader, SIGNAL( clicked() ), this, SLOT( pickHeaderColor() ) ); connect( buttonTextFont, SIGNAL( clicked() ), this, SLOT( pickTextFont() ) ); connect( buttonHeaderFont, SIGNAL( clicked() ), this, SLOT( pickHeaderFont() ) ); setCurrentPage(0); }