本文整理汇总了C++中QStringList::length方法的典型用法代码示例。如果您正苦于以下问题:C++ QStringList::length方法的具体用法?C++ QStringList::length怎么用?C++ QStringList::length使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QStringList
的用法示例。
在下文中一共展示了QStringList::length方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: onTextMessageReceived
void Client::onTextMessageReceived(QString message)
{
ui->resultTextBox->setText(message);
/*Process server's response
* first character represent the user's action
* second server's result of action */
QStringList substrings = message.split("|") ;
if(substrings.length() == 1)
{
QMessageBox::information(this, tr("Error"), tr("Error occurs while trying to proccess request"));
return;
}
switch(message[0].digitValue())
{
case authorization:
{
QString result = substrings.value(substrings.length()- 2 );
if(result == SUCCESS)
{
ui->resultTextBox->setText("Authorization succeed");
//check user's type
ui->authorization->setVisible(false);
ui->mainForm->setVisible(true);
}
else
{
QMessageBox::information(this, tr("Error"), tr("Authorization failed. Please check login and password"));
return;
}
QString userRigths = substrings.value(substrings.length()- 2 );
if(userRigths == QString::number(Admin))
{
ui->adminFrame->setVisible(true);
ui->advancUserFrame->setVisible(true);
}
else if(userRigths == QString::number(AdvancedUser))
{
ui->advancUserFrame->setVisible(true);
}
}
break;
case seeHistory:
{
QString result = substrings.value(substrings.length()- 2 );
if(result == SUCCESS)
{
QString result = substrings.value(substrings.length()- 1 );
result.replace("*", " ");
ui->userHistory->setText(result);
}
else
{
QMessageBox::information(this, tr("Error"), tr("Cann't load history. Please contact to developers to fix the problem."));
}
}
break;
case sendVideo:
{
ui->resultTextBox->setText(message);
QString result = substrings.value(substrings.length()- 1 );
if(result == SUCCESS)
{
on_SendVideo_clicked();
}
else
{
QMessageBox::information(this, tr("Error"), tr("Server cann't receive video/picture at the moment"));
}
}
break;
case addPicture:
{
ui->resultTextBox->setText(message);
QString result = substrings.value(substrings.length()- 1 );
if(result == SUCCESS)
{
on_addPictures_clicked();
}
else
{
QMessageBox::information(this, tr("Error"), tr("Server cann't receive video/picture at the moment"));
}
}
break;
case addUser:
{
QString result = substrings.value(substrings.length()- 1 );
if(result == SUCCESS)
//.........这里部分代码省略.........
示例2: qt_win_CID_get_open_file_names
static QStringList qt_win_CID_get_open_file_names(const QFileDialogArgs &args,
QString *initialDirectory,
const QStringList &filterList,
QString *selectedFilter,
int selectedFilterIndex)
{
QStringList result;
QDialog modal_widget;
modal_widget.setAttribute(Qt::WA_NoChildEventsForParent, true);
modal_widget.setParent(args.parent, Qt::Window);
QApplicationPrivate::enterModal(&modal_widget);
// Multiple selection is allowed only in IFileOpenDialog.
IFileOpenDialog *pfd = 0;
HRESULT hr = CoCreateInstance(QT_CLSID_FileOpenDialog, NULL, CLSCTX_INPROC_SERVER, QT_IID_IFileOpenDialog,
reinterpret_cast<void**>(&pfd));
if (SUCCEEDED(hr)) {
qt_win_set_IFileDialogOptions(pfd, args.selection,
args.directory, args.caption,
filterList, QFileDialog::ExistingFiles,
args.options);
// Set the currently selected filter (one-based index).
hr = pfd->SetFileTypeIndex(selectedFilterIndex+1);
QWidget *parentWindow = args.parent;
if (parentWindow)
parentWindow = parentWindow->window();
else
parentWindow = QApplication::activeWindow();
// Show the file dialog.
hr = pfd->Show(parentWindow ? parentWindow->winId() : 0);
if (SUCCEEDED(hr)) {
// Retrieve the results.
IShellItemArray *psiaResults;
hr = pfd->GetResults(&psiaResults);
if (SUCCEEDED(hr)) {
DWORD numItems = 0;
psiaResults->GetCount(&numItems);
for (DWORD i = 0; i<numItems; i++) {
IShellItem *psi = 0;
hr = psiaResults->GetItemAt(i, &psi);
if (SUCCEEDED(hr)) {
// Retrieve the file name from shell item.
wchar_t *pszPath;
hr = psi->GetDisplayName(SIGDN_FILESYSPATH, &pszPath);
if (SUCCEEDED(hr)) {
QString fileName = QString::fromWCharArray(pszPath);
result.append(fileName);
CoTaskMemFree(pszPath);
}
psi->Release(); // Free the current item.
}
}
psiaResults->Release(); // Free the array of items.
}
}
}
QApplicationPrivate::leaveModal(&modal_widget);
qt_win_eatMouseMove();
if (!result.isEmpty()) {
// Retrieve the current folder name.
IShellItem *psi = 0;
hr = pfd->GetFolder(&psi);
if (SUCCEEDED(hr)) {
wchar_t *pszPath;
hr = psi->GetDisplayName(SIGDN_FILESYSPATH, &pszPath);
if (SUCCEEDED(hr)) {
*initialDirectory = QString::fromWCharArray(pszPath);
CoTaskMemFree(pszPath);
}
psi->Release();
}
// Retrieve the currently selected filter.
if (selectedFilter) {
quint32 filetype = 0;
hr = pfd->GetFileTypeIndex(&filetype);
if (SUCCEEDED(hr) && filetype && filetype <= (quint32)filterList.length()) {
// This is a one-based index, not zero-based.
*selectedFilter = filterList[filetype-1];
}
}
}
if (pfd)
pfd->Release();
return result;
}
示例3: on_gameBoard_customContextMenuRequested
void MainWindow::on_gameBoard_customContextMenuRequested(const QPoint &pos)
{
QMenu submenu, *dragons,*worms, *markers;
QPoint item = ui->gameBoard->mapToGlobal(pos);
QString vertex;
submenu.addAction("Clear All Markers");
markers = submenu.addMenu("Clear Marker");
QList<QString> marker_list = ui->gameBoard->markers.keys();
for(int i=0; i<marker_list.length(); i++){
markers->addAction(QString("Marker:%1").arg(marker_list.at(i)));
}
dragons = submenu.addMenu("Dragons");
dragons->addAction("All Dragons");
dragons->addAction("Black Dragons");
dragons->addAction("White Dragons");
submenu.addAction("Move Reasons");
worms = submenu.addMenu("Worms");
worms->addAction("All Worms");
worms->addAction("Black Worms");
worms->addAction("White Worms");
QAction* rightClickItem = submenu.exec(item);
if(!rightClickItem) return;
qDebug() << "context menu item "<< rightClickItem->text()<< " clicked";
vertex = ui->gameBoard->posToAlphaNum(ui->gameBoard->mapToScene(pos));
rightClickItem->dumpObjectInfo();
if( rightClickItem->text() == "Move Reasons"){
QStringList reasons = gtp.move_reasons(vertex);
if(reasons.length()>0) ui->textHistory->appendPlainText(QString("%1 Move Reasons").arg(vertex));
for(int i=0; i<reasons.length(); i++){
ui->textHistory->appendPlainText(reasons.at(i));
}
}
else if( rightClickItem->text() == "All Dragons"){
ui->gameBoard->dragonStones( gtp.dragon_stones());
}
else if( rightClickItem->text() == "Black Dragons"){
ui->gameBoard->dragonStones( gtp.dragon_stones("black"));
}
else if( rightClickItem->text() == "White Dragons"){
ui->gameBoard->dragonStones( gtp.dragon_stones("white"));
}
else if( rightClickItem->text() == "Clear All Markers"){
ui->gameBoard->clearAllMarkers();
}
else if( rightClickItem->text().contains("Marker:")){
QStringList sl = rightClickItem->text().split(":",QString::SkipEmptyParts);
ui->gameBoard->removeMarkers(sl.at(1));
}
else if( rightClickItem->text() == "All Worms"){
ui->gameBoard->wormStones( gtp.worm_stones());
}
else if( rightClickItem->text() == "Black Worms"){
ui->gameBoard->wormStones( gtp.worm_stones("black"));
}
else if( rightClickItem->text() == "White Worms"){
ui->gameBoard->wormStones( gtp.worm_stones("white"));
}
}
示例4: fetchMonster
QStringList Manager::fetchMonster(const int &id, const int &level) {
QTextStream cout(stdout); // set cout for console debug
QStringList array;
QString idString;
if ( id < 10 )
idString = "00" + QString::number(id);
else if ( id < 100)
idString = "0" + QString::number(id);
else
idString = QString::number(id);
array.append(QString::number(id));
array.append(idString);
array.append(QString::number(level));
cout << QDir::setCurrent("/usr/share/harbour-pocketmonsters/qml/pages/xmls/") << endl;
QFile pokedex( idString + ".xml");
cout << pokedex.open(QIODevice::ReadOnly) << endl;
QXmlStreamReader xml(&pokedex);
while (!xml.atEnd() && !xml.hasError()) {
xml.readNext();
if ( xml.isStartElement() && xml.name().toString() == "index" && xml.attributes().value("id").toString() == idString) {
xml.readNext();
} else if ( ( xml.name().toString() == "moveset" ) ) {
break;
}
if ( xml.isStartElement() ) {
QString string = xml.readElementText();
array.append(string);
}
}
if (xml.hasError())
{
cout << "XML error: " << xml.errorString() << "line:column - " << xml.lineNumber() << ":" << xml.columnNumber() << endl;
}
else if (xml.atEnd())
{
cout << "Reached end, done" << endl;
}
QVector <int> levelsArray;
QVector <int> idsArray;
while (!xml.atEnd() && !xml.hasError()) {
xml.readNext();
QXmlStreamAttributes attributes = xml.attributes();
if ( xml.isStartElement() && xml.name().toString() == "move") {
levelsArray.append(attributes.value("level").toInt());
idsArray.append(attributes.value("id").toInt());
}
}
if (xml.hasError())
{
cout << "XML error: " << xml.errorString() << "line:column - " << xml.lineNumber() << ":" << xml.columnNumber() << endl;
}
else if (xml.atEnd())
{
cout << "Reached end, done" << endl;
}
if ( levelsArray.length() < 5 ) {
if ( level >= levelsArray[0])
array.append(QString::number(idsArray[0]));
if ( level >= levelsArray[1])
array.append(QString::number(idsArray[1]));
if ( level >= levelsArray[2])
array.append(QString::number(idsArray[2]));
if ( level >= levelsArray[3])
array.append(QString::number(idsArray[3]));
}
while ( array.length() < 23 )
array.append(QString::number(0));
for ( int i = 0; i < array.length(); i++) {
cout << array[i] << ";";
}
cout << endl;
fetchMonsterDone();
return array;
}
示例5: askForChoice
QString TrustAI::askForChoice(const QString &, const QString &choice, const QVariant &)
{
QStringList choices = choice.split("+");
return choices.at(qrand() % choices.length());
}
示例6: parseCmd
QUrl parseCmd(int argc, char* argv[], artemis::Options& options)
{
std::string usage = "\n"
"artemis [-i <n>][-c <URL>][-t <URL>][-r][-u][-p <path>] <url>\n"
"\n"
"Test the JavaScript application found at <url>.\n"
"\n"
"-i <n> : Iterations - Artemis will generate and execute <n>\n"
" sequences of events. Default is 4.\n"
"\n"
"-f #<formElementId>=<formElementValue> : Set the form element with ID #<formElementId> to the value <formElementValue> at each iteration. Remember to write the # for the element ID.\n"
"\n"
"-F #<formElementId>=true|false : As with -f but for boolean value injections (e.g. into check boxes).\n"
"\n"
"-c <KEY=VALUE> : Set a cookie value for the global domain.\n"
"\n"
"-t <URL>:<PORT> : Set proxy\n"
"\n"
"-s : Enable DOM state checking\n"
"\n"
"-e : Negate the last solved PC printed to stdout (used for testing)\n"
"\n"
"--debug-concolic: Run the concolic subsystem on the last iteration and output results.\n"
"\n"
"--major-mode <mode>:\n"
" The major-mode specifies the top-level test algorithm used by Artemis.\n"
"\n"
" artemis - (default) the top-level test algorithm described in the ICSE'11 Artemis paper\n"
" manual - open a browser window for manual testing of web applications\n"
" concolic - perform an automated concolic analysis of form validation code\n"
"\n"
"--strategy-form-input-generation <strategy>:\n"
" Select form input generation strategy.\n"
"\n"
" javascript-constants - select form inputs based in observed JavaScript constants\n"
" random - (default) random inputs\n"
"\n"
"\n"
"--strategy-target-selection <strategy>:\n"
" Select target selection strategy.\n"
"\n"
" concolic - use concolic testing to select a target\n"
" jquery - use a model to support instrumented jQuery\n"
" legacy - (default) set the target to the element on which the event-handler is registered\n"
"\n"
"--strategy-priority <strategy>:\n"
" Select priority strategy.\n"
"\n"
" constant - (default) assign the same priority to new configurations\n"
" random - assign a random priority to new configurations\n"
" coverage - assign higher priority to configurations with low coverage\n"
" readwrite - use read/write-sets for JavaScript properties to assign priorities\n"
" all - a combination of the constant, the coverage and the readwrite strategy, as defined in the Artemis article\n"
"\n"
"--strategy-event-generation <strategy>:\n"
" Select event-sequence generation strategy.\n"
"\n"
" random-incremental - (default) permutates the latest event or extends event sequence with one new event\n"
" fasttrack - generate one large event-sequence of all known events (forces -i 2) \n"
"\n"
"--event-visibility-check <true|false>:\n"
" Enable or disable event visibility checks, which filters out any event which is not attached to a user visible element. Default: (false).\n"
"\n"
"--input-strategy-same-length <num>:\n"
" Set the number of permutations of an executed sequence (of same length) generated by the input generator.\n"
"\n"
"--load-new-urls <true|false>:\n"
" Whether URLs should be loaded (e.g. after clicking a link) in major-mode 'artemis'. Default: false.\n"
"\n"
"--coverage-report <report-type>:\n"
" Select code coverage report formatting.\n"
"\n"
" html - HTML report dumped in the folder you run Artemis from\n"
" stdout - text report is printed to std out\n"
" none - (default) code coverage report is omitted\n"
"\n"
"--coverage-report-ignore <URL>:\n"
" Exclude the given URL from the coverage report and coverage statistics.\n"
"\n"
"--path-trace-report <report-type>:\n"
" Output a report of the execution path through the covered JavaScript.\n"
"\n"
" all - All executed paths are displayed\n"
" click - Only paths beginning with a click event are displayed\n"
" none - (default) Path trace report is omitted\n"
" html - HTML trace report is generated in the folder you run Artemis from\n"
"\n"
"--concolic-button <XPath>:\n"
" Use the given XPath to locate the button to be used in concolic mode.\n"
" If not supplied, the concolic mode will use its built-in button finding, which is not robust.\n"
"\n"
"--concolic-tree-output <trees>:\n"
" none - Do not output any graphs.\n"
" final (default) - Generate a graph of the final tree after analysis.\n"
" final-overview - Like final but also includes a simplified overview graph.\n"
" all - Generate a graph of the tree at every iteration.\n"
" all-overview - Like all but also includes simplified overview graphs.\n"
"\n"
"--concolic-search-procedure <search>\n"
//.........这里部分代码省略.........
示例7: playerTrackStarted
void PlayingContextWidget::playerTrackStarted(const QStringList & trackInfo)
{
QString filename = trackInfo[Ororok::TrackFieldPath];
Ororok::MusicTrackMetadata * md = Ororok::getMusicFileMetadata(filename);
if (md == 0) {
p->webview->setHtml(p->pageTemplate.arg(tr("Unable to detect file metadata")));
return;
}
QStringList htmlRows;
// order of data fields as follows
// {title} by {author}
// on {album-name} / #{track-num}
// Album date: {year}
// Genre: {genre}
// Bitrate: {bitrate}
// Lyrics by: {lyrics}
// Composed by: {composer}
// title
htmlRows << tr("<div><!--song title--><strong>%1</strong> "
"by <!--artist name--><strong>%2</strong></div>")
.arg(md->title)
.arg(md->artist);
// album
QString albumName = tr("<em>Unknown album</em>");
if (!md->album.isEmpty()) {
albumName = md->album;
}
QString trackNum;
if (md->track > 0) {
trackNum = tr(" / #<strong>%1</strong>")
.arg(md->track);
}
htmlRows << tr("<div>on <strong>%1</strong>%2</div>")
.arg(albumName)
.arg(trackNum);
// cover
QDir albumDir = QFileInfo(filename).absoluteDir();
QStringList coverFilter;
coverFilter << QString("cover.jpg") << QString("cover.png") << QString("cover.gif") << QString("cover.bmp");
QStringList covers = albumDir.entryList(coverFilter);
if (covers.length() > 0) {
QString cover = covers.at(0);
htmlRows << QString("<div class=\"cover\"><img border=\"1\" width=\"100%\" src=\"file://%1\"></div>")
.arg(albumDir.absoluteFilePath(cover));
}
// album date
if (md->year > 0) {
htmlRows << tr("<div>Album year: <strong>%1</strong></div>")
.arg(md->year);
}
// genre
if (!md->genre.isEmpty()) {
htmlRows << tr("<div>Genre: <strong>%1</strong></div>")
.arg(md->genre);
}
// bitrate
htmlRows << tr("<div>Bitrate: <strong>%1</strong> kbps</div>")
.arg(md->bitrate);
if (!md->composer.isEmpty()) {
htmlRows << tr("<div>Composed by <strong>%1</strong></div>")
.arg(md->composer);
}
if (!md->lyricsAuthor.isEmpty()) {
htmlRows << tr("<div>Lyrics by <strong>%1</strong></div>")
.arg(md->lyricsAuthor);
}
QString html = p->pageTemplate.arg(htmlRows.join("\n"));
p->webview->setHtml(html);
}
示例8: createGUIfromTheme
void PCDMgui::createGUIfromTheme(){
QString style;
QString tmpIcon; //used for checking image files before loading them
QWidget *leftscreen = 0;
for(int i=0; i<screens.length(); i++){
if(screens[i]->x()==0){
leftscreen = screens[i];
}
}
//Define the default icon size
int perc = qRound(leftscreen->height()*0.035); //use 3.5% of the screen height
defIconSize = QSize(perc,perc);
//Set the background image
if(DEBUG_MODE){ qDebug() << "Setting Background Image"; }
if( currentTheme->itemIsEnabled("background") ){
tmpIcon = currentTheme->itemIcon("background");
if( tmpIcon.isEmpty() || !QFile::exists(tmpIcon) ){ tmpIcon = ":/images/backgroundimage.jpg"; }
//use "border-image" instead of "background-image" to stretch rather than tile the image
QString bgstyle = "QWidget#BGSCREEN{border-image: url(BGIMAGE) stretch;}";
bgstyle.replace("BGIMAGE", tmpIcon);
style.append(bgstyle);
}
//Set the application style sheet
style.append(" "+ currentTheme->styleSheet() );
this->setStyleSheet( style.simplified() );
//Check for whether the desktop switcher is on the toolbar or not
simpleDESwitcher = (currentTheme->itemValue("desktop") == "simple");
//get the default translation directory
if(DEBUG_MODE){ qDebug() << "Load Translations"; }
translationDir = "/usr/local/share/pcbsd/i18n/";
//Fill the translator
m_translator = new QTranslator();
//Create the Toolbar
toolbar = new QToolBar();
//Add the Toolbar to the window
if(DEBUG_MODE){ qDebug() << "Create Toolbar"; }
//use the theme location
QString tarea = currentTheme->itemValue("toolbar");
if(tarea == "left"){
this->addToolBar( Qt::LeftToolBarArea, toolbar );
}else if( tarea=="top"){
this->addToolBar( Qt::TopToolBarArea, toolbar );
toolbar->setFixedWidth(leftscreen->width());
}else if(tarea=="right"){
this->addToolBar( Qt::RightToolBarArea, toolbar );
}else{ //bottom is default
this->addToolBar( Qt::BottomToolBarArea, toolbar );
toolbar->setFixedWidth(leftscreen->width());
}
//Set toolbar flags
toolbar->setVisible(true);
toolbar->setMovable(false);
toolbar->setFloatable(false);
toolbar->setContextMenuPolicy(Qt::PreventContextMenu); //make sure no right-click menu
//Set the default style and icon sizes
QString tstyle = currentTheme->itemIcon("toolbar").toLower(); //use the theme style
if(tstyle=="textonly"){ toolbar->setToolButtonStyle(Qt::ToolButtonTextOnly); }
else if(tstyle=="textbesideicon"){ toolbar->setToolButtonStyle(Qt::ToolButtonTextBesideIcon); }
else if(tstyle=="textundericon"){ toolbar->setToolButtonStyle(Qt::ToolButtonTextUnderIcon); }
else{ toolbar->setToolButtonStyle(Qt::ToolButtonIconOnly); } //default to icon only
QSize tmpsz = currentTheme->itemIconSize("toolbar");
if(!tmpsz.isValid()){ tmpsz = defIconSize; }
toolbar->setIconSize( tmpsz ); //use theme size
toolbar->setFocusPolicy( Qt::NoFocus );
//Populate the Toolbar with items (starts at leftmost/topmost)
//----Virtual Keyboard
if(currentTheme->itemIsEnabled("vkeyboard") ){
if(DEBUG_MODE){ qDebug() << " - Create Virtual Keyboard Button"; }
tmpIcon = currentTheme->itemIcon("vkeyboard");
if(!QFile::exists(tmpIcon) || tmpIcon.isEmpty() ){ tmpIcon=":/images/input-keyboard.png"; }
virtkeyboardButton = new QAction( QIcon(tmpIcon),tr("Virtual Keyboard"),this );
toolbar->addAction(virtkeyboardButton);
connect( virtkeyboardButton, SIGNAL(triggered()), this, SLOT(slotPushVirtKeyboard()) );
}else{
virtkeyboardButton = new QAction(this);
}
//----Locale Switcher
if(DEBUG_MODE){ qDebug() << " - Create Locale Button"; }
tmpIcon = currentTheme->itemIcon("locale");
if(!QFile::exists(tmpIcon) || tmpIcon.isEmpty() ){ tmpIcon=":/images/language.png"; }
localeButton = new QAction( QIcon(tmpIcon),tr("Locale"),this );
toolbar->addAction(localeButton);
connect( localeButton, SIGNAL(triggered()), this, SLOT(slotChangeLocale()) );
//----Keyboard Layout Switcher
if(DEBUG_MODE){ qDebug() << " - Create Keyboard Layout Button"; }
tmpIcon = currentTheme->itemIcon("keyboard");
if(!QFile::exists(tmpIcon) || tmpIcon.isEmpty() ){ tmpIcon=":/images/keyboard.png"; }
keyboardButton = new QAction( QIcon(tmpIcon),tr("Keyboard Layout"),this );
toolbar->addAction(keyboardButton);
connect( keyboardButton, SIGNAL(triggered()), this, SLOT(slotChangeKeyboardLayout()) );
//----Add a spacer
QWidget* spacer = new QWidget();
spacer->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Expanding);
toolbar->addWidget(spacer);
//.........这里部分代码省略.........
示例9: outputMultiTunnels
int LzExcelOutput::outputMultiTunnels(ClearanceMultiTunnels * inputdata, QString templatepath, QString outputfile, QString insertimgpath)
{
QString templatename = "MultiTunnelsTemplate.xls";
int ret = copy(templatepath, templatename, outputfile);
if (ret != 0)
return ret;
// 插入图片路径不存在
if (!QFile(insertimgpath).exists())
return 3;
//操作已经存在的excel,生成限界尺寸表
ExcelEngine excel;
excel.Open(outputfile, 1, false);
QString linename = inputdata->getLineName();
// 限界表名称
excel.SetCellData(1,1,QObject::tr("%1-区段桥隧综合最小建筑限界尺寸表").arg(linename));
excel.SetCellData(52,1,QObject::tr("%1-区段桥隧综合最小建筑限界尺寸图").arg(linename));
// 线路名称
excel.SetCellData(3,3,linename);
excel.SetCellData(54,2,linename);
excel.SetCellData(54,5,linename);
// 区段
excel.SetCellData(3,9,linename);
QString endStationName = inputdata->getEndStationName();
// 面向站名
excel.SetCellData(3,15,endStationName);
excel.SetCellData(54,13,endStationName);
QStringListModel * tunnelsmodel = inputdata->getTunnelsNames();
// 桥隧总数
excel.SetCellData(4,4,tunnelsmodel->rowCount());
// 桥梁数
excel.SetCellData(4,11,inputdata->getNumOfOutOfClearanceBridges());
// 隧道数
excel.SetCellData(4,14,inputdata->getNumOfOutOfClearanceTunnels());
// 时间
// 采集日期
QModelIndex index = tunnelsmodel->index(0,0);
QString tunnelinfo = index.data().toString();//这两行代码获取QStringListModel中第一行的值
QStringList strlist = tunnelinfo.split("-");
if (strlist.length() < 3)
return -1;
QString collectdate = strlist.at(2);
excel.SetCellData(49,15,collectdate);
excel.SetCellData(54,16,collectdate);
// 最小曲线半径
int minRadius = inputdata->getMinRadius();
excel.SetCellData(5,5,minRadius);
// 最大外轨超高
excel.SetCellData(5,10,inputdata->getWaiGuiChaoGao());
// 最低接触网高度
excel.SetCellData(5,16,inputdata->getJieChuWangGaoDu());
ClearanceData * data = &inputdata->getClearanceStraightData();
int rowcount = data->getMaps().size();
// Excel模板从第10行开始为高度限界数据,前面几行为表头或空格
int startrownum = 10;
int startcolumnnumdef = 1;
// 临时变量
int startcolumnnum = startcolumnnumdef;
float tmpval;
_int64 tmppos;
int tmpradius;
float minHeight;
for (int i = 0; i < 3; i++)
{
startcolumnnum = startcolumnnumdef;
switch(i)
{
case Curve_Straight:
if (inputdata->getNumOfStraight())
{
data = &inputdata->getClearanceStraightData();
startcolumnnum += LzOutputTableColumn::Straight_Left_Val;
}
else
continue;
break;
case Curve_Left:
if (inputdata->getNumOfLeft())
{
data = &inputdata->getClearanceLeftData();
startcolumnnum += LzOutputTableColumn::LeftCurve_Left_Val;
}
else
continue;
//.........这里部分代码省略.........
开发者ID:fanxiang090909,项目名称:Railway-Tunnel-Construction-Dlearance-Measure-LanZhou,代码行数:101,代码来源:lz_excel_output.cpp
示例10: EvaluateRequest
void WebServer::EvaluateRequest(const RestInputStruct &REQ){
RestOutputStruct out;
if(REQ.VERB != "GET"){
//Non-supported request (at the moment) - return an error message
out.CODE = RestOutputStruct::BADREQUEST;
}else{
//GET request
//Now check the body of the message and do what it needs
QJsonDocument doc = QJsonDocument::fromJson(REQ.Body.toUtf8());
if(doc.isNull()){ qWarning() << "Empty JSON Message Body!!" << REQ.Body.toUtf8(); }
//Define the output structures
QJsonDocument ret; //return message
//parse the message and do something
//Objects contain other key/value pairs - this is 99% of cases
if(doc.isObject()){
QJsonObject obj;
QStringList keys = doc.object().keys();
if(REQ.URI.toLower()=="/syscache"){
QStringList reqs = keys.filter("request",Qt::CaseInsensitive);
if(!reqs.isEmpty()){
qDebug() << "Parsing Inputs:" << reqs;
for(int r=0; r<reqs.length(); r++){
QString req = JsonValueToString(doc.object().value(reqs[r]));
qDebug() << " ["+reqs[r]+"]="+req;
QStringList values = SysCacheClient::parseInputs( QStringList() << req );
values.removeAll("");
//Quick check if a list of outputs was returned
if(values.length()==1){
values = values[0].split(SCLISTDELIM); //split up the return list (if necessary)
values.removeAll("");
}
qDebug() << " - Returns:" << values;
keys.removeAll(reqs[r]); //this key was already processed
if(values.length()<2){
obj.insert(reqs[r],values.join(""));
}else{
//This is an array of outputs
QJsonArray arr;
for(int i=0; i<values.length(); i++){ arr.append(values[i]); }
obj.insert(reqs[r],arr);
}
}
} //end of special "request" objects
}else{
qDebug() << "Object Variables:" << keys;
for(int i=0; i<keys.length(); i++){
qDebug() << keys[i]+"="+JsonValueToString(doc.object().value(keys[i]) );
}
}
ret.setObject(obj);
//Special case for a single syscache input (array of strings)
}else if(doc.isArray() && REQ.URI.toLower()=="/syscache"){
QStringList inputs = JsonArrayToStringList(doc.array());
qDebug() << " syscache inputs:" << inputs;
QJsonObject obj;
QStringList values = SysCacheClient::parseInputs(inputs );
for(int i=0; i<values.length(); i++){
if(values[i].contains(SCLISTDELIM)){
//This is an array of values
QStringList vals = values[i].split(SCLISTDELIM);
vals.removeAll("");
QJsonArray arr;
for(int j=0; j<vals.length(); j++){ arr.append(vals[j]); }
obj.insert("Value"+QString::number(i),arr);
}else{
obj.insert("Value"+QString::number(i),values[i]);
}
}
ret.setObject(obj);
}
//Assemble the outputs for this "GET" request
out.CODE = RestOutputStruct::OK;
out.Body = ret.toJson();
out.Header << "Content-Type: text/json; charset=utf-8";
}
//Return any information
csock->sendTextMessage(out.assembleMessage());
}
示例11: retranslateUi
void PCDMgui::retranslateUi(){
//All the text-setting for the main interface needs to be done here
//virtual keyboard button
//if(currentTheme->itemIsEnabled("vkeyboard")){
virtkeyboardButton->setToolTip(tr("Virtual Keyboard"));
virtkeyboardButton->setText(tr("Virtual Keyboard"));
//}
//locale switcher button
localeButton->setToolTip(tr("Change locale"));
localeButton->setText(tr("Locale"));
//keyboard layout button
keyboardButton->setToolTip(tr("Change Keyboard Layout"));
keyboardButton->setText(tr("Keyboard Layout"));
//system button
systemButton->defaultAction()->setToolTip(tr("Shutdown the computer"));
systemButton->defaultAction()->setText(tr("System"));
//Menu entries for system button
systemMenu->clear();
systemMenu->addAction( tr("Restart"),this, SLOT(slotRestartComputer()) );
systemMenu->addAction( tr("Shut Down"), this, SLOT(slotShutdownComputer()) );
if(DEBUG_MODE){systemMenu->addAction( tr("Close PCDM"), this, SLOT(slotClosePCDM()) ); }
systemButton->setMenu(systemMenu);
//The main login widget
if(hostname.isEmpty()){
if(DEBUG_MODE){ qDebug() << "Finding Hostname..."; }
//Find the system hostname
hostname = pcbsd::Utils::runShellCommand("hostname").join(" ").simplified();
if(DEBUG_MODE){ qDebug() << " - Host:" << hostname; }
loginW->displayHostName(hostname);
}
if(DEBUG_MODE){ qDebug() << "Translate Login Widget"; }
loginW->retranslateUi();
//The desktop switcher
//Get the new desktop list (translated)
QStringList deList = Backend::getAvailableDesktops(); //priority ordered
QString lastDE;
if(!loginW->currentUsername().isEmpty()){ lastDE = Backend::getLastDE(loginW->currentUsername()); }
if(DEBUG_MODE){ qDebug() << "DE's:" << deList << lastDE; }
if(lastDE.isEmpty()){ lastDE = deList[0]; }
//Organize the desktop list alphabetically by filename
deList.removeDuplicates();
QStringList DEL;
for(int i=0; i<deList.length(); i++){
//Check the icon
QString deIcon = Backend::getDesktopIcon(deList[i]);
if( deIcon.isEmpty() ){ deIcon = currentTheme->itemIcon("desktop"); } //set the default icon if none given
if( !QFile::exists(deIcon) ){ deIcon = ":/images/desktop.png"; }
QString entry = deList[i] +":::"+deIcon+":::"+Backend::getDesktopComment(deList[i]);
DEL << entry;
}
DEL.sort(); //make it alphabetical
//Now fill the switcher
if(!simpleDESwitcher){
deSwitcher->removeAllItems();
for(int i=0; i<DEL.length(); i++){
//Now add the item
deSwitcher->addItem( DEL[i].section(":::",0,0), DEL[i].section(":::",1,1), DEL[i].section(":::",2,2) );
}
if(DEBUG_MODE){ qDebug() << "Last used DE:" << lastDE; }
//Set the switcher to the last used desktop environment
if( !lastDE.isEmpty() ){ deSwitcher->setCurrentItem(lastDE); }
}else{
//Simple switcher on the login widget
QStringList deNames, deIcons, deInfo;
for(int i=0; i<DEL.length(); i++){
deNames << DEL[i].section(":::",0,0);
deIcons << DEL[i].section(":::",1,1);
deInfo << DEL[i].section(":::",2,2);
}
if(DEBUG_MODE){ qDebug() << "Loading DE's into the login widget"; }
loginW->setDesktops(deNames, deIcons, deInfo);
//Set the switcher to the last used desktop environment
if(DEBUG_MODE){ qDebug() << "Last used DE:" << lastDE; }
loginW->setCurrentDE(lastDE);
}
}
示例12: execute_js
static void execute_js(const QString &js, const QStringList &args, const justice_cmd &cmd) {
QByteArray r_key = cmd.m_rbuf_key.toUtf8();
QByteArray w_key = cmd.m_wbuf_key.toUtf8();
QByteArray info_key = cmd.m_info_key.toUtf8();
QString TestCount;
int cnt = args.length();
QByteArray ref_args[cnt];
for (int i = 0; i != cnt; i++)
ref_args[i] = args[i].toUtf8();
char *argv[3 + cnt];
char *envp[10];
char path[] = "node";
QByteArray script = js.toUtf8();
argv[0] = path;
argv[1] = script.data();
for (int i = 0; i != cnt; i++)
argv[2 + i] = ref_args[i].data();
argv[2 + cnt] = NULL;
envp[0] = r_key.data();
envp[1] = w_key.data();
envp[2] = info_key.data();
envp[3] = NULL;
if( Command_test_enable == 1 )
{
argv[0] = path;
//argv[1] = "/home/justice/justice-script/execute/1.js";
argv[1] = "/home/justice/justice-script/command/blocks.js";
argv[2] = NULL;
envp[3] = admin_str;
envp[4] = buff;
sprintf( Count_str , "TEST_CNT=%s" , TEST_COUNT.toStdString().c_str() );
envp[5] = Count_str ;
envp[6] = NULL;
}
if( Command_test_enable == 1 )
{
qDebug() << "argv";
for (int i = 0; i < 3; i++)
qDebug() << argv[i];
qDebug() << "envp";
for (int i = 0 ; i < 7 ; i++)
qDebug() << envp[i];
}
else
{
qDebug() << "argv";
for (int i = 0; i != 2 + cnt; i++)
qDebug() << argv[i];
qDebug() << "envp";
for (int i = 0; i != 3; i++)
qDebug() << envp[i];
}
int status = execvpe( path, argv, envp);
return ;
}
示例13: journeyResult
//.........这里部分代码省略.........
}
if (regexp.cap(1) == "To:") {
lastJourneyResultList->setArrivalStation(regexp.cap(2).trimmed());
}
if (regexp.cap(1) == "When:") {
lastJourneyResultList->setTimeInfo(regexp.cap(2).trimmed());
}
}
QRegExp regexp2 = QRegExp("(.*), (\\d\\d) (.*) (\\d\\d\\d\\d)");
regexp2.setMinimal(true);
regexp2.indexIn(lastJourneyResultList->timeInfo().trimmed());
QLocale enLocale = QLocale(QLocale::English, QLocale::UnitedStates);
int month = 1;
for (month = 1; month < 10; month++) {
if (regexp2.cap(3).trimmed() == enLocale.standaloneMonthName(month)) {
break;
}
}
QDate journeydate = QDate::fromString(regexp2.cap(2).trimmed() + " " + QString::number(month) + " " + regexp2.cap(4).trimmed(), "dd M yyyy");
//Generate Details search results
QStringList detailsResult;
regexp = QRegExp("<table class=\"dataTbl widthcol2and3\" cellspacing=\"0\" style=\"margin:0px ! important;border-right:0px none;\" summary=\"Search Results Details\">(.*)</table>");
regexp.setMinimal(true);
int pos = 0;
while ((pos = regexp.indexIn(filebuffer->buffer(), pos)) != -1) {
QString element = "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?><html xmlns=\"http://www.w3.org/1999/xhtml\">\n<body><table>\n" + regexp.cap(1) + "\n</table></body>\n</html>\n";
element.replace(" ", " ");
element.replace("bulletin.gif\">", "bulletin.gif\" />");
QBuffer readBuffer;
readBuffer.setData(element.toAscii());
readBuffer.open(QIODevice::ReadOnly);
QXmlQuery query;
query.bindVariable("path", &readBuffer);
query.setQuery("declare default element namespace \"http://www.w3.org/1999/xhtml\"; declare variable $path external; doc($path)/html/body/table/tbody/tr/td[@headers='header2']/string()");
QStringList detailsContentResult;
if (!query.evaluateTo(&detailsContentResult))
{
qDebug() << "parser131500ComAu::getJourneyData - DetailsQuery 1 Failed";
}
detailsResult << detailsContentResult.join("<linesep>");
pos += regexp.matchedLength();
}
//qDebug()<<departResult;
//Create search result
for (int i = 0; i < departResult.count(); i++) {
//Parse transporttypes and changes
QString tmp = trainResult[i].trimmed();
tmp.replace("\t", " ");
tmp.replace("\n", " ");
tmp.replace("\r", " ");
QStringList trains = tmp.split(" ", QString::SkipEmptyParts);
int changes = trains.length() - 1;
trains.removeDuplicates();
//Parse travel time
tmp = timeResult[i].trimmed();
tmp.replace("mins", "");
tmp.replace("min", "");
tmp.replace("hrs ", ":");
tmp.replace("hr ", ":");
QStringList durationLst = tmp.split(":", QString::SkipEmptyParts);
QString durationStr = "";
if (durationLst.length() == 1) {
durationStr.sprintf("00: %02d", durationLst[0].toInt());
}
if (durationLst.length() == 2) {
durationStr.sprintf("%02d:%02d", durationLst[0].toInt(), durationLst[1].toInt());
}
JourneyResultItem *item = new JourneyResultItem();
item->setDate(journeydate);
item->setId(QString::number(i));
item->setTransfers(QString::number(changes));
item->setDuration(durationStr);
item->setTrainType(trains.join(", "));
item->setDepartureTime(QTime::fromString(departResult[i].trimmed(), "h:map").toString("hh:mm"));
item->setArrivalTime(QTime::fromString(arriveResult[i].trimmed(), "h:map").toString("hh:mm"));
item->setInternalData1(detailsResult[i]);
lastJourneyResultList->appendItem(item);
}
emit journeyResult(lastJourneyResultList);
}
示例14: addFontToDatabase
static bool addFontToDatabase(QString familyName, const QString &scriptName,
const TEXTMETRIC *textmetric,
const FONTSIGNATURE *signature,
int type)
{
// the "@family" fonts are just the same as "family". Ignore them.
if (familyName.at(0) == QLatin1Char('@') || familyName.startsWith(QStringLiteral("WST_")))
return false;
const int separatorPos = familyName.indexOf("::");
const QString faceName =
separatorPos != -1 ? familyName.left(separatorPos) : familyName;
const QString fullName =
separatorPos != -1 ? familyName.mid(separatorPos + 2) : QString();
static const int SMOOTH_SCALABLE = 0xffff;
const QString foundryName; // No such concept.
const NEWTEXTMETRIC *tm = (NEWTEXTMETRIC *)textmetric;
const bool fixed = !(tm->tmPitchAndFamily & TMPF_FIXED_PITCH);
const bool ttf = (tm->tmPitchAndFamily & TMPF_TRUETYPE);
const bool scalable = tm->tmPitchAndFamily & (TMPF_VECTOR|TMPF_TRUETYPE);
const int size = scalable ? SMOOTH_SCALABLE : tm->tmHeight;
const QFont::Style style = tm->tmItalic ? QFont::StyleItalic : QFont::StyleNormal;
const bool antialias = false;
const QFont::Weight weight = weightFromInteger(tm->tmWeight);
const QFont::Stretch stretch = QFont::Unstretched;
if (QWindowsContext::verboseFonts > 2) {
QDebug nospace = qDebug().nospace();
nospace << __FUNCTION__ << faceName << fullName << scriptName
<< "TTF=" << ttf;
if (type & DEVICE_FONTTYPE)
nospace << " DEVICE";
if (type & RASTER_FONTTYPE)
nospace << " RASTER";
if (type & TRUETYPE_FONTTYPE)
nospace << " TRUETYPE";
nospace << " scalable=" << scalable << " Size=" << size
<< " Style=" << style << " Weight=" << weight
<< " stretch=" << stretch;
}
/* Fixme: omitted for the moment
if(ttf && localizedName(faceName) && family->english_name.isEmpty())
family->english_name = getEnglishName(faceName);
*/
QSupportedWritingSystems writingSystems;
if (type & TRUETYPE_FONTTYPE) {
quint32 unicodeRange[4] = {
signature->fsUsb[0], signature->fsUsb[1],
signature->fsUsb[2], signature->fsUsb[3]
};
quint32 codePageRange[2] = {
signature->fsCsb[0], signature->fsCsb[1]
};
writingSystems = QBasicFontDatabase::determineWritingSystemsFromTrueTypeBits(unicodeRange, codePageRange);
// ### Hack to work around problem with Thai text on Windows 7. Segoe UI contains
// the symbol for Baht, and Windows thus reports that it supports the Thai script.
// Since it's the default UI font on this platform, most widgets will be unable to
// display Thai text by default. As a temporary work around, we special case Segoe UI
// and remove the Thai script from its list of supported writing systems.
if (writingSystems.supported(QFontDatabase::Thai) &&
faceName == QStringLiteral("Segoe UI"))
writingSystems.setSupported(QFontDatabase::Thai, false);
} else {
const QFontDatabase::WritingSystem ws = writingSystemFromScript(scriptName);
if (ws != QFontDatabase::Any)
writingSystems.setSupported(ws);
}
const QSettings fontRegistry("HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Fonts",
QSettings::NativeFormat);
QByteArray value;
int index = 0;
foreach (const QString &key, fontRegistry.allKeys()) {
QString realKey = key;
realKey = realKey.replace("(TrueType)", "");
realKey = realKey.trimmed();
QStringList fonts = realKey.split('&');
for (int i = 0; i < fonts.length(); ++i) {
const QString font = fonts[i].trimmed();
if (font == faceName || (faceName != fullName && fullName == font)) {
value = fontRegistry.value(key).toByteArray();
index = i;
break;
}
}
if (!value.isEmpty())
break;
}
if (value.isEmpty())
return false;
if (!QDir::isAbsolutePath(value))
value = qgetenv("windir") + "\\Fonts\\" + value;
// Pointer is deleted in QBasicFontDatabase::releaseHandle(void *handle)
FontFile *fontFile = new FontFile;
fontFile->fileName = value;
//.........这里部分代码省略.........
示例15: fi
TextPalette::TextPalette(QWidget* parent)
: QWidget(parent)
{
setWindowFlags(Qt::Tool);
setupUi(this);
pCommon = new Palette;
pCommon->setMag(0.8);
pCommon->setGrid(33, 60);
pCommon->setReadOnly(true);
pSmufl = new Palette;
pSmufl->setMag(0.8);
pSmufl->setGrid(33, 60);
pSmufl->setReadOnly(true);
pUnicode = new Palette;
pUnicode->setMag(0.8);
pUnicode->setGrid(33, 60);
pUnicode->setReadOnly(true);
PaletteScrollArea* psa = new PaletteScrollArea(pCommon);
psa->setRestrictHeight(false);
tabWidget->clear();
tabWidget->addTab(psa, tr("Common Symbols"));
psa = new PaletteScrollArea(pSmufl);
psa->setRestrictHeight(false);
QSplitter* ws = new QSplitter;
lws = new QListWidget;
ScoreFont* scoreFont = ScoreFont::fontFactory("Bravura");
QFile fi(scoreFont->fontPath() + "ranges.json");
if (!fi.open(QIODevice::ReadOnly))
qDebug("ScoreFont: open ranges file <%s> failed", qPrintable(fi.fileName()));
QJsonParseError error;
QJsonObject o = QJsonDocument::fromJson(fi.readAll(), &error).object();
if (error.error != QJsonParseError::NoError)
qDebug("Json parse error in <%s>(offset: %d): %s", qPrintable(fi.fileName()),
error.offset, qPrintable(error.errorString()));
int i = 0;
QStringList smuflRangeNames;
for (auto s : o.keys()) {
QJsonObject range = o.value(s).toObject();
QString desc = range.value("description").toString();
QJsonArray glyphs = range.value("glyphs").toArray();
if (glyphs.size() > 0) {
for (QJsonValue g : glyphs)
smuflMap[i].append(g.toString());
smuflRangeNames.append(desc);
i++;
}
}
lws->addItems(smuflRangeNames);
lws->setCurrentRow(0);
ws->addWidget(lws);
ws->addWidget(psa);
tabWidget->addTab(ws, tr("Musical Symbols"));
psa = new PaletteScrollArea(pUnicode);
psa->setRestrictHeight(false);
QSplitter* wu = new QSplitter;
lwu = new QListWidget;
lwu->setSortingEnabled(true);
for (i = 0; i < unicodeRangeNames.length(); i++) {
QListWidgetItem* newItem = new QListWidgetItem(qApp->translate("accidental", unicodeRangeNames.at(i).toUtf8().constData()));
newItem->setData(Qt::UserRole, i);
lwu->addItem(newItem);
if (i == 0)
lwu->setCurrentItem(newItem);
}
wu->addWidget(lwu);
wu->addWidget(psa);
tabWidget->addTab(wu, tr("Unicode Symbols"));
connect(lws, SIGNAL(currentRowChanged(int)), SLOT(populateSmufl()));
connect(lwu, SIGNAL(currentRowChanged(int)), SLOT(populateUnicode()));
// others are done in setFont
populateSmufl();
setFocusPolicy(Qt::NoFocus);
}