本文整理汇总了C++中Q_ASSERT函数的典型用法代码示例。如果您正苦于以下问题:C++ Q_ASSERT函数的具体用法?C++ Q_ASSERT怎么用?C++ Q_ASSERT使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Q_ASSERT函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: Q_ASSERT
iconv_t QIconvCodec::createIconv_t(const char *to, const char *from)
{
Q_ASSERT((to == 0 && from != 0) || (to != 0 && from == 0));
iconv_t cd = (iconv_t) -1;
#if defined(__GLIBC__) || defined(GNU_LIBICONV)
// both GLIBC and libgnuiconv will use the locale's encoding if from or to is an empty string
static const char empty_codeset[] = "";
const char *codeset = empty_codeset;
cd = iconv_open(to ? to : codeset, from ? from : codeset);
#else
char *codeset = 0;
#endif
#if defined(_XOPEN_UNIX) && !defined(Q_OS_QNX6) && !defined(Q_OS_OSF)
if (cd == (iconv_t) -1) {
codeset = nl_langinfo(CODESET);
if (codeset)
cd = iconv_open(to ? to : codeset, from ? from : codeset);
}
#endif
if (cd == (iconv_t) -1) {
// Very poorly defined and followed standards causes lots of
// code to try to get all the cases... This logic is
// duplicated in QTextCodec, so if you change it here, change
// it there too.
// Try to determine locale codeset from locale name assigned to
// LC_CTYPE category.
// First part is getting that locale name. First try setlocale() which
// definitely knows it, but since we cannot fully trust it, get ready
// to fall back to environment variables.
char * ctype = qstrdup(setlocale(LC_CTYPE, 0));
// Get the first nonempty value from $LC_ALL, $LC_CTYPE, and $LANG
// environment variables.
char * lang = qstrdup(qgetenv("LC_ALL").constData());
if (!lang || lang[0] == 0 || strcmp(lang, "C") == 0) {
if (lang) delete [] lang;
lang = qstrdup(qgetenv("LC_CTYPE").constData());
}
if (!lang || lang[0] == 0 || strcmp(lang, "C") == 0) {
if (lang) delete [] lang;
lang = qstrdup(qgetenv("LANG").constData());
}
// Now try these in order:
// 1. CODESET from ctype if it contains a .CODESET part (e.g. en_US.ISO8859-15)
// 2. CODESET from lang if it contains a .CODESET part
// 3. ctype (maybe the locale is named "ISO-8859-1" or something)
// 4. locale (ditto)
// 5. check for "@euro"
// 1. CODESET from ctype if it contains a .CODESET part (e.g. en_US.ISO8859-15)
codeset = ctype ? strchr(ctype, '.') : 0;
if (codeset && *codeset == '.') {
++codeset;
cd = iconv_open(to ? to : codeset, from ? from : codeset);
}
// 2. CODESET from lang if it contains a .CODESET part
codeset = lang ? strchr(lang, '.') : 0;
if (cd == (iconv_t) -1 && codeset && *codeset == '.') {
++codeset;
cd = iconv_open(to ? to : codeset, from ? from : codeset);
}
// 3. ctype (maybe the locale is named "ISO-8859-1" or something)
if (cd == (iconv_t) -1 && ctype && *ctype != 0 && strcmp (ctype, "C") != 0)
cd = iconv_open(to ? to : ctype, from ? from : ctype);
// 4. locale (ditto)
if (cd == (iconv_t) -1 && lang && *lang != 0)
cd = iconv_open(to ? to : lang, from ? from : lang);
// 5. "@euro"
if ((cd == (iconv_t) -1 && ctype && strstr(ctype, "@euro")) || (lang && strstr(lang, "@euro")))
cd = iconv_open(to ? to : "ISO8859-15", from ? from : "ISO8859-15");
delete [] ctype;
delete [] lang;
}
return cd;
}
开发者ID:Fale,项目名称:qtmoko,代码行数:88,代码来源:qiconvcodec.cpp
示例2: Q_D
bool QTemporaryFileEngine::open(QIODevice::OpenMode openMode)
{
Q_D(QFSFileEngine);
Q_ASSERT(!isReallyOpen());
openMode |= QIODevice::ReadWrite;
if (!filePathIsTemplate)
return QFSFileEngine::open(openMode);
QString qfilename = d->fileEntry.filePath();
// Ensure there is a placeholder mask
uint phPos = qfilename.length();
uint phLength = 0;
while (phPos != 0) {
--phPos;
if (qfilename[phPos] == QLatin1Char('X')) {
++phLength;
continue;
}
if (phLength >= 6
|| qfilename[phPos] == QLatin1Char('/')) {
++phPos;
break;
}
// start over
phLength = 0;
}
if (phLength < 6)
qfilename.append(QLatin1String(".XXXXXX"));
// "Nativify" :-)
QFileSystemEntry::NativePath filename = QFileSystemEngine::absoluteName(
QFileSystemEntry(qfilename, QFileSystemEntry::FromInternalPath()))
.nativeFilePath();
// Find mask in native path
phPos = filename.length();
phLength = 0;
while (phPos != 0) {
--phPos;
if (filename[phPos] == Latin1Char('X')) {
++phLength;
continue;
}
if (phLength >= 6) {
++phPos;
break;
}
// start over
phLength = 0;
}
Q_ASSERT(phLength >= 6);
QSystemError error;
#if defined(Q_OS_WIN)
NativeFileHandle &file = d->fileHandle;
#else // POSIX
NativeFileHandle &file = d->fd;
#endif
if (!createFileFromTemplate(file, filename, phPos, phLength, error)) {
setError(QFile::OpenError, error.toString());
return false;
}
d->fileEntry = QFileSystemEntry(filename, QFileSystemEntry::FromNativePath());
#if !defined(Q_OS_WIN)
d->closeFileHandle = true;
#endif
filePathIsTemplate = false;
d->openMode = openMode;
d->lastFlushFailed = false;
d->tried_stat = 0;
return true;
}
开发者ID:ghjinlei,项目名称:qt5,代码行数:90,代码来源:qtemporaryfile.cpp
示例3: Q_ASSERT
GrandMaster::ValueMode InputOutputMap::grandMasterValueMode()
{
Q_ASSERT(m_grandMaster != NULL);
return m_grandMaster->valueMode();
}
开发者ID:lachmex,项目名称:qlcplus,代码行数:6,代码来源:inputoutputmap.cpp
示例4: Q_ASSERT
void FullScreenContent::showOptionsMenu()
{
Q_ASSERT(!mConfigWidget);
mConfigWidget = new FullScreenConfigWidget;
FullScreenConfigWidget* widget = mConfigWidget;
// Put widget in a menu
QMenu menu;
QWidgetAction* action = new QWidgetAction(&menu);
action->setDefaultWidget(widget);
menu.addAction(action);
// Slideshow checkboxes
widget->mSlideShowLoopCheckBox->setChecked(mSlideShow->loopAction()->isChecked());
connect(widget->mSlideShowLoopCheckBox, SIGNAL(toggled(bool)),
mSlideShow->loopAction(), SLOT(trigger()));
widget->mSlideShowRandomCheckBox->setChecked(mSlideShow->randomAction()->isChecked());
connect(widget->mSlideShowRandomCheckBox, SIGNAL(toggled(bool)),
mSlideShow->randomAction(), SLOT(trigger()));
// Interval slider
widget->mSlideShowIntervalSlider->setValue(int(GwenviewConfig::interval()));
connect(widget->mSlideShowIntervalSlider, SIGNAL(valueChanged(int)),
mSlideShow, SLOT(setInterval(int)));
connect(widget->mSlideShowIntervalSlider, SIGNAL(valueChanged(int)),
SLOT(updateSlideShowIntervalLabel()));
// Interval label
QString text = formatSlideShowIntervalText(88);
int width = widget->mSlideShowIntervalLabel->fontMetrics().width(text);
widget->mSlideShowIntervalLabel->setFixedWidth(width);
updateSlideShowIntervalLabel();
// Image information
connect(widget->mConfigureDisplayedInformationButton, SIGNAL(clicked()),
SLOT(showImageMetaInfoDialog()));
// Thumbnails
widget->mThumbnailGroupBox->setVisible(mViewPageVisible);
if (mViewPageVisible) {
widget->mShowThumbnailsCheckBox->setChecked(GwenviewConfig::showFullScreenThumbnails());
widget->mHeightSlider->setMinimum(mRightToolBar->sizeHint().height());
widget->mHeightSlider->setValue(mThumbnailBar->height());
connect(widget->mShowThumbnailsCheckBox, SIGNAL(toggled(bool)),
SLOT(slotShowThumbnailsToggled(bool)));
connect(widget->mHeightSlider, SIGNAL(valueChanged(int)),
SLOT(setFullScreenBarHeight(int)));
}
// Show menu below its button
QPoint pos;
QWidget* button = mOptionsAction->associatedWidgets().first();
Q_ASSERT(button);
qWarning() << button << button->geometry();
if (QApplication::isRightToLeft()) {
pos = button->mapToGlobal(button->rect().bottomLeft());
} else {
pos = button->mapToGlobal(button->rect().bottomRight());
pos.rx() -= menu.sizeHint().width();
}
qWarning() << pos;
menu.exec(pos);
}
开发者ID:shlomif,项目名称:gwenview,代码行数:65,代码来源:fullscreencontent.cpp
示例5: winTouchInputs
// from bool QApplicationPrivate::translateTouchEvent()
bool QWindowsMouseHandler::translateTouchEvent(QWindow *window, HWND,
QtWindows::WindowsEventType,
MSG msg, LRESULT *)
{
#ifndef Q_OS_WINCE
typedef QWindowSystemInterface::TouchPoint QTouchPoint;
typedef QList<QWindowSystemInterface::TouchPoint> QTouchPointList;
const QRect screenGeometry = window->screen()->geometry();
const int winTouchPointCount = msg.wParam;
QScopedArrayPointer<TOUCHINPUT> winTouchInputs(new TOUCHINPUT[winTouchPointCount]);
memset(winTouchInputs.data(), 0, sizeof(TOUCHINPUT) * winTouchPointCount);
QTouchPointList touchPoints;
touchPoints.reserve(winTouchPointCount);
Qt::TouchPointStates allStates = 0;
Q_ASSERT(QWindowsContext::user32dll.getTouchInputInfo);
QWindowsContext::user32dll.getTouchInputInfo((HANDLE) msg.lParam, msg.wParam, winTouchInputs.data(), sizeof(TOUCHINPUT));
for (int i = 0; i < winTouchPointCount; ++i) {
const TOUCHINPUT &winTouchInput = winTouchInputs[i];
int id = m_touchInputIDToTouchPointID.value(winTouchInput.dwID, -1);
if (id == -1) {
id = m_touchInputIDToTouchPointID.size();
m_touchInputIDToTouchPointID.insert(winTouchInput.dwID, id);
}
QTouchPoint touchPoint;
touchPoint.pressure = 1.0;
touchPoint.id = id;
if (m_lastTouchPositions.contains(id))
touchPoint.normalPosition = m_lastTouchPositions.value(id);
QPointF screenPos = QPointF(qreal(winTouchInput.x) / qreal(100.), qreal(winTouchInput.y) / qreal(100.));
if (winTouchInput.dwMask & TOUCHINPUTMASKF_CONTACTAREA)
touchPoint.area.setSize(QSizeF(qreal(winTouchInput.cxContact) / qreal(100.),
qreal(winTouchInput.cyContact) / qreal(100.)));
touchPoint.area.moveCenter(screenPos);
QPointF normalPosition = QPointF(screenPos.x() / screenGeometry.width(),
screenPos.y() / screenGeometry.height());
const bool stationaryTouchPoint = (normalPosition == touchPoint.normalPosition);
touchPoint.normalPosition = normalPosition;
if (winTouchInput.dwFlags & TOUCHEVENTF_DOWN) {
touchPoint.state = Qt::TouchPointPressed;
m_lastTouchPositions.insert(id, touchPoint.normalPosition);
} else if (winTouchInput.dwFlags & TOUCHEVENTF_UP) {
touchPoint.state = Qt::TouchPointReleased;
m_lastTouchPositions.remove(id);
} else {
touchPoint.state = (stationaryTouchPoint
? Qt::TouchPointStationary
: Qt::TouchPointMoved);
m_lastTouchPositions.insert(id, touchPoint.normalPosition);
}
allStates |= touchPoint.state;
touchPoints.append(touchPoint);
}
QWindowsContext::user32dll.closeTouchInputHandle((HANDLE) msg.lParam);
// all touch points released, forget the ids we've seen, they may not be reused
if (allStates == Qt::TouchPointReleased)
m_touchInputIDToTouchPointID.clear();
if (!m_touchDevice) {
m_touchDevice = new QTouchDevice;
// TODO: Device used to be hardcoded to screen in previous code.
m_touchDevice->setType(QTouchDevice::TouchScreen);
m_touchDevice->setCapabilities(QTouchDevice::Position | QTouchDevice::Area | QTouchDevice::NormalizedPosition);
QWindowSystemInterface::registerTouchDevice(m_touchDevice);
}
QWindowSystemInterface::handleTouchEvent(window,
m_touchDevice,
touchPoints);
return true;
#else
return false;
#endif
}
开发者ID:cedrus,项目名称:qt,代码行数:85,代码来源:qwindowsmousehandler.cpp
示例6: Q_ASSERT
void InternalNodeListProperty::remove(const InternalNodePointer &internalNode)
{
Q_ASSERT(m_nodeList.contains(internalNode));
m_nodeList.removeAll(internalNode);
}
开发者ID:KDE,项目名称:android-qt-creator,代码行数:5,代码来源:internalnodelistproperty.cpp
示例7: Q_ASSERT
vtkResliceImageViewer* medResliceViewer::getResliceImageViewer(int i)
{
Q_ASSERT(0 <= i <= 3);
return riw[i];
}
开发者ID:Inria-Asclepios,项目名称:medInria-public,代码行数:6,代码来源:medResliceViewer.cpp
示例8: Q_ASSERT
bool ShrinkToFitShapeContainerModel::isChildLocked(const KoShape *child) const
{
Q_ASSERT(child == d->childShape); Q_UNUSED(child);
return true;
}
开发者ID:KDE,项目名称:calligra,代码行数:5,代码来源:ShrinkToFitShapeContainer.cpp
示例9: KoShapeManagerPaintingStrategy
KarbonOutlinePaintingStrategy::KarbonOutlinePaintingStrategy( KoShapeManager * shapeManager )
: KoShapeManagerPaintingStrategy( shapeManager ), m_border( new OutlineStroke() )
{
Q_ASSERT( shapeManager );
shapeManager->setPaintingStrategy( this );
}
开发者ID:JeremiasE,项目名称:KFormula,代码行数:6,代码来源:KarbonOutlinePaintingStrategy.cpp
示例10: accessibleInterface
// moz: [important, but no need to implement up/down/left/right]
HRESULT STDMETHODCALLTYPE QWindowsMsaaAccessible::accNavigate(long navDir, VARIANT varStart, VARIANT *pvarEnd)
{
QAccessibleInterface *accessible = accessibleInterface();
accessibleDebugClientCalls(accessible);
if (!accessible)
return E_FAIL;
QAccessibleInterface *acc = 0;
switch (navDir) {
case NAVDIR_FIRSTCHILD:
acc = accessible->child(0);
break;
case NAVDIR_LASTCHILD:
acc = accessible->child(accessible->childCount() - 1);
break;
case NAVDIR_NEXT:
case NAVDIR_PREVIOUS:
if (!varStart.lVal) {
QAccessibleInterface *parent = accessible->parent();
if (parent && parent->isValid()) {
int index = parent->indexOfChild(accessible);
index += (navDir == NAVDIR_NEXT) ? 1 : -1;
if (index >= 0 && index < parent->childCount())
acc = parent->child(index);
}
} else {
int index = varStart.lVal;
index += (navDir == NAVDIR_NEXT) ? 1 : -1;
if (index > 0 && index <= accessible->childCount())
acc = accessible->child(index - 1);
}
break;
// Geometrical
case NAVDIR_UP:
case NAVDIR_DOWN:
case NAVDIR_LEFT:
case NAVDIR_RIGHT: {
QAccessibleInterface *pIface = accessible->parent();
if (pIface && pIface->isValid()) {
const int indexOfOurself = pIface->indexOfChild(accessible);
QRect startg = accessible->rect();
QPoint startc = startg.center();
QAccessibleInterface *candidate = 0;
unsigned mindist = UINT_MAX; // will work on screen sizes at least up to 46340x46340
const int sibCount = pIface->childCount();
for (int i = 0; i < sibCount; ++i) {
QAccessibleInterface *sibling = 0;
sibling = pIface->child(i);
Q_ASSERT(sibling);
if (i == indexOfOurself || sibling->state().invisible) {
//ignore ourself and invisible siblings
continue;
}
QRect sibg = sibling->rect();
QPoint sibc = sibg.center();
QPoint sibp;
QPoint startp;
QPoint distp;
switch (navDir) {
case NAVDIR_LEFT:
startp = QPoint(startg.left(), startg.top() + startg.height() / 2);
sibp = QPoint(sibg.right(), sibg.top() + sibg.height() / 2);
if (QPoint(sibc - startc).x() >= 0) {
continue;
}
distp = sibp - startp;
break;
case NAVDIR_RIGHT:
startp = QPoint(startg.right(), startg.top() + startg.height() / 2);
sibp = QPoint(sibg.left(), sibg.top() + sibg.height() / 2);
if (QPoint(sibc - startc).x() <= 0) {
continue;
}
distp = sibp - startp;
break;
case NAVDIR_UP:
startp = QPoint(startg.left() + startg.width() / 2, startg.top());
sibp = QPoint(sibg.left() + sibg.width() / 2, sibg.bottom());
if (QPoint(sibc - startc).y() >= 0) {
continue;
}
distp = sibp - startp;
break;
case NAVDIR_DOWN:
startp = QPoint(startg.left() + startg.width() / 2, startg.bottom());
sibp = QPoint(sibg.left() + sibg.width() / 2, sibg.top());
if (QPoint(sibc - startc).y() <= 0) {
continue;
}
distp = sibp - startp;
break;
default:
break;
}
// Since we're *comparing* (and not measuring) distances, we can compare the
// squared distance, (thus, no need to take the sqrt()).
//.........这里部分代码省略.........
开发者ID:2gis,项目名称:2gisqt5android,代码行数:101,代码来源:qwindowsmsaaaccessible.cpp
示例11: Q_ASSERT
void KateFadeEffect::opacityChanged(qreal value)
{
Q_ASSERT(m_effect);
m_effect->setOpacity(value);
}
开发者ID:dividedmind,项目名称:kate,代码行数:5,代码来源:katefadeeffect.cpp
示例12: Q_ASSERT
void KisSobelFilter::process(KisPaintDeviceSP device,
const QRect& applyRect,
const KisFilterConfiguration* configuration,
KoUpdater* progressUpdater
) const
{
QPoint srcTopLeft = applyRect.topLeft();
Q_ASSERT(!device.isNull());
//read the filter configuration values from the KisFilterConfiguration object
bool doHorizontal = configuration->getBool("doHorizontally", true);
bool doVertical = configuration->getBool("doVertically", true);
bool keepSign = configuration->getBool("keepSign", true);
bool makeOpaque = configuration->getBool("makeOpaque", true);
quint32 width = applyRect.width();
quint32 height = applyRect.height();
quint32 pixelSize = device->pixelSize();
int cost = applyRect.height();
/* allocate row buffers */
quint8* prevRow = new quint8[(width + 2) * pixelSize];
Q_CHECK_PTR(prevRow);
quint8* curRow = new quint8[(width + 2) * pixelSize];
Q_CHECK_PTR(curRow);
quint8* nextRow = new quint8[(width + 2) * pixelSize];
Q_CHECK_PTR(nextRow);
quint8* dest = new quint8[ width * pixelSize];
Q_CHECK_PTR(dest);
quint8* pr = prevRow + pixelSize;
quint8* cr = curRow + pixelSize;
quint8* nr = nextRow + pixelSize;
prepareRow(device, pr, srcTopLeft.x(), srcTopLeft.y() - 1, width, height);
prepareRow(device, cr, srcTopLeft.x(), srcTopLeft.y(), width, height);
quint32 counter = 0;
quint8* d;
quint8* tmp;
qint32 gradient, horGradient, verGradient;
// loop through the rows, applying the sobel convolution
KisHLineIteratorSP dstIt = device->createHLineIteratorNG(srcTopLeft.x(), srcTopLeft.y(), width);
for (quint32 row = 0; row < height; row++) {
// prepare the next row
prepareRow(device, nr, srcTopLeft.x(), srcTopLeft.y() + row + 1, width, height);
d = dest;
for (quint32 col = 0; col < width * pixelSize; col++) {
int positive = col + pixelSize;
int negative = col - pixelSize;
horGradient = (doHorizontal ?
((pr[negative] + 2 * pr[col] + pr[positive]) -
(nr[negative] + 2 * nr[col] + nr[positive]))
: 0);
verGradient = (doVertical ?
((pr[negative] + 2 * cr[negative] + nr[negative]) -
(pr[positive] + 2 * cr[positive] + nr[positive]))
: 0);
gradient = (qint32)((doVertical && doHorizontal) ?
(ROUND(RMS(horGradient, verGradient)) / 5.66) // always >0
: (keepSign ? (127 + (ROUND((horGradient + verGradient) / 8.0)))
: (ROUND(qAbs(horGradient + verGradient) / 4.0))));
*d++ = gradient;
if (gradient > 10) counter ++;
}
// shuffle the row pointers
tmp = pr;
pr = cr;
cr = nr;
nr = tmp;
//store the dest
device->writeBytes(dest, srcTopLeft.x(), row, width, 1);
if (makeOpaque) {
do {
device->colorSpace()->setOpacity(dstIt->rawData(), OPACITY_OPAQUE_U8, 1);
} while(dstIt->nextPixel());
dstIt->nextRow();
}
if (progressUpdater) progressUpdater->setProgress(row / cost);
}
delete[] prevRow;
delete[] curRow;
delete[] nextRow;
delete[] dest;
}
开发者ID:abhishekmurthy,项目名称:Calligra,代码行数:96,代码来源:kis_sobel_filter.cpp
示例13: Q_ASSERT
void KisShapeLayerCanvas::addCommand(KUndo2Command *)
{
Q_ASSERT(false); // This should never be called as this canvas should have no tools.
}
开发者ID:IGLOU-EU,项目名称:krita,代码行数:4,代码来源:kis_shape_layer_canvas.cpp
示例14: Q_UNUSED
bool Acl::watchNB(QString calendarId)
{
// TODO: Implement.
Q_UNUSED(calendarId);
Q_ASSERT(false);
}
开发者ID:cybercatalyst,项目名称:qgooglecalendar,代码行数:6,代码来源:acl.cpp
示例15: Q_ASSERT
void GLC_PullManipulator::setPullingDirection(const GLC_Vector3d& pullingDirection)
{
Q_ASSERT(!GLC_AbstractManipulator::isInManipulateState());
m_PullDirection= pullingDirection;
}
开发者ID:Alex-Rongzhen-Huang,项目名称:OpenPilot,代码行数:5,代码来源:glc_pullmanipulator.cpp
示例16: qtscript_QStackedLayout_prototype_call
static QScriptValue qtscript_QStackedLayout_prototype_call(QScriptContext *context, QScriptEngine *)
{
#if QT_VERSION > 0x040400
Q_ASSERT(context->callee().isFunction());
uint _id = context->callee().data().toUInt32();
#else
uint _id;
if (context->callee().isFunction())
_id = context->callee().data().toUInt32();
else
_id = 0xBABE0000 + 4;
#endif
Q_ASSERT((_id & 0xFFFF0000) == 0xBABE0000);
_id &= 0x0000FFFF;
QStackedLayout* _q_self = qscriptvalue_cast<QStackedLayout*>(context->thisObject());
if (!_q_self) {
return context->throwError(QScriptContext::TypeError,
QString::fromLatin1("QStackedLayout.%0(): this object is not a QStackedLayout")
.arg(qtscript_QStackedLayout_function_names[_id+1]));
}
switch (_id) {
case 0:
if (context->argumentCount() == 1) {
QWidget* _q_arg0 = qscriptvalue_cast<QWidget*>(context->argument(0));
int _q_result = _q_self->addWidget(_q_arg0);
return QScriptValue(context->engine(), _q_result);
}
break;
case 1:
if (context->argumentCount() == 0) {
QWidget* _q_result = _q_self->currentWidget();
return qScriptValueFromValue(context->engine(), _q_result);
}
break;
case 2:
if (context->argumentCount() == 2) {
int _q_arg0 = context->argument(0).toInt32();
QWidget* _q_arg1 = qscriptvalue_cast<QWidget*>(context->argument(1));
int _q_result = _q_self->insertWidget(_q_arg0, _q_arg1);
return QScriptValue(context->engine(), _q_result);
}
break;
case 3:
if (context->argumentCount() == 1) {
int _q_arg0 = context->argument(0).toInt32();
QWidget* _q_result = _q_self->widget(_q_arg0);
return qScriptValueFromValue(context->engine(), _q_result);
}
break;
case 4: {
QString result = QString::fromLatin1("QStackedLayout");
return QScriptValue(context->engine(), result);
}
default:
Q_ASSERT(false);
}
return qtscript_QStackedLayout_throw_ambiguity_error_helper(context,
qtscript_QStackedLayout_function_names[_id+1],
qtscript_QStackedLayout_function_signatures[_id+1]);
}
开发者ID:Mistobaan,项目名称:MuseScore,代码行数:66,代码来源:qtscript_QStackedLayout.cpp
示例17: Q_ASSERT
void QPlatformThemePrivate::initializeSystemPalette()
{
Q_ASSERT(!systemPalette);
systemPalette = new QPalette(qt_fusionPalette());
}
开发者ID:venkatarajasekhar,项目名称:Qt,代码行数:5,代码来源:qplatformtheme.cpp
示例18: Q_ASSERT
void KoGenStyle::writeStyle(KoXmlWriter* writer, const KoGenStyles& styles, const char* elementName, const QString& name, const char* propertiesElementName, bool closeElement, bool drawElement) const
{
//kDebug(30003) <<"writing out style" << name <<" display-name=" << m_attributes["style:display-name"] <<" family=" << m_familyName;
writer->startElement(elementName);
const KoGenStyle* parentStyle = 0;
if (!m_defaultStyle) {
if (!drawElement)
writer->addAttribute("style:name", name);
else
writer->addAttribute("draw:name", name);
if (!m_parentName.isEmpty()) {
parentStyle = styles.style(m_parentName);
if (parentStyle && m_familyName.isEmpty()) {
// get family from parent style, just in case
// Note: this is saving code, don't convert to attributeNS!
const_cast<KoGenStyle *>(this)->
m_familyName = parentStyle->attribute("style:family").toLatin1();
//kDebug(30003) <<"Got familyname" << m_familyName <<" from parent";
}
if (parentStyle && !parentStyle->isDefaultStyle())
writer->addAttribute("style:parent-style-name", m_parentName);
}
} else { // default-style
Q_ASSERT(qstrcmp(elementName, "style:default-style") == 0);
Q_ASSERT(m_parentName.isEmpty());
}
if (!m_familyName.isEmpty())
const_cast<KoGenStyle *>(this)->
addAttribute("style:family", QString::fromLatin1(m_familyName));
else {
if (qstrcmp(elementName, "style:style") == 0)
kWarning(30003) << "User style " << name << " is without family - invalid. m_type=" << m_type;
}
#if 0 // #ifndef NDEBUG
kDebug(30003) << "style:" << name;
printDebug();
if (parentStyle) {
kDebug(30003) << " parent:" << m_parentName;
parentStyle->printDebug();
}
#endif
// Write attributes [which differ from the parent style]
// We only look at the direct parent style because we assume
// that styles are fully specified, i.e. the inheritance is
// only in the final file, not in the caller's code.
QMap<QString, QString>::const_iterator it = m_attributes.constBegin();
for (; it != m_attributes.constEnd(); ++it) {
bool writeit = true;
if (parentStyle && it.key() != "style:family" // always write the family out
&& parentStyle->attribute(it.key()) == it.value())
writeit = false;
if (writeit)
writer->addAttribute(it.key().toUtf8(), it.value().toUtf8());
}
bool createPropertiesTag = propertiesElementName && propertiesElementName[0] != '\0';
KoGenStyle::PropertyType i = KoGenStyle::DefaultType;
KoGenStyle::PropertyType defaultPropertyType = KoGenStyle::DefaultType;
if (createPropertiesTag)
defaultPropertyType = propertyTypeByElementName(propertiesElementName);
if (!m_properties[i].isEmpty() ||
!m_properties[KoGenStyle::ChildElement].isEmpty() ||
!m_properties[defaultPropertyType].isEmpty()) {
if (createPropertiesTag)
writer->startElement(propertiesElementName); // e.g. paragraph-properties
it = m_properties[i].constBegin();
for (; it != m_properties[i].constEnd(); ++it) {
if (!parentStyle || parentStyle->property(it.key(), i) != it.value())
writer->addAttribute(it.key().toUtf8(), it.value().toUtf8());
}
//write the explicitly-defined properties that are the same type as the default,
//but only if defaultPropertyType is Text, Paragraph, or GraphicType
if (defaultPropertyType != 0) {
it = m_properties[defaultPropertyType].constBegin();
for (; it != m_properties[defaultPropertyType].constEnd(); ++it) {
if (!parentStyle || parentStyle->property(it .key(), defaultPropertyType) != it.value())
writer->addAttribute(it.key().toUtf8(), it.value().toUtf8());
}
}
//write child elements of the properties elements
i = KoGenStyle::ChildElement;
it = m_properties[i].constBegin();
for (; it != m_properties[i].constEnd(); ++it) {
if (!parentStyle || parentStyle->property(it.key(), i) != it.value()) {
writer->addCompleteElement(it.value().toUtf8());
}
}
if (createPropertiesTag)
writer->endElement();
}
// now write out any other properties elements
//start with i=1 to skip the defaultType that we already took care of
for (int i = 1; i < s_propertyNamesCount; ++i) {
//skip any properties that are the same as the defaultType
if (s_propertyTypes[i] != defaultPropertyType) {
writeStyleProperties(writer, s_propertyTypes[i], parentStyle);
}
}
//.........这里部分代码省略.........
开发者ID:KDE,项目名称:calligra-history,代码行数:101,代码来源:KoGenStyle.cpp
示例19: createFileFromTemplate
/*!
\internal
Generates a unique file path and returns a native handle to the open file.
\a path is used as a template when generating unique paths, \a pos
identifies the position of the first character that will be replaced in the
template and \a length the number of characters that may be substituted.
Returns an open handle to the newly created file if successful, an invalid
handle otherwise. In both cases, the string in \a path will be changed and
contain the generated path name.
*/
static bool createFileFromTemplate(NativeFileHandle &file,
QFileSystemEntry::NativePath &path, size_t pos, size_t length,
QSystemError &error)
{
Q_ASSERT(length != 0);
Q_ASSERT(pos < size_t(path.length()));
Q_ASSERT(length <= size_t(path.length()) - pos);
Char *const placeholderStart = (Char *)path.data() + pos;
Char *const placeholderEnd = placeholderStart + length;
// Initialize placeholder with random chars + PID.
{
Char *rIter = placeholderEnd;
#if defined(QT_BUILD_CORE_LIB)
quint64 pid = quint64(QCoreApplication::applicationPid());
do {
*--rIter = Latin1Char((pid % 10) + '0');
pid /= 10;
} while (rIter != placeholderStart && pid != 0);
#endif
while (rIter != placeholderStart) {
char ch = char((qrand() & 0xffff) % (26 + 26));
if (ch < 26)
*--rIter = Latin1Char(ch + 'A');
else
*--rIter = Latin1Char(ch - 26 + 'a');
}
}
for (;;) {
// Atomically create file and obtain handle
#if defined(Q_OS_WIN)
file = CreateFile((const wchar_t *)path.constData(),
GENERIC_READ | GENERIC_WRITE,
FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, CREATE_NEW,
FILE_ATTRIBUTE_NORMAL, NULL);
if (file != INVALID_HANDLE_VALUE)
return true;
DWORD err = GetLastError();
if (err != ERROR_FILE_EXISTS) {
error = QSystemError(err, QSystemError::NativeError);
return false;
}
#else // POSIX
file = QT_OPEN(path.constData(),
QT_OPEN_CREAT | O_EXCL | QT_OPEN_RDWR | QT_OPEN_LARGEFILE,
0600);
if (file != -1)
return true;
int err = errno;
if (err != EEXIST) {
error = QSystemError(err, QSystemError::NativeError);
return false;
}
#endif
/* tricky little algorwwithm for backward compatibility */
for (Char *iter = placeholderStart;;) {
// Character progression: [0-9] => 'a' ... 'z' => 'A' .. 'Z'
// String progression: "ZZaiC" => "aabiC"
switch (char(*iter)) {
case 'Z':
// Rollover, advance next character
*iter = Latin1Char('a');
if (++iter == placeholderEnd) {
// Out of alternatives. Return file exists error, previously set.
error = QSystemError(err, QSystemError::NativeError);
return false;
}
continue;
case '0': case '1': case '2': case '3': case '4':
case '5': case '6': case '7': case '8': case '9':
*iter = Latin1Char('a');
break;
case 'z':
// increment 'z' to 'A'
*iter = Latin1Char('A');
break;
//.........这里部分代码省略.........
开发者ID:ghjinlei,项目名称:qt5,代码行数:101,代码来源:qtemporaryfile.cpp
示例20: defined
QByteArray QIconvCodec::convertFromUnicode(const QChar *uc, int len, ConverterState *convState) const
{
char *inBytes;
char *outBytes;
size_t inBytesLeft;
#if defined(GNU_LIBICONV)
const char **inBytesPtr = const_cast<const char **>(&inBytes);
#else
char **inBytesPtr = &inBytes;
#endif
QThreadStorage<QIconvCodec::IconvState *> *ts = fromUnicodeState();
if (!qt_locale_initialized || !ts) {
// we're running after the Q_GLOBAL_STATIC has been deleted
// or before the QCoreApplication initialization
// bad programmer, no cookie for you
if (!len)
// this is a special case - zero-sized string should be
// translated to empty but not-null QByteArray.
return QByteArray("");
return QString::fromRawData(uc, len).toLatin1();
}
IconvState *&state = ts->localData();
if (!state) {
state = new IconvState(QIconvCodec::createIconv_t(0, UTF16));
if (state->cd != reinterpret_cast<iconv_t>(-1)) {
size_t outBytesLeft = len + 3; // +3 for the BOM
QByteArray ba;
ba.resize(outBytesLeft);
outBytes = ba.data();
#if !defined(NO_BOM)
// give iconv() a BOM
QChar bom[] = { QChar(QChar::ByteOrderMark) };
inBytes = reinterpret_cast<char *>(bom);
inBytesLeft = sizeof(bom);
if (iconv(state->cd, inBytesPtr, &inBytesLeft, &outBytes, &outBytesLeft) == (size_t) -1) {
perror("QIconvCodec::convertFromUnicode: using ASCII for conversion, iconv failed for BOM");
iconv_close(state->cd);
state->cd = reinterpret_cast<iconv_t>(-1);
return QString(uc, len).toAscii();
}
#endif // NO_BOM
}
}
if (state->cd == reinterpret_cast<iconv_t>(-1)) {
static int reported = 0;
if (!reported++) {
fprintf(stderr,
"QIconvCodec::convertFromUnicode: using ASCII for conversion, iconv_open failed\n");
}
return QString(uc, len).toAscii();
}
size_t outBytesLeft = len;
QByteArray ba;
ba.resize(outBytesLeft);
outBytes = ba.data();
// now feed iconv() the real data
inBytes = const_cast<char *>(reinterpret_cast<const char *>(uc));
inBytesLeft = len * sizeof(QChar);
QByteArray in;
if (convState && convState->remainingChars) {
// we have one surrogate char to be prepended
in.resize(sizeof(QChar) + len);
inBytes = in.data();
QChar remaining = convState->state_data[0];
memcpy(in.data(), &remaining, sizeof(QChar));
memcpy(in.data() + sizeof(QChar), uc, inBytesLeft);
inBytesLeft += sizeof(QChar);
convState->remainingChars = 0;
}
int invalidCount = 0;
do {
if (iconv(state->cd, inBytesPtr, &inBytesLeft, &outBytes, &outBytesLeft) == (size_t) -1) {
if (errno == EINVAL && convState) {
// buffer ends in a surrogate
Q_ASSERT(inBytesLeft == 2);
convState->remainingChars = 1;
convState->state_data[0] = uc[len - 1].unicode();
break;
}
switch (errno) {
case EILSEQ:
++invalidCount;
|
请发表评论