本文整理汇总了C++中QMapIterator::data方法的典型用法代码示例。如果您正苦于以下问题:C++ QMapIterator::data方法的具体用法?C++ QMapIterator::data怎么用?C++ QMapIterator::data使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QMapIterator
的用法示例。
在下文中一共展示了QMapIterator::data方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: boundingRect
QwtDoubleRect Plot::boundingRect ()
{
QMapIterator<int, QwtPlotCurve *> it = d_curves.begin();
QwtPlotCurve *c = (QwtPlotCurve *)it.data();
double minX = c->minXValue();
double minY = c->minYValue();
double maxX = c->maxXValue();
double maxY = c->maxYValue();
it++;
for (it; it != d_curves.end(); ++it)
{
QwtPlotCurve *c = (QwtPlotCurve *)it.data();
if (!c)
continue;
minX = (c->minXValue() < minX) ? c->minXValue() : minX;
maxX = (c->maxXValue() > maxX) ? c->maxXValue() : maxX;
minY = (c->minYValue() < minY) ? c->minYValue() : minY;
maxY = (c->maxYValue() > maxY) ? c->maxYValue() : maxY;
}
QwtDoubleRect r;
r.setLeft(minX);
r.setRight(maxX);
r.setTop(minY);
r.setBottom(maxY);
return r;
}
示例2: closestCurve
int Plot::closestCurve(int xpos, int ypos, int &dist, int &point)
{
QwtScaleMap map[QwtPlot::axisCnt];
for ( int axis = 0; axis < QwtPlot::axisCnt; axis++ )
map[axis] = canvasMap(axis);
double dmin = 1.0e10;
int key = -1;
for (QMapIterator<int, QwtPlotCurve *> it = d_curves.begin(); it != d_curves.end(); ++it )
{
QwtPlotCurve *c = (QwtPlotCurve *)it.data();
if (!c)
continue;
for (int i=0; i<c->dataSize(); i++)
{
double cx = map[c->xAxis()].xTransform(c->x(i)) - double(xpos);
double cy = map[c->yAxis()].xTransform(c->y(i)) - double(ypos);
double f = qwtSqr(cx) + qwtSqr(cy);
if (f < dmin)
{
dmin = f;
key = it.key();
point = i;
}
}
}
dist = int(sqrt(dmin));
return key;
}
示例3: drawPoints
bool tGraph::drawPoints() {
//return _drawPoints;
QMapIterator<int, ORStyleData> mit = _setStyle.begin();
for( ; mit != _setStyle.end(); ++mit) {
if(mit.data().point) return TRUE;
}
return FALSE;
}
示例4: QueueItem
void
QueueManager::addQueuedItem( PlaylistItem *item )
{
Playlist *pl = Playlist::instance();
if( !pl ) return; //should never happen
const int index = pl->m_nextTracks.findRef( item );
QListViewItem *after;
if( !index ) after = 0;
else
{
int find = m_listview->childCount();
if( index - 1 <= find )
find = index - 1;
after = m_listview->itemAtIndex( find );
}
QValueList<PlaylistItem*> current = m_map.values();
QValueListIterator<PlaylistItem*> newItem = current.find( item );
QString title = i18n("%1 - %2").arg( item->artist(), item->title() );
if( newItem == current.end() ) //avoid duplication
{
after = new QueueItem( m_listview, after, title );
m_map[ after ] = item;
}
else //track is in the queue, remove it.
{
QListViewItem *removableItem = m_listview->findItem( title, 0 );
if( removableItem )
{
//Remove the key from the map, so we can re-queue the item
QMapIterator<QListViewItem*, PlaylistItem*> end( m_map.end() );
for( QMapIterator<QListViewItem*, PlaylistItem*> it = m_map.begin(); it != end; ++it )
{
if( it.data() == item )
{
m_map.remove( it );
//Remove the item from the queuelist
m_listview->takeItem( removableItem );
delete removableItem;
return;
}
}
}
}
}
示例5: clicked
void
QDialogButtons::handleClicked()
{
const QObject *s = sender();
if(!s)
return;
for(QMapIterator<QDialogButtons::Button, QWidget *> it = d->buttons.begin(); it != d->buttons.end(); ++it) {
if(it.data() == s) {
emit clicked((QDialogButtons::Button)it.key());
switch(it.key()) {
case Retry:
emit retryClicked();
break;
case Ignore:
emit ignoreClicked();
break;
case Abort:
emit abortClicked();
break;
case All:
emit allClicked();
break;
case Accept:
emit acceptClicked();
break;
case Reject:
emit rejectClicked();
break;
case Apply:
emit applyClicked();
break;
case Help:
emit helpClicked();
break;
default:
break;
}
return;
}
}
}
示例6: update
/*! This function updates .ini file in two stages. It copies original .ini file
into temporary one line by line, replacing/deleting/adding lines as necessary.
Then it copies temporary file into original one and deletes temporary file.
*/
bool TEIniFile::update()
{
close();
if (!f.open(IO_ReadWrite)) return false;
QString tempfn=f.name()+".tmp";
QFile tempf(tempfn);
if (!tempf.open(IO_ReadWrite | IO_Truncate)) return false;
QTextStream tsorg;
bool skipsec=false;
tsorg.setEncoding(QTextStream::UnicodeUTF8);
tsorg.setDevice(&f);
ts.setDevice(&tempf); // writeXXX function hardwired to write into ts. So we set it appropriatedly.
// prepare
QMap<QString,bool> secProcd, valueProcd; // processedp flag's maps
QMapIterator<QString,type_ValueList> it1;
for(it1=SectionList.begin();it1!=SectionList.end();++it1)
{
secProcd[it1.key()]=false;
}
// scan form sections
QString line, sec;
type_Processing pr = P_NONE; // nothing done yet
type_ValueList ValueList;
while (!((line = tsorg.readLine()).isNull())) {
if ((pr == P_NONE) || (pr == P_SECTION)) {
// trim line
line = line.stripWhiteSpace();
// skip if empty
if (line.isEmpty())
{
writeBreak();
continue;
}
// skip if comment
if (line.startsWith("#"))
{
writeComment(line.mid(1));
continue;
}
// check if section
if (line.startsWith("[") && line.endsWith("]")) {
if (pr == P_SECTION) {
// update previous section
// write new values
type_ValueList::iterator it;
type_ValueList & curSec=SectionList[sec];
type_ValueList & curSecDef=SectionListDef[sec];
for(it=curSec.begin();it!=curSec.end();++it)
{
if (!valueProcd[it.key()])
{ // this value was not processed yet, hence it's new or just default.
if (curSecDef.find(it.key())==curSecDef.end() || curSecDef[it.key()]!=it.data()) // if it equals default value, skip it.
ts << it.key() << "\t" << it.data() << "\n";
valueProcd[it.key()]=true; // it is for completeness' sake, so it don't really necessary (yet?).
}
}
secProcd[sec]=true;
}
// section found!
valueProcd.clear(); // get ready for next section
pr = P_SECTION;
sec = line.mid(1, line.length()-2).stripWhiteSpace();
writeSection(sec);
skipsec=SectionList.find(sec)==SectionList.end() || secProcd[sec]==true; // Skip deleted or already processed section
type_ValueList & curSec=SectionList[sec];
type_ValueList::iterator it;
for(it=curSec.begin();it!=curSec.end();++it)
{
valueProcd[it.key()]=false;
}
ValueList.clear();
continue;
}
if (pr == P_SECTION) {
// read name
if (skipsec)
continue;
QString nam;
int j = 0, l = (int)line.length();
QChar c;
while ( (j < l) && !((c = line.ref((uint)j)).isSpace()) ) {
nam += c;
j++;
}
// read value
bool rawData=false;
bool doubleQuotes=false;
QString val;
val = line.mid((uint)j).stripWhiteSpace();
if (val == "data{") {
rawData=true;
// read raw data...
val = "";
while (!((line = ts.readLine()).isNull())) {
//.........这里部分代码省略.........
示例7: draw
void tGraph::draw(QPainter & paint) {
//QPainter paint(this);
paint.save();
int gx1 = hPadding() + _rect.x();
int gy1 = vPadding() + _rect.y();
int gx2 = _rect.x() + width() - hPadding();
int gy2 = _rect.y() + height() - vPadding();
//paint.drawRect(gx1, gy1, gx2 - gx1, gy2 - gy1);
QFontMetrics fm(font());
//QRect brect;
// get the dimensions of the title label and then draw it
if(title().length() > 0) {
fm = QFontMetrics(titleFont());
//brect = fm.boundingRect(title());
paint.setFont(titleFont());
paint.drawText(gx1, gy1, gx2 - gx1, fm.height(), titleAlignment(), title());
gy1 += fm.height();
}
// we need to do some drawing that depends on some other elements having
// already been placed... since those require that these have already been
// placed we will just save the old value of gy2 and then calculate the
// value that we should have after the other code runs without actually
// drawing anything right now
int gy2_old = gy2;
if(dataLabel().length() > 0) {
fm = QFontMetrics(dataLabelFont());
gy2 -= fm.height();
}
fm = QFontMetrics(dataFont());
QMapIterator<int, GReference> dlit = _data.begin();
double tlh = 0.0;
for(dlit = _data.begin(); dlit != _data.end(); ++dlit) {
tlh = QMAX(sin45deg * fm.width(dlit.data().first), tlh);
}
// don't change this variable as we use it later
int th = (tlh == 0.0 ? 0 : (int)(tlh + (fm.height() * sin45deg)) + 2);
gy2 -= th;
// get the dimensions of the value label then draw it
if(valueLabel().length() > 0) {
fm = QFontMetrics(valueLabelFont());
//brect = fm.boundingRect(valueLabel());
paint.setFont(valueLabelFont());
paint.save();
paint.rotate(-90);
paint.drawText(-gy2, gx1, gy2 - gy1, fm.height(), valueLabelAlignment(), valueLabel());
paint.restore();
gx1 += fm.height();
}
fm = QFontMetrics(valueFont());
QString min_str = QString().sprintf("%-.0f",minValue());
QString org_str = ( minValue() == 0.0 ? QString::null : "0" );
QString max_str = QString().sprintf("%-.0f",maxValue());
int width = QMAX(fm.width(min_str), fm.width(max_str));
if(org_str.length() > 0) width = QMAX(width, fm.width(org_str));
gx1 += width;
int gy_max = gy1;
int gy_min = gy2 - 1;
int gy_org = gy_min;
paint.setFont(valueFont());
int tfa = Qt::AlignTop | Qt::AlignRight;
paint.drawText(gx1 - fm.width(min_str), gy_min, fm.width(min_str), fm.height(), tfa, min_str);
paint.drawLine(gx1 - 3, gy_min, gx1 + 2, gy_min);
paint.drawText(gx1 - fm.width(max_str), gy_max, fm.width(max_str), fm.height(), tfa, max_str);
paint.drawLine(gx1 - 3, gy_max, gx1 + 2, gy_max);
int gheight = gy2 - gy1;
double grng = maxValue() - minValue();
if(org_str.length() > 0) {
double perc = (0 - minValue()) / grng;
gy_org = gy2 - (int)(perc * (double)gheight);
paint.drawText(gx1 - fm.width(org_str), gy_org, fm.width(org_str), fm.height(), tfa, org_str);
paint.drawLine(gx1 - 3, gy_org, gx1 + 2, gy_org);
}
gx1 += 3;
// put the old value back so all the code to come draw correctly!
gy2 = gy2_old;
// get the dimensions of the data label then draw it
if(dataLabel().length() > 0) {
fm = QFontMetrics(dataLabelFont());
//brect = fm.boundingRect(dataLabel());
paint.setFont(dataLabelFont());
gy2 -= fm.height();
paint.drawText(gx1, gy2, gx2 - gx1, fm.height(), dataLabelAlignment(), dataLabel());
}
//.........这里部分代码省略.........
示例8: document
QDomDocument ReportWindow::document() {
QDomDocument doc = QDomDocument("openRPTDef");
QDomElement root = doc.createElement("report");
doc.appendChild(root);
//title
QDomElement title = doc.createElement("title");
title.appendChild(doc.createTextNode(reportTitle()));
root.appendChild(title);
QDomElement rname = doc.createElement("name");
rname.appendChild(doc.createTextNode(reportName()));
root.appendChild(rname);
QDomElement rdesc = doc.createElement("description");
rdesc.appendChild(doc.createTextNode(reportDescription()));
root.appendChild(rdesc);
for(QMap<QString,QString>::iterator it = _definedParams.begin();
it != _definedParams.end(); it++) {
QDomElement param = doc.createElement("parameter");
param.setAttribute("name", it.key());
param.appendChild(doc.createTextNode(it.data()));
root.appendChild(param);
}
if((watermarkUseStaticText() && !watermarkText().isEmpty()) ||
(!watermarkUseStaticText() && !watermarkQuery().isEmpty() && !watermarkColumn().isEmpty())) {
QDomElement wm = doc.createElement("watermark");
if(watermarkUseStaticText()) {
QDomElement wmtext = doc.createElement("text");
wmtext.appendChild(doc.createTextNode(watermarkText()));
wm.appendChild(wmtext);
} else {
QDomElement wmdata = doc.createElement("data");
QDomElement wmdq = doc.createElement("query");
wmdq.appendChild(doc.createTextNode(watermarkQuery()));
wmdata.appendChild(wmdq);
QDomElement wmdc = doc.createElement("column");
wmdc.appendChild(doc.createTextNode(watermarkColumn()));
wmdata.appendChild(wmdc);
wm.appendChild(wmdata);
}
if(!watermarkUseDefaultFont()) {
ReportEntity::buildXMLFont(doc,wm,watermarkFont());
}
QDomElement wmopac = doc.createElement("opacity");
wmopac.appendChild(doc.createTextNode(QString::number(watermarkOpacity())));
wm.appendChild(wmopac);
root.appendChild(wm);
}
if(bgEnabled()) {
QDomElement bg = doc.createElement("background");
if(bgStatic()) {
QDomElement bgimg = doc.createElement("image");
bgimg.appendChild(doc.createTextNode(bgImage()));
bg.appendChild(bgimg);
} else {
QDomElement bgdata = doc.createElement("data");
QDomElement bgdq = doc.createElement("query");
bgdq.appendChild(doc.createTextNode(bgQuery()));
bgdata.appendChild(bgdq);
QDomElement bgdc = doc.createElement("column");
bgdc.appendChild(doc.createTextNode(bgColumn()));
bgdata.appendChild(bgdc);
bg.appendChild(bgdata);
}
QDomElement bgmode = doc.createElement("mode");
bgmode.appendChild(doc.createTextNode(bgResizeMode()));
bg.appendChild(bgmode);
QDomElement bgopac = doc.createElement("opacity");
bgopac.appendChild(doc.createTextNode(QString::number(bgOpacity())));
bg.appendChild(bgopac);
QDomElement bgrect = doc.createElement("rect");
QDomElement bgrectx = doc.createElement("x");
bgrectx.appendChild(doc.createTextNode(QString::number(bgBoundsX())));
bgrect.appendChild(bgrectx);
QDomElement bgrecty = doc.createElement("y");
bgrecty.appendChild(doc.createTextNode(QString::number(bgBoundsY())));
bgrect.appendChild(bgrecty);
QDomElement bgrectw = doc.createElement("width");
bgrectw.appendChild(doc.createTextNode(QString::number(bgBoundsWidth())));
bgrect.appendChild(bgrectw);
QDomElement bgrecth = doc.createElement("height");
bgrecth.appendChild(doc.createTextNode(QString::number(bgBoundsHeight())));
bgrect.appendChild(bgrecth);
bg.appendChild(bgrect);
int align = bgAlign();
// horizontal
if((align & Qt::AlignRight) == Qt::AlignRight)
bg.appendChild(doc.createElement("right"));
else if((align & Qt::AlignHCenter) == Qt::AlignHCenter)
bg.appendChild(doc.createElement("hcenter"));
else // Qt::AlignLeft
bg.appendChild(doc.createElement("left"));
// vertical
if((align & Qt::AlignBottom) == Qt::AlignBottom)
//.........这里部分代码省略.........