本文整理汇总了C++中QList::count方法的典型用法代码示例。如果您正苦于以下问题:C++ QList::count方法的具体用法?C++ QList::count怎么用?C++ QList::count使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QList
的用法示例。
在下文中一共展示了QList::count方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: if
QString
ShaderFactory::genDefaultSliceShaderString(bool bit16,
bool lighting,
bool emissive,
QList<CropObject> crops,
bool peel, int peelType,
float peelMin, float peelMax, float peelMix)
{
bool cropPresent = false;
bool tearPresent = false;
bool viewPresent = false;
bool glowPresent = false;
for(int i=0; i<crops.count(); i++)
if (crops[i].cropType() < CropObject::Tear_Tear)
cropPresent = true;
else if (crops[i].cropType() < CropObject::View_Tear)
tearPresent = true;
else if (crops[i].cropType() < CropObject::Glow_Ball)
viewPresent = true;
else
glowPresent = true;
for(int i=0; i<crops.count(); i++)
if (crops[i].cropType() >= CropObject::View_Tear &&
crops[i].cropType() <= CropObject::View_Block &&
crops[i].magnify() > 1.0)
tearPresent = true;
bool pathCropPresent = PathShaderFactory::cropPresent();
bool pathViewPresent = PathShaderFactory::blendPresent();
float lastSet = (Global::lutSize()-1.0)/Global::lutSize();
QString shader;
shader = "#extension GL_ARB_texture_rectangle : enable\n";
shader += "varying vec3 pointpos;\n";
shader += "uniform sampler2D lutTex;\n";
shader += "uniform sampler2DRect dataTex;\n";
shader += "uniform sampler1D paintTex;\n";
shader += "uniform float tfSet;\n";
shader += "uniform vec3 delta;\n";
shader += "uniform vec3 eyepos;\n";
shader += "uniform vec3 lightpos;\n";
shader += "uniform float ambient;\n";
shader += "uniform float diffuse;\n";
shader += "uniform float specular;\n";
shader += "uniform float speccoeff;\n";
shader += "uniform int gridx;\n";
shader += "uniform int tsizex;\n";
shader += "uniform int tsizey;\n";
shader += "uniform float depthcue;\n";
shader += "uniform sampler2DRect lightTex;\n";
shader += "uniform int lightgridx;\n";
shader += "uniform int lightgridy;\n";
shader += "uniform int lightgridz;\n";
shader += "uniform int lightnrows;\n";
shader += "uniform int lightncols;\n";
shader += "uniform int lightlod;\n";
shader += "uniform sampler2DRect pruneTex;\n";
shader += "uniform int prunegridx;\n";
shader += "uniform int prunetsizex;\n";
shader += "uniform int prunetsizey;\n";
shader += "uniform float prunelod;\n";
shader += "uniform int zoffset;\n";
shader += "uniform vec2 dataMin;\n";
shader += "uniform vec2 dataSize;\n";
shader += "uniform int tminz;\n";
shader += "uniform int lod;\n";
shader += "uniform vec3 dirFront;\n";
shader += "uniform vec3 dirUp;\n";
shader += "uniform vec3 dirRight;\n";
shader += "uniform vec3 brickMin;\n";
shader += "uniform vec3 brickMax;\n";
shader += genTextureCoordinate();
if (tearPresent) shader += TearShaderFactory::generateTear(crops);
if (cropPresent) shader += CropShaderFactory::generateCropping(crops);
if (glowPresent) shader += GlowShaderFactory::generateGlow(crops);
if (viewPresent) shader += BlendShaderFactory::generateBlend(crops);
if (pathCropPresent) shader += PathShaderFactory::applyPathCrop();
if (pathViewPresent) shader += PathShaderFactory::applyPathBlend();
shader += "void main(void)\n";
shader += "{\n";
shader += " vec3 lightcol = vec3(1.0,1.0,1.0);\n";
shader += " vec3 texCoord = gl_TexCoord[0].xyz;\n";
shader += "if (any(lessThan(texCoord,brickMin)) || any(greaterThan(texCoord, brickMax)))\n";
shader += " discard;\n";
if (crops.count() > 0)
//.........这里部分代码省略.........
示例2: populate
void KonqPopupMenuPrivate::populate()
{
Q_ASSERT(m_popupItemProperties.items().count() >= 1);
bool bTrashIncluded = false;
const KFileItemList lstItems = m_popupItemProperties.items();
KFileItemList::const_iterator it = lstItems.constBegin();
const KFileItemList::const_iterator kend = lstItems.constEnd();
for (; it != kend; ++it) {
const QUrl url = (*it).url();
if (!bTrashIncluded && ((url.scheme() == QLatin1String("trash") && url.path().length() <= 1))) {
bTrashIncluded = true;
}
}
const bool isDirectory = m_popupItemProperties.isDirectory();
const bool sReading = m_popupItemProperties.supportsReading();
bool sDeleting = (m_popupFlags & KonqPopupMenu::NoDeletion) == 0
&& m_popupItemProperties.supportsDeleting();
const bool sWriting = m_popupItemProperties.supportsWriting();
const bool sMoving = sDeleting && m_popupItemProperties.supportsMoving();
QUrl url = m_sViewURL.adjusted(QUrl::NormalizePathSegments);
bool isTrashLink = false;
bool isCurrentTrash = false;
bool currentDir = false;
bool isSymLink = false;
bool isSymLinkInSameDir = false; // true for "ln -s foo bar", false for links to foo/sub or /foo
//check if url is current directory
if (lstItems.count() == 1) {
KFileItem firstPopupItem(lstItems.first());
if (firstPopupItem.isLink()) {
isSymLink = true;
isSymLinkInSameDir = !firstPopupItem.linkDest().contains(QLatin1Char('/'));
}
QUrl firstPopupURL(firstPopupItem.url().adjusted(QUrl::NormalizePathSegments));
//kDebug(1203) << "View path is " << url.url();
//kDebug(1203) << "First popup path is " << firstPopupURL.url();
currentDir = (firstPopupURL.matches(url, QUrl::StripTrailingSlash));
if (firstPopupItem.isDesktopFile()) {
KDesktopFile desktopFile(firstPopupItem.localPath());
const KConfigGroup cfg = desktopFile.desktopGroup();
isTrashLink = cfg.readEntry("Type") == QLatin1String("Link")
&& cfg.readEntry("URL") == QLatin1String("trash:/");
}
if (isTrashLink) {
sDeleting = false;
}
// isCurrentTrash: popup on trash:/ itself, or on the trash.desktop link
isCurrentTrash = (firstPopupURL.scheme() == QLatin1String("trash") && firstPopupURL.path().length() <= 1)
|| isTrashLink;
}
const bool isIntoTrash = (url.scheme() == QLatin1String("trash")) && !isCurrentTrash; // trashed file, not trash:/ itself
const bool bIsLink = (m_popupFlags & KonqPopupMenu::IsLink);
//kDebug() << "isLocal=" << isLocal << " url=" << url << " isCurrentTrash=" << isCurrentTrash << " isIntoTrash=" << isIntoTrash << " bTrashIncluded=" << bTrashIncluded;
//////////////////////////////////////////////////////////////////////////
addGroup(KonqPopupMenu::TopActions); // used e.g. for ShowMenuBar. includes a separator at the end
QAction *act;
QAction *actNewWindow = 0;
#if 0 // TODO in the desktop code itself.
if ((flags & KonqPopupMenu::ShowProperties) && isOnDesktop &&
!KAuthorized::authorizeKAction("editable_desktop_icons")) {
flags &= ~KonqPopupMenu::ShowProperties; // remove flag
}
#endif
// Either 'newview' is in the actions we're given (probably in the tabhandling group)
// or we need to insert it ourselves (e.g. for the desktop).
// In the first case, actNewWindow must remain 0.
if (((m_popupFlags & KonqPopupMenu::ShowNewWindow) != 0) && sReading) {
const QString openStr = i18n("&Open");
actNewWindow = new QAction(m_parentWidget /*for status tips*/);
m_ownActions.append(actNewWindow);
actNewWindow->setIcon(QIcon::fromTheme(QStringLiteral("window-new")));
actNewWindow->setText(openStr);
QObject::connect(actNewWindow, &QAction::triggered, [this]() {
slotPopupNewView();
});
}
if (isDirectory && sWriting && !isCurrentTrash) { // A dir, and we can create things into it
const bool mkdirRequested = m_popupFlags & KonqPopupMenu::ShowCreateDirectory;
if ((currentDir || mkdirRequested) && m_pMenuNew) { // Current dir -> add the "new" menu
// As requested by KNewFileMenu :
m_pMenuNew->checkUpToDate();
m_pMenuNew->setPopupFiles(m_popupItemProperties.urlList());
//.........这里部分代码省略.........
示例3: generateConfirmationText
void wizardDisk::generateConfirmationText()
{
// If running in expert mode, we just create a simple config / confirmation
if ( radioExpert->isChecked() ) {
QStringList filesystem;
filesystem << "MANUAL" << "/mnt" ;
sysFinalDiskLayout << filesystem;
textConfirmation->setText(tr("Installing to file-system mounted at /mnt"));
return;
}
QList<QStringList> copyList;
QStringList summaryList;
QString tmp, workingDisk, workingSlice, tmpSlice, XtraTmp, startPart, sliceSize;
int disk = 0;
// Copy over the list to a new variable we can mangle without modifying the original
copyList = sysFinalDiskLayout;
// Start our summary
summaryList << "";
summaryList << "<b>" + tr("The disk will be setup with the following configuration:") + "</b>";
while ( ! copyList.empty() )
{
workingDisk = copyList.at(0).at(0);
workingSlice = copyList.at(0).at(1);
tmpSlice = workingSlice;
// Check if this is an install to "Unused Space"
for (int z=0; z < sysDisks.count(); ++z)
if ( sysDisks.at(z).at(0) == "SLICE" \
&& sysDisks.at(z).at(2) == workingDisk + workingSlice \
&& sysDisks.at(z).at(4) == "Unused Space" )
tmpSlice = "free";
// Check for any mirror for this device
for (int i=0; i < copyList.count(); ++i) {
if ( copyList.at(i).at(2).indexOf("MIRROR(" + workingDisk + ")") != -1 )
{
summaryList << tr("Disk:") + copyList.at(i).at(0) + " " + tr("Mirroring:") + workingDisk;
copyList.removeAt(i);
break;
}
}
// If after doing the mirror, our list is empty, break out
if ( copyList.empty() )
break;
// If there is a dedicated /boot partition, need to list that first, see what is found
for (int i=0; i < copyList.count(); ++i) {
QStringList mounts = copyList.at(i).at(2).split(",");
for (int z = 0; z < mounts.size(); ++z) {
if ( copyList.at(i).at(0) == workingDisk \
&& copyList.at(i).at(1) == workingSlice \
&& mounts.at(z) == "/boot" )
startPart="/boot";
}
}
// If no dedicated /boot partition, then lets list "/" first
if(startPart.isEmpty())
startPart="/";
// Start by looking for the root partition
for (int i=0; i < copyList.count(); ++i) {
QStringList mounts = copyList.at(i).at(2).split(",");
for (int z = 0; z < mounts.size(); ++z) {
if ( copyList.at(i).at(0) == workingDisk \
&& copyList.at(i).at(1) == workingSlice \
&& mounts.at(z) == startPart ) {
// Check if we have any extra arguments to throw on the end
XtraTmp="";
if ( ! copyList.at(i).at(5).isEmpty() )
XtraTmp=" (" + copyList.at(i).at(5) + ")" ;
// Write the user summary
summaryList << "";
summaryList << tr("Partition:") + " " + workingDisk + "(" + workingSlice + "):";
summaryList << tr("FileSystem:") + " " + copyList.at(i).at(3);
summaryList << tr("Size:") + " " + copyList.at(i).at(4) + "MB ";
if ( copyList.at(i).at(3) == "ZFS" || copyList.at(i).at(3) == "ZFS.eli" ) {
QStringList zDS = copyList.at(i).at(2).split(",/");
QString zTMP;
for (int ds = 0; ds < zDS.size(); ++ds) {
if ( zDS.at(ds) != "/" )
zDS.replace(ds, "/" + zDS.at(ds));
if ( zDS.at(ds).indexOf("(") != -1 ) {
zTMP = zDS.at(ds);
zTMP.replace("(", " (");
zDS.replace(ds, zTMP );
}
}
summaryList << tr("ZFS Datasets:<br>") + " " + zDS.join("<br>");
} else {
summaryList << tr("Mount:") + " " + copyList.at(i).at(2);
}
//.........这里部分代码省略.........
示例4: macValue
static QCFType<CFPropertyListRef> macValue(const QVariant &value)
{
CFPropertyListRef result = 0;
switch (value.type()) {
case QVariant::ByteArray:
{
QByteArray ba = value.toByteArray();
result = CFDataCreate(kCFAllocatorDefault, reinterpret_cast<const UInt8 *>(ba.data()),
CFIndex(ba.size()));
}
break;
// should be same as below (look for LIST)
case QVariant::List:
case QVariant::StringList:
case QVariant::Polygon:
result = macList(value.toList());
break;
case QVariant::Map:
{
/*
QMap<QString, QVariant> is potentially a multimap,
whereas CFDictionary is a single-valued map. To allow
for multiple values with the same key, we store
multiple values in a CFArray. To avoid ambiguities,
we also wrap lists in a CFArray singleton.
*/
QMap<QString, QVariant> map = value.toMap();
QMap<QString, QVariant>::const_iterator i = map.constBegin();
int maxUniqueKeys = map.size();
int numUniqueKeys = 0;
QVarLengthArray<QCFType<CFPropertyListRef> > cfkeys(maxUniqueKeys);
QVarLengthArray<QCFType<CFPropertyListRef> > cfvalues(maxUniqueKeys);
while (i != map.constEnd()) {
const QString &key = i.key();
QList<QVariant> values;
do {
values << i.value();
++i;
} while (i != map.constEnd() && i.key() == key);
bool singleton = (values.count() == 1);
if (singleton) {
switch (values.first().type()) {
// should be same as above (look for LIST)
case QVariant::List:
case QVariant::StringList:
case QVariant::Polygon:
singleton = false;
default:
;
}
}
cfkeys[numUniqueKeys] = QCFString::toCFStringRef(key);
cfvalues[numUniqueKeys] = singleton ? macValue(values.first()) : macList(values);
++numUniqueKeys;
}
result = CFDictionaryCreate(kCFAllocatorDefault,
reinterpret_cast<const void **>(cfkeys.data()),
reinterpret_cast<const void **>(cfvalues.data()),
CFIndex(numUniqueKeys),
&kCFTypeDictionaryKeyCallBacks,
&kCFTypeDictionaryValueCallBacks);
}
break;
case QVariant::DateTime:
{
/*
CFDate, unlike QDateTime, doesn't store timezone information.
*/
QDateTime dt = value.toDateTime();
if (dt.timeSpec() == Qt::LocalTime) {
QDateTime reference;
reference.setTime_t((uint)kCFAbsoluteTimeIntervalSince1970);
result = CFDateCreate(kCFAllocatorDefault, CFAbsoluteTime(reference.secsTo(dt)));
} else {
goto string_case;
}
}
break;
case QVariant::Bool:
result = value.toBool() ? kCFBooleanTrue : kCFBooleanFalse;
break;
case QVariant::Int:
case QVariant::UInt:
{
int n = value.toInt();
result = CFNumberCreate(kCFAllocatorDefault, kCFNumberIntType, &n);
}
break;
case QVariant::Double:
{
double n = value.toDouble();
result = CFNumberCreate(kCFAllocatorDefault, kCFNumberDoubleType, &n);
}
//.........这里部分代码省略.........
示例5: readCalendarItems
void ThemeImporter::readCalendarItems( const QString &viewType, const int year,
const int month, const int day )
{
Q_ASSERT( isStartElement() && name() == "calendar-items" );
// As the available settings are the same for the various calendar items
// types, we use a "stack" to keep in mind where we are in the hierarchy
// while having the possibility of using the same methods to read the
// settings' tags.
QList< QPair<QString, QString> > stack;
stack.append( qMakePair( QString(), QString( "CalendarItems" ) ) );
while ( !atEnd() ) {
readNext();
if ( isEndElement() ) {
if ( stack.count() > 1 ) {
stack.removeLast(); // We are going down one level
} else {
break;
}
}
if ( isStartElement() ) {
/* Item type tags: first level */
if ( stack.count() == 1 && name() == "events" ) {
stack.append( qMakePair( QString( "events" ),
QString( "CalendarItems Events" ) ) );
} else if ( stack.count() == 1 && name() == "to-dos" ) {
stack.append( qMakePair( QString( "to-dos" ),
QString( "CalendarItems ToDos" ) ) );
/* Sub-elements of to-dos (second level) */
} else if ( stack.count() == 2 && stack.last().first == "to-dos" &&
name() == "overdue" ) {
stack.append( qMakePair( QString( "to-dos/overdue" ),
QString( "CalendarItems ToDos Overdue" ) ) );
} else if ( stack.count() == 2 && stack.last().first == "to-dos" &&
name() == "due-today" ) {
stack.append( qMakePair( QString( "to-dos/due-today" ),
QString( "CalendarItems ToDos DueToday" ) ) );
/* The sub-elements of these tags allow free text */
} else if ( stack.count() == 1 && name() == "categories" ) {
stack.append( qMakePair( QString( "categories" ),
// When a setting applies to all categories,
// it applies to all items.
QString( "CalendarItems" ) ) );
} else if ( stack.count() == 1 && name() == "resources" ) {
stack.append( qMakePair( QString( "resources" ),
// When a setting applies to all resources,
// it applies to all items.
QString( "CalendarItems" ) ) );
}
/* The said sub-elements */
else if ( stack.count() == 2 && stack.last().first == "categories" &&
name() == "category" ) {
QString n = attributes().value( "name" ).toString();
stack.append( qMakePair( QString( "categories/" + n ),
QString( "CalendarItems Categories " + n ) ) );
} else if ( stack.count() == 2 && stack.last().first == "resources" &&
name() == "resource" ) {
QString n = attributes().value( "name" ).toString();
stack.append( qMakePair( QString( "resources/" + n ),
QString( "CalendarItems Resources " + n ) ) );
}
/* Settings' tags */
else if ( name() == "background" ) {
setColor( viewType, year, month, day,
stack.last().second + " Background Color",
attributes().value( "color" ).toString() );
setPath( viewType, year, month, day,
stack.last().second + " Background Image",
attributes().value( "src" ).toString() );
readNext();
} else if ( name() == "font" ) {
setFont( viewType, year, month, day,
stack.last().second + " Font",
attributes().value( "family" ).toString(),
attributes().value( "style-hint" ).toString(),
attributes().value( "point-size" ).toString().toInt(),
attributes().value( "weight" ).toString().toInt(),
attributes().value( "style" ).toString(),
attributes().value( "stretch-factor" ).toString().toInt() );
readNext();
} else if ( name() == "frame" ) {
setColor( viewType, year, month, day,
stack.last().second + " Frame Color",
attributes().value( "color" ).toString() );
readNext();
} else if ( name() == "icon" ) {
setString( viewType, year, month, day,
stack.last().second + " Icon",
attributes().value( "name" ).toString() );
setPath( viewType, year, month, day,
stack.last().second + " IconFile",
attributes().value( "src" ).toString() );
readNext();
} else {
readUnknownElement();
}
}
//.........这里部分代码省略.........
示例6: SetupTable
void ImageFilesWidget::SetupTable(int sort_column, Qt::SortOrder sort_order)
{
m_ItemModel->clear();
QStringList header;
header.append(tr("Name" ));
header.append(tr("File Size (KB)" ));
header.append(tr("Times Used" ));
header.append(tr("Width" ));
header.append(tr("Height" ));
header.append(tr("Pixels" ));
header.append(tr("Color" ));
if (m_ThumbnailSize) {
header.append(tr("Image" ));
}
m_ItemModel->setHorizontalHeaderLabels(header);
ui.imageTree->setSelectionBehavior(QAbstractItemView::SelectRows);
ui.imageTree->setModel(m_ItemModel);
ui.imageTree->header()->setSortIndicatorShown(true);
QSize icon_size(m_ThumbnailSize, m_ThumbnailSize);
ui.imageTree->setIconSize(icon_size);
double total_size = 0;
int total_links = 0;
QHash<QString, QStringList> image_html_files_hash = m_Book->GetHTMLFilesUsingImages();
foreach (Resource *resource, m_ImageResources) {
QString filepath = "../" + resource->GetRelativePathToOEBPS();
QString path = resource->GetFullPath();
QImage image(path);
QList<QStandardItem *> rowItems;
// Filename
QStandardItem *name_item = new QStandardItem();
name_item->setText(resource->Filename());
name_item->setToolTip(filepath);
rowItems << name_item;
// File Size
double ffsize = QFile(path).size() / 1024.0;
total_size += ffsize;
QString fsize = QLocale().toString(ffsize, 'f', 2);
NumericItem *size_item = new NumericItem();
size_item->setText(fsize);
rowItems << size_item;
// Times Used
QStringList image_html_files = image_html_files_hash[filepath];
total_links += image_html_files.count();
NumericItem *link_item = new NumericItem();
link_item->setText(QString::number(image_html_files.count()));
if (!image_html_files.isEmpty()) {
link_item->setToolTip(image_html_files.join("\n"));
}
rowItems << link_item;
// Width
NumericItem *width_item = new NumericItem();
width_item->setText(QString::number(image.width()));
rowItems << width_item;
// Height
NumericItem *height_item = new NumericItem();
height_item->setText(QString::number(image.width()));
rowItems << height_item;
// Pixels
NumericItem *pixel_item = new NumericItem();
pixel_item->setText(QString::number(image.width() * image.height()));
rowItems << pixel_item;
// Color
QStandardItem *color_item = new QStandardItem();
color_item->setText(image.allGray() ? "Grayscale" : "Color");
rowItems << color_item;
// Thumbnail
if (m_ThumbnailSize) {
QPixmap pixmap(resource->GetFullPath());
if (pixmap.height() > m_ThumbnailSize || pixmap.width() > m_ThumbnailSize) {
pixmap = pixmap.scaled(QSize(m_ThumbnailSize, m_ThumbnailSize), Qt::KeepAspectRatio);
}
QStandardItem *icon_item = new QStandardItem();
icon_item->setIcon(QIcon(pixmap));
rowItems << icon_item;
}
for (int i = 0; i < rowItems.count(); i++) {
rowItems[i]->setEditable(false);
}
m_ItemModel->appendRow(rowItems);
}
示例7: if
void QgsMarkerLineSymbolLayerV2::renderPolyline( const QPolygonF& points, QgsSymbolV2RenderContext& context )
{
double offset = mOffset;
QgsExpression* offsetExpression = expression( "offset" );
if ( offsetExpression )
{
offset = offsetExpression->evaluate( const_cast<QgsFeature*>( context.feature() ) ).toDouble();
}
Placement placement = mPlacement;
QgsExpression* placementExpression = expression( "placement" );
if ( placementExpression )
{
QString placementString = placementExpression->evaluate( const_cast<QgsFeature*>( context.feature() ) ).toString();
if ( placementString.compare( "vertex", Qt::CaseInsensitive ) == 0 )
{
placement = Vertex;
}
else if ( placementString.compare( "lastvertex", Qt::CaseInsensitive ) == 0 )
{
placement = LastVertex;
}
else if ( placementString.compare( "firstvertex", Qt::CaseInsensitive ) == 0 )
{
placement = FirstVertex;
}
else if ( placementString.compare( "centerpoint", Qt::CaseInsensitive ) == 0 )
{
placement = CentralPoint;
}
else
{
placement = Interval;
}
}
if ( offset == 0 )
{
if ( placement == Interval )
renderPolylineInterval( points, context );
else if ( placement == CentralPoint )
renderPolylineCentral( points, context );
else
renderPolylineVertex( points, context, placement );
}
else
{
QList<QPolygonF> mline = ::offsetLine( points, offset * QgsSymbolLayerV2Utils::lineWidthScaleFactor( context.renderContext(), mOffsetUnit, mOffsetMapUnitScale ), context.feature() ? context.feature()->geometry()->type() : QGis::Line );
for ( int part = 0; part < mline.count(); ++part )
{
const QPolygonF &points2 = mline[ part ];
if ( placement == Interval )
renderPolylineInterval( points2, context );
else if ( placement == CentralPoint )
renderPolylineCentral( points2, context );
else
renderPolylineVertex( points2, context, placement );
}
}
}
示例8: createGeneralOptionsGroupBox
void Window::createGeneralOptionsGroupBox()
{
/*
QGroupBox *generalOptionsGroupBox;
QLabel *localeLabel;
QLabel *firstDayLabel;
QLabel *selectionModeLabel;
QLabel *horizontalHeaderLabel;
QLabel *verticalHeaderLabel;
QComboBox *localeCombo;
QComboBox *firstDayCombo;
QComboBox *selectionModeCombo;
QCheckBox *gridCheckBox;
QCheckBox *navigationCheckBox;
QComboBox *horizontalHeaderCombo;
QComboBox *verticalHeaderCombo;
*/
generalOptionsGroupBox = new QGroupBox(tr("GeneralOptions"));
localeCombo = new QComboBox;
int currentIndex = -1;
int index = 0;
for(int _lang = QLocale::C; _lang <= QLocale::LastLanguage; ++_lang)
{
QLocale::Language lang = static_cast<QLocale::Language>(_lang);
QList<QLocale::Country> countries = QLocale::countriesForLanguage(lang);
for(int i=0; i<countries.count(); i++)
{
QLocale::Country country = countries.at(i);
QLocale locale(lang, country);
QString label = QLocale::languageToString(lang);
label += QLatin1Char('/');
label += QLocale::countryToString(country);
if(this->locale().language() == lang && this->locale().country() == country)
{
currentIndex = index;
}
localeCombo->addItem(label, locale);
++index;
}
}
if(currentIndex != -1)
localeCombo->setCurrentIndex(currentIndex);
localeLabel = new QLabel(tr("Locale"));
localeLabel->setBuddy(localeCombo);
firstDayCombo = new QComboBox;
firstDayCombo->addItem(tr("Sunday"), Qt::Sunday);
firstDayCombo->addItem(tr("Monday"), Qt::Monday);
firstDayCombo->addItem(tr("Tuesday"), Qt::Tuesday);
firstDayCombo->addItem(tr("Wednesday"), Qt::Wednesday);
firstDayCombo->addItem(tr("Thursday"), Qt::Thursday);
firstDayCombo->addItem(tr("Friday"), Qt::Friday);
firstDayCombo->addItem(tr("Saturday"), Qt::Saturday);
firstDayLabel = new QLabel(tr("firstDay"));
firstDayLabel->setBuddy(firstDayCombo);
selectionModeCombo = new QComboBox;
selectionModeCombo->addItem(tr("Singleselection"), QCalendarWidget::SingleSelection);
selectionModeCombo->addItem(tr("None"), QCalendarWidget::NoSelection);
selectionModeLabel = new QLabel(tr("SelectionMode"));
selectionModeLabel->setBuddy(selectionModeCombo);
horizontalHeaderCombo = new QComboBox;
horizontalHeaderCombo->addItem(tr("Singleletter"), QCalendarWidget::SingleLetterDayNames);
horizontalHeaderCombo->addItem(tr("Shortday"), QCalendarWidget::ShortDayNames);
horizontalHeaderCombo->addItem(tr("None"), QCalendarWidget::NoHorizontalHeader);
horizontalHeaderLabel = new QLabel(tr("HorizontalHeader"));
horizontalHeaderLabel->setBuddy(horizontalHeaderCombo);
verticalHeaderCombo = new QComboBox;
verticalHeaderCombo->addItem(tr("ISOWeek"), QCalendarWidget::ISOWeekNumbers);
verticalHeaderCombo->addItem(tr("None"), QCalendarWidget::NoVerticalHeader);
verticalHeaderLabel = new QLabel(tr("VerticalHeader"));
verticalHeaderLabel->setBuddy(verticalHeaderCombo);
gridCheckBox = new QCheckBox(tr("GridVisible"));
gridCheckBox->setChecked(calendar->isGridVisible());
navigationCheckBox = new QCheckBox(tr("NavigationBar"));
navigationCheckBox->setChecked(calendar->isNavigationBarVisible());
connect(localeCombo, SIGNAL(currentIndexChanged(int)), this, SLOT(localeChanged(int)));
connect(firstDayCombo, SIGNAL(currentIndexChanged(int)), this, SLOT(firstDayChanged(int)));
connect(selectionModeCombo, SIGNAL(currentIndexChanged(int)), this, SLOT(selectionModeChanged(int)));
connect(horizontalHeaderCombo, SIGNAL(currentIndexChanged(int)), this, SLOT(horizontalHeaderChanged(int)));
connect(verticalHeaderCombo, SIGNAL(currentIndexChanged(int)), this, SLOT(verticalHeaderChanged(int)));
connect(gridCheckBox, SIGNAL(toggled(bool)), calendar, SLOT(setGridVisible(bool)));
connect(navigationCheckBox, SIGNAL(toggled(bool)), calendar, SLOT(setNavigationBarVisible(bool)));
QHBoxLayout *hLayout = new QHBoxLayout;
hLayout->addWidget(gridCheckBox);
hLayout->addStretch();
hLayout->addWidget(navigationCheckBox);
//.........这里部分代码省略.........
示例9: setColors
void LedDeviceArdulight::setColors(const QList<QRgb> & colors)
{
DEBUG_MID_LEVEL << Q_FUNC_INFO << colors;
// Save colors for showing changes of the brightness
m_colorsSaved = colors;
resizeColorsBuffer(colors.count());
applyColorModifications(colors, m_colorsBuffer);
for(int i=0; i < m_colorsBuffer.count(); i++) {
m_colorsBuffer[i].r = m_colorsBuffer[i].r >> 4;
m_colorsBuffer[i].g = m_colorsBuffer[i].g >> 4;
m_colorsBuffer[i].b = m_colorsBuffer[i].b >> 4;
PrismatikMath::maxCorrection(254, m_colorsBuffer[i]);
}
m_writeBuffer.clear();
m_writeBuffer.append(m_writeBufferHeader);
for (int i = 0; i < m_colorsBuffer.count(); i++)
{
StructRgb color = m_colorsBuffer[i];
if (m_colorSequence == "RBG")
{
m_writeBuffer.append(color.r);
m_writeBuffer.append(color.b);
m_writeBuffer.append(color.g);
}
else if (m_colorSequence == "BRG")
{
m_writeBuffer.append(color.b);
m_writeBuffer.append(color.r);
m_writeBuffer.append(color.g);
}
else if (m_colorSequence == "BGR")
{
m_writeBuffer.append(color.b);
m_writeBuffer.append(color.g);
m_writeBuffer.append(color.r);
}
else if (m_colorSequence == "GRB")
{
m_writeBuffer.append(color.g);
m_writeBuffer.append(color.r);
m_writeBuffer.append(color.b);
}
else if (m_colorSequence == "GBR")
{
m_writeBuffer.append(color.g);
m_writeBuffer.append(color.b);
m_writeBuffer.append(color.r);
}
else
{
m_writeBuffer.append(color.r);
m_writeBuffer.append(color.g);
m_writeBuffer.append(color.b);
}
}
bool ok = writeBuffer(m_writeBuffer);
emit commandCompleted(ok);
}
示例10: sImport
void ImportWindow::sImport()
{
_log->append(tr("Import Started..."));
QList<QListWidgetItem *> list = _reports->selectedItems();
if(list.empty())
{
if(QMessageBox::question(this, tr("No Reports Selected"),
tr("You have not selected any reports to import. Would you like to select all loaded reports now?"),
QMessageBox::Yes | QMessageBox::No, QMessageBox::Yes) == QMessageBox::Yes)
{
_reports->selectAll();
list = _reports->selectedItems();
}
}
QSqlQuery qtrig;
QSqlError err;
if(!qtrig.exec(getSqlFromTag("fmt16", QSqlDatabase::database().driverName())))
{
err = qtrig.lastError();
_log->append(tr("<font color=red>The following error was encountered disabling the trigger:\n"
"\t%1\n\t%2\n</font>")
.arg(err.driverText())
.arg(err.databaseText()));
return;
}
for(int i = 0; i < list.count(); i++)
{
QListWidgetItem * item = list.at(i);
QString xml_file = item->text();
QString metasql_name = QString::null;
QString metasql_group = QString::null;
QString metasql_desc = QString::null;
QString metasql_src = QString::null;
if(!xml_file.isEmpty())
{
QFile file(xml_file);
if(file.open(QIODevice::ReadOnly))
{
QByteArray contents = file.readAll();
metasql_src = contents;
if(!contents.isEmpty())
{
MQLUtil::extractMetadata(contents, metasql_group,
metasql_name, metasql_desc);
if(!metasql_name.isEmpty() && !metasql_group.isEmpty())
{
QSqlQuery qry;
QSqlQuery query;
query.prepare(getSqlFromTag("fmt17", QSqlDatabase::database().driverName()));
query.bindValue(":name", metasql_name);
query.bindValue(":group", metasql_group);
query.bindValue(":notes", metasql_desc);
query.bindValue(":query", metasql_src);
query.bindValue(":system",QVariant(false));
query.bindValue(":schema",(_schema->currentText().isEmpty() ? "public" : _schema->currentText()));
if(!query.exec())
{
err = query.lastError();
_log->append(tr("<font color=red>The following error was encountered while trying to import %1 into the database:\n"
"\t%2\n\t%3\n</font>")
.arg(xml_file)
.arg(err.driverText())
.arg(err.databaseText()));
}
else
{
if (query.first())
{
int metasqlid = query.value(0).toInt();
if (metasqlid < 0)
{
_log->append(tr("The saveMetasql stored procedure failed for %1, returning %2.")
.arg(xml_file).arg(metasqlid));
}
else
_log->append(tr("Import successful of %1").arg(xml_file));
}
else
_log->append(tr("No results returned from query for %1").arg(xml_file));
}
}
else
_log->append(tr("<font color=orange>The document %1 does not have a name and/or group defined\n</font>")
.arg(xml_file));
}
else
_log->append(tr("<font color=red>Error reading file %1 or file was empty\n</font>")
.arg(xml_file));
}
else
_log->append(tr("<font color=red>Could not open the specified file: %1\n</font>")
.arg(xml_file));
}
else
_log->append("<font color=red>Encountered and empty entry: No file name was given.\n</font>");
//.........这里部分代码省略.........
示例11: paintEvent
/**
* Repaint the viewport
*
* @internal
* @history 2011-08-23 Tracie Sucharski - Use the GetMeasuresInCube method
* from ControlNet to get list of measures rather
* than searching through entire net.
* @history 2011-11-09 Tracie Sucharski - If there are no measures for
* this cube, return.
*/
void ChipViewport::paintEvent(QPaintEvent *e) {
QPainter painter(this);
if (p_tempView != NULL) {
painter.drawImage(0, 0, *(p_tempView->p_image));
}
else {
painter.drawImage(0, 0, *p_image);
}
if (p_cross == true) {
painter.setPen(Qt::red);
painter.drawLine(0, (p_height - 1) / 2, p_width - 1, (p_height - 1) / 2);
painter.drawLine((p_width - 1) / 2, 0, (p_width - 1) / 2, p_height - 1);
}
if (p_circle == true) {
painter.setPen(Qt::red);
painter.drawEllipse((p_height - 1) / 2 - p_circleSize / 2,
(p_width - 1) / 2 - p_circleSize / 2,
p_circleSize, p_circleSize);
}
QString serialNumber = p_chipCube? SerialNumber::Compose(*p_chipCube) : QString();
if (p_controlNet && !serialNumber.isEmpty() && p_controlNet->GetCubeSerials().contains(
serialNumber)) {
// draw measure locations if we have a control network
// If the serial number is Unknown, we probably have a ground source
// file or level 2 which means it does not exist in the network
// TODO: Is there a better way to handle this?
if (p_showPoints && serialNumber.compare("Unknown") &&
p_controlNet->GetNumPoints() != 0) {
QList<ControlMeasure *> measures =
p_controlNet->GetMeasuresInCube(serialNumber);
// loop through all points in the control net
for (int i = 0; i < measures.count(); i++) {
ControlMeasure *m = measures[i];
// Find the measurments on the viewport
double samp = m->GetSample();
double line = m->GetLine();
int x, y;
cubeToViewport(samp, line, x, y);
// Determine pen color
// if the point or measure is ignored set to yellow
if (m->Parent()->IsIgnored() ||
(!m->Parent()->IsIgnored() && m->IsIgnored())) {
painter.setPen(QColor(255, 255, 0)); // set point marker yellow
}
// check for ground measure
else if (m->Parent()->GetType() == ControlPoint::Fixed) {
painter.setPen(Qt::magenta);// set point marker magenta
}
else {
painter.setPen(Qt::green); // set all other point markers green
}
// draw points which are not under cross
if (x != (p_width - 1) / 2 || y != (p_height - 1) / 2) {
painter.drawLine(x - 5, y, x + 5, y);
painter.drawLine(x, y - 5, x, y + 5);
}
}
}
}
p_tempView = NULL;
//painter.end();
}
示例12: setupModelData
void ScHelpTreeModel::setupModelData(const QString &dataFile, TreeItem *parent, QMap<QString, QString>* indexToBuild)
{
QFile file( dataFile );
if ( !file.open( QIODevice::ReadOnly ) )
return;
QDomDocument doc( "menuentries" );
if ( !doc.setContent( &file ) )
{
file.close();
return;
}
file.close();
QList<TreeItem*> parents;
QList<int> indentations;
parents << parent;
indentations << 0;
QDomElement docElem = doc.documentElement();
QDomNode n = docElem.firstChild();
// bool haveTutorials=false;
QList<QVariant> columnData;
int position=0;
while( !n.isNull() )
{
QDomElement e = n.toElement(); // try to convert the node to an element.
if( !e.isNull() )
{
if (e.hasAttribute( "text" ) && e.hasAttribute( "file" ))
{
QDomAttr textAttr = e.attributeNode( "text" );
QDomAttr fileAttr = e.attributeNode( "file" );
columnData.clear();
columnData << textAttr.value() << fileAttr.value();
if (position > indentations.last())
{
// The last child of the current parent is now the new parent
// unless the current parent has no children.
if (parents.last()->childCount() > 0)
{
parents << parents.last()->child(parents.last()->childCount()-1);
indentations << position;
}
}
else
{
while (position < indentations.last() && parents.count() > 0) {
parents.pop_back();
indentations.pop_back();
}
}
// Append a new item to the current parent's list of children.
parents.last()->appendChild(new TreeItem(columnData, parents.last()));
if (indexToBuild)
indexToBuild->insert(textAttr.value(), fileAttr.value());
}
QDomNodeList nl=n.childNodes();
if (nl.count()>0)
position=1;
for(int i=0 ; i<= nl.count() ; i++)
{
QDomNode child=nl.item(i);
if (child.isElement())
{
QDomElement ec = child.toElement();
if (!ec.isNull())
{
if (ec.hasAttribute( "text" ) && ec.hasAttribute( "file" ))
{
QDomAttr textAttr = ec.attributeNode( "text" );
QDomAttr fileAttr = ec.attributeNode( "file" );
columnData.clear();
columnData << textAttr.value() << fileAttr.value();
if (position > indentations.last())
{
// The last child of the current parent is now the new parent
// unless the current parent has no children.
if (parents.last()->childCount() > 0)
{
parents << parents.last()->child(parents.last()->childCount()-1);
indentations << position;
}
}
else
{
while (position < indentations.last() && parents.count() > 0) {
parents.pop_back();
indentations.pop_back();
}
}
// Append a new item to the current parent's list of children.
parents.last()->appendChild(new TreeItem(columnData, parents.last()));
if (indexToBuild)
indexToBuild->insert(textAttr.value(), fileAttr.value());
}
//3rd level
QDomNodeList nl2=child.childNodes();
if (nl2.count()>0)
//.........这里部分代码省略.........
示例13: onIssuesReturned
void LYGithubManager::onIssuesReturned(){
QList<QByteArray> headerList = getIssuesReply_->rawHeaderList();
for(int x = 0; x < headerList.count(); x++){
if(headerList.at(x) == "Link" && lastPageNumber_ == -1){
QString linkHeader = getIssuesReply_->rawHeader(headerList.at(x));
int lastPageNumber = -1;
int nextPageNumber = -1;
QStringList linkHeaderItems = linkHeader.split(',');
for(int y = 0; y < linkHeaderItems.count(); y++){
if(linkHeaderItems.at(y).contains("; rel=\"last\""))
lastPageNumber = pageNumberFromURLString(linkHeaderItems.at(y));
if(linkHeaderItems.at(y).contains("; rel=\"next\""))
nextPageNumber = pageNumberFromURLString(linkHeaderItems.at(y));
}
lastPageNumber_ = lastPageNumber;
}
}
int currentPageNumber = -1;
if(lastPageNumber_ != -1)
currentPageNumber = pageNumberFromURLString(lastGetIssuesRequest_);
QJson::Parser parser;
QVariant githubFullReply = parser.parse(getIssuesReply_->readAll());
bool doEmit = false;
QList<QVariantMap> localRetVal;
QVariantMap oneIssue;
if(githubFullReply.canConvert(QVariant::List)){
QVariantList githubListReply = githubFullReply.toList();
if(githubListReply.at(0).canConvert(QVariant::Map)){
if((lastPageNumber_ == -1) || (currentPageNumber == lastPageNumber_) )
doEmit = true;
for(int x = 0; x < githubListReply.count(); x++){
oneIssue = githubListReply.at(x).toMap();
localRetVal.append(oneIssue);
}
}
}
fullIssuesReply_.append(localRetVal);
disconnect(getIssuesReply_, 0);
getIssuesReply_->deleteLater();
getIssuesReply_ = 0;
if((lastPageNumber_ != -1) && (currentPageNumber != lastPageNumber_)){
QNetworkRequest request;
QString currentPageNumberString = QString("&page=%1").arg(currentPageNumber);
QString nextPageNumberString = QString("&page=%1").arg(currentPageNumber+1);
lastGetIssuesRequest_.replace(currentPageNumberString, nextPageNumberString);
request.setUrl(QUrl(lastGetIssuesRequest_));
QString userInfo = userName_+":"+password_;
QByteArray userData = userInfo.toLocal8Bit().toBase64();
QString headerData = "Basic " + userData;
request.setRawHeader("Authorization", headerData.toLocal8Bit());
LYGithubProductBacklogStatusLog::statusLog()->appendStatusMessage(QString("Processed page %1 of %2 for getIssues request").arg(currentPageNumber).arg(lastPageNumber_));
getIssuesReply_ = manager_->get(request);
connect(getIssuesReply_, SIGNAL(readyRead()), this, SLOT(onIssuesReturned()));
return;
}
if(doEmit){
LYGithubProductBacklogStatusLog::statusLog()->appendStatusMessage("Processed final getIssues request");
lastPageNumber_ = -1;
emit issuesReturned(fullIssuesReply_);
return;
}
LYGithubProductBacklogStatusLog::statusLog()->appendStatusMessage("Something went wrong in getIssues request");
}
示例14: countAllNotTagged
/**
* Counts all notes that are not tagged
*/
int Note::countAllNotTagged() {
QList<Note> noteList = Note::fetchAllNotTagged();
return noteList.count();
}
示例15: QWidget
DriverWidget::DriverWidget(const Device &device, QWidget *parent)
: QWidget(parent)
, ui(new Ui::Form)
, m_radioGroup(new QButtonGroup(this))
{
ui->setupUi(this);
ui->label->setText(xi18nc("@info %1 is hardware vendor, %2 is hardware model",
"<title>%1 %2</title>",
device.vendor,
device.model));
// We want to sort drivers so they have consistent order across starts.
QList<Driver> driverList = device.drivers;
qSort(driverList);
foreach (const Driver &driver, driverList) {
// This driver is not manual, but also has no package, hence we cannot
// do anything with it and should not display anything.
if (driver.package == nullptr && !driver.manualInstall){
qDebug() << "encountered invalid driver" << driver.package << driver.manualInstall << "for" << device.model;
continue;
}
QAbstractButton *button;
if (driverList.count() <= 1) {
button = new QCheckBox(this);
m_radioGroup->setExclusive(false);
} else {
button = new QRadioButton(this);
}
button->setProperty("package", driver.packageName);
button->setProperty("builtin", driver.builtin);
ui->verticalLayout->addWidget(button);
m_radioGroup->addButton(button);
if (driver.fuzzyActive) {
button->setChecked(true);
}
if (driver.manualInstall) {
button->setText(i18nc("Manually installed 3rd party driver",
"This device is using a manually-installed driver : (%1)",
driver.packageName));
break; // Manually installed drivers have no additional information available.
}
if (driver.recommended) {
button->setText(i18nc("%1 is description and %2 is package name; when driver is recommended for use",
"Using %1 from %2 (Recommended Driver)",
driver.package->shortDescription(),
driver.package->name()));
} else { // !recommended
button->setText(i18nc("%1 is description and %2 is package name",
"Using %1 from %2",
driver.package->shortDescription(),
driver.package->name()));
}
if (driver.free) {
button->setToolTip(i18nc("The driver is under a open source license",
"Open Source Driver"));
} else { // !free
button->setToolTip(i18nc("The driver is under a proprietary license",
"Proprietary Driver"));
}
}
m_indexSelected = m_radioGroup->checkedId();
m_defaultSelection = m_indexSelected;
connect(m_radioGroup, SIGNAL(buttonClicked(QAbstractButton*)), this, SIGNAL(selectionChanged()));
}