void MainWindowMenuPlan::cleanListViewING()                 //Se borra el listview con los ingredientes mostrados en el apartado Ingredientes
{
    QStringListModel *model = new QStringListModel();
    model->removeRows(0, model->rowCount());
    ui->listView_Ingredientes->setModel(model);
    delete model;
}
示例#2
0
void QQBoardsSettings::addBouchot()
{
	QQBouchotSettingsDialog bouchotSettingsDialog(this);
	bouchotSettingsDialog.setGroups(m_listGroups);
	bouchotSettingsDialog.setNames(m_listNames);

	if(bouchotSettingsDialog.exec() == QDialog::Accepted)
	{
		QQBouchot::QQBouchotSettings bSettings = bouchotSettingsDialog.bouchotSettings();
		QString bouchotName = bouchotSettingsDialog.bouchotName();

		if(m_listNames.contains(bouchotName))
		{
			qWarning() << "Trying to insert a bouchot with an already existing name, that's forbidden";
		}
		else
		{
			m_listNames.append(bouchotName);

			if(! m_listGroups.contains(bSettings.group()))
				m_listGroups.append(bSettings.group());

			QStringListModel *model = (QStringListModel *) ui->bouchotListView->model();
			int numRow = model->rowCount();
			model->insertRows(numRow,1);
			model->setData(model->index(numRow), QVariant(bouchotName));
			m_newBouchots.insert(bouchotName, bSettings);
			m_oldBouchots.removeAll(bouchotName);
		}
	}
}
示例#3
0
void QQBoardsSettings::olccsAddBouchot()
{
	QQBoardWizard wizard(this);
	if(wizard.exec() == QDialog::Accepted)
	{
		QQBouchot::QQBouchotSettings bSettings = wizard.bouchotSettings();
		QString bouchotName = wizard.bouchotName();

		if(m_listNames.contains(bouchotName))
		{
			qWarning() << "Trying to insert a bouchot with an already existing name, that's forbidden";
		}
		else
		{
			m_listNames.append(bouchotName);

			if(! m_listGroups.contains(bSettings.group()))
				m_listGroups.append(bSettings.group());

			QStringListModel *model = (QStringListModel *) ui->bouchotListView->model();
			int numRow = model->rowCount();
			model->insertRows(numRow, 1);
			model->setData(model->index(numRow), QVariant(bouchotName));
			m_newBouchots.insert(bouchotName, bSettings);
			m_oldBouchots.removeAll(bouchotName);
		}

		if(wizard.showAdvanced())
		{
			QStringListModel *model = (QStringListModel *) ui->bouchotListView->model();
			QItemSelectionModel *selModel = ui->bouchotListView->selectionModel();
			for(int i = 0; i < model->rowCount(); i++)
			{
				QModelIndex mIndex = model->index(i);
				if(model->data(mIndex, Qt::EditRole).toString() == bouchotName)
				{
					selModel->select(mIndex, QItemSelectionModel::ClearAndSelect);
					editBouchot();
				}
			}
		}
	}
}
Login::Login(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::Login)
{
    ui->setupUi(this);
    QIcon icon;
    icon.addFile(QString::fromUtf8(":image/icon.png"), QSize(), QIcon::Normal, QIcon::Off);
    this->setWindowIcon(icon);

    group = new QButtonGroup(this);

    QStringListModel * model = AdminDAO::getAdminDAOInstance()->getUsernames();
    
    QString img = ":/users/0.jpg";
    QRadioButton * tmpbutton = ui->userButton_0;

    for (int i = 0; i < model->rowCount(); i++)
    {
        img = QString(":/users/%1.jpg").arg(i); 
        switch (i)
        {
        case 0: tmpbutton = ui->userButton_0; break;
        case 1: tmpbutton = ui->userButton_1; break;
        case 2: tmpbutton = ui->userButton_2; break;
        case 3: tmpbutton = ui->userButton_3; break;
        case 4: tmpbutton = ui->userButton_4; break;
        case 5: tmpbutton = ui->userButton_5; break;
        default: tmpbutton = ui->userButton_0; break;
        }
        tmpbutton->setIcon(QPixmap(img));
        tmpbutton->setIconSize(QSize(40,40));
    }

    group->addButton(ui->userButton_0);
    group->addButton(ui->userButton_1);
    group->addButton(ui->userButton_2);
    group->addButton(ui->userButton_3);
    group->addButton(ui->userButton_4);
    group->addButton(ui->userButton_5);

    group->setId(ui->userButton_0, 0);
    group->setId(ui->userButton_1, 1);
    group->setId(ui->userButton_2, 2);
    group->setId(ui->userButton_3, 3);
    group->setId(ui->userButton_4, 4);
    group->setId(ui->userButton_5, 5);

    connect(ui->userButton_0, SIGNAL(clicked()), this, SLOT(sellectOneUser()));
    connect(ui->userButton_1, SIGNAL(clicked()), this, SLOT(sellectOneUser()));
    connect(ui->userButton_2, SIGNAL(clicked()), this, SLOT(sellectOneUser()));
    connect(ui->userButton_3, SIGNAL(clicked()), this, SLOT(sellectOneUser()));
    connect(ui->userButton_4, SIGNAL(clicked()), this, SLOT(sellectOneUser()));
    connect(ui->userButton_5, SIGNAL(clicked()), this, SLOT(sellectOneUser()));
}
示例#5
0
void QQBoardsSettings::setBouchots(const QMap<QString, QQBouchot::QQBouchotSettings> currentListBouchot)
{
	m_bouchots = currentListBouchot;

	QStringListModel *model = (QStringListModel *) ui->bouchotListView->model();
	model->removeRows(0, model->rowCount());
	model->insertRows(0, m_bouchots.size());

	m_listNames = currentListBouchot.keys();

	QMapIterator<QString, QQBouchot::QQBouchotSettings> i(m_bouchots);
	int index = 0;
	while(i.hasNext())
	{
		i.next();
		QQBouchot::QQBouchotSettings settings = i.value();
		if(! m_listGroups.contains(settings.group()))
			m_listGroups.append(settings.group());

		model->setData(model->index(index++), QVariant(i.key()));
	}
}
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;
                break;
            case Curve_Right:
                if (inputdata->getNumOfRight())
                {
                    data = &inputdata->getClearanceRightData();
                    startcolumnnum += LzOutputTableColumn::RightCurve_Left_Val;
                }
                else
                    continue;
                break;
            default:
                break;
        }

        minHeight = data->getMinCenterHeight();

        // map反向遍历,正向为高度从小到大,插入图表是需要高度从大到小
        std::map<int, ClearanceItem>::reverse_iterator it = data->getMaps().rbegin();
        int k = 0; // 相对行数
        while (it != data->getMaps().rend())
        {
            std::pair<int, ClearanceItem> pair = (*it);

            if (pair.first > minHeight)
            {
                it++;
                k++;
                continue;
            }

            // 此处写要插入的内容
            if (pair.second.leftval >= 0)
                excel.SetCellData(k + startrownum, startcolumnnum, pair.second.leftval); 
            if (pair.second.rightval >= 0)
                excel.SetCellData(k + startrownum, startcolumnnum + 1, pair.second.rightval);
            if (i == Curve_Straight) // 直线
            {
                if (pair.second.leftval >= 0)
                {
                    excel.SetCellData(k + startrownum, startcolumnnum + 2, toTunnelPosString2(pair.second.leftpos, pair.second.lefttunnelid, "0"));
                    qDebug() << toTunnelPosString2(pair.second.leftpos, pair.second.lefttunnelid, "0");
                }
                if (pair.second.rightval >= 0)
                {
                    excel.SetCellData(k + startrownum, startcolumnnum + 3, toTunnelPosString2(pair.second.rightpos, pair.second.righttunnelid, "0"));
                    qDebug() << toTunnelPosString2(pair.second.rightpos, pair.second.righttunnelid, "0");
                }
            }
            else
            {
                if (pair.second.leftval >= 0)
                {
                    excel.SetCellData(k + startrownum, startcolumnnum + 2, pair.second.leftradius); 
                    excel.SetCellData(k + startrownum, startcolumnnum + 4, toTunnelPosString2(pair.second.leftpos, pair.second.lefttunnelid, "0"));
                    qDebug() << toTunnelPosString2(pair.second.leftpos, pair.second.lefttunnelid, "0");
                }
                if (pair.second.rightval >= 0)
                {
                    excel.SetCellData(k + startrownum, startcolumnnum + 3, pair.second.rightradius);
                    excel.SetCellData(k + startrownum, startcolumnnum + 5, toTunnelPosString2(pair.second.rightpos, pair.second.righttunnelid, "0"));
                    qDebug() << toTunnelPosString2(pair.second.rightpos, pair.second.righttunnelid, "0");
                }
            }
            it++;
            k++;
        }
    }

    // <150高度手动输入? ///TODO

    // 线路中心线上方最低净高mm
    excel.SetCellData(rowcount+startrownum+1,9, inputdata->getMinHeight());
    
    excel.setProperty("DisplayAlerts", 0);
    
    // 保存
    excel.Save(); 
    excel.Close();    
    
    // 生成限界图
    initExcelEngine();
    QAxObject *workBooks1 = excel1->querySubObject("Workbooks");
    workBooks1->dynamicCall("Open(const QString&)", outputfile);
    QAxObject *workBook1 = excel1->querySubObject("ActiveWorkBook");
    QAxObject *sheets1 = workBook1->querySubObject("WorkSheets");
    QAxObject *sheet1 = sheets1->querySubObject("Item(int)", 1);//获得第一个工作表

    // QAxObject *range=sheet1->querySubObject("Range(const QVariant&)",QVariant(QString("D52:AA92")));
    // range->dynamicCall("Clear()");//指定清除某个区域

    /////////////AddPicture函数详解////////////////
    // AddPicture(FileName, LinkToFile, SaveWithDocument, Left, Top, Width, Height)中7个参数的意思。
    // (1)FileName 必选 String 图片的路径和文件名。
    // (2)LinkToFile 可选 Variant 如果该参数值为 True,则将图片链接到创建它的文件。如果该参数值为 False,则将图片作为该文件的独立副本。默认值为 False。
    // (3)SaveWithDocument 可选 Variant 如果该参数值为 True,则将链接的图片与文档一起保存。默认值为 False。
    // (4)Left 可选 Variant 新图片的左边缘相对于绘图画布的位置,以磅为单位。
    // (5)Top 可选 Variant 新图片的上边缘相对于绘图画布的位置,以磅为单位。
    // (6)Width 可选 Variant 图片的宽度,以磅为单位。
    // (7)Height 可选 Variant 图片的高度,以磅为单位。
    ///////////////////////////////////////////////

    // @author 熊雪、范翔。路径变成反斜杠,否则AddPicture,SaveAs函数出错
    outputfile = toBackSlashStr(outputfile);
    insertimgpath = toBackSlashStr(insertimgpath);

    QAxObject *shapes1 = sheet1->querySubObject("Shapes");
    shapes1->dynamicCall("AddPicture(QString&,bool,bool,double,double,double,double",QString("%1").arg(insertimgpath),true,true,8,770,510,595);//8,750,510,627  QString("%1image.jpg").arg(outputfile)
    excel1->setProperty("DisplayAlerts", 0);
    //excel1->dynamicCall("Save()");
    workBook1->dynamicCall("SaveAs(const QString&)", outputfile);
    // QMessageBox::information(NULL, tr("OK"), tr("成功生成Excel文件!"),QMessageBox::Yes | QMessageBox::No);
    excel1->dynamicCall("Quit()");

    return 0;
}