本文整理汇总了C++中QStringList::begin方法的典型用法代码示例。如果您正苦于以下问题:C++ QStringList::begin方法的具体用法?C++ QStringList::begin怎么用?C++ QStringList::begin使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QStringList
的用法示例。
在下文中一共展示了QStringList::begin方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Load
int LAPlatformManager::Load(const QString& aDirectory,
const bool& aKeepPlatforms)
{
LALogger::TraceBeginMethod(LA_DEBUG_STATIC_ARGS);
/* Returned value */
int numberOfPlatforms = 0;
/* Create singleton if needed */
LAPlatformManager::checkSingleton();
/* Factories to insert */
LAPlatformList insertedPlatforms;
QDir platformsDirectory(aDirectory);
QString fullPath = "";
LAPlatform* platform = NULL;
LALogger::Trace(LALogger::DEBUG,
LALogger::MAIN,
"LAPlatformManager::Load: Path = " + aDirectory,
LA_DEBUG_STATIC_ARGS);
if (!(platformsDirectory.exists()))
{
qWarning() << "LAPlatformManager::Load: Failed to load platforms from" << aDirectory << "- Directory does not exist";
numberOfPlatforms = -1;
}
/*! Filter directories and order them */
platformsDirectory.setFilter(QDir::Dirs);
platformsDirectory.setSorting(QDir::Name);
QStringList platformList = platformsDirectory.entryList();
if (-1 != numberOfPlatforms &&
0 >= platformList.count())
{
qWarning() << "LAPlatformManager::Load: No platform to load from" << aDirectory;
numberOfPlatforms = -1;
}
else
{
/* For all directories, load the platform (if no file is in the directory, it will be ignored */
for (QStringList::Iterator platformDirectory = platformList.begin(); platformList.end() != platformDirectory; platformDirectory++)
{
/* Do not consider dot directories */
if (!(*platformDirectory).startsWith("."))
{
LALogger::Trace(LALogger::DEBUG,
LALogger::MAIN,
"LAPlatformManager::Load: Processing " + *platformDirectory,
LA_DEBUG_STATIC_ARGS);
platform = new LAPlatform(aDirectory + *platformDirectory);
/* Load factory */
if (-1 == platform->Load())
{
delete platform;
platform = NULL;
}
else
{
/* If factory is successfully loaded, add it to list */
insertedPlatforms.insert(platform->getName(), platform);
numberOfPlatforms++;
}
}
}
}
/* If platform list to insert is not empty */
if (0 < insertedPlatforms.count())
{
/* If old platforms are to be erased before */
if (false == aKeepPlatforms)
{
LALogger::Trace(LALogger::DEBUG,
LALogger::MAIN,
"LAPlatformManager::Load: Erasing old platforms",
LA_DEBUG_STATIC_ARGS);
/* Put them in the old platforms list */
_M_ManagerSingleton->m_oldPlatforms += _M_ManagerSingleton->m_platforms;
/* Clear platforms */
_M_ManagerSingleton->m_platforms.clear();
}
LALogger::Trace(LALogger::DEBUG,
LALogger::MAIN,
QString("LAPlatformManager::Load: Adding %1 platforms").arg(insertedPlatforms.count()),
LA_DEBUG_STATIC_ARGS);
/* Add newly loaded platforms to current list */
//.........这里部分代码省略.........
示例2: fileSave
void MainWindow::fileSave()
{
if (! modified) {
statusBar()->showMessage(tr("No changes to be saved."), 2000);
return;
}
statusBar()->showMessage(tr("Saving changes..."));
{
QSettings settings(QLatin1String("Trolltech"));
settings.beginGroup(QLatin1String("Qt"));
QFontDatabase db;
QFont font = db.font(familycombo->currentText(),
stylecombo->currentText(),
psizecombo->currentText().toInt());
QStringList actcg, inactcg, discg;
bool overrideDesktopSettings = (gstylecombo->currentText() != desktopThemeName);
if (overrideDesktopSettings) {
int i;
for (i = 0; i < QColorGroup::NColorRoles; i++)
actcg << editPalette.color(QPalette::Active,
(QColorGroup::ColorRole) i).name();
for (i = 0; i < QColorGroup::NColorRoles; i++)
inactcg << editPalette.color(QPalette::Inactive,
(QColorGroup::ColorRole) i).name();
for (i = 0; i < QColorGroup::NColorRoles; i++)
discg << editPalette.color(QPalette::Disabled,
(QColorGroup::ColorRole) i).name();
}
settings.setValue(QLatin1String("font"), font.toString());
settings.setValue(QLatin1String("Palette/active"), actcg);
settings.setValue(QLatin1String("Palette/inactive"), inactcg);
settings.setValue(QLatin1String("Palette/disabled"), discg);
settings.setValue(QLatin1String("fontPath"), fontpaths);
settings.setValue(QLatin1String("embedFonts"), fontembeddingcheckbox->isChecked());
settings.setValue(QLatin1String("style"), overrideDesktopSettings ? gstylecombo->currentText() : QString());
settings.setValue(QLatin1String("doubleClickInterval"), dcispin->value());
settings.setValue(QLatin1String("cursorFlashTime"), cfispin->value() == 9 ? 0 : cfispin->value() );
settings.setValue(QLatin1String("wheelScrollLines"), wslspin->value());
settings.setValue(QLatin1String("resolveSymlinks"), resolvelinks->isChecked());
QSize strut(strutwidth->value(), strutheight->value());
settings.setValue(QLatin1String("globalStrut/width"), strut.width());
settings.setValue(QLatin1String("globalStrut/height"), strut.height());
settings.setValue(QLatin1String("useRtlExtensions"), rtlExtensions->isChecked());
#ifdef Q_WS_X11
QString style = inputStyle->currentText();
QString str = QLatin1String("On The Spot");
if ( style == trUtf8( "Over The Spot" ) )
str = QLatin1String("Over The Spot");
else if ( style == trUtf8( "Off The Spot" ) )
str = QLatin1String("Off The Spot");
else if ( style == trUtf8( "Root" ) )
str = QLatin1String("Root");
settings.setValue( QLatin1String("XIMInputStyle"), str );
#endif
#if defined(Q_WS_X11) && !defined(QT_NO_XIM)
settings.setValue(QLatin1String("DefaultInputMethod"), inputMethod->currentText());
#endif
QString audioSink = settings.value(QLatin1String("audiosink"), QLatin1String("Auto")).toString();
QString videoMode = settings.value(QLatin1String("videomode"), QLatin1String("Auto")).toString();
settings.setValue(QLatin1String("audiosink"), audiosinkCombo->itemData(audiosinkCombo->currentIndex()));
settings.setValue(QLatin1String("videomode"), videomodeCombo->itemData(videomodeCombo->currentIndex()));
QStringList effects;
if (effectcheckbox->isChecked()) {
effects << QLatin1String("general");
switch (menueffect->currentItem()) {
case 1: effects << QLatin1String("animatemenu"); break;
case 2: effects << QLatin1String("fademenu"); break;
}
switch (comboeffect->currentItem()) {
case 1: effects << QLatin1String("animatecombo"); break;
}
switch (tooltipeffect->currentItem()) {
case 1: effects << QLatin1String("animatetooltip"); break;
case 2: effects << QLatin1String("fadetooltip"); break;
}
switch ( toolboxeffect->currentItem() ) {
case 1: effects << QLatin1String("animatetoolbox"); break;
}
} else
effects << QLatin1String("none");
settings.setValue(QLatin1String("GUIEffects"), effects);
QStringList familysubs = QFont::substitutions();
QStringList::Iterator fit = familysubs.begin();
settings.beginGroup(QLatin1String("Font Substitutions"));
//.........这里部分代码省略.........
示例3: parse
void MakefileHandler::parse( const QString& folder, bool recursive )
{
//look for either Makefile.am.in, Makefile.am, or Makefile.in, in that order
AutoTools::ProjectAST* ast;
int ret = -1;
QString filePath = folder + "/Makefile.am.in";
if ( QFile::exists( filePath ) )
ret = AutoTools::Driver::parseFile( filePath, &ast );
else
{
filePath = folder + "/Makefile.am";
if ( QFile::exists( filePath ) )
ret = AutoTools::Driver::parseFile( filePath, &ast );
else
{
filePath = folder + "/Makefile.in";
if ( QFile::exists( filePath ) )
ret = AutoTools::Driver::parseFile( filePath, &ast );
else
kdDebug(9020) << k_funcinfo << "no appropriate file to parse in "
<< folder << endl;
}
}
if ( ret != 0 )
{
return;
}
kdDebug(9020) << k_funcinfo << filePath << " was parsed correctly. Adding information" << endl;
Q_ASSERT( ast != 0 );
d->projects[filePath] = ast;
d->folderToFileMap[folder] = filePath;
if ( recursive && ast && ast->hasChildren() )
{
QValueList<AutoTools::AST*> astChildList = ast->children();
QValueList<AutoTools::AST*>::iterator it(astChildList.begin()), clEnd(astChildList.end());
for ( ; it != clEnd; ++it )
{
if ( (*it)->nodeType() == AutoTools::AST::AssignmentAST )
{
AutoTools::AssignmentAST* assignment = static_cast<AutoTools::AssignmentAST*>( (*it) );
if ( assignment->scopedID == "SUBDIRS" )
{
QString list = assignment->values.join( QString::null );
list.simplifyWhiteSpace();
kdDebug(9020) << k_funcinfo << "subdirs is " << list << endl;
QStringList subdirList = QStringList::split( " ", list );
QStringList::iterator vit = subdirList.begin();
for ( ; vit != subdirList.end(); ++vit )
{
QString realDir = ( *vit );
if ( realDir.startsWith( "\\" ) )
realDir.remove( 0, 1 );
realDir = realDir.stripWhiteSpace();
if ( realDir != "." && realDir != ".." && !realDir.isEmpty() )
{
if ( isVariable( realDir ) )
{
kdDebug(9020) << k_funcinfo << "'" << realDir << "' is a variable" << endl;
realDir = resolveVariable( realDir, ast );
}
kdDebug(9020) << k_funcinfo << "Beginning parsing of '" << realDir << "'" << endl;
parse( folder + '/' + realDir, recursive );
}
}
}
}
}
}
}
示例4: ProcessData
void SSDP::ProcessData( MSocketDevice *pSocket )
{
long nBytes = 0;
long nRead = 0;
while ((nBytes = pSocket->bytesAvailable()) > 0)
{
QByteArray buffer;
buffer.resize(nBytes);
nRead = pSocket->readBlock( buffer.data(), nBytes );
QHostAddress peerAddress = pSocket->peerAddress();
quint16 peerPort = pSocket->peerPort ();
// ------------------------------------------------------------------
QString str = QString(buffer.constData());
QStringList lines = str.split("\r\n", QString::SkipEmptyParts);
QString sRequestLine = lines.size() ? lines[0] : "";
lines.pop_front();
// ------------------------------------------------------------------
// Parse request Type
// ------------------------------------------------------------------
VERBOSE(VB_UPNP+VB_EXTRA,
QString( "SSDP::ProcessData - requestLine: %1" )
.arg( sRequestLine ));
SSDPRequestType eType = ProcessRequestLine( sRequestLine );
// ------------------------------------------------------------------
// Read Headers into map
// ------------------------------------------------------------------
QStringMap headers;
for ( QStringList::Iterator it = lines.begin();
it != lines.end(); ++it )
{
QString sLine = *it;
QString sName = sLine.section( ':', 0, 0 ).trimmed();
QString sValue = sLine.section( ':', 1 );
sValue.truncate( sValue.length() ); //-2
if ((sName.length() != 0) && (sValue.length() !=0))
headers.insert( sName.toLower(), sValue.trimmed() );
}
// pSocket->SetDestAddress( peerAddress, peerPort );
// --------------------------------------------------------------
// See if this is a valid request
// --------------------------------------------------------------
switch( eType )
{
case SSDP_MSearch :
ProcessSearchRequest ( headers, peerAddress, peerPort ); break;
case SSDP_MSearchResp:
ProcessSearchResponse( headers ); break;
case SSDP_Notify :
ProcessNotify ( headers ); break;
case SSDP_Unknown:
default:
VERBOSE(VB_UPNP, "SSPD::ProcessData - Unknown request Type.");
break;
}
}
}
示例5: KDialogBase
OptionsDialog::OptionsDialog(QWidget *parent, const char *name)
: KDialogBase(IconList, i18n("Configure"), Help|Default|Ok|Apply|Cancel, Ok, parent, name, false, true)
{
//******** Server ************************************
serverTab = addPage(i18n("Server"),i18n("DICT Server Configuration"), BarIcon("network", KIcon::SizeMedium ));
QGridLayout* grid = new QGridLayout(serverTab,10,3,0,spacingHint());
w_server = new KLineEdit(serverTab);
w_server->setText(global->server);
QLabel *l = new QLabel(w_server, i18n("Host&name:"), serverTab);
grid->addWidget(l,0,0);
grid->addMultiCellWidget(w_server,0,0,1,2);
connect( w_server, SIGNAL( textChanged ( const QString & ) ), this, SLOT( slotChanged() ) );
w_port = new KLineEdit(serverTab);
w_port->setValidator(new KIntValidator(0,65536,this));
w_port->setText(QString::number(global->port));
l = new QLabel(w_port, i18n("&Port:"), serverTab);
grid->addWidget(l,1,0);
grid->addWidget(w_port,1,1);
connect( w_port, SIGNAL( textChanged ( const QString & ) ), this, SLOT( slotChanged() ) );
w_idleHold = new KIntSpinBox(0,300,5,0,10,serverTab);
w_idleHold->setSuffix(i18n(" sec"));
w_idleHold->setValue(global->idleHold);
l = new QLabel(w_idleHold, i18n("Hold conn&ection for:"), serverTab);
grid->addWidget(l,2,0);
grid->addWidget(w_idleHold,2,1);
connect( w_idleHold, SIGNAL( valueChanged(int) ), this, SLOT( slotChanged() ) );
w_timeout = new KIntSpinBox(5,600,5,5,10,serverTab);
w_timeout->setSuffix(i18n(" sec"));
w_timeout->setValue(global->timeout);
l = new QLabel(w_timeout, i18n("T&imeout:"), serverTab);
grid->addWidget(l,3,0);
grid->addWidget(w_timeout,3,1);
connect( w_timeout, SIGNAL( valueChanged(int) ), this, SLOT( slotChanged() ) );
w_pipesize = new KIntSpinBox(100,5000,2,2,10,serverTab);
w_pipesize->setSuffix(i18n(" bytes"));
w_pipesize->setValue(global->pipeSize);
l = new QLabel(w_pipesize, i18n("Command &buffer:"), serverTab);
grid->addWidget(l,4,0);
grid->addWidget(w_pipesize,4,1);
connect( w_pipesize, SIGNAL( valueChanged(int) ), this, SLOT( slotChanged() ) );
QStringList encodingNames = KGlobal::charsets()->descriptiveEncodingNames();
int i=0,x=0;
for ( QStringList::Iterator it = encodingNames.begin(); it != encodingNames.end(); ++it ) {
if (KGlobal::charsets()->encodingForName(*it)==global->encoding) {
x = i;
break;
}
i++;
}
w_encoding = new QComboBox(serverTab);
w_encoding->insertStringList(encodingNames);
w_encoding->setCurrentItem(x);
l = new QLabel(w_encoding, i18n("Encod&ing:"), serverTab);
grid->addWidget(l,5,0);
grid->addMultiCellWidget(w_encoding,5,5,1,2);
connect( w_encoding, SIGNAL( activated(int) ), this, SLOT( slotChanged() ) );
w_auth = new QCheckBox(i18n("Server requires a&uthentication"),serverTab);
w_auth->setChecked(global->authEnabled);
grid->addMultiCellWidget(w_auth,6,6,0,2);
connect( w_auth, SIGNAL( toggled(bool) ), this, SLOT( slotChanged() ) );
connect(w_auth,SIGNAL(toggled(bool)),SLOT(slotAuthRequiredToggled(bool)));
w_user = new KLineEdit(serverTab);
w_user->setText(global->user);
l_user = new QLabel(w_user, i18n("U&ser:"),serverTab);
grid->addWidget(l_user,7,0);
grid->addMultiCellWidget(w_user,7,7,1,2);
connect( w_user, SIGNAL( textChanged ( const QString & ) ), this, SLOT( slotChanged() ) );
w_secret = new KLineEdit(serverTab);
w_secret->setEchoMode(QLineEdit::Password);
w_secret->setText(global->secret);
l_secret = new QLabel(w_secret, i18n("Pass&word:"), serverTab);
grid->addWidget(l_secret,8,0);
grid->addMultiCellWidget(w_secret,8,8,1,2);
connect( w_secret, SIGNAL( textChanged ( const QString & ) ), this, SLOT( slotChanged() ) );
slotAuthRequiredToggled( w_auth->isChecked() );
grid->setColStretch(1,2);
grid->setColStretch(2,2);
//************ Appearance ***************************
appTab = addPage(i18n("Appearance"),i18n("Customize Visual Appearance"), BarIcon("appearance", KIcon::SizeMedium ));
QGridLayout *topL=new QGridLayout(appTab, 8, 3, 0, spacingHint());
//color-list
c_List = new DialogListBox(false, appTab);
topL->addMultiCellWidget(c_List,1,3,0,1);
connect(c_List, SIGNAL(selected(QListBoxItem*)),SLOT(slotColItemSelected(QListBoxItem*)));
connect(c_List, SIGNAL(selectionChanged()), SLOT(slotColSelectionChanged()));
//.........这里部分代码省略.........
示例6: rehighlight
//.........这里部分代码省略.........
amp_seq +=txt[i];
if (txt[i]==';') close_amp_seq =true;
}
if (!tag && txt[i] == '&')
{
if (word) close_word=true;
if (spacer) close_spacer=true;
amp_seq = "&";
}
if ((!tag) && (!amp_seq) && (txt[i].isSpace() || txt[i].isPunct()))
{
spacer+=txt[i];
if (word) close_word=true;
}
if ((!tag) && (!amp_seq) && !txt[i].isSpace() && !txt[i].isPunct())
{
word+=txt[i];
if (spacer) close_spacer=true;
}
if (close_amp_seq)
{
if (! current_style.isEmpty())
new_txt+="<span style=\""+current_style+"\">"+amp_seq+"</span>";
else
new_txt+=amp_seq;
amp_seq = QString::null;
}
if (close_spacer)
{
if (! current_style.isEmpty())
new_txt+="<span style=\""+current_style+"\">"+spacer+"</span>";
else
new_txt+=spacer;
spacer =QString::null;
}
if (close_word)
{
if (! current_misspelled_style.isEmpty())
if (m_plugin->checkWord(word))
new_txt+="<span style=\""+current_style+"\">"+word+"</span>";
else
new_txt+="<span style=\""+current_misspelled_style+"\">"+word+"</span>";
else
new_txt+=word;
word =QString::null;
}
if (close_tag)
{
if (tag.find(QRegExp("<span "),0)>-1)
{
current_style = tag;
current_style.replace(QRegExp("^\\<span\\ style=\"(.*)\">"),"\\1");
current_misspelled_style = current_style;
current_misspelled_style.replace(";","|");
current_misspelled_style = "font-family:sim-im-misspelled|"+current_misspelled_style+";color:red";
QStringList items = QStringList::split(";",current_style);
for ( QStringList::Iterator it = items.begin(); it != items.end(); ++it )
{
QString item = *it;
if ( (item.find(QRegExp("^font\\-family\\:")) ==-1) &&
(item.find(QRegExp("^color\\:")) ==-1) )
{
current_misspelled_style+=";"+item;
}
}
tag=QString::null;
}
if (tag.find(QRegExp("</span>"),0)>-1)
{
current_style= QString::null;
current_misspelled_style="font-family:sim-im-misspelled|;color:red";
tag=QString::null;
}
new_txt+=tag;
tag=QString::null;
}
}
// SIM::log(SIM::L_DEBUG, "SpellHighlighter::rehighlight: new_text: %s",new_txt.utf8().data());
// remembering cursor position, changing text, and then returning cursor to it's original position.
int para;
int index;
int sel_paraFrom;
int sel_indexFrom;
int sel_paraTo;
int sel_indexTo;
textEdit()->getSelection (&sel_paraFrom, &sel_indexFrom, &sel_paraTo, &sel_indexTo);
textEdit()->getCursorPosition ( ¶, &index );
textEdit()->setText(new_txt);
textEdit()->setCursorPosition ( para, index );
textEdit()->setSelection (sel_paraFrom, sel_indexFrom, sel_paraTo, sel_indexTo);
m_isInRehighlight = false;
}
}
示例7: if
FilterChain *FilterManager::LoadFilters(QString Filters,
VideoFrameType &inpixfmt,
VideoFrameType &outpixfmt, int &width,
int &height, int &bufsize,
int max_threads)
{
if (Filters.toLower() == "none")
return NULL;
vector<const FilterInfo*> FiltInfoChain;
FilterChain *FiltChain = new FilterChain;
vector<FmtConv*> FmtList;
const FilterInfo *FI;
const FilterInfo *FI2;
QString Opts;
const FilterInfo *Convert = GetFilterInfo("convert");
QStringList OptsList;
QStringList FilterList = Filters.split(",", QString::SkipEmptyParts);
VideoFilter *NewFilt = NULL;
FmtConv *FC, *FC2, *S1, *S2, *S3;
VideoFrameType ifmt;
unsigned int i;
int nbufsize;
int cbufsize;
int postfilt_width = width;
int postfilt_height = height;
for (QStringList::Iterator i = FilterList.begin();
i != FilterList.end(); ++i)
{
QString FiltName = (*i).section('=', 0, 0);
QString FiltOpts = (*i).section('=', 1);
if (FiltName.contains("opengl", Qt::CaseInsensitive) ||
FiltName.contains("vdpau", Qt::CaseInsensitive))
continue;
FI = GetFilterInfo(FiltName);
if (FI)
{
FiltInfoChain.push_back(FI);
OptsList.push_back(FiltOpts);
}
else
{
LOG(VB_GENERAL, LOG_ERR, LOC +
QString("Failed to load filter '%1', "
"no such filter exists").arg(FiltName));
FiltInfoChain.clear();
break;
}
}
ifmt = inpixfmt;
for (i = 0; i < FiltInfoChain.size(); i++)
{
S1 = S2 = S3 = NULL;
FI = FiltInfoChain[i];
if (FiltInfoChain.size() - i == 1)
{
for (FC = FI->formats; FC->in != FMT_NONE; FC++)
{
if (FC->out == outpixfmt && FC->in == ifmt)
{
S1 = FC;
break;
}
if (FC->in == ifmt && !S2)
S2 = FC;
if (FC->out == outpixfmt && !S3)
S3 = FC;
}
}
else
{
FI2 = FiltInfoChain[i+1];
for (FC = FI->formats; FC->in != FMT_NONE; FC++)
{
for (FC2 = FI2->formats; FC2->in != FMT_NONE; FC2++)
{
if (FC->in == ifmt && FC->out == FC2->in)
{
S1 = FC;
break;
}
if (FC->out == FC2->in && !S3)
S3 = FC;
}
if (S1)
break;
if (FC->in == ifmt && !S2)
S2 = FC;
}
}
if (S1)
FC = S1;
else if (S2)
FC = S2;
//.........这里部分代码省略.........
示例8: populateConnections
bool QgsManageConnectionsDialog::populateConnections()
{
// Export mode. Populate connections list from settings
if ( mDialogMode == Export )
{
QSettings settings;
switch ( mConnectionType )
{
case WMS:
settings.beginGroup( "/Qgis/connections-wms" );
break;
case WFS:
settings.beginGroup( "/Qgis/connections-wfs" );
break;
case WCS:
settings.beginGroup( "/Qgis/connections-wcs" );
break;
case PostGIS:
settings.beginGroup( "/PostgreSQL/connections" );
break;
case MSSQL:
settings.beginGroup( "/MSSQL/connections" );
break;
case Oracle:
settings.beginGroup( "/Oracle/connections" );
break;
}
QStringList keys = settings.childGroups();
QStringList::Iterator it = keys.begin();
while ( it != keys.end() )
{
QListWidgetItem *item = new QListWidgetItem();
item->setText( *it );
listConnections->addItem( item );
++it;
}
settings.endGroup();
}
// Import mode. Populate connections list from file
else
{
QFile file( mFileName );
if ( !file.open( QIODevice::ReadOnly | QIODevice::Text ) )
{
QMessageBox::warning( this, tr( "Loading connections" ),
tr( "Cannot read file %1:\n%2." )
.arg( mFileName )
.arg( file.errorString() ) );
return false;
}
QDomDocument doc;
QString errorStr;
int errorLine;
int errorColumn;
if ( !doc.setContent( &file, true, &errorStr, &errorLine, &errorColumn ) )
{
QMessageBox::warning( this, tr( "Loading connections" ),
tr( "Parse error at line %1, column %2:\n%3" )
.arg( errorLine )
.arg( errorColumn )
.arg( errorStr ) );
return false;
}
QDomElement root = doc.documentElement();
switch ( mConnectionType )
{
case WMS:
if ( root.tagName() != "qgsWMSConnections" )
{
QMessageBox::information( this, tr( "Loading connections" ),
tr( "The file is not an WMS connections exchange file." ) );
return false;
}
break;
case WFS:
if ( root.tagName() != "qgsWFSConnections" )
{
QMessageBox::information( this, tr( "Loading connections" ),
tr( "The file is not an WFS connections exchange file." ) );
return false;
}
break;
case WCS:
if ( root.tagName() != "qgsWCSConnections" )
{
QMessageBox::information( this, tr( "Loading connections" ),
tr( "The file is not an WCS connections exchange file." ) );
return false;
}
break;
case PostGIS:
if ( root.tagName() != "qgsPgConnections" )
{
QMessageBox::information( this, tr( "Loading connections" ),
//.........这里部分代码省略.........
示例9: search
void SearchManager::search(const QString &pattern, const KABC::Field::List &fields, Type type)
{
mPattern = pattern;
mFields = fields;
mType = type;
KABC::Addressee::List allContacts;
mContacts.clear();
#if KDE_VERSION >= 319
KABC::AddresseeList list(mAddressBook->allAddressees());
if(!fields.isEmpty())
list.sortByField(fields.first());
allContacts = list;
#else
KABC::AddressBook::ConstIterator abIt(mAddressBook->begin());
const KABC::AddressBook::ConstIterator abEndIt(mAddressBook->end());
for(; abIt != abEndIt; ++abIt)
allContacts.append(*abIt);
#endif
#ifdef KDEPIM_NEW_DISTRLISTS
// Extract distribution lists from allContacts
mDistributionLists.clear();
KABC::Addressee::List::Iterator rmIt(allContacts.begin());
const KABC::Addressee::List::Iterator rmEndIt(allContacts.end());
while(rmIt != rmEndIt)
{
if(KPIM::DistributionList::isDistributionList(*rmIt))
{
mDistributionLists.append(static_cast<KPIM::DistributionList>(*rmIt));
rmIt = allContacts.remove(rmIt);
}
else
++rmIt;
}
typedef KPIM::DistributionList::Entry Entry;
if(!mSelectedDistributionList.isNull())
{
const KPIM::DistributionList dl = KPIM::DistributionList::findByName(mAddressBook, mSelectedDistributionList);
if(!dl.isEmpty())
{
allContacts.clear();
const Entry::List entries = dl.entries(mAddressBook);
const Entry::List::ConstIterator end = entries.end();
for(Entry::List::ConstIterator it = entries.begin(); it != end; ++it)
{
allContacts.append((*it).addressee);
}
}
}
#endif
if(mPattern.isEmpty()) // no pattern, return all
{
mContacts = allContacts;
emit contactsUpdated();
return;
}
const KABC::Field::List fieldList = !mFields.isEmpty() ? mFields : KABC::Field::allFields();
KABC::Addressee::List::ConstIterator it(allContacts.begin());
const KABC::Addressee::List::ConstIterator endIt(allContacts.end());
for(; it != endIt; ++it)
{
#ifdef KDEPIM_NEW_DISTRLISTS
if(KPIM::DistributionList::isDistributionList(*it))
continue;
#endif
bool found = false;
// search over all fields
KABC::Field::List::ConstIterator fieldIt(fieldList.begin());
const KABC::Field::List::ConstIterator fieldEndIt(fieldList.end());
for(; fieldIt != fieldEndIt; ++fieldIt)
{
if(type == StartsWith && (*fieldIt)->value(*it).startsWith(pattern, false))
{
mContacts.append(*it);
found = true;
break;
}
else if(type == EndsWith && (*fieldIt)->value(*it).endsWith(pattern, false))
{
mContacts.append(*it);
found = true;
break;
}
else if(type == Contains && (*fieldIt)->value(*it).find(pattern, 0, false) != -1)
{
mContacts.append(*it);
found = true;
break;
//.........这里部分代码省略.........
示例10: richText
BalloonMsg::BalloonMsg(void *param, const QString &_text, QStringList &btn, QWidget *parent, const QRect *rcParent,
bool bModal, bool bAutoHide, unsigned bwidth, const QString &box_msg, bool *bChecked)
: QDialog(parent, "ballon", bModal,
(bAutoHide ? WType_Popup : WType_TopLevel | WStyle_StaysOnTop)
| WStyle_Customize | WStyle_NoBorderEx | WStyle_Tool | WDestructiveClose | WX11BypassWM)
{
m_param = param;
m_parent = parent;
m_width = bwidth;
m_bAutoHide = bAutoHide;
m_bYes = false;
m_bChecked = bChecked;
bool bTailDown = true;
setPalette(QToolTip::palette());
text = _text;
QFrame *frm = new QFrame(this);
frm->setPalette(palette());
QVBoxLayout *vlay = new QVBoxLayout(frm);
vlay->setMargin(0);
m_check = NULL;
if (!box_msg.isEmpty()){
m_check = new QCheckBox(box_msg, frm);
vlay->addWidget(m_check);
if (m_bChecked)
m_check->setChecked(*m_bChecked);
}
QHBoxLayout *lay = new QHBoxLayout(vlay);
lay->setSpacing(5);
lay->addStretch();
unsigned id = 0;
bool bFirst = true;
for (QStringList::Iterator it = btn.begin(); it != btn.end(); ++it, id++){
BalloonButton *b = new BalloonButton(*it, frm, id);
connect(b, SIGNAL(action(int)), this, SLOT(action(int)));
lay->addWidget(b);
if (bFirst){
b->setDefault(true);
bFirst = false;
}
}
setButtonsPict(this);
lay->addStretch();
int wndWidth = frm->minimumSizeHint().width();
int hButton = frm->minimumSizeHint().height();
int txtWidth = bwidth;
QRect rc;
if (rcParent){
rc = *rcParent;
}else{
QPoint p = parent->mapToGlobal(parent->rect().topLeft());
rc = QRect(p.x(), p.y(), parent->width(), parent->height());
}
if (rc.width() > txtWidth) txtWidth = rc.width();
QSimpleRichText richText(_text, font(), "", QStyleSheet::defaultSheet(), QMimeSourceFactory::defaultFactory(), -1, Qt::blue, false);
richText.setWidth(wndWidth);
richText.adjustSize();
QSize s(richText.widthUsed(), richText.height());
QSize sMin = frm->minimumSizeHint();
if (s.width() < sMin.width())
s.setWidth(sMin.width());
int BALLOON_SHADOW = BALLOON_SHADOW_DEF;
#ifdef WIN32
/* FIXME */
/* if ((GetClassLong(winId(), GCL_STYLE) & CS_DROPSHADOW) && style().inherits("QWindowsXPStyle"))
BALLOON_SHADOW = 0; */
#endif
resize(s.width() + BALLOON_R * 2 + BALLOON_SHADOW,
s.height() + BALLOON_R * 2 + BALLOON_TAIL + BALLOON_SHADOW + hButton + BALLOON_MARGIN);
mask = QBitmap(width(), height());
int w = width() - BALLOON_SHADOW;
int tailX = w / 2;
int posX = rc.left() + rc.width() / 2 + BALLOON_TAIL_WIDTH - tailX;
if (posX <= 0) posX = 1;
QRect rcScreen = screenGeometry();
if (posX + width() >= rcScreen.width())
posX = rcScreen.width() - 1 - width();
int tx = posX + tailX - BALLOON_TAIL_WIDTH;
if (tx < rc.left()) tx = rc.left();
if (tx > rc.left() + rc.width()) tx = rc.left() + rc.width();
tailX = tx + BALLOON_TAIL_WIDTH - posX;
if (tailX < BALLOON_R) tailX = BALLOON_R;
if (tailX > width() - BALLOON_R - BALLOON_TAIL_WIDTH) tailX = width() - BALLOON_R - BALLOON_TAIL_WIDTH;
if (rc.top() <= height() + 2){
bTailDown = false;
move(posX, rc.top() + rc.height() + 1);
}else{
move(posX, rc.top() - height() - 1);
}
int pos = 0;
int h = height() - BALLOON_SHADOW - BALLOON_TAIL;
if (!bTailDown) pos += BALLOON_TAIL;
textRect.setRect(BALLOON_R, pos + BALLOON_R, w - BALLOON_R * 2, h);
frm->resize(s.width(), hButton);
frm->move(BALLOON_R, pos + h - BALLOON_R - hButton);
QPainter p;
p.begin(&mask);
#ifdef WIN32
QColor bg(255, 255, 255);
//.........这里部分代码省略.........
示例11: AddBookConfs
//.........这里部分代码省略.........
}
}
else if (text[i].indexOf("WeaveLevel") != -1)
{
QString wl = text[i].mid(text[i].size()-1);
book->WeaveLevel = wl;
}
else if (text[i].indexOf("AddSource") != -1)
{
if ( book->mWeavedSources.size() == 0)
{
//Add the book it self as the first source
weavedSource base;
base.FilePath = book->getPath();
base.Zoom = 0;
base.id = 0;
base.show = true;
book->mWeavedSources.append(base);
}
QStringList p = text[i].mid(10).split(":");
if (p.size() > 1)
{
weavedSource src;
src.FilePath = BOOKPATH + (BOOKPATH.endsWith("/") ? "" : "/") + p[0];
src.Title = p[1];
src.Zoom = 0;
src.id = book->mWeavedSources.size();
src.show = false;
book->mWeavedSources.append(src);
}
else
{
qDebug() << "Invalid weaved source in:" << book->getPath();
qDebug() << "Bad path:" << text[i];
}
}
// code from yoch to add new commentaries by id
else if (text[i].indexOf("MixedSources") != -1)
{
QString srcLst = text[i].mid(12);
srcLst = srcLst.mid(srcLst.indexOf("(") + 1);
srcLst = srcLst.mid(0, srcLst.indexOf(")"));
QList<int> wsrc;
QStringList srcId = srcLst.split(',', QString::SkipEmptyParts);
for (QStringList::const_iterator it = srcId.begin(); it != srcId.end(); ++it)
{
int id;
if(ToNum(*it, &id))
{
weavedSource src;
src.show = false;
src.id = id;
// mWeavedSources.push_back(src);
book->mWeavedSources.append(src);
}
}
}
else if (text[i].indexOf("CosmeticsType") != -1)
{
book->setCosmetics(text[i]);
}
else if (text[i].indexOf("UniqueId") != -1)
{
int id;
if(ToNum(text[i].mid(9), &id) == true)
book->setUniqueId(id);
}
else if (text[i].indexOf("Nikud") != -1)
{
book->hasNikud=true;
}
else if (text[i].indexOf("Teamim") != -1)
{
book->hasTeamim=true;
}
else if (text[i].indexOf("Kukayta") != -1)
{
book->isEncrypted=true;
}
}
}
示例12: qurl
MythSocket *RemoteFile::openSocket(bool control)
{
QUrl qurl(path);
QString dir;
QString host = qurl.host();
int port = qurl.port();
dir = qurl.path();
if (qurl.hasQuery())
dir += "?" + QUrl::fromPercentEncoding(qurl.encodedQuery());
if (qurl.hasFragment())
dir += "#" + qurl.fragment();
QString sgroup = qurl.userName();
MythSocket *lsock = new MythSocket();
QString stype = (control) ? "control socket" : "file data socket";
QString loc_err = QString("RemoteFile::openSocket(%1), Error: ").arg(stype);
if (port <= 0)
{
port = GetMythDB()->GetSettingOnHost("BackendServerPort", host).toInt();
// if we still have no port use the default
if (port <= 0)
port = 6543;
}
if (!lsock->connect(host, port))
{
VERBOSE(VB_IMPORTANT, loc_err +
QString("\n\t\t\tCould not connect to server %1:%2")
.arg(host).arg(port));
lsock->DownRef();
return NULL;
}
QString hostname = GetMythDB()->GetHostName();
QStringList strlist;
if (control)
{
strlist.append( QString("ANN Playback %1 %2").arg(hostname).arg(false) );
lsock->writeStringList(strlist);
if (!lsock->readStringList(strlist, true))
{
VERBOSE(VB_IMPORTANT, loc_err +
QString("\n\t\t\tCould not read string list from server "
"%1:%2").arg(host).arg(port));
lsock->DownRef();
return NULL;
}
}
else
{
strlist.push_back(QString("ANN FileTransfer %1 %2 %3 %4")
.arg(hostname).arg(writemode)
.arg(usereadahead).arg(timeout_ms));
strlist << QString("%1").arg(dir);
strlist << sgroup;
QStringList::const_iterator it = possibleauxfiles.begin();
for (; it != possibleauxfiles.end(); ++it)
strlist << *it;
if (!lsock->writeStringList(strlist) ||
!lsock->readStringList(strlist, true))
{
VERBOSE(VB_IMPORTANT, loc_err +
QString("Did not get proper response from %1:%2")
.arg(host).arg(port));
strlist.clear();
strlist.push_back("ERROR");
strlist.push_back("invalid response");
}
if (strlist.size() >= 4)
{
it = strlist.begin(); ++it;
recordernum = (*it).toInt(); ++it;
filesize = decodeLongLong(strlist, it);
for (; it != strlist.end(); ++it)
auxfiles << *it;
}
else if (0 < strlist.size() && strlist.size() < 4 &&
strlist[0] != "ERROR")
{
VERBOSE(VB_IMPORTANT, loc_err +
QString("Did not get proper response from %1:%2")
.arg(host).arg(port));
strlist.clear();
strlist.push_back("ERROR");
strlist.push_back("invalid response");
}
}
//.........这里部分代码省略.........
示例13: process
void MigrateDialog::process()
{
unsigned size = 0;
for (list<QCheckBox*>::iterator it = m_boxes.begin(); it != m_boxes.end(); ++it){
if (!(*it)->isChecked())
continue;
QString path = user_file((*it)->text());
path += '/';
icqConf.close();
clientsConf.close();
contactsConf.close();
icqConf.setName(path + "icq.conf");
clientsConf.setName(path + "clients.conf");
contactsConf.setName(path + "contacts.conf");
lblStatus->setText(path + "icq.conf");
if (!icqConf.open(IO_ReadOnly)){
error(i18n("Can't open %1") .arg(path + "icq.conf"));
return;
}
if (!clientsConf.open(IO_WriteOnly | IO_Truncate)){
error(i18n("Can't open %1") .arg(path + "clients.conf"));
return;
}
if (!contactsConf.open(IO_WriteOnly | IO_Truncate)){
error(i18n("Can't open %1") .arg(path + "contacts.conf"));
return;
}
m_uin = 0;
m_passwd = "";
m_state = 0;
m_grpId = 0;
m_contactId = 0;
Buffer cfg;
cfg.init(icqConf.size());
icqConf.readBlock(cfg.data(), icqConf.size());
for (;;){
QCString section = cfg.getSection();
if (section.isEmpty())
break;
m_state = 3;
if (section == "Group")
m_state = 1;
if (section == "User")
m_state = 2;
if (!m_bProcess)
return;
for (;;){
QCString l = cfg.getLine();
if (l.isEmpty())
break;
QCString line = l;
QCString name = getToken(line, '=');
if (name == "UIN")
m_uin = line.toUInt();
if (name == "EncryptPassword")
m_passwd = line;
if (name == "Name")
m_name = line;
if (name == "Alias")
m_name = line;
}
flush();
barCnv->setProgress(cfg.readPos());
qApp->processEvents();
}
icqConf.close();
clientsConf.close();
contactsConf.close();
m_state = 3;
size += icqConf.size();
if (!m_bProcess)
return;
barCnv->setProgress(size);
qApp->processEvents();
QString h_path = path;
#ifdef WIN32
h_path += "history\\";
#else
h_path += "history/";
#endif
QDir history(h_path);
QStringList l = history.entryList("*.history", QDir::Files);
for (QStringList::Iterator it = l.begin(); it != l.end(); ++it){
hFrom.close();
hTo.close();
hFrom.setName(h_path + (*it));
lblStatus->setText(h_path + (*it));
hTo.setName(h_path + QString(m_owner) + '.' + (*it).left((*it).find('.')));
if (!hFrom.open(IO_ReadOnly)){
error(i18n("Can't open %1") .arg(hFrom.name()));
return;
}
if (!hTo.open(IO_WriteOnly | IO_Truncate)){
error(i18n("Can't open %1") .arg(hTo.name()));
return;
}
cfg.init(hFrom.size());
hFrom.readBlock(cfg.data(), hFrom.size());
for (;;){
QCString section = cfg.getSection();
//.........这里部分代码省略.........
示例14: readPropertyEntry
QVariant KConfigBase::readPropertyEntry(const char *pKey, const QVariant &aDefault) const
{
if(!hasKey(pKey))
return aDefault;
QVariant tmp = aDefault;
switch(aDefault.type())
{
case QVariant::Invalid:
return QVariant();
case QVariant::String:
return QVariant(readEntry(pKey, aDefault.toString()));
case QVariant::StringList:
return QVariant(readListEntry(pKey));
case QVariant::List:
{
QStringList strList = readListEntry(pKey);
QStringList::ConstIterator it = strList.begin();
QStringList::ConstIterator end = strList.end();
QValueList< QVariant > list;
for(; it != end; ++it)
{
tmp = *it;
list.append(tmp);
}
return QVariant(list);
}
case QVariant::Font:
return QVariant(readFontEntry(pKey, &tmp.asFont()));
case QVariant::Point:
return QVariant(readPointEntry(pKey, &tmp.asPoint()));
case QVariant::Rect:
return QVariant(readRectEntry(pKey, &tmp.asRect()));
case QVariant::Size:
return QVariant(readSizeEntry(pKey, &tmp.asSize()));
case QVariant::Color:
return QVariant(readColorEntry(pKey, &tmp.asColor()));
case QVariant::Int:
return QVariant(readNumEntry(pKey, aDefault.toInt()));
case QVariant::UInt:
return QVariant(readUnsignedNumEntry(pKey, aDefault.toUInt()));
case QVariant::LongLong:
return QVariant(readNum64Entry(pKey, aDefault.toLongLong()));
case QVariant::ULongLong:
return QVariant(readUnsignedNum64Entry(pKey, aDefault.toULongLong()));
case QVariant::Bool:
return QVariant(readBoolEntry(pKey, aDefault.toBool()), 0);
case QVariant::Double:
return QVariant(readDoubleNumEntry(pKey, aDefault.toDouble()));
case QVariant::DateTime:
return QVariant(readDateTimeEntry(pKey, &tmp.asDateTime()));
case QVariant::Date:
return QVariant(readDateTimeEntry(pKey, &tmp.asDateTime()).date());
case QVariant::Pixmap:
case QVariant::Image:
case QVariant::Brush:
case QVariant::Palette:
case QVariant::ColorGroup:
case QVariant::Map:
case QVariant::IconSet:
case QVariant::CString:
case QVariant::PointArray:
case QVariant::Region:
case QVariant::Bitmap:
case QVariant::Cursor:
case QVariant::SizePolicy:
case QVariant::Time:
case QVariant::ByteArray:
case QVariant::BitArray:
case QVariant::KeySequence:
case QVariant::Pen:
break;
}
Q_ASSERT(0);
return QVariant();
}
示例15: getLang
QStringList ScribusQApp::getLang(QString lang)
{
QStringList langs;
// read the locales
if (!lang.isEmpty())
langs.push_back(lang);
//add in user preferences lang, only overridden by lang command line option
QString Pff = QDir::convertSeparators(ScPaths::getApplicationDataDir());
QFileInfo Pffi = QFileInfo(Pff);
if (Pffi.exists())
{
QString PrefsPfad;
if (Pffi.isDir())
PrefsPfad = Pff;
else
PrefsPfad = QDir::homePath();
QString prefsXMLFile=QDir::convertSeparators(PrefsPfad + "/prefs135.xml");
QFileInfo infoPrefsFile(prefsXMLFile);
if (infoPrefsFile.exists())
{
PrefsFile* prefsFile = new PrefsFile(prefsXMLFile);
if (prefsFile) {
PrefsContext* userprefsContext = prefsFile->getContext("user_preferences");
if (userprefsContext) {
QString prefslang = userprefsContext->get("gui_language","");
if (!prefslang.isEmpty())
langs.push_back(prefslang);
}
}
delete prefsFile;
}
}
if (!(lang = ::getenv("LC_ALL")).isEmpty())
langs.push_back(lang);
if (!(lang = ::getenv("LC_MESSAGES")).isEmpty())
langs.push_back(lang);
if (!(lang = ::getenv("LANG")).isEmpty())
langs.push_back(lang);
#if defined(_WIN32)
wchar_t out[256];
QString language, sublanguage;
LCID lcIdo = GetUserDefaultLCID();
WORD sortId = SORTIDFROMLCID(lcIdo);
LANGID langId = GetUserDefaultUILanguage();
LCID lcIdn = MAKELCID(langId, sortId);
if ( GetLocaleInfoW(lcIdn, LOCALE_SISO639LANGNAME , out, 255) )
{
language = QString::fromUtf16( (ushort*)out );
if ( GetLocaleInfoW(lcIdn, LOCALE_SISO3166CTRYNAME, out, 255) )
{
sublanguage = QString::fromUtf16( (ushort*)out ).toLower();
lang = language;
if ( sublanguage != language && !sublanguage.isEmpty() )
lang += "_" + sublanguage.toUpper();
langs.push_back(lang);
}
}
#endif
langs.push_back(QString(QLocale::system().name()));
// remove duplicate entries...
QStringList::Iterator it = langs.end();
while (it != langs.begin())
{
--it;
if (langs.count(*it) > 1)
it = langs.erase(it);
}
return langs;
}