本文整理汇总了C++中Q_ASSERT函数的典型用法代码示例。如果您正苦于以下问题:C++ Q_ASSERT函数的具体用法?C++ Q_ASSERT怎么用?C++ Q_ASSERT使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Q_ASSERT函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
}
示例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;
}
示例3: Q_ASSERT
GrandMaster::ValueMode InputOutputMap::grandMasterValueMode()
{
Q_ASSERT(m_grandMaster != NULL);
return m_grandMaster->valueMode();
}
示例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);
}
示例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
}
示例6: Q_ASSERT
void InternalNodeListProperty::remove(const InternalNodePointer &internalNode)
{
Q_ASSERT(m_nodeList.contains(internalNode));
m_nodeList.removeAll(internalNode);
}
示例7: Q_ASSERT
vtkResliceImageViewer* medResliceViewer::getResliceImageViewer(int i)
{
Q_ASSERT(0 <= i <= 3);
return riw[i];
}
示例8: Q_ASSERT
bool ShrinkToFitShapeContainerModel::isChildLocked(const KoShape *child) const
{
Q_ASSERT(child == d->childShape); Q_UNUSED(child);
return true;
}
示例9: KoShapeManagerPaintingStrategy
KarbonOutlinePaintingStrategy::KarbonOutlinePaintingStrategy( KoShapeManager * shapeManager )
: KoShapeManagerPaintingStrategy( shapeManager ), m_border( new OutlineStroke() )
{
Q_ASSERT( shapeManager );
shapeManager->setPaintingStrategy( this );
}
示例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()).
//.........这里部分代码省略.........
示例11: Q_ASSERT
void KateFadeEffect::opacityChanged(qreal value)
{
Q_ASSERT(m_effect);
m_effect->setOpacity(value);
}
示例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;
}
示例13: Q_ASSERT
void KisShapeLayerCanvas::addCommand(KUndo2Command *)
{
Q_ASSERT(false); // This should never be called as this canvas should have no tools.
}
示例14: Q_UNUSED
bool Acl::watchNB(QString calendarId)
{
// TODO: Implement.
Q_UNUSED(calendarId);
Q_ASSERT(false);
}
示例15: Q_ASSERT
void GLC_PullManipulator::setPullingDirection(const GLC_Vector3d& pullingDirection)
{
Q_ASSERT(!GLC_AbstractManipulator::isInManipulateState());
m_PullDirection= pullingDirection;
}