本文整理汇总了C++中QStringList::count方法的典型用法代码示例。如果您正苦于以下问题:C++ QStringList::count方法的具体用法?C++ QStringList::count怎么用?C++ QStringList::count使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QStringList
的用法示例。
在下文中一共展示了QStringList::count方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: QMainWindow
//.........这里部分代码省略.........
// helpMenu->addAction(tr("About"), this, SLOT(about()));
// helpMenu->addAction(tr("About &Qt"), qApp, SLOT(aboutQt()));
}
textEdit = new QTextEdit(this);
//////////////////////////////////////////////////
connect(textEdit, SIGNAL(currentCharFormatChanged(QTextCharFormat)),
this, SLOT(currentCharFormatChanged(QTextCharFormat)));
connect(textEdit, SIGNAL(cursorPositionChanged()),
this, SLOT(cursorPositionChanged()));
///////////
//setCentralWidget(textEdit);
//blank=new Blank(this);
//setCentralWidget(blank);
//create a transparent canvas and put it on the top of textEdit
image =new MyCanvas(900,800,this);
textEdit->setFixedSize(QSize(800,800));
textEdit->setBackgroundRole(QPalette::Light); //scrollArea对象的背景色设为Dark
image->setFixedSize(QSize(800,800));
image->setStyleSheet(QString::fromUtf8("border:1px solid #000000;"));
QScrollArea* scrollArea = new QScrollArea;
scrollArea->setFixedSize(QSize(1800,900));
//scrollArea->setWidget(image); //将画布添加到scrollArea中
scrollArea->setBackgroundRole(QPalette::Light); //scrollArea对象的背景色设为Dark
//scrollArea->setBackgroundColor(QColor::white);
// QStackedLayout *stackedLayout = new QStackedLayout;
// stackedLayout->addWidget(image);
// stackedLayout->addWidget(textEdit);
// stackedLayout->setStackingMode(QStackedLayout::StackAll);
QHBoxLayout* hLayout=new QHBoxLayout();
hLayout->addWidget(textEdit);
hLayout->addWidget(image);
// scrollArea->setLayout(stackedLayout);
scrollArea->setLayout(hLayout);
//scrollArea->setGeometry(QRect(50,50,800,800));
setCentralWidget(scrollArea); //将scrollArea加入到主窗口的中心区new QPainter(this);
scrollArea->setAlignment(Qt::AlignHCenter);
//after canvas handle the mouse-drag event, emit it to the edittext for farther handling
connect(image,SIGNAL(mouseMoveSig(QMouseEvent*)),this,SLOT(onMouseMove(QMouseEvent*)));
//connect(image,SIGNAL(mouseMoveSig(QMouseEvent*)),textEdit,SLOT(mouseMoveEvent(QMouseEvent*)));
//connect(image,SIGNAL(mouseMoveSig(QMouseEvent*)),textEdit,SLOT(cursorPositionChanged(QMouseEvent*)));
//connect(this,SIGNAL(mouseMoveSig(QMouseEvent*)),image,SLOT(mouseMoveSlot(QMouseEvent*)));
//connect(textEdit,SIGNAL(mouseMoveEvent(QMouseEvent*)),image,SLOT(mouseMoveSlot(QMouseEvent*)));
// textEdit->setFocus();
setCurrentFileName(QString());
fontChanged(textEdit->font());
colorChanged(textEdit->textColor());
alignmentChanged(textEdit->alignment());
connect(textEdit->document(), SIGNAL(modificationChanged(bool)),
actionSave, SLOT(setEnabled(bool)));
connect(textEdit->document(), SIGNAL(modificationChanged(bool)),
this, SLOT(setWindowModified(bool)));
connect(textEdit->document(), SIGNAL(undoAvailable(bool)),
actionUndo, SLOT(setEnabled(bool)));
connect(textEdit->document(), SIGNAL(redoAvailable(bool)),
actionRedo, SLOT(setEnabled(bool)));
setWindowModified(textEdit->document()->isModified());
actionSave->setEnabled(textEdit->document()->isModified());
actionUndo->setEnabled(textEdit->document()->isUndoAvailable());
actionRedo->setEnabled(textEdit->document()->isRedoAvailable());
connect(actionUndo, SIGNAL(triggered()), textEdit, SLOT(undo()));
connect(actionRedo, SIGNAL(triggered()), textEdit, SLOT(redo()));
actionCut->setEnabled(false);
actionCopy->setEnabled(false);
connect(actionCut, SIGNAL(triggered()), textEdit, SLOT(cut()));
connect(actionCopy, SIGNAL(triggered()), textEdit, SLOT(copy()));
connect(actionPaste, SIGNAL(triggered()), textEdit, SLOT(paste()));
connect(textEdit, SIGNAL(copyAvailable(bool)), actionCut, SLOT(setEnabled(bool)));
connect(textEdit, SIGNAL(copyAvailable(bool)), actionCopy, SLOT(setEnabled(bool)));
#ifndef QT_NO_CLIPBOARD
connect(QApplication::clipboard(), SIGNAL(dataChanged()), this, SLOT(clipboardDataChanged()));
#endif
//QString initialFile = ":/data/example.html";
QString initialFile = ":/data/test.txt";
const QStringList args = QCoreApplication::arguments();
if (args.count() == 2)
initialFile = args.at(1);
if (!load(initialFile))
fileNew();
}
示例2: main
QT_USE_NAMESPACE
int main(int argc, char **argv)
{
Q_INIT_RESOURCE(linguist);
QApplication app(argc, argv);
QApplication::setOverrideCursor(Qt::WaitCursor);
QStringList files;
QString resourceDir = QLibraryInfo::location(QLibraryInfo::TranslationsPath);
QStringList args = app.arguments();
for (int i = 1; i < args.count(); ++i) {
QString argument = args.at(i);
if (argument == QLatin1String("-resourcedir")) {
if (i + 1 < args.count()) {
resourceDir = QFile::decodeName(args.at(++i).toLocal8Bit());
} else {
// issue a warning
}
} else if (!files.contains(argument)) {
files.append(argument);
}
}
QTranslator translator;
QTranslator qtTranslator;
QString sysLocale = QLocale::system().name();
if (translator.load(QLatin1String("linguist_") + sysLocale, resourceDir)) {
app.installTranslator(&translator);
if (qtTranslator.load(QLatin1String("qt_") + sysLocale, resourceDir))
app.installTranslator(&qtTranslator);
else
app.removeTranslator(&translator);
}
app.setOrganizationName(QLatin1String("Trolltech"));
app.setApplicationName(QLatin1String("Linguist"));
QSettings config;
QWidget tmp;
tmp.restoreGeometry(config.value(settingPath("Geometry/WindowGeometry")).toByteArray());
QSplashScreen *splash = 0;
int screenId = QApplication::desktop()->screenNumber(tmp.geometry().center());
splash = new QSplashScreen(QApplication::desktop()->screen(screenId),
QPixmap(QLatin1String(":/images/splash.png")));
if (QApplication::desktop()->isVirtualDesktop()) {
QRect srect(0, 0, splash->width(), splash->height());
splash->move(QApplication::desktop()->availableGeometry(screenId).center() - srect.center());
}
splash->setAttribute(Qt::WA_DeleteOnClose);
splash->show();
MainWindow mw;
mw.show();
splash->finish(&mw);
QApplication::restoreOverrideCursor();
mw.openFiles(files, true);
return app.exec();
}
示例3: sortByProtocol
void sortByProtocol(QStringList &sortList)
{
// Карта для хранения ссылок по протоколу доступа
// Ключ карты - имя , значения - список путь
QMap<protocolType, QStringList> sortingMap;
QStringList res; // Результирующий лист
QString temp; // Буфер для текущей обрабатываемой строки
QString buf; // Буфер для ключа - домена
QString str; // Буфер для одного из значений ключа - имени адреса
QString aIterKlein; // Буфер для строки из списка для каждой строки из списка
// Заполнение карты путей
for(int i=0; i<sortList.count(); i++)
{
// Загрузка в бущер текущей строки для сортировки
temp=sortList[i];
// Условия для разных протоколов доступа
if(temp.contains("DHCP"))
{
// Получение адреса
str=temp.remove(QString("DHCP:"));
// Заполнение значение карты
sortingMap[dhcp]<<temp;
}
else if(temp.contains("DNS"))
{
// Получение адреса
str=temp.remove(QString("DNS:"));
// Заполнение значение карты
sortingMap[dns]<<temp;
}
else if(temp.contains("ftp"))
{
// Получение адреса
str=temp.remove(QString("ftp://"));
// Заполнение значение карты
sortingMap[ftp]<<temp;
}
else if(temp.contains("https"))
{
// Получение адреса
str=temp.remove(QString("https://"));
// Заполнение значение карты
sortingMap[https]<<temp;
}
else if(temp.contains("http"))
{
// Получение адреса
str=temp.remove(QString("http://"));
// Заполнение значение карты
sortingMap[http]<<temp;
}
else if(temp.contains("nntp"))
{
// Заполнение значение карты
sortingMap[nntp]<<temp;
}
else if(temp.contains("ntp"))
{
// Заполнение значение карты
sortingMap[ntp]<<temp;
}
else if(temp.contains("@") && temp.indexOf(":", temp.indexOf("@"))!=-1)
{
// Заполнение значение карты
sortingMap[ssh]<<temp;
}
else if(temp.contains("telnet"))
{
// Получение адреса
str=temp.remove(QString("telnet://"));
// Заполнение значение карты
sortingMap[telnet]<<temp;
}
else
{
// Заполнение значение карты
sortingMap[otherProtocol]<<temp;
}
}
// Сортировка значений для каждого ключа
QMap<protocolType, QStringList>::iterator it=sortingMap.begin();
for(;it!=sortingMap.end(); it++)
{
if(it.value().count()>1)
{
//.........这里部分代码省略.........
示例4: loadOdf
bool KoStarShape::loadOdf( const KoXmlElement & element, KoShapeLoadingContext & context )
{
bool loadAsCustomShape = false;
if( element.localName() == "custom-shape" )
{
QString drawEngine = element.attributeNS( KoXmlNS::draw, "engine", "" );
if( drawEngine != "koffice:star" )
return false;
loadAsCustomShape = true;
}
else if( element.localName() != "regular-polygon" )
{
return false;
}
QPointF loadedPosition = position();
m_radius[tip] = 50;
m_center = QPointF(50,50);
if( ! loadAsCustomShape )
{
QString corners = element.attributeNS( KoXmlNS::draw, "corners", "" );
if( ! corners.isEmpty() ) {
m_cornerCount = corners.toUInt();
// initialize default angles of tip and base
m_angles[base] = m_angles[tip] = defaultAngleRadian();
}
m_convex = (element.attributeNS( KoXmlNS::draw, "concave", "false" ) == "false" );
if( m_convex )
{
m_radius[base] = m_radius[tip];
}
else
{
// sharpness is radius of ellipse on which inner polygon points are located
// 0% means all polygon points are on a single ellipse
// 100% means inner points are located at polygon center point
QString sharpness = element.attributeNS( KoXmlNS::draw, "sharpness", "" );
if( ! sharpness.isEmpty() && sharpness.right( 1 ) == "%" )
{
float percent = sharpness.left( sharpness.length()-1 ).toFloat();
m_radius[base] = m_radius[tip] * (100-percent)/100;
}
}
}
else
{
QString drawData = element.attributeNS( KoXmlNS::draw, "data" );
if( drawData.isEmpty() )
return false;
QStringList properties = drawData.split( ';' );
if( properties.count() == 0 )
return false;
foreach( const QString &property, properties )
{
QStringList pair = property.split( ':' );
if( pair.count() != 2 )
continue;
if( pair[0] == "corners" )
{
m_cornerCount = pair[1].toInt();
}
else if( pair[0] == "concave" )
{
m_convex = (pair[1] == "false");
}
else if( pair[0] == "baseRoundness" )
{
m_roundness[base] = pair[1].toDouble();
}
else if( pair[0] == "tipRoundness" )
{
m_roundness[tip] = pair[1].toDouble();
}
else if( pair[0] == "baseAngle" )
{
m_angles[base] = pair[1].toDouble();
}
else if( pair[0] == "tipAngle" )
{
m_angles[tip] = pair[1].toDouble();
}
else if( pair[0] == "sharpness" )
{
float percent = pair[1].left( pair[1].length()-1 ).toFloat();
m_radius[base] = m_radius[tip] * (100-percent)/100;
}
}
if( m_convex )
{
m_radius[base] = m_radius[tip];
}
}
示例5: parseToMessage
/*
Message type
"C2ACamion"
"0-02:06:18.040"
"EngSpeed 898,500 rpm"
"Accel 0,0 %"
"TCO 114,30 km/h MD:0 OS:0 DI:0 TP:0 HI:0 EV:0 D1:0/0/0 D2:0/0/0"
"Speed 114,30 km/h CC:0 BR:0 CS:0 PB:0"
"Distance 0,000 km"
"EngHours 1,90 h"
"FuelC 0,0 L"
"EngTemp +61 degr"
"FuelLev 36,8 %"
"VehID azerty"
"FMS 02.51 Diag:0 Requ:0"
"Gear S:* C:*"
"DoorCtr1 P:* R:* S:*"
"DC2 loe 1:* 2:* 3:* 4:* 5:* 6:* 7:* 8:* 9:* 10:*"
"BellowPr FAL:* kPa FAR:* kPa RAL:* kPa RAR:* kPa"
"BrakePr 1:* kPa 2:* kPa"
"Alternat 1:* 2:* 3:* 4:*"
"DateTime *"
"AmbTemp * degr" */
void CPluginCANGine::parseToMessage ()
{
QStringList list = m_message.split('\n');
if (2 < list.count())
{
QStringList list_engspeed = list[2].split(QRegExp("\\s+"));
if (1 < list_engspeed.count())
{
m_list_data_plugin[INFORMATIONS_DATA].setValueData("PCAN_ENGSPEED" , list_engspeed[1]);
}
}
if (3 < list.count())
{
QStringList list_accel = list[3].split(QRegExp("\\s+"));
if (1 < list_accel.count() )
{
m_list_data_plugin[INFORMATIONS_DATA].setValueData("PCAN_ACCEL" , list_accel[1]);
}
}
if (4 < list.count())
{
QStringList list_tco = list[4].split(QRegExp("\\s+"));
if (1 < list_tco.count())
{
m_list_data_plugin[INFORMATIONS_DATA].setValueData("PCAN_TCO" , list_tco[1]);
}
if (3 < list_tco.count())
{
QStringList list_tco_md = list_tco[3].split(":");
if (1 < list_tco_md.count())
{
m_list_data_plugin[INFORMATIONS_DATA].setValueData("PCAN_TCO_MD" , list_tco_md [1]);
}
}
if (4 < list_tco.count())
{
QStringList list_tco_os = list_tco[4].split(":");
if (1 < list_tco_os.count())
{
m_list_data_plugin[INFORMATIONS_DATA].setValueData("PCAN_TCO_OS" ,list_tco_os[1]);
}
}
if (5 < list_tco.count())
{
QStringList list_tco_di = list_tco[5].split(":");
if (1 < list_tco_di.count())
{
m_list_data_plugin[INFORMATIONS_DATA].setValueData("PCAN_TCO_DI" , list_tco_di[1]);
}
}
if (6 < list_tco.count())
{
QStringList list_tco_tp = list_tco[6].split(":");
if (1 < list_tco_tp.count())
{
m_list_data_plugin[INFORMATIONS_DATA].setValueData("PCAN_TCO_TP" , list_tco_tp[1]);
}
}
if (7 < list_tco.count())
{
QStringList list_tco_hi = list_tco[7].split(":");
if (1 < list_tco_hi.count())
{
m_list_data_plugin[INFORMATIONS_DATA].setValueData("PCAN_TCO_HI" ,list_tco_hi[1]);
}
}
if (8 < list_tco.count())
{
//.........这里部分代码省略.........
示例6: searchPath
QStringList djvSystem::searchPath()
{
//DJV_DEBUG("djvSystem::searchPath");
QStringList out;
// Add paths from environment variables.
QString path = env(djvPathEnv());
if (! path.isEmpty())
{
//DJV_DEBUG_PRINT("DJV_PATH = " << path);
QString match;
Q_FOREACH(QChar c, djvFileInfoUtil::listSeparators)
match += c;
out += path.split(
QRegExp(QString("[%1]+").arg(match)),
QString::SkipEmptyParts);
}
path = env(ldLibPathEnv());
if (! path.isEmpty())
{
//DJV_DEBUG_PRINT("LD_LIBRARY_PATH = " << path);
QString match;
Q_FOREACH(QChar c, djvFileInfoUtil::listSeparators)
match += c;
//DJV_DEBUG_PRINT("match = " << match);
out += path.split(
QRegExp(QString("[%1]+").arg(match)),
QString::SkipEmptyParts);
}
// Add the application path.
//DJV_DEBUG_PRINT("qApp = " << qApp);
const QString applicationPath = qApp->applicationDirPath();
//DJV_DEBUG_PRINT("application path = " << applicationPath);
out += applicationPath;
// Add library and translation paths.
out += QDir(applicationPath + "/../lib").absolutePath();
out += QDir(applicationPath + "/../translations").absolutePath();
#if defined(DJV_WINDOWS) || defined(DJV_OSX)
const QString dirName = QDir(qApp->applicationDirPath()).dirName();
out += QDir(applicationPath + "/../../lib/" + dirName).absolutePath();
out += QDir(applicationPath + "/../../translations/" + dirName).absolutePath();
#endif
// Add the build directories.
out += QDir("lib/djvCore").absolutePath();
out += QDir("lib/djvGui").absolutePath();
out += QDir("lib/djvViewLib").absolutePath();
out += QDir("bin/djv_ls").absolutePath();
out += QDir("bin/djv_info").absolutePath();
out += QDir("bin/djv_convert").absolutePath();
// Add the current directory.
out += ".";
//DJV_DEBUG_PRINT("out = " << out);
QSet<QString> set;
for (int i = 0; i < out.count(); ++i)
set.insert(out[i]);
QList<QString> list = set.toList();
out.clear();
Q_FOREACH(const QString & s, list)
out += s;
return out;
}
示例7: writeAssociationRoleDecl
void XMLSchemaWriter::writeAssociationRoleDecl( UMLClassifier *c, const QString &multi, QTextStream &XMLschema)
{
bool isAbstract = c->getAbstract();
bool isInterface = c->isInterface();
QString elementName = getElementName(c);
QString doc = c->getDoc();
if (!doc.isEmpty())
writeComment(doc, XMLschema);
// Min/Max Occurs is based on whether it is this a single element
// or a List (maxoccurs>1). One day this will be done correctly with special
// multiplicity object that we don't have to figure out what it means via regex.
QString minOccurs = "0";
QString maxOccurs = "unbounded";
if (multi.isEmpty())
{
// in this case, association will only specify ONE element can exist
// as a child
minOccurs = "1";
maxOccurs = "1";
}
else
{
QStringList values = QStringList::split( QRegExp("[^\\d{1,}|\\*]"), multi);
// could use some improvement here.. for sequences like "0..1,3..5,10" we
// don't capture the whole "richness" of the multi. Instead we translate it
// now to minOccurs="0" maxOccurs="10"
if (values.count() > 0)
{
// populate both with the actual value as long as our value isnt an asterix
// In that case, use special value (from above)
if(values[0].contains(QRegExp("\\d{1,}")))
minOccurs = values[0]; // use first number in sequence
if(values[values.count()-1].contains(QRegExp("\\d{1,}")))
maxOccurs = values[values.count()-1]; // use only last number in sequence
}
}
// Now declare the class in the association as an element or group.
//
// In a semi-arbitrary way, we have decided to make abstract classes into
// "groups" and concrete classes into "complexTypes".
//
// This is because about the only thing you can do with an abstract
// class (err. node) is inherit from it with a "concrete" element. Therefore,
// in this manner, we need a group node for abstract classes to lay out the child
// element choices so that the child, concrete class may be plugged into whatever spot
// it parent could go. The tradeoff is that "group" nodes may not be extended, so the
// choices that you lay out here are it (e.g. no more nodes may inherit" from this group)
//
// The flipside for concrete classes is that we want to use them as elements in our document.
// Unfortunately, about all you can do with complexTypes in terms of inheritance, is to
// use these as the basis for a new node type. This is NOT full inheritence because the new
// class (err. element node) wont be able to go into the document where it parent went without
// you heavily editing the schema.
//
// Therefore, IF a group is abstract, but has no inheriting sub-classes, there are no choices, and its nigh
// on pointless to declare it as a group, in this special case, abstract classes get declared
// as complexTypes.
//
// Of course, in OO methodology, you should be able to inherit from
// any class, but schema just don't allow use to have full inheritence using either groups
// or complexTypes. Thus we have taken a middle rode. If someone wants to key me into a
// better way to represent this, I'd be happy to listen. =b.t.
//
// UPDATE: partial solution to the above: as of 13-Mar-2003 we now write BOTH a complexType
// AND a group declaration for interfaces AND classes which are inherited from.
//
if ((isAbstract || isInterface ) && c->findSubClassConcepts().count() > 0)
XMLschema<<getIndent()<<"<"<<makeSchemaTag("group")
<<" ref=\""<<makePackageTag(getElementGroupTypeName(c))<<"\"";
else
XMLschema<<getIndent()<<"<"<<makeSchemaTag("element")
<<" name=\""<<getElementName(c)<<"\""
<<" type=\""<<makePackageTag(getElementTypeName(c))<<"\"";
// min/max occurs
if (minOccurs != "1")
XMLschema<<" minOccurs=\""<<minOccurs<<"\"";
if (maxOccurs != "1")
XMLschema<<" maxOccurs=\""<<maxOccurs<<"\"";
// tidy up the node
XMLschema<<"/>"<<m_endl;
}
示例8: load
void MacroManager::load()
{
QDir dir(savePath);
if(!dir.exists())
return; //no need to bother trying to load
QFile data(savePath + "/qtmacrocodes.cfg");
if(!data.exists())
return;
if(data.open(QFile::ReadOnly))
{
QTextStream in(&data);
QString line;
int i=0;
QString curProg;
int curMKey = 0;
int curGKey = 0;
Macro m;
while((line = in.readLine()) != NULL)
{
if(i==0) //this is version line. Isn't needed in first version
{
i++;
continue;
}
if(line.left(2) == "#p")
{
trySaveMacro(&m, curProg, curMKey, curGKey);
//Prog line
curProg = line.right(line.length()-2);
setCurActiveId(&curProg);
writeDbg(tr("mm> found program ") + curProg);
}
else if(line.left(2) == "#m")
{
trySaveMacro(&m, curProg, curMKey, curGKey);
//Mkey line
curMKey = line.right(1).toInt(NULL);
writeDbg(tr("mm> found mkey ") + QString::number(curMKey));
}
else if(line.left(2) == "#g")
{
trySaveMacro(&m, curProg, curMKey, curGKey);
//GKey line
if(line.length() == 3)
curGKey = line.right(1).toInt(NULL);
else
curGKey = line.right(2).toInt(NULL);
writeDbg(tr("mm> found gkey ") + QString::number(curGKey));
}
else if(line.contains("=", Qt::CaseSensitive))
{
//Event line
QStringList eventInfo = line.split("=");
if(eventInfo.count() != 2)
continue;
writeDbg(tr("mm> found key: ") + QString::number(eventInfo.at(0).toInt(NULL)) + tr(":") + QString::number(eventInfo.at(1).toInt(NULL)));
m.addEvent(eventInfo.at(0).toInt(NULL), (bool)eventInfo.at(1).toInt(NULL));
}
}
trySaveMacro(&m, curProg, curMKey, curGKey);
}
}
示例9: slotCompute
//.........这里部分代码省略.........
Object2 = KSPlanetBase::createPlanet( Obj2ComboBox->currentIndex() );
if( FilterTypeComboBox->currentIndex() == 0 && Object1->name() == Object2->name() ) {
// FIXME: Must free the created Objects
KMessageBox::sorry( 0 , i18n("Please select two different objects to check conjunctions with.") );
return;
}
// Init KSConjunct object
KSConjunct ksc;
connect( &ksc, SIGNAL(madeProgress(int)), this, SLOT(showProgress(int)) );
ksc.setGeoLocation( geoPlace );
switch ( FilterTypeComboBox->currentIndex() ) {
case 1: // All object types
foreach( int type, data->skyComposite()->objectNames().keys() )
objects += data->skyComposite()->objectNames( type );
break;
case 2: // Stars
objects += data->skyComposite()->objectNames( SkyObject::STAR );
objects += data->skyComposite()->objectNames( SkyObject::CATALOG_STAR );
break;
case 3: // Solar system
objects += data->skyComposite()->objectNames( SkyObject::PLANET );
objects += data->skyComposite()->objectNames( SkyObject::COMET );
objects += data->skyComposite()->objectNames( SkyObject::ASTEROID );
objects += data->skyComposite()->objectNames( SkyObject::MOON );
objects += i18n("Sun");
// Remove Object2 planet
objects.removeAll( Object2->name() );
break;
case 4: // Planet
objects += data->skyComposite()->objectNames( SkyObject::PLANET );
// Remove Object2 planet
objects.removeAll( Object2->name() );
break;
case 5: // Comet
objects += data->skyComposite()->objectNames( SkyObject::COMET );
break;
case 6: // Ateroid
objects += data->skyComposite()->objectNames( SkyObject::ASTEROID );
break;
case 7: // Open Clusters
objects = data->skyComposite()->objectNames( SkyObject::OPEN_CLUSTER );
break;
case 8: // Open Clusters
objects = data->skyComposite()->objectNames( SkyObject::GLOBULAR_CLUSTER );
break;
case 9: // Gaseous nebulae
objects = data->skyComposite()->objectNames( SkyObject::GASEOUS_NEBULA );
break;
case 10: // Planetary nebula
objects = data->skyComposite()->objectNames( SkyObject::PLANETARY_NEBULA );
break;
case 11: // Galaxies
objects = data->skyComposite()->objectNames( SkyObject::GALAXY );
break;
}
// Remove all Jupiter and Saturn moons
// KStars crash if we compute a conjunction between a planet and one of this moon
if ( FilterTypeComboBox->currentIndex() == 1 ||
FilterTypeComboBox->currentIndex() == 3 ||
FilterTypeComboBox->currentIndex() == 6 ) {
objects.removeAll( "Io" );
objects.removeAll( "Europa" );
objects.removeAll( "Ganymede" );
objects.removeAll( "Callisto" );
objects.removeAll( "Mimas" );
objects.removeAll( "Enceladus" );
objects.removeAll( "Tethys" );
objects.removeAll( "Dione" );
objects.removeAll( "Rhea" );
objects.removeAll( "Titan" );
objects.removeAll( "Hyperion" );
objects.removeAll( "Iapetus" );
}
if ( FilterTypeComboBox->currentIndex() != 0 ) {
// Show a progress dialog while processing
QProgressDialog progressDlg( i18n( "Compute conjunction..." ), i18n( "Abort" ), 0, objects.count(), this);
progressDlg.setWindowModality( Qt::WindowModal );
progressDlg.setValue( 0 );
foreach( QString object, objects ) {
// If the user click on the 'cancel' button
if ( progressDlg.wasCanceled() )
break;
// Update progress dialog
++progress;
progressDlg.setValue( progress );
progressDlg.setLabelText( i18n( "Compute conjunction between %1 and %2", Object2->name(), object ) );
// Compute conjuction
Object1 = data->skyComposite()->findByName( object );
showConjunctions( ksc.findClosestApproach(*Object1, *Object2, startJD, stopJD, maxSeparation, opposition), object, Object2->name() );
}
progressDlg.setValue( objects.count() );
} else {
示例10: if
/** add the given key and value
@param scope scope of key
@param key key name
@param rootProperty is the property from which to start adding
@param value the value associated with the key
*/
static
QgsProperty * addKey_( QString const & scope,
QString const & key,
QgsPropertyKey * rootProperty,
QVariant value )
{
QStringList keySequence = makeKeyTokens_( scope, key );
// cursor through property key/value hierarchy
QgsPropertyKey * currentProperty = rootProperty;
QgsProperty * newProperty; // link to next property down hiearchy
while ( ! keySequence.isEmpty() )
{
// if the current head of the sequence list matches the property name,
// then traverse down the property hierarchy
if ( keySequence.first() == currentProperty->name() )
{
// remove front key since we're traversing down a level
keySequence.pop_front();
// if key sequence has one last element, then we use that as the
// name to store the value
if ( 1 == keySequence.count() )
{
currentProperty->setValue( keySequence.front(), value );
return currentProperty;
}
// we're at the top element if popping the keySequence element
// will leave it empty; in that case, just add the key
else if ( keySequence.isEmpty() )
{
currentProperty->setValue( value );
return currentProperty;
}
else if (( newProperty = currentProperty->find( keySequence.first() ) ) )
{
currentProperty = dynamic_cast<QgsPropertyKey*>( newProperty );
if ( currentProperty )
{
continue;
}
else // QgsPropertyValue not Key, so return null
{
return 0x0;
}
}
else // the next subkey doesn't exist, so add it
{
newProperty = currentProperty->addKey( keySequence.first() );
if ( newProperty )
{
currentProperty = dynamic_cast<QgsPropertyKey*>( newProperty );
}
continue;
}
}
else
{
return 0x0;
}
}
return 0x0;
} // addKey_
示例11: parseOtoolLibraryLine
FrameworkInfo parseOtoolLibraryLine(const QString &line, bool useDebugLibs)
{
FrameworkInfo info;
QString trimmed = line.trimmed();
if (trimmed.isEmpty())
return info;
// Don't deploy system libraries.
if (trimmed.startsWith("/System/Library/") ||
(trimmed.startsWith("/usr/lib/") && trimmed.contains("libQt") == false) // exception for libQtuitools and libQtlucene
|| trimmed.startsWith("@executable_path"))
return info;
enum State {QtPath, FrameworkName, DylibName, Version, End};
State state = QtPath;
int part = 0;
QString name;
QString qtPath;
QString suffix = useDebugLibs ? "_debug" : "";
// Split the line into [Qt-path]/lib/qt[Module].framework/Versions/[Version]/
QStringList parts = trimmed.split("/");
while (part < parts.count()) {
const QString currentPart = parts.at(part).simplified() ;
++part;
if (currentPart == "")
continue;
if (state == QtPath) {
// Check for library name part
if (part < parts.count() && parts.at(part).contains(".dylib ")) {
state = DylibName;
info.installName += "/" + (qtPath + "lib/").simplified();
info.frameworkDirectory = info.installName;
state = DylibName;
continue;
} else if (part < parts.count() && parts.at(part).endsWith(".framework")) {
info.installName += "/" + (qtPath + "lib/").simplified();
info.frameworkDirectory = info.installName;
state = FrameworkName;
continue;
} else if (trimmed.startsWith("/") == false) { // If the line does not contain a full path, the app is using a binary Qt package.
if (currentPart.contains(".framework")) {
info.frameworkDirectory = "/Library/Frameworks/";
state = FrameworkName;
} else {
info.frameworkDirectory = "/usr/lib/";
state = DylibName;
}
--part;
continue;
}
qtPath += (currentPart + "/");
} if (state == FrameworkName) {
// remove ".framework"
name = currentPart;
name.chop(QString(".framework").length());
info.frameworkName = currentPart;
state = Version;
++part;
continue;
} if (state == DylibName) {
name = currentPart.split(" (compatibility").at(0);
info.frameworkName = name;
info.binaryName = name.left(name.indexOf('.')) + suffix + name.mid(name.indexOf('.'));
info.installName += name;
info.deployedInstallName = "@executable_path/../Frameworks/" + info.binaryName;
info.frameworkPath = info.frameworkDirectory + info.binaryName;
info.sourceFilePath = info.frameworkPath;
info.destinationDirectory = bundleFrameworkDirectory + "/";
info.binaryDirectory = info.frameworkDirectory;
info.binaryPath = info.frameworkPath;
state = End;
++part;
continue;
} else if (state == Version) {
info.version = currentPart;
info.binaryDirectory = "Versions/" + info.version;
info.binaryName = name + suffix;
info.binaryPath = "/" + info.binaryDirectory + "/" + info.binaryName;
info.installName += info.frameworkName + "/" + info.binaryDirectory + "/" + name;
info.deployedInstallName = "@executable_path/../Frameworks/" + info.frameworkName + info.binaryPath;
info.frameworkPath = info.frameworkDirectory + info.frameworkName;
info.sourceFilePath = info.frameworkPath + info.binaryPath;
info.destinationDirectory = bundleFrameworkDirectory + "/" + info.frameworkName + "/" + info.binaryDirectory;
state = End;
} else if (state == End) {
break;
}
}
return info;
}
示例12: themeBoxChanged
void SoundSettingsPage::themeBoxChanged(int index)
{
QStringList themeDirs = soundEngine->getAvailableThemes().keys();
if(index >= 0 && index < themeDirs.count())
settingsCache->setSoundThemeName(themeDirs.at(index));
}
示例13: runFunction
//.........这里部分代码省略.........
int x = floor( param[1].toFloat() );
int y = floor( param[2].toFloat() );
result = sw.widget->picwinPtr()->colorAt(layer, x, y);
return true;
}
if (fn == "CURWINTYPE") {
// Returns the current target type (msg or channel)
subwindow_t sw = winList->value(*activeWid);
if (sw.type == WT_CHANNEL)
result = "CHANNEL";
else if (sw.type == WT_GRAPHIC)
result = "GRAPHIC";
else if (sw.type == WT_GWINPUT)
result = "GRAPHICINPUT";
else if (sw.type == WT_NOTHING)
result = "NOTHIG";
else if (sw.type == WT_PRIVMSG)
result = "PRIVMSG";
else if (sw.type == WT_STATUS)
result = "STATUS";
else if (sw.type == WT_TXTONLY)
result = "TXTONLY";
else
result = "UNKNOWN";
return true;
}
if (fn == "DLG") {
// Returns information of a dialog or its objects
// $dlg(dialog,object)
if (param.count() == 2) {
QString dlg = param[0];
QString object = param[1];
QHashIterator<QString,TCustomScriptDialog*> i(*dialogs);
while (i.hasNext()) {
i.next();
if (i.key().toUpper() == dlg.toUpper()) {
result = i.value()->getLabel(object);
return true;
}
}
}
// $dlg(dialog,object,index)
if (param.count() == 3) {
QString dlg = param[0];
QString object = param[1];
QString index = param[2];
QHashIterator<QString,TCustomScriptDialog*> i(*dialogs);
while (i.hasNext()) {
i.next();
if (i.key().toUpper() == dlg.toUpper()) {
result = i.value()->getItem(object, index.toInt());
return true;
}
}
}
// Default
return false;
}
示例14: glCreateShaderObjectARB
bool
ShaderFactory::loadShader(GLhandleARB &progObj,
QString shaderString)
{
GLhandleARB fragObj = glCreateShaderObjectARB(GL_FRAGMENT_SHADER_ARB);
glAttachObjectARB(progObj, fragObj);
GLhandleARB vertObj = glCreateShaderObjectARB(GL_VERTEX_SHADER_ARB);
glAttachObjectARB(progObj, vertObj);
{ // vertObj
QString qstr;
qstr = "varying vec3 pointpos;\n";
qstr += "void main(void)\n";
qstr += "{\n";
qstr += " // Transform vertex position into homogenous clip-space.\n";
qstr += " gl_FrontColor = gl_Color;\n";
qstr += " gl_BackColor = gl_Color;\n";
qstr += " gl_Position = ftransform();\n";
qstr += " gl_TexCoord[0] = gl_TextureMatrix[0] * gl_MultiTexCoord0;\n";
qstr += " gl_TexCoord[1] = gl_TextureMatrix[1] * gl_MultiTexCoord1;\n";
qstr += " gl_TexCoord[2] = gl_TextureMatrix[2] * gl_MultiTexCoord2;\n";
qstr += " gl_ClipVertex = gl_ModelViewMatrix * gl_Vertex;\n";
qstr += " pointpos = gl_Vertex.xyz;\n";
qstr += "}\n";
int len = qstr.length();
char *tbuffer = new char[len+1];
sprintf(tbuffer, qstr.toLatin1().data());
const char *sstr = tbuffer;
glShaderSourceARB(vertObj, 1, &sstr, NULL);
delete [] tbuffer;
GLint compiled = -1;
glCompileShaderARB(vertObj);
glGetObjectParameterivARB(vertObj,
GL_OBJECT_COMPILE_STATUS_ARB,
&compiled);
if (!compiled)
{
GLcharARB str[1000];
GLsizei len;
glGetInfoLogARB(vertObj,
(GLsizei) 1000,
&len,
str);
QMessageBox::information(0,
"Error : Vertex Shader",
str);
return false;
}
}
{ // fragObj
int len = shaderString.length();
char *tbuffer = new char[len+1];
sprintf(tbuffer, shaderString.toLatin1().data());
const char *sstr = tbuffer;
glShaderSourceARB(fragObj, 1, &sstr, NULL);
delete [] tbuffer;
GLint compiled = -1;
glCompileShaderARB(fragObj);
glGetObjectParameterivARB(fragObj,
GL_OBJECT_COMPILE_STATUS_ARB,
&compiled);
if (!compiled)
{
GLcharARB str[1000];
GLsizei len;
glGetInfoLogARB(fragObj,
(GLsizei) 1000,
&len,
str);
//-----------------------------------
// display error
//qApp->beep();
QString estr;
QStringList slist = shaderString.split("\n");
for(int i=0; i<slist.count(); i++)
estr += QString("%1 : %2\n").arg(i+1).arg(slist[i]);
QTextEdit *tedit = new QTextEdit();
tedit->insertPlainText("-------------Error----------------\n\n");
tedit->insertPlainText(str);
tedit->insertPlainText("\n-----------Shader---------------\n\n");
tedit->insertPlainText(estr);
QVBoxLayout *layout = new QVBoxLayout();
layout->addWidget(tedit);
QDialog *showError = new QDialog();
showError->setWindowTitle("Error in Fragment Shader");
showError->setSizeGripEnabled(true);
showError->setModal(true);
//.........这里部分代码省略.........
示例15: stream
BrowserApplication::BrowserApplication(int &argc, char **argv)
: QApplication(argc, argv)
, m_localServer(0)
{
QCoreApplication::setOrganizationName(QLatin1String("Qt"));
QCoreApplication::setApplicationName(QLatin1String("demobrowser"));
QCoreApplication::setApplicationVersion(QLatin1String("0.1"));
#ifdef Q_WS_QWS
// Use a different server name for QWS so we can run an X11
// browser and a QWS browser in parallel on the same machine for
// debugging
QString serverName = QCoreApplication::applicationName() + QLatin1String("_qws");
#else
QString serverName = QCoreApplication::applicationName();
#endif
QLocalSocket socket;
socket.connectToServer(serverName);
if (socket.waitForConnected(500)) {
QTextStream stream(&socket);
QStringList args = QCoreApplication::arguments();
if (args.count() > 1)
stream << args.last();
else
stream << QString();
stream.flush();
socket.waitForBytesWritten();
return;
}
#if defined(Q_WS_MAC)
QApplication::setQuitOnLastWindowClosed(false);
#else
QApplication::setQuitOnLastWindowClosed(true);
#endif
m_localServer = new QLocalServer(this);
connect(m_localServer, SIGNAL(newConnection()),
this, SLOT(newLocalSocketConnection()));
if (!m_localServer->listen(serverName)) {
if (m_localServer->serverError() == QAbstractSocket::AddressInUseError
&& QFile::exists(m_localServer->serverName())) {
QFile::remove(m_localServer->serverName());
m_localServer->listen(serverName);
}
}
#ifndef QT_NO_OPENSSL
if (!QSslSocket::supportsSsl()) {
QMessageBox::information(0, "Demo Browser",
"This system does not support OpenSSL. SSL websites will not be available.");
}
#endif
QDesktopServices::setUrlHandler(QLatin1String("http"), this, "openUrl");
QString localSysName = QLocale::system().name();
installTranslator(QLatin1String("qt_") + localSysName);
QSettings settings;
settings.beginGroup(QLatin1String("sessions"));
m_lastSession = settings.value(QLatin1String("lastSession")).toByteArray();
settings.endGroup();
#if defined(Q_WS_MAC)
connect(this, SIGNAL(lastWindowClosed()),
this, SLOT(lastWindowClosed()));
#endif
QTimer::singleShot(0, this, SLOT(postLaunch()));
}