Exemplo n.º 1
0
void CSVWholeview::enumSVSE()
{
    if(!m_pContent)
        return;

    PAIRLIST selist;
    string szRootname("");
    int nRow = 0;

    WTable *pTable = m_pContent;
    if(GetIniFileInt("solover","solover",1,"general.ini") == 1)
    {       
        sv_pair svpair;
        svpair.name = "1";
        OBJECT objSE = GetSVSE("1");//, m_szIDCUser, m_szIDCPwd);
        if(objSE != INVALID_VALUE)
        {
            svpair.value = GetSVSELabel(objSE);
            CloseSVSE(objSE);
        }        
        selist.push_back(svpair);
    }
    else
    {
        GetAllSVSEInfo(selist);
        szRootname = GetIniFileString("segroup","name","","general.ini");
        if(szRootname.empty())
            szRootname = "SiteView ECC 7.0";        
        nRow = m_pContent->numRows();
        //WImage *pShow = new WImage("../Images/foldopen.gif", m_pContent->elementAt(nRow, 0));
        //WImage *pHide = new WImage("../Images/foldclose.gif", m_pContent->elementAt(nRow, 0));
        WImage *pShow = new WImage("/Images/cb1-unwrap.gif", m_pContent->elementAt(nRow, 0));
        WImage *pHide = new WImage("/Images/cb1-fold.gif", m_pContent->elementAt(nRow, 0));

		new WText(" ",m_pContent->elementAt(nRow, 0));

        //new WImage("../Images/home.gif", m_pContent->elementAt(nRow, 1));
		new WImage("/Images/cbb-2main.gif", m_pContent->elementAt(nRow, 1));

		new WText(" ",m_pContent->elementAt(nRow, 1));

        WText *pName = new WText(szRootname, m_pContent->elementAt(nRow, 2));
        if(pName)
        {
            sprintf(pName->contextmenu_, "style='color:#669;cursor:pointer;' onmouseover='" \
                "this.style.textDecoration=\"underline\"' " \
                "onmouseout='this.style.textDecoration=\"none\"'");
        }
        pTable = new WTable(m_pContent->elementAt(nRow + 1, 2));
		pTable->setStyleClass("widthauto");
        if(!pTable)
            return;
        else
        {
            if(pShow && pHide)
            {
                string szShow = "", szHide = "", szSubTable = "";
                szShow = pHide->formName();
                szHide = pShow->formName();
                szSubTable = pTable->formName();

                string szShowText = "onclick='showsubtable(\"" + szShow + "\", \"" + szHide + "\", \"" + szSubTable + "\")' " + "style='display:none;cursor:pointer'";
                string szHideText = "onclick='hidesubtable(\"" + szShow + "\", \"" + szHide + "\", \"" + szSubTable + "\")' " + "style='cursor:pointer'";
                sprintf(pShow->contextmenu_, szShowText.c_str());
                sprintf(pHide->contextmenu_, szHideText.c_str());            
            }
        }
    }

    PAIRLIST::iterator iSe;
    
    bool bHasRight = true;

    int  nChildCount = 0, nIndex = 0;

    OBJECT objSE = INVALID_VALUE;
    OBJECT objGroup = INVALID_VALUE;
    MAPNODE node = INVALID_VALUE;

    string szSEID(""), szSubGroupID(""), szEntityID("");
    string szName(""), szIndex("");
    string szContext(""), szShow(""), szHide(""), szSubTable("");
    string szShowText(""), szHideText("");

    list<string> lsGroupID;
    list<string> lsDeviceID;
    list<string>::iterator lstItem;

    for(iSe= selist.begin(); iSe!=selist.end(); iSe++)
    {
        szSEID = (*iSe).name;
        bHasRight = true;
        if(m_pSVUser)
            bHasRight = m_pSVUser->haveGroupRight(szSEID, Tree_SE);
        if(bHasRight)
        {
            nRow = pTable->numRows();
            //WImage *pShow = new WImage("../Images/foldopen.gif", pTable->elementAt(nRow, 0));
            //WImage *pHide = new WImage("../Images/foldclose.gif", pTable->elementAt(nRow, 0));
            WImage *pShow = new WImage("/Images/cb1-unwrap.gif", pTable->elementAt(nRow, 0));
            WImage *pHide = new WImage("/Images/cb1-fold.gif", pTable->elementAt(nRow, 0));
           
			new WText("&nbsp;",pTable->elementAt(nRow, 0));

			new WImage("/Images/cbb-2main.gif", pTable->elementAt(nRow, 1));

			new WText("&nbsp;",pTable->elementAt(nRow, 1));

            WText *pName = new WText((*iSe).value, pTable->elementAt(nRow, 2));
            if(pName)
            {
                szContext = "onclick='parent.document.frames(\"left\").location.replace(\"/fcgi-bin/menu.exe?cmd=treeview.exe?svseid=" + szSEID 
                    + "\");' style='color:#669;cursor:pointer;' onmouseover='this.style.textDecoration=\"underline\"'"
                    + "onmouseout='this.style.textDecoration=\"none\"'";
                sprintf(pName->contextmenu_, szContext.c_str());
            }
            WTable *pSubTable = new WTable(pTable->elementAt(nRow + 1, 2));
			pSubTable->setStyleClass("widthauto");
            if(!pSubTable)
                return;
            else
            {
                if(pShow && pHide)
                {                    
                    szShow = pHide->formName();
                    szHide = pShow->formName();
                    szSubTable = pSubTable->formName();

                    szShowText = "onclick='showsubtable(\"" + szShow + "\", \"" + szHide + "\", \"" + szSubTable + "\")' " + "style='display:none;cursor:pointer'";
                    szHideText = "onclick='hidesubtable(\"" + szShow + "\", \"" + szHide + "\", \"" + szSubTable + "\")' " + "style='cursor:pointer'";
                    sprintf(pShow->contextmenu_, szShowText.c_str());
                    sprintf(pHide->contextmenu_, szHideText.c_str());            
                }
            }
            
            objSE = GetSVSE(szSEID);
            if(objSE != INVALID_VALUE)
            {
                lsGroupID.clear();
                if(GetSubGroupsIDBySE(objSE, lsGroupID))
			    {
                    map<int, base_param, less<int> > sortList;
                    map<int, base_param, less<int> >::iterator lsItem;
					map<int, base_param, less<int> >::iterator compItem;

                    base_param group;

                    for(lstItem = lsGroupID.begin(); lstItem != lsGroupID.end(); lstItem ++)
                    {
                        szSubGroupID =(*lstItem);
                        bHasRight = true;
                        if(m_pSVUser)
                            bHasRight = m_pSVUser->haveGroupRight(szSubGroupID, Tree_GROUP);
                        if(bHasRight)
                        {
                            objGroup = GetGroup(szSubGroupID, m_szIDCUser, m_szIDCPwd);
                            if(objGroup != INVALID_VALUE)
                            {
                                node = GetGroupMainAttribNode(objGroup);
                                if(node != INVALID_VALUE)
                                {
                                    FindNodeValue(node, "sv_name", szName);
                                    FindNodeValue(node, "sv_index", szIndex);

                                    if(szIndex.empty())
                                        nIndex = FindIndexByID(szSubGroupID);
                                    else
                                        nIndex = atoi(szIndex.c_str());

                                    group.szIndex = szSubGroupID;
                                    group.szName = szName;

                                    lsItem = sortList.find(nIndex);
                                    while(lsItem != sortList.end())
                                    {
                                        nIndex ++;
                                        lsItem = sortList.find(nIndex);
                                    }
                                    sortList[nIndex] = group;
                                }
                                CloseGroup(objGroup);
                            }
                        }
                    }
                    nChildCount += static_cast<int>(sortList.size());

                    for(lsItem = sortList.begin(); lsItem != sortList.end(); lsItem ++)
                    {
						//PrintDebugString("In first setting ---------" + lsItem->second.szName + "\n");
						//bool bbbb = false;
                        nRow = pSubTable->numRows();
					    WImage *pShow = new WImage("/Images/cb1-unwrap.gif", pSubTable->elementAt(nRow, 0));
					    WImage *pHide = new WImage("/Images/cb1-fold.gif", pSubTable->elementAt(nRow, 0));

						new WText("&nbsp;",pSubTable->elementAt(nRow, 0));

						new WImage("/Images/cbb-3group.gif", pSubTable->elementAt(nRow, 1));

						new WText("&nbsp;",pSubTable->elementAt(nRow, 1));

                        WText *pName = new WText(lsItem->second.szName, pSubTable->elementAt(nRow, 2));
                        if(pName)
                        {
                            string szContext = "onclick='parent.document.frames(\"left\").location.replace(\"/fcgi-bin/menu.exe?cmd=treeview.exe?groupid=" + lsItem->second.szIndex 
                                + "\");' style='color:#669;cursor:pointer;' onmouseover='this.style.textDecoration=\"underline\"'"
                                + "onmouseout='this.style.textDecoration=\"none\"'";
                            sprintf(pName->contextmenu_, szContext.c_str());
                        }
                        WTable * pSub = new WTable(pSubTable->elementAt(nRow + 1, 2));
                        if(pSub)
                        {                        
                            if(pShow && pHide)
                            {
                                szShow = pHide->formName();
                                szHide = pShow->formName();
                                szSubTable = pSub->formName();

                                string szShowText = "onclick='showsubtable(\"" + szShow + "\", \"" + szHide + "\", \"" + szSubTable + "\")' " + "style='display:none;cursor:pointer'";
                                string szHideText = "onclick='hidesubtable(\"" + szShow + "\", \"" + szHide + "\", \"" + szSubTable + "\")' " + "style='cursor:pointer'";
                                sprintf(pShow->contextmenu_, szShowText.c_str());
                                sprintf(pHide->contextmenu_, szHideText.c_str());            
                            }
                            if(!enumGroups(lsItem->second.szIndex, pSub))
							{
								//bbbb = true;
                                //pSubTable->deleteRow(nRow);
								pShow->hide();
								pHide->hide();

							}
                        }
                    }

                }
                lsDeviceID.clear();
                if(GetSubEntitysIDBySE(objSE, lsDeviceID))
                {
                    map<int, base_param, less<int> > sortList;
                    map<int, base_param, less<int> >::iterator lsItem;
                    base_param device;
                    for(lstItem = lsDeviceID.begin(); lstItem != lsDeviceID.end(); lstItem ++)
                    {
                        szEntityID =(*lstItem);
                        bHasRight = true;
                        if(m_pSVUser)
                            bHasRight = m_pSVUser->haveGroupRight(szEntityID, Tree_DEVICE);
                        if(bHasRight)
                        {
                            OBJECT objDevice = GetEntity(szEntityID, m_szIDCUser, m_szIDCPwd);
                            if(objDevice != INVALID_VALUE)
                            {
                                MAPNODE node = GetEntityMainAttribNode(objDevice);
                                if(node != INVALID_VALUE)
                                {
                                    FindNodeValue(node, "sv_name", szName);
                                    FindNodeValue(node, "sv_index", szIndex);
                                    if(szIndex.empty())
                                        nIndex = FindIndexByID(szEntityID);
                                    else
                                        nIndex = atoi(szIndex.c_str());

                                    device.szIndex = szEntityID;
                                    device.szName = szName;

                                    lsItem = sortList.find(nIndex);
                                    while(lsItem != sortList.end())
                                    {
                                        nIndex ++;
                                        lsItem = sortList.find(nIndex);
                                    }
                                    sortList[nIndex] = device;
                                }
                                CloseEntity(objDevice);
                            }
                        }
                    }
                    nChildCount += static_cast<int>(sortList.size());
                    for(lsItem = sortList.begin(); lsItem != sortList.end(); lsItem ++)
                    {
                        nRow = pSubTable->numRows();

						new WText("&nbsp;",pSubTable->elementAt(nRow , 0));

						new WImage("/Images/cbb-4server.gif", pSubTable->elementAt(nRow, 1));

						new WText("&nbsp;",pSubTable->elementAt(nRow , 1));

                        WText *pName = new WText(lsItem->second.szName, pSubTable->elementAt(nRow, 2));
                        if(pName)
                        {
                            szContext = "onclick='parent.document.frames(\"left\").location.replace(\"/fcgi-bin/menu.exe?cmd=treeview.exe?deviceid=" + lsItem->second.szIndex 
                                + "\");' style='color:#669;cursor:pointer;' onmouseover='this.style.textDecoration=\"underline\"'"
                                + "onmouseout='this.style.textDecoration=\"none\"'";
                            sprintf(pName->contextmenu_, szContext.c_str());
                        }
                        if(!enumMonitors(lsItem->second.szIndex, lsItem->second.szName, pSubTable->elementAt(nRow, 2)))
						{
							//pSubTable->deleteRow(nRow);
						}

                    }
                }
                CloseSVSE(objSE);

                if(nChildCount <= 0)
                {
                    new WText(m_szNoChild, pSubTable->elementAt(nRow, 2));
                }
            }
        }
    }
}
Exemplo n.º 2
0
void MediaInfoPanel::info( Media &media )
{
  clear();
  WContainerWidget *header = WW<WContainerWidget>().setContentAlignment( AlignCenter );
  Dbo::Transaction t( *d->session );
  WString title = media.title( t );
  header->addWidget( WW<WText>( title ).css( "media-title" ) );
  Dbo::ptr<MediaAttachment> previewAttachment = media.preview( t, Media::PreviewPlayer );

  if( previewAttachment )
  {
    WLink previewLink = previewAttachment->link( previewAttachment, t, header );
    WLink fullImage = previewLink;

    Dbo::ptr<MediaAttachment> fullImageAttachment = media.preview( t, Media::PreviewFull );

    if( fullImageAttachment )
      fullImage = fullImageAttachment->link( fullImageAttachment, t, header );

    WAnchor *fullImageLink = new WAnchor {fullImage, WW<WImage>(previewLink, title).css("img-responsive img-rounded")};
    fullImageLink->setTarget( Wt::AnchorTarget::TargetNewWindow );
    header->addWidget( fullImageLink );
  }
  else
  {
    auto iconType = ( media.mimetype().find( "video" ) == string::npos ) ? Settings::AudioFile : Settings::VideoFile;
    WImage *icon = new WImage { d->settings->icon( iconType ) };
    header->addWidget( icon );
  }

  auto mediaMediaInfoPanel = d->createPanel( "mediabrowser.information" );
  WTable *table = new WTable( mediaMediaInfoPanel.second );
  table->setWidth( WLength( 100, WLength::Percentage ) );
  d->labelValueBox( "mediabrowser.filename", WString::fromUTF8(media.filename()), table );
  d->labelValueBox( "mediabrowser.filesize", Utils::formatFileSize( fs::file_size( media.path() ) ), table );

  MediaPropertiesPtr mediaProperties = media.properties( t );

  if( mediaProperties )
  {
    d->labelValueBox( "mediabrowser.creation_time", mediaProperties->creationTime().toString(), table );
    d->labelValueBox( "mediabrowser.medialength", WTime( 0, 0, 0 ).addSecs( mediaProperties->duration() ).toString(), table );

    if( media.mimetype().find( "video" ) != string::npos && mediaProperties->width() > 0 && mediaProperties->height() > 0 )
      d->labelValueBox( "mediabrowser.resolution", WString( "{1}x{2}" ).arg( mediaProperties->width() ).arg( mediaProperties->height() ), table );
  }

  Ratings rating = MediaRating::ratingFor( media, t );

  if( rating.users > 0 )
  {
    WContainerWidget *avgRatingWidget = new WContainerWidget;

    for( int i = 1; i <= 5; i++ )
    {
      avgRatingWidget->addWidget( WW<WImage>( Settings::staticPath( "/icons/rating_small.png" ) ).css( rating.ratingAverage < i ? "rating-unrated" : "" ) );
    }

    d->labelValueBox( "mediabrowser.rating", avgRatingWidget, table );
  }

  auto actions = d->createPanel( "mediabrowser.actions" );
  actions.second->addWidget( WW<WPushButton>( wtr( "mediabrowser.play" ) ).css( "btn btn-block btn-sm btn-primary" ).onClick( [ = ]( WMouseEvent )
  {
    d->play.emit( media );
  } ) );
  actions.second->addWidget( WW<WPushButton>( wtr( "mediabrowser.queue" ) ).css( "btn btn-block btn-sm" ).onClick( [ = ]( WMouseEvent )
  {
    d->queue.emit( media );
  } ) );
  actions.second->addWidget( WW<WPushButton>( wtr( "mediabrowser.share" ) ).css( "btn btn-block btn-sm" ).onClick( [ = ]( WMouseEvent )
  {
    Wt::Dbo::Transaction t( *d->session );
    WW<WMessageBox>(wtr( "mediabrowser.share" ),
                    wtr( "mediabrowser.share.dialog" )
                      .arg( media.title( t ) )
                      .arg( d->settings->shareLink( media.uid() ).url() ),
                    Wt::Information, Ok)
    .button(Ok, [=](WMessageBox *msgBox){ msgBox->accept(); }).get()->show();
  } ) );
  addWidget( WW<WPushButton>( wtr( "button.close.info" ) ).css( "btn btn-primary btn-block hidden-lg hidden-md" )
             .onClick( [ = ]( WMouseEvent )
  {
    wasResetted().emit();
  } ) );
  actions.second->addWidget( WW<WPushButton>( wtr( "player.downloadlink" ) ).css( "btn btn-block btn-sm btn-success" ).onClick( [ = ]( WMouseEvent )
  {
    WDialog *downloadDialog = new WDialog(wtr("player.downloadlink"));
    downloadDialog->contents()->addWidget(new WText{wtr("player.downloadlink.message").arg(d->settings->linkFor( media.path() , d->session).url()), XHTMLUnsafeText});
    downloadDialog->footer()->addWidget(WW<WPushButton>(wtr("button.ok")).css("btn btn-primary").onClick([=](WMouseEvent){ downloadDialog->accept(); }));
    downloadDialog->show();
  } ) );
  addWidget( WW<WPushButton>( wtr( "button.close.info" ) ).css( "btn btn-primary btn-block hidden-lg hidden-md" )
             .onClick( [ = ]( WMouseEvent )
  {
    wasResetted().emit();
  } ) );
  addWidget( header );
  addWidget( mediaMediaInfoPanel.first );
  addWidget( actions.first );

  if( d->isAdmin )
  {
    auto adminActions = d->createPanel( "mediabrowser.admin.actions" );
    adminActions.first->addStyleClass( "visible-lg visible-md" );
    adminActions.first->collapse();
    adminActions.second->addWidget( WW<WPushButton>( wtr( "mediabrowser.admin.settitle" ) ).css( "btn btn-block btn-sm btn-primary" ).onClick( [ = ]( WMouseEvent )
    {
      setTitle().emit( media );
    } ) );
    adminActions.second->addWidget( WW<WPushButton>( wtr( "mediabrowser.admin.setposter" ) ).css( "btn btn-block btn-sm btn-primary" ).onClick( [ = ]( WMouseEvent )
    {
      setPoster().emit( media );
    } ) );
    adminActions.second->addWidget( WW<WPushButton>( wtr( "mediabrowser.admin.deletepreview" ) ).css( "btn btn-block btn-sm btn-danger" ).onClick( [ = ]( WMouseEvent )
    {
      deletePoster().emit( media );
    } ) );
    adminActions.second->addWidget( WW<WPushButton>( wtr( "mediabrowser.admin.deleteattachments" ) ).css( "btn btn-block btn-sm btn-danger" ).onClick( [ = ]( WMouseEvent )
    {
      deleteAttachments().emit( media );
    } ) );
    addWidget( adminActions.first );
  }

  gotInfo().emit();
}
Exemplo n.º 3
0
void SysMon::Impl::RefreshResourceUsage()
{
    sg_cpu_percents *cpuPercents;
    sg_mem_stats *memStats;
    sg_swap_stats *swapStats;
    sg_host_info *hostInfo;
    sg_disk_io_stats *diskIoStats;
    sg_network_io_stats *networkIoStats;

    std::size_t cpuPercentsEntries = 0;
    std::size_t memStatsEntries = 0;
    std::size_t swapStatsEntries = 0;
    std::size_t hostInfoEntries = 0;
    std::size_t diskIoStatsEntries = 0;
    std::size_t networkIoStatsEntries = 0;


    /// Get the host info
    if ((hostInfo = sg_get_host_info(&hostInfoEntries)) != NULL) {
        HostInfoDiv->clear();

        WTable *hostTable = new WTable(HostInfoDiv);
        hostTable->setStyleClass("table table-hover");
        hostTable->setHeaderCount(1, Orientation::Horizontal);

        hostTable->elementAt(0, 0)->addWidget(new WText(tr("system-monitor-host-info-os-name")));
        hostTable->elementAt(0, 1)->addWidget(new WText(tr("system-monitor-host-info-os-release")));
        hostTable->elementAt(0, 2)->addWidget(new WText(tr("system-monitor-host-info-os-version")));
        hostTable->elementAt(0, 3)->addWidget(new WText(tr("system-monitor-host-info-platform")));
        hostTable->elementAt(0, 4)->addWidget(new WText(tr("system-monitor-host-info-hostname")));
        hostTable->elementAt(0, 5)->addWidget(new WText(tr("system-monitor-host-info-bitwidth")));
        hostTable->elementAt(0, 6)->addWidget(new WText(tr("system-monitor-host-info-host-state")));
        hostTable->elementAt(0, 7)->addWidget(new WText(tr("system-monitor-host-info-ncpus")));
        hostTable->elementAt(0, 8)->addWidget(new WText(tr("system-monitor-host-info-maxcpus")));
        hostTable->elementAt(0, 9)->addWidget(new WText(tr("system-monitor-host-info-uptime")));
        hostTable->elementAt(0, 10)->addWidget(new WText(tr("system-monitor-host-info-systime")));

        hostTable->elementAt(1, 0)->addWidget(new WText(WString(hostInfo->os_name)));
        hostTable->elementAt(1, 1)->addWidget(new WText(WString(hostInfo->os_release)));
        hostTable->elementAt(1, 2)->addWidget(new WText(WString(hostInfo->os_version)));
        hostTable->elementAt(1, 3)->addWidget(new WText(WString(hostInfo->platform)));
        hostTable->elementAt(1, 4)->addWidget(new WText(WString(hostInfo->hostname)));
        hostTable->elementAt(1, 5)->addWidget(new WText(lexical_cast<string>(hostInfo->bitwidth)));
        hostTable->elementAt(1, 6)->addWidget(new WText(lexical_cast<string>(HostState[hostInfo->host_state])));
        hostTable->elementAt(1, 7)->addWidget(new WText(lexical_cast<string>(hostInfo->ncpus)));
        hostTable->elementAt(1, 8)->addWidget(new WText(lexical_cast<string>(hostInfo->maxcpus)));
        hostTable->elementAt(1, 9)->addWidget(new WText(lexical_cast<string>(hostInfo->uptime)));
        hostTable->elementAt(1, 10)->addWidget(new WText(lexical_cast<string>(hostInfo->systime)));
    }

    /// Shift and fill the CPU usage cache and model
    if ((cpuPercents = sg_get_cpu_percents(&cpuPercentsEntries)) != NULL) {
        CpuInstant cpuInstant;
        cpuInstant[Cpu::User] = cpuPercents->user;
        cpuInstant[Cpu::Kernel] = cpuPercents->kernel;
        cpuInstant[Cpu::Idle] = cpuPercents->idle;
        cpuInstant[Cpu::IoWait] = cpuPercents->iowait;
        cpuInstant[Cpu::Swap] = cpuPercents->swap;
        cpuInstant[Cpu::Nice] = cpuPercents->nice;

        CpuUsageCache.push_back(cpuInstant);
        CpuUsageCache.pop_front();

        int i = 0;
        for (std::list<CpuInstant>::const_iterator it =
             CpuUsageCache.begin(); it != CpuUsageCache.end(); ++it) {
            cpuInstant = *it;
            CpuUsageModel->setData(i, 0, cpuInstant[Cpu::User]);
            CpuUsageModel->setData(i, 1, cpuInstant[Cpu::Kernel]);
            CpuUsageModel->setData(i, 2, cpuInstant[Cpu::Idle]);
            CpuUsageModel->setData(i, 3, cpuInstant[Cpu::IoWait]);
            CpuUsageModel->setData(i, 4, cpuInstant[Cpu::Swap]);
            CpuUsageModel->setData(i, 5, cpuInstant[Cpu::Nice]);
            CpuUsageModel->setData(i, 6, i);
            ++i;
        }
    }


    /// Shift and fill the memory usage cache and model
    if(((memStats = sg_get_mem_stats(&memStatsEntries)) != NULL)) {
        MemoryInstant memoryInstant;
        memoryInstant[Memory::Total] = 100.0;
        memoryInstant[Memory::Free] = 100.0 * memStats->free / memStats->total;
        memoryInstant[Memory::Used] = 100.0 * memStats->used / memStats->total;
        memoryInstant[Memory::Cache] = 100.0 * memStats->cache / memStats->total;

        MemoryUsageCache.push_back(memoryInstant);
        MemoryUsageCache.pop_front();

        MemoryUsageModel->setHeaderData(
                    0, WString::fromUTF8("{1} {2}")
                    .arg(Utility::CalculateSize(memStats->total))
                    .arg(tr("system-monitor-memory-stats-total")));
        MemoryUsageModel->setHeaderData(
                    1, WString::fromUTF8("{1} ({2}%) {3}")
                    .arg(Utility::CalculateSize(memStats->free))
                    .arg((wformat(L"%.1f") % memoryInstant[Memory::Free]).str())
                .arg(tr("system-monitor-memory-stats-free"))
                );
        MemoryUsageModel->setHeaderData(
                    2, WString::fromUTF8("{1} ({2}%) {3}")
                    .arg((Utility::CalculateSize(memStats->used)))
                    .arg((wformat(L"%.1f") % memoryInstant[Memory::Used]).str())
                .arg(tr("system-monitor-memory-stats-used"))
                );
        MemoryUsageModel->setHeaderData(
                    3, WString::fromUTF8("{1} ({2}%) {3}")
                    .arg(Utility::CalculateSize(memStats->cache))
                    .arg((wformat(L"%.1f") % memoryInstant[Memory::Cache]).str())
                .arg(tr("system-monitor-memory-stats-cache"))
                );

        int i = 0;
        for (std::list<MemoryInstant>::const_iterator it =
             MemoryUsageCache.begin(); it != MemoryUsageCache.end(); ++it) {
            memoryInstant = *it;
            MemoryUsageModel->setData(i, 0, memoryInstant[Memory::Total]);
            MemoryUsageModel->setData(i, 1, memoryInstant[Memory::Free]);
            MemoryUsageModel->setData(i, 2, memoryInstant[Memory::Used]);
            MemoryUsageModel->setData(i, 3, memoryInstant[Memory::Cache]);
            MemoryUsageModel->setData(i, 4, i);
            ++i;
        }
    }


    /// Shift and fill the swap usage cache and model
    if(((swapStats = sg_get_swap_stats(&swapStatsEntries)) != NULL)) {
        SwapInstant swapInstant;
        swapInstant[Swap::Total] = 100.0;
        swapInstant[Swap::Used] = 100.0 * swapStats->used / swapStats->total;
        swapInstant[Swap::Free] = 100.0 * swapStats->free / swapStats->total;

        SwapUsageCache.push_back(swapInstant);
        SwapUsageCache.pop_front();

        SwapUsageModel->setHeaderData(
                    0, WString::fromUTF8("{1} {2}")
                    .arg(Utility::CalculateSize(swapStats->total))
                    .arg(tr("system-monitor-swap-stats-total")));
        SwapUsageModel->setHeaderData(
                    1, WString::fromUTF8("{1} ({2}%) {3}")
                    .arg((Utility::CalculateSize(swapStats->used)))
                    .arg((wformat(L"%.1f") % (!isnan(swapInstant[Swap::Used]) ? swapInstant[Swap::Used] : 0.0)).str())
                .arg(tr("system-monitor-swap-stats-used"))
                );
        SwapUsageModel->setHeaderData(
                    2, WString::fromUTF8("{1} ({2}%) {3}")
                    .arg(Utility::CalculateSize(swapStats->free))
                    .arg((wformat(L"%.1f") % (!isnan(swapInstant[Swap::Free]) ? swapInstant[Swap::Free] : 0.0)).str())
                .arg(tr("system-monitor-swap-stats-free"))
                );

        int i = 0;
        for (std::list<SwapInstant>::const_iterator it =
             SwapUsageCache.begin(); it != SwapUsageCache.end(); ++it) {
            swapInstant = *it;
            SwapUsageModel->setData(i, 0, swapInstant[Swap::Total]);
            SwapUsageModel->setData(i, 1, swapInstant[Swap::Used]);
            SwapUsageModel->setData(i, 2, swapInstant[Swap::Free]);
            SwapUsageModel->setData(i, 3, i);
            ++i;
        }
    }


    /// Shift and fill the virtual memory usage cache and model
    if (memStatsEntries > 0 && swapStatsEntries > 0) {
        unsigned long long total;
        unsigned long long used;
        unsigned long long free;

        if (!isnan(100.0 * swapStats->total / swapStats->total))
            total = memStats->total + swapStats->total;
        else
            total = memStats->total;

        if (!isnan(100.0 * swapStats->used / swapStats->total))
            used = memStats->used + swapStats->used;
        else
            used = memStats->used;

        if (!isnan(100.0 * swapStats->free / swapStats->total))
            free = memStats->free + swapStats->free;
        else
            free = memStats->free;


        VirtualMemoryInstant virtualMemoryInstant;
        virtualMemoryInstant[VirtualMemory::Total] = 100.0;
        virtualMemoryInstant[VirtualMemory::Used] = 100.0 * used / total;
        virtualMemoryInstant[VirtualMemory::Free] = 100.0 * free / total;

        VirtualMemoryUsageCache.push_back(virtualMemoryInstant);
        VirtualMemoryUsageCache.pop_front();

        VirtualMemoryUsageModel->setHeaderData(
                    0, WString::fromUTF8("{1} {2}")
                    .arg(Utility::CalculateSize(total))
                    .arg(tr("system-monitor-virtual-memory-stats-total")));
        VirtualMemoryUsageModel->setHeaderData(
                    1, WString::fromUTF8("{1} ({2}%) {3}")
                    .arg((Utility::CalculateSize(used)))
                    .arg((wformat(L"%.1f") % virtualMemoryInstant[VirtualMemory::Used]).str())
                .arg(tr("system-monitor-virtual-memory-stats-used"))
                );
        VirtualMemoryUsageModel->setHeaderData(
                    2, WString::fromUTF8("{1} ({2}%) {3}")
                    .arg(Utility::CalculateSize(free))
                    .arg((wformat(L"%.1f") % virtualMemoryInstant[VirtualMemory::Free]).str())
                .arg(tr("system-monitor-virtual-memory-stats-free"))
                );

        int i = 0;
        for (std::list<VirtualMemoryInstant>::const_iterator it =
             VirtualMemoryUsageCache.begin(); it != VirtualMemoryUsageCache.end(); ++it) {
            virtualMemoryInstant = *it;
            VirtualMemoryUsageModel->setData(i, 0, virtualMemoryInstant[VirtualMemory::Total]);
            VirtualMemoryUsageModel->setData(i, 1, virtualMemoryInstant[VirtualMemory::Used]);
            VirtualMemoryUsageModel->setData(i, 2, virtualMemoryInstant[VirtualMemory::Free]);
            VirtualMemoryUsageModel->setData(i, 3, i);
            ++i;
        }
    }


    /// Get the disk info
    DiskInfoDiv->clear();

    size_t diskTotalRead = 0;
    size_t diskTotalWrite = 0;

    WTable *diskTable = new WTable(DiskInfoDiv);
    diskTable->setStyleClass("table table-hover");
    diskTable->setHeaderCount(1, Orientation::Horizontal);

    diskTable->elementAt(0, 0)->addWidget(new WText(tr("system-monitor-disk-io-stats-disk-name")));
    diskTable->elementAt(0, 1)->addWidget(new WText(tr("system-monitor-disk-io-stats-read-bytes")));
    diskTable->elementAt(0, 2)->addWidget(new WText(tr("system-monitor-disk-io-stats-write-bytes")));
    diskTable->elementAt(0, 3)->addWidget(new WText(tr("system-monitor-disk-io-stats-systime")));

    if ((diskIoStats = sg_get_disk_io_stats_diff(&diskIoStatsEntries)) != NULL) {
        for (size_t i = 0; i < diskIoStatsEntries; ++i) {
            diskTable->elementAt((int)i + 1, 0)->addWidget(new WText(lexical_cast<string>(diskIoStats->disk_name)));
            diskTable->elementAt((int)i + 1, 1)->addWidget(new WText(WString(L"{1}")
                                                                     .arg(Utility::CalculateSize(diskIoStats->read_bytes))));
            diskTable->elementAt((int)i + 1, 2)->addWidget(new WText(WString(L"{1}")
                                                                     .arg(Utility::CalculateSize(diskIoStats->write_bytes))));
            diskTable->elementAt((int)i + 1, 3)->addWidget(new WText(lexical_cast<string>((long)diskIoStats->systime)));

            diskTotalRead += diskIoStats->read_bytes;
            diskTotalWrite += diskIoStats->write_bytes;

            ++diskIoStats;
        }

        diskTable->elementAt((int)diskIoStatsEntries + 1, 0)->addWidget(new WText(tr("system-monitor-disk-io-stats-total")));
        diskTable->elementAt((int)diskIoStatsEntries + 1, 1)->addWidget(new WText(WString(L"{1}")
                                                                                  .arg(Utility::CalculateSize(diskTotalRead))));
        diskTable->elementAt((int)diskIoStatsEntries + 1, 2)->addWidget(new WText(WString(L"{1}")
                                                                                  .arg(Utility::CalculateSize(diskTotalWrite))));
        diskTable->elementAt((int)diskIoStatsEntries + 1, 3)->addWidget(new WText("-"));
    }

    /// Get the netowrk info
    NetworkInfoDiv->clear();

    size_t networkTotalRx = 0;
    size_t networkTotalTx = 0;
    size_t networkTotalPacketsIn = 0;
    size_t networkTotalPacketsOut = 0;
    size_t networkTotalErrorsIn = 0;
    size_t networkTotalErrorsOut = 0;
    size_t networkTotalCollisions = 0;

    WTable *networkTable = new WTable(NetworkInfoDiv);
    networkTable->setStyleClass("table table-hover");
    networkTable->setHeaderCount(1, Orientation::Horizontal);

    networkTable->elementAt(0, 0)->addWidget(new WText(tr("system-monitor-network-io-stats-interface_name")));
    networkTable->elementAt(0, 1)->addWidget(new WText(tr("system-monitor-network-io-stats-tx")));
    networkTable->elementAt(0, 2)->addWidget(new WText(tr("system-monitor-network-io-stats-rx")));
    networkTable->elementAt(0, 3)->addWidget(new WText(tr("system-monitor-network-io-stats-ipackets")));
    networkTable->elementAt(0, 4)->addWidget(new WText(tr("system-monitor-network-io-stats-opackets")));
    networkTable->elementAt(0, 5)->addWidget(new WText(tr("system-monitor-network-io-stats-ierrors")));
    networkTable->elementAt(0, 6)->addWidget(new WText(tr("system-monitor-network-io-stats-oerrors")));
    networkTable->elementAt(0, 7)->addWidget(new WText(tr("system-monitor-network-io-stats-collisions")));
    networkTable->elementAt(0, 8)->addWidget(new WText(tr("system-monitor-network-io-stats-systime")));

    if ((networkIoStats = sg_get_network_io_stats_diff(&networkIoStatsEntries)) != NULL) {
        for (size_t i = 0; i < networkIoStatsEntries; ++i) {
            networkTable->elementAt((int)i + 1, 0)->addWidget(new WText(lexical_cast<string>(networkIoStats->interface_name)));
            networkTable->elementAt((int)i + 1, 1)->addWidget(new WText(WString(L"{1}")
                                                                        .arg(Utility::CalculateSize(networkIoStats->tx))));
            networkTable->elementAt((int)i + 1, 2)->addWidget(new WText(WString(L"{1}")
                                                                        .arg(Utility::CalculateSize(networkIoStats->rx))));
            networkTable->elementAt((int)i + 1, 3)->addWidget(new WText(lexical_cast<string>(networkIoStats->ipackets)));
            networkTable->elementAt((int)i + 1, 4)->addWidget(new WText(lexical_cast<string>(networkIoStats->opackets)));
            networkTable->elementAt((int)i + 1, 5)->addWidget(new WText(lexical_cast<string>(networkIoStats->ierrors)));
            networkTable->elementAt((int)i + 1, 6)->addWidget(new WText(lexical_cast<string>(networkIoStats->oerrors)));
            networkTable->elementAt((int)i + 1, 7)->addWidget(new WText(lexical_cast<string>(networkIoStats->collisions)));
            networkTable->elementAt((int)i + 1, 8)->addWidget(new WText(lexical_cast<string>((long)networkIoStats->systime)));

            networkTotalTx += networkIoStats->tx;
            networkTotalRx += networkIoStats->rx;
            networkTotalPacketsIn += networkIoStats->ipackets;
            networkTotalPacketsOut += networkIoStats->opackets;
            networkTotalErrorsIn += networkIoStats->ierrors;
            networkTotalErrorsOut += networkIoStats->oerrors;
            networkTotalCollisions += networkIoStats->collisions;

            new WBreak(NetworkInfoDiv);

            ++networkIoStats;
        }

        networkTable->elementAt((int)networkIoStatsEntries + 1, 0)->addWidget(new WText(tr("system-monitor-network-io-stats-total")));
        networkTable->elementAt((int)networkIoStatsEntries + 1, 1)->addWidget(new WText(WString(L"{1}")
                                                                                        .arg(Utility::CalculateSize(networkTotalTx))));
        networkTable->elementAt((int)networkIoStatsEntries + 1, 2)->addWidget(new WText(WString(L"{1}")
                                                                                        .arg(Utility::CalculateSize(networkTotalRx))));
        networkTable->elementAt((int)networkIoStatsEntries + 1, 3)->addWidget(new WText(lexical_cast<string>(networkTotalPacketsIn)));
        networkTable->elementAt((int)networkIoStatsEntries + 1, 4)->addWidget(new WText(lexical_cast<string>(networkTotalPacketsOut)));
        networkTable->elementAt((int)networkIoStatsEntries + 1, 5)->addWidget(new WText(lexical_cast<string>(networkTotalErrorsIn)));
        networkTable->elementAt((int)networkIoStatsEntries + 1, 6)->addWidget(new WText(lexical_cast<string>(networkTotalErrorsOut)));
        networkTable->elementAt((int)networkIoStatsEntries + 1, 7)->addWidget(new WText(lexical_cast<string>(networkTotalCollisions)));
        networkTable->elementAt((int)networkIoStatsEntries + 1, 8)->addWidget(new WText("-"));

        new WBreak(NetworkInfoDiv);
    }
}
Exemplo n.º 4
0
void CSVReportSet::initForm()
{

	new WText("<SCRIPT language='JavaScript' src='/Calendar.js'></SCRIPT>",this);
	new WText("<SCRIPT language='JavaScript' src='/basic.js'></SCRIPT>", this);
	new WText("<div id='view_panel' class='panel_view'>",this);


	m_pMainTable = new WSVMainTable(this,m_formText.szMainTitle,false);

	m_pReportListTable = new WSVFlexTable(m_pMainTable->GetContentTable()->elementAt(0,0), List, m_formText.szTBTitle);
	

	if (m_pReportListTable->GetContentTable() != NULL)
	{
		m_pReportListTable->AppendColumn("",WLength(5,WLength::Percentage));
		m_pReportListTable->SetDataRowStyle("table_data_grid_item_img");

		m_pReportListTable->AppendColumn(m_formText.szColName,WLength(55,WLength::Percentage));
		m_pReportListTable->SetDataRowStyle("table_data_grid_item_text");

		m_pReportListTable->AppendColumn(m_formText.szColPeriod,WLength(20,WLength::Percentage));
		m_pReportListTable->SetDataRowStyle("table_data_grid_item_img");

		m_pReportListTable->AppendColumn(m_formText.szColEdit,WLength(20,WLength::Percentage));
		m_pReportListTable->SetDataRowStyle("table_data_grid_item_text");
	}

	addPhoneListNew();
	connect(&m_signalMapper, SIGNAL(mapped(const std::string)), this, SLOT(EditRow(const std::string)));

	if (m_pReportListTable->GetActionTable() != NULL)
	{
		
		m_pReportListTable->SetNullTipInfo(szListEmpty);

		if(m_pListReport.size() <= 0)
		{
			m_pReportListTable->ShowNullTip();
		}
		else
		{
			m_pReportListTable->HideNullTip();
		}
		
		m_pReportListTable->AddStandardSelLink(m_formText.szTipSelAll1 ,m_formText.szTipSelNone,m_formText.szTipSelInv);
		connect(m_pReportListTable->pSelAll, SIGNAL(clicked()), this, SLOT(SelAll()));
		connect(m_pReportListTable->pSelNone, SIGNAL(clicked()), this, SLOT(SelNone()));
		connect(m_pReportListTable->pSelReverse, SIGNAL(clicked()), this, SLOT(SelInvert()));


		WTable *pTbl;

		m_pReportListTable->GetActionTable()->elementAt(0,1)->setContentAlignment(AlignCenter);
		m_pReportListTable->GetActionTable()->elementAt(0,1)->setStyleClass("textbold");
		pTbl = new WTable(m_pReportListTable->GetActionTable()->elementAt(0,1));

		pTbl->setStyleClass("widthauto");
		m_pDel = new WSVButton(pTbl->elementAt(0,1),m_formText.szTipDel, "button_bg_del.png", "", false);

		if(!GetUserRight("m_reportlistDel"))
			m_pDel->hide();
		else
			m_pDel->show();

		if (m_pDel)
		{
			m_pDel->setToolTip(m_formText.szTipDel);
			connect(m_pDel , SIGNAL(clicked()),this, SLOT(BeforeDelPhone()));
		}

		m_pReportListTable->GetActionTable()->elementAt(0,2)->setContentAlignment(AlignRight);
		m_pAdd = new WSVButton(m_pReportListTable->GetActionTable()->elementAt(0,2),m_formText.szAddPhoneBut, "button_bg_add_black.png", m_formText.szTipAddNew, true);
		if(!GetUserRight("m_reportlistAdd"))
			m_pAdd->hide();
		else
			m_pAdd->show();

		if (m_pAdd)
		{
			m_pAdd->setToolTip(m_formText.szTipAddNew);
			WObject::connect(m_pAdd, SIGNAL(clicked()),"showbar();", this, SLOT(AddPhone())
				, WObject::ConnectionType::JAVASCRIPTDYNAMIC);
		}

		//隐藏按钮
		pHideBut = new WPushButton("hide button",this);
		if(pHideBut)
		{
			pHideBut->setToolTip("Hide Button");
			connect(pHideBut,SIGNAL(clicked()),this,SLOT(DelPhone()));
			pHideBut->hide();
		}
		
	}








//	new WText("\n<SCRIPT language='JavaScript' src='/basic.js'></SCRIPT>", this);
////	new WText("<SCRIPT language='JavaScript' src='/Calendar.js'></SCRIPT>", this);
//	//CMainTable * T1table = new CMainTable(this ,"统计报告");
//		
//	WTable* T1table = new WTable(this);
//	T1table->setStyleClass("t1");
//	new WText(m_formText.szMainTitle, T1table->elementAt(0,0));
//	T1table->elementAt(0,0)->setStyleClass("t1title");
//	
//
//	WTable * TitleTable = new WTable(T1table->elementAt(1,0));
//
//	TitleTable->setStyleClass("t3");
		



	//Jansion.zhou 2006-12-25
	m_pConnErr = new WText("", (WContainerWidget *)this);
	m_pConnErr->decorationStyle().setForegroundColor(Wt::red);
	m_pConnErr ->hide();



	//if(m_pReportListTable->GetContentTable() != NULL)
	//{
	//	m_pReportListTable->AppendRows("");
	//	//int NowRows = m_pReportListTable->GeDataTable()->numRows();
	//	m_pConnErr = new WText("", m_pReportListTable->AppendRowsContent(0, "","",m_formText.szConnErr));
	//	m_pConnErr->decorationStyle().setForegroundColor(Wt::red);
	//}

	
	//测试连接SVDB
	std::list<string> sectionlist;
	bool IsConn = GetIniFileSections(sectionlist, "smsconfig.ini");
	if(!IsConn)
	{
		//连接SVDB失败
		m_pConnErr ->setText(m_formText.szConnErr);
		m_pConnErr ->show();
	}





	pTranslateBtn = new WPushButton(strTranslate, this);
	connect(pTranslateBtn, SIGNAL(clicked()), this, SLOT(Translate()));	
    pTranslateBtn->setToolTip(strTranslateTip);
	pTranslateBtn->hide();

	pExChangeBtn = new WPushButton(strRefresh, this);
	connect(pExChangeBtn, SIGNAL(clicked()), this, SLOT(ExChange()));	
	pExChangeBtn->setToolTip(strRefreshTip);
	pExChangeBtn->hide();
	//翻译
	int bTrans = GetIniFileInt("translate", "translate", 0, "general.ini");
	if(bTrans == 1)
	{
		pTranslateBtn->show();
		pExChangeBtn->show();
	}
	else
	{
		pTranslateBtn->hide();
		pExChangeBtn->hide();
	}

	////主框架帮助按钮	
	//m_pHelpImg = new WImage("../icons/help.gif", (WContainerWidget *)TitleTable->elementAt( 0, 1));
	//m_pHelpImg -> hide();
	//m_pHelpImg ->setStyleClass("helpimg");
	//TitleTable->elementAt(0, 1) -> setContentAlignment(AlignTop | AlignRight);
	//WObject::connect(m_pHelpImg, SIGNAL(clicked()), this, SLOT(MainHelp()));

	//

	////接受列表
	////WTable * m_pListGeneral = new WTable(this);
	//WTable * m_pListGeneral = new WTable(T1table->elementAt(2,0));
	//
	//m_pListGeneral ->setStyleClass("t2");
	//
	////接受列表收/放显示栏
	//pHide2 = new WImage("../icons/open.gif", (WContainerWidget *)m_pListGeneral->elementAt( 0, 0));
 //   if ( pHide2 )
 //   {
 //       pHide2->decorationStyle().setCursor(WCssDecorationStyle::Pointer);
 //       WObject::connect(pHide2, SIGNAL(clicked()), this, SLOT(showSmsList2()));   
 //       pHide2->hide();        
 //   }
 //   pShow2 = new WImage("../icons/close.gif", (WContainerWidget *)m_pListGeneral->elementAt( 0, 0));
 //   if ( pShow2 )
 //   {
 //       pShow2->decorationStyle().setCursor(WCssDecorationStyle::Pointer);
 //       WObject::connect(pShow2, SIGNAL(clicked()), this, SLOT(hideSmsList2())); 
 //   }
	//m_pListGeneral->elementAt(0, 0)->setStyleClass("t2title");
	//new WText(m_formText.szTBTitle, (WContainerWidget *)m_pListGeneral->elementAt( 0, 0));

	//table2 = new WTable((WContainerWidget *)m_pListGeneral->elementAt(1,0));
	////table2 -> setStyleClass("bg_Border");
	//table2 ->setStyleClass("t3");

	//PrintDebugString("Init Old Table\n");

 //   if ( table2 )
 //   {
 //       addPhoneList(table2);
	//	connect(&m_signalMapper, SIGNAL(mapped(const std::string)), this, SLOT(EditRow(const std::string)));

	//	PrintDebugString("Init Old Table2\n");

	//	//AddGroupOperate(table2);
	//}
		
	new WText("</div>", this);

	AddJsParam("uistyle", "viewpan");
	AddJsParam("fullstyle", "true");
	AddJsParam("bGeneral", "false");
	new WText("<SCRIPT language='JavaScript' src='/Script.js'></SCRIPT>", this);

}
Exemplo n.º 5
0
void HighScoresWidget::update()
{
  clear();
  
  new WText("<h2>Hall of fame</h2>", this);
  
  int ranking = session_->findRanking();
  
  std::string yourScore;
  if (ranking == 1)
    yourScore = "Congratulations! You are currently leading the pack.";
  else {
    yourScore = "You are currently ranked number "
      + boost::lexical_cast<std::string>(ranking)
      + ". Almost there !";
  }

  WText *score = new WText("<p>" + yourScore + "</p>", this);
  score->addStyleClass("score");
  
  std::vector<User> top = session_->topUsers(20);

  WTable *table = new WTable(this);

  new WText("Rank", table->elementAt(0, 0));
  new WText("User", table->elementAt(0, 1));
  new WText("Games", table->elementAt(0, 2));
  new WText("Score", table->elementAt(0, 3));
  new WText("Last game", table->elementAt(0, 4));
  table->setHeaderCount(1);

  int formerScore = -1;
  int rank = 0;
  for (unsigned i = 0; i < top.size(); i++) {
    User u = top[i];

    if (u.score != formerScore) {
      formerScore = u.score;
      ++rank;
    }
    
    int row = table->rowCount();
    new WText(boost::lexical_cast<std::string>(rank),
	      table->elementAt(row, 0));
    new WText(u.name, table->elementAt(row, 1));
    new WText(boost::lexical_cast<std::string>(u.gamesPlayed),
	      table->elementAt(row, 2));
    new WText(boost::lexical_cast<std::string>(u.score),
	      table->elementAt(row, 3));
    if (!u.lastGame.isNull())
      new WText(u.lastGame.timeTo(WDateTime::currentDateTime())
		+ " ago", table->elementAt(row, 4));
    else
      new WText("---", table->elementAt(row, 4));
    
    if (session_->login().loggedIn() && session_->userName() == u.name)
      table->rowAt(row)->setId("self");
  }

  WText *fineprint = new WText(tr("highscore.info"), this);
  fineprint->addStyleClass("fineprint");
}
Exemplo n.º 6
0
void TrendReportFrame::initQueryTable(WSVFlexTable **pFlexTable_Add ,int nRow,std::string strTitle, WSVMainTable * pUserTable)
{
	*pFlexTable_Add = new WSVFlexTable((WContainerWidget *)pUserTable->GetContentTable()->elementAt(nRow,0), Blank, strTitle); 

	WSVFlexTable *pFlexTable = *pFlexTable_Add;



	if(pFlexTable->GetContentTable() != NULL)
	{
		//标题链接
		WTable *QueryTitleTable1 = new WTable(pFlexTable->GetContentTable()->elementAt(0,0));

		QueryTitleTable1->elementAt(0, 1)->resize(WLength(8,WLength::Percentage),0);
		WText * p2HourText = new WText("2h", QueryTitleTable1->elementAt(0, 1));
		p2HourText->setStyleClass("linktext");
		connect(p2HourText, SIGNAL(clicked()), "showbar();" ,this, SLOT(Query2HourText()) , WObject::ConnectionType::JAVASCRIPTDYNAMIC);	

		QueryTitleTable1->elementAt(0, 2)->resize(WLength(8,WLength::Percentage),0);
		WText * p4HourText = new WText("4h", QueryTitleTable1->elementAt(0, 2));
		p4HourText->setStyleClass("linktext");
		connect(p4HourText, SIGNAL(clicked()), "showbar();" ,this, SLOT(Query4HourText()) , WObject::ConnectionType::JAVASCRIPTDYNAMIC);	

		QueryTitleTable1->elementAt(0, 3)->resize(WLength(8,WLength::Percentage),0);
		WText * p8HourText = new WText("8h", QueryTitleTable1->elementAt(0, 3));
		p8HourText->setStyleClass("linktext");
		connect(p8HourText, SIGNAL(clicked()), "showbar();" ,this, SLOT(Query8HourText()) , WObject::ConnectionType::JAVASCRIPTDYNAMIC);	

		QueryTitleTable1->elementAt(0, 4)->resize(WLength(8,WLength::Percentage),0);
		WText * p1DayText = new WText("1d", QueryTitleTable1->elementAt(0, 4));
		p1DayText->setStyleClass("linktext");
		connect(p1DayText, SIGNAL(clicked()), "showbar();" ,this, SLOT(Query1DayText()) , WObject::ConnectionType::JAVASCRIPTDYNAMIC);	

		QueryTitleTable1->elementAt(0, 5)->resize(WLength(8,WLength::Percentage),0);
		WText * p3DayText = new WText("3d", QueryTitleTable1->elementAt(0, 5));
		p3DayText->setStyleClass("linktext");
		connect(p3DayText, SIGNAL(clicked()), "showbar();" ,this, SLOT(Query3DayText()) , WObject::ConnectionType::JAVASCRIPTDYNAMIC);	

		QueryTitleTable1->elementAt(0, 6)->resize(WLength(8,WLength::Percentage),0);
		WText * p5DayText = new WText("5d", QueryTitleTable1->elementAt(0, 6));
		p5DayText->setStyleClass("linktext");
		connect(p5DayText, SIGNAL(clicked()), "showbar();" ,this, SLOT(Query5DayText()) , WObject::ConnectionType::JAVASCRIPTDYNAMIC);	

		QueryTitleTable1->elementAt(0, 7)->resize(WLength(8,WLength::Percentage),0);
		WText * p1WeekText = new WText("1w", QueryTitleTable1->elementAt(0, 7));
		p1WeekText->setStyleClass("linktext");
		connect(p1WeekText, SIGNAL(clicked()), "showbar();" ,this, SLOT(Query1WeekText()) , WObject::ConnectionType::JAVASCRIPTDYNAMIC);	

		QueryTitleTable1->elementAt(0, 8)->resize(WLength(12,WLength::Percentage),0);
		WText * pCurWeekText = new WText(strWeek, QueryTitleTable1->elementAt(0, 8));
		pCurWeekText->setStyleClass("linktext");
		connect(pCurWeekText, SIGNAL(clicked()), "showbar();" ,this, SLOT(QueryCurWeekText()) , WObject::ConnectionType::JAVASCRIPTDYNAMIC);	

		QueryTitleTable1->elementAt(0, 9)->resize(WLength(8,WLength::Percentage),0);
		WText * p1MonthText = new WText("1m", QueryTitleTable1->elementAt(0, 9));
		p1MonthText->setStyleClass("linktext");
		connect(p1MonthText, SIGNAL(clicked()), "showbar();" ,this, SLOT(Query1MonthText()) , WObject::ConnectionType::JAVASCRIPTDYNAMIC);	

		QueryTitleTable1->elementAt(0, 10)->resize(WLength(8,WLength::Percentage),0);
		WText * p3MonthText = new WText("3m", QueryTitleTable1->elementAt(0, 10));
		p3MonthText->setStyleClass("linktext");
		connect(p3MonthText, SIGNAL(clicked()), "showbar();" ,this, SLOT(Query3MonthText()) , WObject::ConnectionType::JAVASCRIPTDYNAMIC);	

		QueryTitleTable1->elementAt(0, 11)->resize(WLength(8,WLength::Percentage),0);
		WText * p6MonthText = new WText("6m", QueryTitleTable1->elementAt(0, 11));
		p6MonthText->setStyleClass("linktext");
		connect(p6MonthText, SIGNAL(clicked()), "showbar();" ,this, SLOT(Query6MonthText()) , WObject::ConnectionType::JAVASCRIPTDYNAMIC);	

		QueryTitleTable1->elementAt(0, 12)->resize(WLength(12,WLength::Percentage),0);
		WText * pCurDayText = new WText(strDay, QueryTitleTable1->elementAt(0, 12));
		pCurDayText->setStyleClass("linktext");
		connect(pCurDayText, SIGNAL(clicked()), "showbar();" ,this, SLOT(QueryCurDayText()) , WObject::ConnectionType::JAVASCRIPTDYNAMIC);	

		//时间
		WTable * QueryTitleTable2 = new WTable((WContainerWidget *)pFlexTable->GetContentTable()->elementAt(1,0));
		pFlexTable->GetContentTable()->elementAt(1, 0)->setContentAlignment(AlignTop | AlignCenter);

		QueryTitleTable2->resize(WLength(100,WLength::Percentage),WLength(30,WLength::Pixel));
		TTime curTime = TTime::GetCurrentTimeEx();
		new WText(strStartTimeLabel, QueryTitleTable2->elementAt(0, 0));
		pAlertStartTime = new WLineEdit("", QueryTitleTable2->elementAt(0, 1));
		TTimeSpan ts(0,24,0,0);
		curTime -= ts;
		pAlertStartTime->setText(curTime.Format());
		pAlertStartTime->setStyleClass("input_text");
		strcpy(pAlertStartTime->contextmenu_ , "onFocus=\"calendar()\"");

		curTime = TTime::GetCurrentTimeEx();
		new WText(strEndTimeLabel, QueryTitleTable2->elementAt(0, 3));
		pAlertEndTime = new WLineEdit("", QueryTitleTable2->elementAt(0, 4));
		pAlertEndTime->setText(curTime.Format());
		pAlertEndTime->setStyleClass("input_text");
		strcpy(pAlertEndTime->contextmenu_ , "onFocus=\"calendar()\"");

		pFlexTable->ShowOrHideHelp();
		pFlexTable->HideAllErrorMsg();
	}	

	if(pFlexTable->GetActionTable()!=NULL)
	{
		WTable *pTbl;
		pTbl = new WTable(pFlexTable->GetActionTable()->elementAt(0, 1));

		WSVButton * pQueryBtn = new WSVButton(pTbl->elementAt(0,0), strQueryBtn, "button_bg_m_black.png", "", true);
		connect(pQueryBtn, SIGNAL(clicked()), "showbar();" ,this, SLOT(TrendReportQuery()) , WObject::ConnectionType::JAVASCRIPTDYNAMIC);	
	}
}
Exemplo n.º 7
0
void CSVPlanSet::InitFlexTable(std::string strTitle1, std::string strTitle2)
{
	ReceiveAddrSetTable = new WSVFlexTable(pMainTable->GetContentTable()->elementAt(1,0), List, strTitle1);

	//new WText("\n<SCRIPT language='JavaScript' src='/basic.js'></SCRIPT>", this);
	//WTable * m_pGeneral4 = new WTable(this);
	//WTable * m_pGeneral = new WTable( this );
	//m_pGeneral ->setStyleClass("t2");
    //if ( m_pGeneral )

	ReceiveAddrSetTable->SetDivId("listpan1");
	if(ReceiveAddrSetTable->GetContentTable()!=NULL)
    {
		strListHeights += "200";
		strListHeights += ",";
		strListPans += ReceiveAddrSetTable->GetDivId();
		strListPans += ",";
		strListTitles +=  ReceiveAddrSetTable->dataTitleTable->formName();
		strListTitles += ",";
		
		ReceiveAddrSetTable->AppendColumn("", WLength(5, WLength::Percentage));
		ReceiveAddrSetTable->SetDataRowStyle("table_data_grid_item_img");
		ReceiveAddrSetTable->AppendColumn(m_FormShowText.szColName, WLength(70, WLength::Percentage));
		ReceiveAddrSetTable->SetDataRowStyle("table_data_grid_item_img");
		ReceiveAddrSetTable->AppendColumn(m_FormShowText.szColMod, WLength(25, WLength::Percentage));
		ReceiveAddrSetTable->SetDataRowStyle("table_data_grid_item_text");
		
//older list table header
//		// 列表
//		ContainerReceiveAddrSetTable = new WTable((WContainerWidget *) m_pGeneral->elementAt(1,0));
//		ContainerReceiveAddrSetTable -> setStyleClass("t3");
//		ReceiveAddrSetTable = new WTable((WContainerWidget *) ContainerReceiveAddrSetTable->elementAt(0,0));
//		nullTable = new WTable((WContainerWidget *) ContainerReceiveAddrSetTable->elementAt(1, 0));
//
//		ReceiveAddrSetTable->setStyleClass("t3");
//		ReceiveAddrSetTable->setCellPadding(0);
//		ReceiveAddrSetTable->setCellSpaceing(0);
//		nullTable -> setStyleClass("t8");
//
//		// 添加表头
//		// 全选  clicked 事件处理 函数 SelAll
////		new WText(m_FormShowText.szColStatus, (WContainerWidget*)ReceiveAddrSetTable->elementAt(0, 0));
//		new WText("", (WContainerWidget*)ReceiveAddrSetTable->elementAt(0, 0));
//		new WText(m_FormShowText.szColName, (WContainerWidget*)ReceiveAddrSetTable->elementAt(0, 1));
////		new WText(m_FormShowText.szColType, (WContainerWidget*)ReceiveAddrSetTable->elementAt(0, 2));
//		new WText(m_FormShowText.szColMod, (WContainerWidget*)ReceiveAddrSetTable->elementAt(0, 2));
//		ReceiveAddrSetTable->elementAt(0, 0)->setStyleClass("t3title");
//		ReceiveAddrSetTable->elementAt(0, 1)->setStyleClass("t3title");
//		ReceiveAddrSetTable->elementAt(0, 2)->setStyleClass("t3title");
//		ReceiveAddrSetTable->elementAt(0, 3)->setStyleClass("t3title");

		updateRangeSchedule();
	}

	if(ReceiveAddrSetTable->GetActionTable()!=NULL)
	{
		ReceiveAddrSetTable->AddStandardSelLink(m_FormShowText.szTipSelAll , m_FormShowText.szTipNotSelAll, m_FormShowText.szTipInvSel );
		WObject::connect(ReceiveAddrSetTable->pSelAll, SIGNAL(clicked()), this, SLOT(SelAll()));
		WObject::connect(ReceiveAddrSetTable->pSelNone, SIGNAL(clicked()), this, SLOT(SelNone()));
		WObject::connect(ReceiveAddrSetTable->pSelReverse, SIGNAL(clicked()), this, SLOT(SelInvert()));

		WTable *pTbl;
		ReceiveAddrSetTable->GetActionTable()->elementAt(0,1)->setContentAlignment(AlignCenter);
		ReceiveAddrSetTable->GetActionTable()->elementAt(0,1)->setStyleClass("textbold");

		pTbl = new WTable(ReceiveAddrSetTable->GetActionTable()->elementAt(0,1));
		pTbl->setStyleClass("widthauto");
		WSVButton * DelBtn = new WSVButton(pTbl->elementAt(0,0),m_FormShowText.szTipDel,"button_bg_del.png",m_FormShowText.szTipDel, false);
		connect(DelBtn, SIGNAL(clicked()) ,this, SLOT(BeforeDelPlan()));

		pTbl = new WTable(ReceiveAddrSetTable->GetActionTable()->elementAt(0,2));
		ReceiveAddrSetTable->GetActionTable()->elementAt(0,2)->setContentAlignment(AlignRight);
		WSVButton * btn = new WSVButton(ReceiveAddrSetTable->GetActionTable()->elementAt(0,2),m_FormShowText.szAddRelPlanBut,"button_bg_add_black.png",m_FormShowText.szAddRelPlanBut, true);
		connect(btn, SIGNAL(clicked()), this, SLOT(AddPlan()));
	

//
		//ft = new CFlexTable();
		//ft->AddGroupOperate(m_pGeneral,m_FormShowText.szValDel);
		//ft->AddGroupAddBtn(m_pGeneral,m_FormShowText.szAddRelPlanBut);
		//WObject::connect(ft->pSelAll, SIGNAL(clicked()), this, SLOT(SelAll()));
		//WObject::connect(ft->pSelNone, SIGNAL(clicked()), this, SLOT(SelNone()));
		//WObject::connect(ft->pSelinvert, SIGNAL(clicked()), this, SLOT(SelInvert()));
  //      WObject::connect(ft->pDel , SIGNAL(clicked()) ,this, SLOT(BeforeDelPlan()));
		//WObject::connect(ft->pAdd, SIGNAL(clicked()), this, SLOT(AddPlan()));

		connect(&m_signalMapper, SIGNAL(mapped(const std::string)), this, SLOT(EditPlan(const std::string)));
		
		//ReceiveAddrSetTable->SetNullTipInfo(strSepPlanNull);


		ReceiveAddrSetTable->SetNullTipInfo(strSepPlanNull);

		if(m_pListPlan.size() <= 0)
		{
			//OutputDebugString("---------------- NO S ------------------\n");
			//OutputDebugString(("---------------- NO S"+ strSepPlanNull + " ------------------\n").c_str());
			ReceiveAddrSetTable->ShowNullTip();
		}
		else
		{
			//OutputDebugString("---------------- Yes S------------------\n");
			ReceiveAddrSetTable->HideNullTip();
		}

		//隐藏按钮
		pHideBut = new WPushButton("hide button",this);
		if(pHideBut)
		{
			pHideBut->setToolTip("Hide Button");
			connect(pHideBut,SIGNAL(clicked()),this,SLOT(DelPlan()));
			pHideBut->hide();
		}

		//隐藏按钮
		pHideBut1 = new WPushButton("hide button",this);
		if(pHideBut1)
		{
			pHideBut1->setToolTip("Hide Button");
			connect(pHideBut1,SIGNAL(clicked()),this,SLOT(DelPlan1()));
			pHideBut1->hide();
		}
	}
Exemplo n.º 8
0
void CSVAddPlan::showMainForm()
{
	
	string szMon,szThurs,szWed,szTues,szFri,szSat,szSun,szDisable,szEnable,szfrom,szTo,szAddRelPlanBut;
	//Resource
	OBJECT objRes=LoadResource("default", "localhost");  
	if( objRes !=INVALID_VALUE )
	{	
		MAPNODE ResNode=GetResourceNode(objRes);
		if( ResNode != INVALID_VALUE )
		{
			FindNodeValue(ResNode,"IDS_Time_Area_Task_Add",szAddRelPlanBut);

			FindNodeValue(ResNode,"IDS_Disable",szDisable);
			FindNodeValue(ResNode,"IDS_Enable",szEnable);
			FindNodeValue(ResNode,"IDS_Monday",szMon);
			FindNodeValue(ResNode,"IDS_Tuesday",szThurs);
			FindNodeValue(ResNode,"IDS_Wednesday",szWed);
			FindNodeValue(ResNode,"IDS_Thursday",szTues);
			FindNodeValue(ResNode,"IDS_Friday",szFri);
			FindNodeValue(ResNode,"IDS_Saturday",szSat);
			FindNodeValue(ResNode,"IDS_Sunday",szSun);
			FindNodeValue(ResNode,"IDS_From",szfrom);
			FindNodeValue(ResNode,"IDS_To",szTo);
		}
		CloseResource(objRes);
	}

	
	new WText("<SCRIPT language='JavaScript' src='/basic.js'></SCRIPT>", this);
	new WText("<div id='view_panel' class='panel_view'>", this);


OutputDebugString("----------------strUser----------------\n");
	pMainTable = new WSVMainTable(this, szTitle, true);
	if(pMainTable->pHelpImg)
	{
		connect(pMainTable->pHelpImg, SIGNAL(clicked()),this,SLOT(AddPlanHelp()));
	}
	

	AddRangeTable = new WSVFlexTable((WContainerWidget *)pMainTable->GetContentTable()->elementAt(1,0), Group, m_FormShowText.szAddReTitle);

	if (AddRangeTable->GetContentTable() != NULL)
	{
		AddRangeTable->AppendRows(m_FormShowText.szBasicAdd);

		m_pName = new WLineEdit("", AddRangeTable->AppendRowsContent(0, m_FormShowText.szRunName+"<span class =required>*</span>", m_FormShowText.szRunNameHelp, m_FormShowText.szErrorMsg));
		//m_pName -> setTextSize(50);
		m_pName->resize(WLength(300, WLength::Pixel),WLength(20, WLength::Pixel));
		m_pName->setStyleClass("input_text");
		
		new WText("", AddRangeTable->AppendRowsContent(0, "", "", m_FormShowText.szErrorMsg1));

		m_pTasklist = new CTaskList(NULL, AddRangeTable,m_FormShowText.strWeekHelp);
		/*
		m_pCombo[0] = new WComboBox(RecList->elementAt(0, 1));
		m_pCombo[0]->addItem(szEnable);
		m_pCombo[0]->addItem(szDisable);
		pFrom[0] = new WText(szfrom, RecList->elementAt(0, 2));
		m_pStart[0] = new WLineEdit("00:00", RecList->elementAt(0, 3));
		m_pStart[0]->setStyleClass("input_text");
		pTo[0] = new WText(szTo, RecList->elementAt(0, 4));
		m_pEnd[0] = new WLineEdit("23:59", RecList->elementAt(0, 5));
		m_pEnd[0]->setStyleClass("input_text");

		for (int i=1; i<7; i++)
		{
			WTable *RecList = new WTable(AddRangeTable->AppendRowsContent(0, DayType[i], "", ""));
			RecList->setStyleClass("widthauto");
			m_pCombo[i] = new WComboBox(RecList->elementAt(0, 1));
			m_pCombo[i]->addItem(szEnable);
			m_pCombo[i]->addItem(szDisable);
			pFrom[i] = new WText(szfrom, RecList->elementAt(0, 2));
			m_pStart[i] = new WLineEdit("00:00", RecList->elementAt(0, 3));
			m_pStart[i]->setStyleClass("input_text");
			pTo[i] = new WText(szTo, RecList->elementAt(0, 4));
			m_pEnd[i] = new WLineEdit("23:59", RecList->elementAt(0, 5));
			m_pEnd[i]->setStyleClass("input_text");
		}
		*/
		AddRangeTable->AppendRows(m_FormShowText.szAdvanceAdd);
		textarea = new WTextArea("", AddRangeTable->AppendRowsContent(1, m_FormShowText.szDescript, "", ""));
		textarea->resize(WLength(400, WLength::Pixel),WLength(100, WLength::Pixel));
		textarea->setStyleClass("input_text");

		AddRangeTable->ShowOrHideHelp();
		AddRangeTable->HideAllErrorMsg();
	}

	if (AddRangeTable->GetActionTable() != NULL)
	{
		WTable *pGroupOperate = new WTable(AddRangeTable->GetActionTable()->elementAt(0, 1));
		pGroupOperate->setStyleClass("widthauto");

		WSVButton * pSave = new WSVButton(pGroupOperate->elementAt(0,0),m_FormShowText.szSaveBut,"button_bg_m_black.png",m_FormShowText.szSaveBut,true);
		WObject::connect(pSave, SIGNAL(clicked()), this, SLOT(Save()));
		//pGroupOperate->elementAt(0,0)-> addWidget(pSave);

		WSVButton * pCancel = new WSVButton(pGroupOperate->elementAt(0,1),m_FormShowText.szCancelBut,"button_bg_m.png",m_FormShowText.szCancelBut,false);
		WObject::connect(pCancel, SIGNAL(clicked()), this, SLOT(Cancel()));

		//pGroupOperate->elementAt(0,0)-> addWidget(pCancel);
		//pGroupOperate->elementAt(0,0)->setContentAlignment(AlignCenter);
		
	}

	//new WText("</div>");

	//Jansion.zhou 2006-12-25
 //   WTable * TitleTable = new WTable(this);
	//TitleTable->setStyleClass("t3");
	//m_pErrMsg = new WText("", (WContainerWidget *)TitleTable->elementAt(0,0));
 //   m_pErrMsg->decorationStyle().setForegroundColor(Wt::red);
 //   m_pErrMsg->hide();

	//Jansion.zhou 2006-12-25
	////connect svdb failure WText
	//m_pConnErr = new WText("", (WContainerWidget *)TitleTable->elementAt(0, 0));
	//m_pConnErr->decorationStyle().setForegroundColor(Wt::red);
	//m_pConnErr ->hide();
	



	new WText("</div>", this);

	AddJsParam("uistyle", "viewpan");
	AddJsParam("fullstyle", "true");
	AddJsParam("bGeneral", "false");
	new WText("<SCRIPT language='JavaScript' src='/Script.js'></SCRIPT>", this);
}
VanetMobilityModelForm::VanetMobilityModelForm(WContainerWidget* parent)
{
    WTable* t = new WTable(this);
    int row = 0;

    WLabel* l = new WLabel(tr("vanet.property.form.mobility.combo"), t->elementAt(row, 0));
    mobilityCombo_ = new WComboBox(t->elementAt(row, 1));
    mobilityCombo_->addItem(tr("vanet.property.form.mobility.combo.im"));
    mobilityCombo_->addItem(tr("vanet.property.form.mobility.combo.lc"));
    mobilityCombo_->activated().connect(this, &VanetMobilityModelForm::mobilityChanged);
    l->setBuddy(mobilityCombo_);
    
    ++row;
    l = new WLabel(tr("vanet.property.form.mobility.minspeed"), t->elementAt(row, 0));
    minSpeed_ = new WDoubleSpinBox(t->elementAt(row, 1));
    minSpeed_->setDecimals(1);
    minSpeed_->setMaximum(100.0);
    minSpeed_->setMinimum(0.0);
    minSpeed_->setValue(0.0);
    l->setBuddy(minSpeed_);
    
    ++row;
    l = new WLabel(tr("vanet.property.form.mobility.maxspeed"), t->elementAt(row, 0));
    maxSpeed_ = new WDoubleSpinBox(t->elementAt(row, 1));
    maxSpeed_->setDecimals(1);
    maxSpeed_->setMaximum(300.0);
    maxSpeed_->setMinimum(0.0);
    maxSpeed_->setValue(0.0);
    l->setBuddy(maxSpeed_);
    
    ++row;
    l = new WLabel(tr("vanet.property.form.mobility.length"), t->elementAt(row, 0));
    length_ = new WDoubleSpinBox(t->elementAt(row, 1));
    length_->setDecimals(1);
    length_->setMaximum(20.0);
    length_->setMinimum(0.0);
    length_->setValue(5.0);
    l->setBuddy(length_);
    
    ++row;
    l = new WLabel(tr("vanet.property.form.mobility.maxaccel"), t->elementAt(row, 0));
    maxAccel_ = new WDoubleSpinBox(t->elementAt(row, 1));
    maxAccel_->setDecimals(1);
    maxAccel_->setMaximum(10.0);
    maxAccel_->setMinimum(0.0);
    maxAccel_->setValue(0.6);
    l->setBuddy(maxAccel_);
    
    ++row;
    l = new WLabel(tr("vanet.property.form.mobility.comfydecel"), t->elementAt(row, 0));
    comfyDecel_ = new WDoubleSpinBox(t->elementAt(row, 1));
    comfyDecel_->setDecimals(1);
    comfyDecel_->setMaximum(10.0);
    comfyDecel_->setMinimum(0.0);
    comfyDecel_->setValue(0.6);
    l->setBuddy(comfyDecel_);
    
    ++row;
    l = new WLabel(tr("vanet.property.form.mobility.jamdist"), t->elementAt(row, 0));
    jamDistance_ = new WDoubleSpinBox(t->elementAt(row, 1));
    jamDistance_->setDecimals(1);
    jamDistance_->setMaximum(5.0);
    jamDistance_->setMinimum(0.0);
    jamDistance_->setValue(2.0);
    l->setBuddy(jamDistance_);
    
    ++row;
    l = new WLabel(tr("vanet.property.form.mobility.t"), t->elementAt(row, 0));
    safeTimeHeadway_ = new WDoubleSpinBox(t->elementAt(row, 1));
    safeTimeHeadway_->setDecimals(1);
    safeTimeHeadway_->setMaximum(10.0);
    safeTimeHeadway_->setMinimum(0.0);
    safeTimeHeadway_->setValue(1.5);
    l->setBuddy(safeTimeHeadway_);
    
    ++row;
    l = new WLabel(tr("vanet.property.form.mobility.step"), t->elementAt(row, 0));
    step_ = new WDoubleSpinBox(t->elementAt(row, 1));
    step_->setDecimals(1);
    step_->setMaximum(10.0);
    step_->setMinimum(0.1);
    step_->setValue(0.9);
    l->setBuddy(step_);
    
    ++row;
    l = new WLabel(tr("vanet.property.form.mobility.stay"), t->elementAt(row, 0));
    stay_ = new WDoubleSpinBox(t->elementAt(row, 1));
    stay_->setDecimals(1);
    stay_->setMaximum(10.0);
    stay_->setMinimum(0.0);
    stay_->setValue(0.0);
    l->setBuddy(stay_);
    
    ++row;
    l = new WLabel(tr("vanet.property.form.mobility.bsave"), t->elementAt(row, 0));
    bsave_ = new WDoubleSpinBox(t->elementAt(row, 1));
    bsave_->setDecimals(1);
    bsave_->setMaximum(10.0);
    bsave_->setMinimum(0.0);
    bsave_->setValue(4.0);
    bsave_->setDisabled(true);
    l->setBuddy(bsave_);
    
    ++row;
    l = new WLabel(tr("vanet.property.form.mobility.p"), t->elementAt(row, 0));
    politeness_ = new WDoubleSpinBox(t->elementAt(row, 1));
    politeness_->setDecimals(1);
    politeness_->setMaximum(1.0);
    politeness_->setMinimum(0.0);
    politeness_->setValue(0.5);
    politeness_->setDisabled(true);
    l->setBuddy(politeness_);
    
    ++row;
    l = new WLabel(tr("vanet.property.form.mobility.athr"), t->elementAt(row, 0));
    accelThresh_ = new WDoubleSpinBox(t->elementAt(row, 1));
    accelThresh_->setDecimals(1);
    accelThresh_->setMaximum(10.0);
    accelThresh_->setMinimum(0.0);
    accelThresh_->setValue(0.2);
    accelThresh_->setDisabled(true);
    l->setBuddy(accelThresh_);
    
    ++row;
    t->elementAt(row, 0)->setColumnSpan(2);
    random_ = new WCheckBox(tr("vanet.property.form.mobility.random"), t->elementAt(row, 0));
    random_->setCheckState(Unchecked);
    
    ++row;
    t->elementAt(row, 0)->setColumnSpan(2);
    ignoreBorders_ = new WCheckBox(tr("vanet.property.form.mobility.ignoreborders"), t->elementAt(row, 0));
    ignoreBorders_->setCheckState(Unchecked);
}
void CmsSubscribers::Impl::FillDataTable(const CmsSubscribers::Impl::Table &tableType)
{
    try {
        SubscribersTableContainer->clear();

        WTable *table = new WTable(SubscribersTableContainer);
        table->setStyleClass("table table-striped table-hover");
        table->setHeaderCount(1, Orientation::Horizontal);

        table->elementAt(0, 0)->addWidget(new WText(tr("cms-subscribers-no")));
        table->elementAt(0, 1)->addWidget(new WText(tr("cms-subscribers-inbox")));
        table->elementAt(0, 2)->addWidget(new WText(tr("cms-subscribers-subscription")));
        table->elementAt(0, 3)->addWidget(new WText(tr("cms-subscribers-pending-confirm")));
        table->elementAt(0, 4)->addWidget(new WText(tr("cms-subscribers-pending-cancel")));
        table->elementAt(0, 5)->addWidget(new WText(tr("cms-subscribers-join-date")));
        table->elementAt(0, 6)->addWidget(new WText(tr("cms-subscribers-update-date")));
        table->elementAt(0, 7)->addWidget(new WText(tr("cms-subscribers-uuid")));

        result r;
        switch (tableType) {
        case Table::All:
            r = Pool::Database()->Sql()
                    << (format("SELECT inbox, uuid, subscription, pending_confirm, pending_cancel, join_date, update_date"
                               " FROM \"%1%\" ORDER BY inbox COLLATE \"en_US.UTF-8\" ASC;")
                        % Pool::Database()->GetTableName("SUBSCRIBERS")).str();
            break;
        case Table::EnFa:
            r = Pool::Database()->Sql()
                    << (format("SELECT inbox, uuid, subscription, pending_confirm, pending_cancel, join_date, update_date"
                               " FROM \"%1%\" WHERE subscription = 'en_fa' ORDER BY inbox COLLATE \"en_US.UTF-8\" ASC;")
                        % Pool::Database()->GetTableName("SUBSCRIBERS")).str();
            break;
        case Table::En:
            r = Pool::Database()->Sql()
                    << (format("SELECT inbox, uuid, subscription, pending_confirm, pending_cancel, join_date, update_date"
                               " FROM \"%1%\" WHERE subscription = 'en' ORDER BY inbox COLLATE \"en_US.UTF-8\" ASC;")
                        % Pool::Database()->GetTableName("SUBSCRIBERS")).str();
            break;
        case Table::Fa:
            r = Pool::Database()->Sql()
                    << (format("SELECT inbox, uuid, subscription, pending_confirm, pending_cancel, join_date, update_date"
                               " FROM \"%1%\" WHERE subscription = 'fa' ORDER BY inbox COLLATE \"en_US.UTF-8\" ASC;")
                        % Pool::Database()->GetTableName("SUBSCRIBERS")).str();
            break;
        case Table::Inactive:
            r = Pool::Database()->Sql()
                    << (format("SELECT inbox, uuid, subscription, pending_confirm, pending_cancel, join_date, update_date"
                               " FROM \"%1%\" WHERE subscription = 'none' ORDER BY inbox COLLATE \"en_US.UTF-8\" ASC;")
                        % Pool::Database()->GetTableName("SUBSCRIBERS")).str();
            break;
        }

        int i = 0;
        while(r.next()) {
            ++i;
            string inbox;
            string uuid;
            string subscription;
            string pending_confirm;
            string pending_cancel;
            string join_date;
            string update_date;

            r >> inbox >> uuid >> subscription >> pending_confirm >> pending_cancel >> join_date >> update_date;

            WString subscriptionTypeName;
            WString pendingConfirmTypeName;
            WString pendingCancelTypeName;

            this->GetSubscriptionTypeName(subscription, subscriptionTypeName);
            this->GetSubscriptionTypeName(pending_confirm, pendingConfirmTypeName);
            this->GetSubscriptionTypeName(pending_cancel, pendingCancelTypeName);

            WString joinDate;
            WString updateDate;

            this->GetDate(join_date, joinDate);
            this->GetDate(join_date, updateDate);

            table->elementAt(i, 0)->addWidget(new WText(WString::fromUTF8(lexical_cast<string>(i))));
            table->elementAt(i, 1)->addWidget(new WText(WString::fromUTF8(inbox)));
            table->elementAt(i, 2)->addWidget(new WText(subscriptionTypeName));
            table->elementAt(i, 3)->addWidget(new WText(pendingConfirmTypeName));
            table->elementAt(i, 4)->addWidget(new WText(pendingCancelTypeName));
            table->elementAt(i, 5)->addWidget(new WText(joinDate));
            table->elementAt(i, 6)->addWidget(new WText(updateDate));
            table->elementAt(i, 7)->addWidget(new WText(WString::fromUTF8(uuid)));
        }
    }

    catch (boost::exception &ex) {
        LOG_ERROR(boost::diagnostic_information(ex));
    }

    catch (std::exception &ex) {
        LOG_ERROR(ex.what());
    }

    catch (...) {
        LOG_ERROR(UNKNOWN_ERROR);
    }
}
Exemplo n.º 11
0
WWidget *MvcWidgets::proxyModels()
{
  WContainerWidget *result = new WContainerWidget();

  topic("WAbstractProxyModel", "WSortFilterProxyModel", result);
  addText(tr("mvc-proxymodels"), result);

  WStandardItemModel* cocktails = new WStandardItemModel(result);
  cocktails->appendRow(new WStandardItem("The Last WordLime Rickey"));
  cocktails->appendRow(new WStandardItem("Gin pahit"));
  cocktails->appendRow(new WStandardItem("Alexander"));
  cocktails->appendRow(new WStandardItem("Montgomery"));
  cocktails->appendRow(new WStandardItem("Gin Sour"));
  cocktails->appendRow(new WStandardItem("Hanky-Panky"));
  cocktails->appendRow(new WStandardItem("Gimlet"));
  cocktails->appendRow(new WStandardItem("Chocolate Soldier"));
  cocktails->appendRow(new WStandardItem("Joker"));
  cocktails->appendRow(new WStandardItem("Mickey Slim"));
  cocktails->appendRow(new WStandardItem("Long Island Iced Tea"));
  cocktails->appendRow(new WStandardItem("Old Etonian"));
  cocktails->appendRow(new WStandardItem("Lorraine"));
  cocktails->appendRow(new WStandardItem("Bijou"));
  cocktails->appendRow(new WStandardItem("Bronx"));
  cocktails->appendRow(new WStandardItem("Gin and tonic"));
  cocktails->appendRow(new WStandardItem("Pall Mall"));
  cocktails->appendRow(new WStandardItem("Gin Fizz"));
  cocktails->appendRow(new WStandardItem("French 75"));
  cocktails->appendRow(new WStandardItem("Martini"));
  cocktails->appendRow(new WStandardItem("Negroni"));
  cocktails->appendRow(new WStandardItem("20th Century"));
  cocktails->appendRow(new WStandardItem("My Fair Lady"));
  cocktails->appendRow(new WStandardItem("Gibson"));

  addText("<b>Filter regular expression: </b>", result);
  regexpFilter = new WLineEdit(result);
  regexpFilter->setText("Gi.*");
  regexpFilter->enterPressed().
    connect(this, &MvcWidgets::changeRegexp);
  WPushButton *filter = new WPushButton("Apply", result);
  filter->clicked().
    connect(this, &MvcWidgets::changeRegexp);
  
  std::vector<WAbstractItemModel*> models;
  std::vector<WString> headers;

  headers.push_back(WString("<b>Source:</b>"));
  models.push_back(cocktails);

  headers.push_back(WString("<b>Sorted proxy:</b>"));
  WSortFilterProxyModel *sortedCocktails = new WSortFilterProxyModel(this);
  sortedCocktails->setSourceModel(cocktails);
  sortedCocktails->setDynamicSortFilter(true);
  sortedCocktails->sort(0);
  models.push_back(sortedCocktails);

  headers.push_back(WString("<b>Filtered proxy:</b>"));
  filteredCocktails = new WSortFilterProxyModel(this);
  filteredCocktails->setSourceModel(cocktails);
  filteredCocktails->setDynamicSortFilter(true);
  filteredCocktails->setFilterKeyColumn(0);
  filteredCocktails->setFilterRole(Wt::DisplayRole);
  filteredCocktails->setFilterRegExp(regexpFilter->text());
  models.push_back(filteredCocktails);

  headers.push_back(WString("<b>Sorted and filtered proxy:</b>"));
  filteredSortedCocktails = new WSortFilterProxyModel(this);
  filteredSortedCocktails->setSourceModel(cocktails);
  filteredSortedCocktails->setDynamicSortFilter(true);
  filteredSortedCocktails->setFilterKeyColumn(0);
  filteredSortedCocktails->setFilterRole(Wt::DisplayRole);
  filteredSortedCocktails->setFilterRegExp(regexpFilter->text());
  filteredSortedCocktails->sort(0);
  models.push_back(filteredSortedCocktails);

  WTable *layout = new WTable(result);

  for (unsigned i = 0; i < headers.size(); ++i) {
    layout->columnAt(i)->setWidth(WLength(25, WLength::Percentage));
    layout->elementAt(0, i)->setPadding(4);
    layout->elementAt(0, i)->setContentAlignment(AlignCenter);

    addText(headers[i], layout->elementAt(0, i));
    new WBreak(layout->elementAt(0, i));

    WSelectionBox *view = new WSelectionBox(layout->elementAt(0, i));
    view->setModel(models[i]);
    view->setVerticalSize(cocktails->rowCount());
    view->resize(WLength(90, WLength::Percentage), WLength::Auto);
  }

  return result;
}
Exemplo n.º 12
0
//添加栏目
void WSPopTable::AppendRows(std::string strRowName)
{
	int iLast = pFirstTable->numRows();
	iLast++;

	//RowTitle
	WTable * pTitleTable = new WTable((WContainerWidget *)pFirstTable->elementAt(iLast,0));
	pTitleTable->setStyleClass("padding_5");
	pTitleTable->resize(WLength(100,WLength::Percentage),WLength());
	pTitleTable->elementAt(0,0)->setStyleClass("textbold");
	pTitleText = new WText(strRowName, pTitleTable->elementAt(0,0));

	//Help
	if(bHelp)
	{
		pTitleTable->elementAt(0, 1)->setContentAlignment(AlignRight|AlignTop);
		pHelpImg = new WImage("/Images/help.png","", pTitleTable->elementAt(0, 1));
		pHelpImg->setStyleClass("hand");
	}

	//RowContent
	iLast++;
	pFirstTable->elementAt(iLast,0)->setStyleClass("padding_2");
	
	WTable * pRowContentTable = new WTable((WContainerWidget *)pFirstTable->elementAt(iLast, 0));
	
	pRowContentTable->resize(WLength(100,WLength::Percentage),WLength());
	
	//top
	ShowTop(pRowContentTable);

	//content
	pRowContentTable->elementAt(1, 0)->setStyleClass("pop_table_mid_l");	
	
	WTable * pReturnTable = new WTable((WContainerWidget *)pRowContentTable->elementAt(1, 1));
	
	pReturnTable->resize(WLength(100,WLength::Percentage),WLength());
	pReturnTable->setStyleClass("bgcolor");

	//
	pReturnTable->elementAt(0, 0)->setStyleClass("padding_5");
	m_pListContentTable.push_back(new WTable((WContainerWidget *)pReturnTable->elementAt(0, 0)));

	//分隔线
	pReturnTable->elementAt(1,0)->setStyleClass("padding_5");
	WTable * pLineTable = new WTable((WContainerWidget *)pReturnTable->elementAt(1, 0));
	pLineTable->resize(WLength(100,WLength::Percentage), WLength());
	pLineTable->elementAt(0, 0)->setStyleClass("table_data_input_space");
	new WImage("/Images/space.gif","",pLineTable->elementAt(0, 0));
	
	//ActionTable
	pReturnTable->elementAt(2,0)->setStyleClass("padding_2");
	m_pListActionTable.push_back(new WTable((WContainerWidget *)pReturnTable->elementAt(2,0)));

	pRowContentTable->elementAt(1, 2)->setStyleClass("pop_table_mid_r");
	
	//bottom
	ShowBottom(pRowContentTable);
}