本文整理汇总了C++中qstringlist::iterator类的典型用法代码示例。如果您正苦于以下问题:C++ iterator类的具体用法?C++ iterator怎么用?C++ iterator使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了iterator类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: query
MixxxLibraryFeature::MixxxLibraryFeature(Library* pLibrary,
TrackCollection* pTrackCollection,
ConfigObject<ConfigValue>* pConfig)
: LibraryFeature(pLibrary),
kMissingTitle(tr("Missing Tracks")),
kHiddenTitle(tr("Hidden Tracks")),
m_pLibrary(pLibrary),
m_pMissingView(NULL),
m_pHiddenView(NULL),
m_trackDao(pTrackCollection->getTrackDAO()),
m_pConfig(pConfig),
m_pTrackCollection(pTrackCollection) {
QStringList columns;
columns << "library." + LIBRARYTABLE_ID
<< "library." + LIBRARYTABLE_PLAYED
<< "library." + LIBRARYTABLE_TIMESPLAYED
//has to be up here otherwise Played and TimesPlayed are not show
<< "library." + LIBRARYTABLE_ALBUMARTIST
<< "library." + LIBRARYTABLE_ALBUM
<< "library." + LIBRARYTABLE_ARTIST
<< "library." + LIBRARYTABLE_TITLE
<< "library." + LIBRARYTABLE_YEAR
<< "library." + LIBRARYTABLE_RATING
<< "library." + LIBRARYTABLE_GENRE
<< "library." + LIBRARYTABLE_COMPOSER
<< "library." + LIBRARYTABLE_GROUPING
<< "library." + LIBRARYTABLE_TRACKNUMBER
<< "library." + LIBRARYTABLE_KEY
<< "library." + LIBRARYTABLE_KEY_ID
<< "library." + LIBRARYTABLE_BPM
<< "library." + LIBRARYTABLE_BPM_LOCK
<< "library." + LIBRARYTABLE_DURATION
<< "library." + LIBRARYTABLE_BITRATE
<< "library." + LIBRARYTABLE_FILETYPE
<< "library." + LIBRARYTABLE_DATETIMEADDED
<< "track_locations.location"
<< "track_locations.fs_deleted"
<< "library." + LIBRARYTABLE_COMMENT
<< "library." + LIBRARYTABLE_MIXXXDELETED
<< "library." + LIBRARYTABLE_COVERART_SOURCE
<< "library." + LIBRARYTABLE_COVERART_TYPE
<< "library." + LIBRARYTABLE_COVERART_LOCATION
<< "library." + LIBRARYTABLE_COVERART_HASH;
QSqlQuery query(pTrackCollection->getDatabase());
QString tableName = "library_cache_view";
QString queryString = QString(
"CREATE TEMPORARY VIEW IF NOT EXISTS %1 AS "
"SELECT %2 FROM library "
"INNER JOIN track_locations ON library.location = track_locations.id")
.arg(tableName, columns.join(","));
query.prepare(queryString);
if (!query.exec()) {
LOG_FAILED_QUERY(query);
}
// Strip out library. and track_locations.
for (QStringList::iterator it = columns.begin();
it != columns.end(); ++it) {
if (it->startsWith("library.")) {
*it = it->replace("library.", "");
} else if (it->startsWith("track_locations.")) {
*it = it->replace("track_locations.", "");
}
}
BaseTrackCache* pBaseTrackCache = new BaseTrackCache(
pTrackCollection, tableName, LIBRARYTABLE_ID, columns, true);
connect(&m_trackDao, SIGNAL(trackDirty(int)),
pBaseTrackCache, SLOT(slotTrackDirty(int)));
connect(&m_trackDao, SIGNAL(trackClean(int)),
pBaseTrackCache, SLOT(slotTrackClean(int)));
connect(&m_trackDao, SIGNAL(trackChanged(int)),
pBaseTrackCache, SLOT(slotTrackChanged(int)));
connect(&m_trackDao, SIGNAL(tracksAdded(QSet<int>)),
pBaseTrackCache, SLOT(slotTracksAdded(QSet<int>)));
connect(&m_trackDao, SIGNAL(tracksRemoved(QSet<int>)),
pBaseTrackCache, SLOT(slotTracksRemoved(QSet<int>)));
connect(&m_trackDao, SIGNAL(dbTrackAdded(TrackPointer)),
pBaseTrackCache, SLOT(slotDbTrackAdded(TrackPointer)));
m_pBaseTrackCache = QSharedPointer<BaseTrackCache>(pBaseTrackCache);
pTrackCollection->setTrackSource(m_pBaseTrackCache);
// These rely on the 'default' track source being present.
m_pLibraryTableModel = new LibraryTableModel(this, pTrackCollection, "mixxx.db.model.library");
TreeItem* pRootItem = new TreeItem();
TreeItem* pmissingChildItem = new TreeItem(kMissingTitle, kMissingTitle,
this, pRootItem);
TreeItem* phiddenChildItem = new TreeItem(kHiddenTitle, kHiddenTitle,
this, pRootItem);
pRootItem->appendChild(pmissingChildItem);
pRootItem->appendChild(phiddenChildItem);
m_childModel.setRootItem(pRootItem);
}
示例2: quoteText
/** @short Take the initial text and mark it as a quotation */
QStringList quoteText(QStringList inputLines)
{
QStringList quote;
for (QStringList::iterator line = inputLines.begin(); line != inputLines.end(); ++line) {
if (UiUtils::signatureSeparator().match(*line).hasMatch()) {
// This is the signature separator, we should not include anything below that in the quote
break;
}
// rewrap - we need to keep the quotes at < 79 chars, yet the grow with every level
if (line->length() < 79-2) {
// this line is short enough, prepend quote mark and continue
if (line->isEmpty() || line->at(0) == QLatin1Char('>'))
line->prepend(QLatin1Char('>'));
else
line->prepend(QLatin1String("> "));
quote << *line;
continue;
}
// long line -> needs to be wrapped
// 1st, detect the quote depth and eventually stript the quotes from the line
int quoteLevel = 0;
int contentStart = 0;
if (line->at(0) == QLatin1Char('>')) {
quoteLevel = 1;
while (quoteLevel < line->length() && line->at(quoteLevel) == QLatin1Char('>'))
++quoteLevel;
contentStart = quoteLevel;
if (quoteLevel < line->length() && line->at(quoteLevel) == QLatin1Char(' '))
++contentStart;
}
// 2nd, build a quote string
QString quotemarks;
for (int i = 0; i < quoteLevel; ++i)
quotemarks += QLatin1Char('>');
quotemarks += QLatin1String("> ");
// 3rd, wrap the line, prepend the quotemarks to each line and add it to the quote text
int space(contentStart), lastSpace(contentStart), pos(contentStart), length(0);
while (pos < line->length()) {
if (line->at(pos) == QLatin1Char(' '))
space = pos+1;
++length;
if (length > 65-quotemarks.length() && space != lastSpace) {
// wrap
quote << quotemarks + line->mid(lastSpace, space - lastSpace);
lastSpace = space;
length = pos - space;
}
++pos;
}
quote << quotemarks + line->mid(lastSpace);
}
return quote;
}
示例3: if
//.........这里部分代码省略.........
QgsDebugMsg( "Found y field: " + ( *it ) );
mYFieldIndex = fieldPos;
}
QgsDebugMsg( "Adding field: " + ( *it ) );
// assume that the field could be integer or double
couldBeInt.insert( fieldPos, true );
couldBeDouble.insert( fieldPos, true );
fieldPos++;
}
}
QgsDebugMsg( "Field count for the delimited text file is " + QString::number( attributeFields.size() ) );
hasFields = true;
}
else if ( mXFieldIndex != -1 && mYFieldIndex != -1 )
{
mNumberFeatures++;
// split the line on the delimiter
QStringList parts;
if ( mDelimiterType == "regexp" )
parts = line.split( mDelimiterRegexp );
else
parts = line.split( mDelimiter );
// Skip malformed lines silently. Report line number with nextFeature()
if ( attributeFields.size() != parts.size() )
{
continue;
}
// Get the x and y values, first checking to make sure they
// aren't null.
QString sX = parts[mXFieldIndex];
QString sY = parts[mYFieldIndex];
bool xOk = true;
bool yOk = true;
double x = sX.toDouble( &xOk );
double y = sY.toDouble( &yOk );
if ( xOk && yOk )
{
if ( !firstPoint )
{
mExtent.combineExtentWith( x, y );
}
else
{ // Extent for the first point is just the first point
mExtent.set( x, y, x, y );
firstPoint = false;
}
}
int i = 0;
for ( QStringList::iterator it = parts.begin(); it != parts.end(); ++it, ++i )
{
// try to convert attribute values to integer and double
if ( couldBeInt[i] )
{
it->toInt( &couldBeInt[i] );
}
if ( couldBeDouble[i] )
{
it->toDouble( &couldBeDouble[i] );
}
}
}
}
// now it's time to decide the types for the fields
for ( QgsFieldMap::iterator it = attributeFields.begin(); it != attributeFields.end(); ++it )
{
if ( couldBeInt[it.key()] )
{
it->setType( QVariant::Int );
it->setTypeName( "integer" );
}
else if ( couldBeDouble[it.key()] )
{
it->setType( QVariant::Double );
it->setTypeName( "double" );
}
}
if ( mXFieldIndex != -1 && mYFieldIndex != -1 )
{
QgsDebugMsg( "Data store is valid" );
QgsDebugMsg( "Number of features " + QString::number( mNumberFeatures ) );
QgsDebugMsg( "Extents " + mExtent.toString() );
mValid = true;
}
else
{
QgsDebugMsg( "Data store is invalid. Specified x,y fields do not match those in the database" );
}
QgsDebugMsg( "Done checking validity" );
}
示例4: main
int main( int argc, char ** argv )
{
#if defined (FC_OS_LINUX) || defined(FC_OS_BSD)
// Make sure to setup the Qt locale system before setting LANG and LC_ALL to C.
// which is needed to use the system locale settings.
(void)QLocale::system();
// http://www.freecadweb.org/tracker/view.php?id=399
// Because of setting LANG=C the Qt automagic to use the correct encoding
// for file names is broken. This is a workaround to force the use of UTF-8 encoding
QFile::setEncodingFunction(myEncoderFunc);
QFile::setDecodingFunction(myDecoderFunc);
// Make sure that we use '.' as decimal point. See also
// http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=559846
putenv("LC_NUMERIC=C");
putenv("PYTHONPATH=");
#elif defined(FC_OS_MACOSX)
(void)QLocale::system();
putenv("LC_NUMERIC=C");
putenv("PYTHONPATH=");
#else
setlocale(LC_NUMERIC, "C");
_putenv("PYTHONPATH=");
#endif
#if defined (FC_OS_WIN32)
int argc_ = argc;
QVector<QByteArray> data;
QVector<char *> argv_;
// get the command line arguments as unicode string
{
QCoreApplication app(argc, argv);
QStringList args = app.arguments();
for (QStringList::iterator it = args.begin(); it != args.end(); ++it) {
data.push_back(it->toUtf8());
argv_.push_back(data.back().data());
}
argv_.push_back(0); // 0-terminated string
}
#endif
// Name and Version of the Application
App::Application::Config()["ExeName"] = "FreeCAD";
App::Application::Config()["ExeVendor"] = "FreeCAD";
App::Application::Config()["AppDataSkipVendor"] = "true";
App::Application::Config()["MaintainerUrl"] = "http://www.freecadweb.org/wiki/index.php?title=Main_Page";
// set the banner (for logging and console)
App::Application::Config()["CopyrightInfo"] = sBanner;
App::Application::Config()["AppIcon"] = "freecad";
App::Application::Config()["SplashScreen"] = "freecadsplash";
App::Application::Config()["StartWorkbench"] = "StartWorkbench";
//App::Application::Config()["HiddenDockWindow"] = "Property editor";
App::Application::Config()["SplashAlignment" ] = "Bottom|Left";
App::Application::Config()["SplashTextColor" ] = "#ffffff"; // white
App::Application::Config()["SplashInfoColor" ] = "#c8c8c8"; // light grey
try {
// Init phase ===========================================================
// sets the default run mode for FC, starts with gui if not overridden in InitConfig...
App::Application::Config()["RunMode"] = "Gui";
// Inits the Application
#if defined (FC_OS_WIN32)
App::Application::init(argc_, argv_.data());
#else
App::Application::init(argc, argv);
#endif
#if defined(_MSC_VER)
// create a dump file when the application crashes
std::string dmpfile = App::Application::getUserAppDataDir();
dmpfile += "crash.dmp";
InitMiniDumpWriter(dmpfile);
#endif
std::map<std::string, std::string>::iterator it = App::Application::Config().find("NavigationStyle");
if (it != App::Application::Config().end()) {
ParameterGrp::handle hGrp = App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Preferences/View");
// if not already defined do it now (for the very first start)
std::string style = hGrp->GetASCII("NavigationStyle", it->second.c_str());
hGrp->SetASCII("NavigationStyle", style.c_str());
}
Gui::Application::initApplication();
// Only if 'RunMode' is set to 'Gui' do the replacement
if (App::Application::Config()["RunMode"] == "Gui")
Base::Interpreter().replaceStdOutput();
}
catch (const Base::UnknownProgramOption& e) {
QApplication app(argc,argv);
QString appName = QString::fromLatin1(App::Application::Config()["ExeName"].c_str());
QString msg = QString::fromLatin1(e.what());
QString s = QLatin1String("<pre>") + msg + QLatin1String("</pre>");
QMessageBox::critical(0, appName, s);
exit(1);
}
catch (const Base::ProgramInformation& e) {
QApplication app(argc,argv);
QString appName = QString::fromLatin1(App::Application::Config()["ExeName"].c_str());
QString msg = QString::fromLatin1(e.what());
//.........这里部分代码省略.........