void BasePage::printSeries(const Dbo::collection<Dbo::ptr<Seria> >& listseries){ WTable *seriaTable = new WTable(); seriaTable->setHeaderCount(1); seriaTable->setStyleClass("tablestyle"); seriaTable->elementAt(0, 0)->addWidget(new WText("<p align='left'> # </p>")); seriaTable->elementAt(0, 1)->addWidget(new WText("<p align='left'> Name of seria </p>")); seriaTable->elementAt(0, 2)->addWidget(new WText("<p align='left'> Number of books </p>")); _pagecontent->addWidget(seriaTable); int row=1; for (Dbo::collection<Dbo::ptr<Seria> >::const_iterator i = listseries.begin(); i != listseries.end(); ++i){ Dbo::ptr<Seria> Seria = *i; seriaTable->setStyleClass("tablestyle th,td,tr"); //headers seriaTable->elementAt(row, 0) ->addWidget(new WText(WString::fromUTF8("{1}") .arg(row))); //genre seriaTable->elementAt(row, 1) ->addWidget(new WText(WString::fromUTF8(Seria.get()->seria))); //num of books in seria seriaTable->elementAt(row, 2) ->addWidget(new WText(WString::fromUTF8("{1}") .arg((Seria.get()->numOfBooks)))); _pagecontent->addWidget(seriaTable); row++; } }
void BasePage::printAuthors(const Dbo::collection<Dbo::ptr<Author> >& listauthors){ WTable *authTable = new WTable(); authTable->setHeaderCount(1); authTable->setStyleClass("tablestyle"); authTable->elementAt(0, 0)->addWidget(new WText("<p align='left'> # </p>")); authTable->elementAt(0, 1)->addWidget(new WText("<p align='left'> Full name or pseudo </p>")); authTable->elementAt(0, 2)->addWidget(new WText("<p align='left'> Years of life </p>")); _pagecontent->addWidget(authTable); int row=1; for (Dbo::collection<Dbo::ptr<Author> >::const_iterator i = listauthors.begin(); i != listauthors.end(); ++i){ Dbo::ptr<Author> Author = *i; authTable->setStyleClass("tablestyle th,td,tr"); //headers authTable->elementAt(row, 0) ->addWidget(new WText(WString::fromUTF8("{1}") .arg(row))); //name authTable->elementAt(row, 1) ->addWidget(new WText(WString::fromUTF8(Author.get()->name))); //authors authTable->elementAt(row, 2) ->addWidget(new WText(WString::fromUTF8("{1}") .arg((Author.get()->years)))); _pagecontent->addWidget(authTable); row++; } }
/*void BasePage::addAuthor(){ WContainerWidget *container1 = new WContainerWidget(); Wt::WTemplate *r = new Wt::WTemplate(Wt::WString::tr("addAuthorForm")); WLineEdit *editName = new WLineEdit(container1); editName->setPlaceholderText("name"); r->bindWidget("name", editName); WLineEdit *editYears = new WLineEdit(container1); editYears->setPlaceholderText("years"); r->bindWidget("years", editYears); WPushButton *button = new WPushButton("Add author", container1); button->setMargin(10, Top | Bottom); button->clicked().connect(std::bind([=] () {BookManager am; am.addAuthor("123","2016"); })); r->bindWidget("button", button); _pagecontent->addWidget(r); }*/ void BasePage::addMark(const Dbo::collection<Dbo::ptr<Book> >& listaddmark){ WTable *table = new WTable(); table->setHeaderCount(1); table->setStyleClass("tablestyle"); table->elementAt(0, 0)->addWidget(new WText("<p align='left'> # </p>")); table->elementAt(0, 1)->addWidget(new WText("<p align='left'> Title of book </p>")); table->elementAt(0, 2)->addWidget(new WText("<p align='left'> Author </p>")); table->elementAt(0, 3)->addWidget(new WText("<p align='left'> Genre </p>")); table->elementAt(0, 4)->addWidget(new WText("<p align='left'> Add your mark </p>")); _pagecontent->addWidget(table); int row=1; for (Dbo::collection<Dbo::ptr<Book> >::const_iterator i = listaddmark.begin(); i != listaddmark.end(); ++i){ Dbo::ptr<Book> book = *i; table->setStyleClass("tablestyle th,td,tr"); //headers table->elementAt(row, 0) ->addWidget(new WText(WString::fromUTF8("{1}") .arg(row))); //titles table->elementAt(row, 1) ->addWidget(new WText(WString::fromUTF8("{1}") .arg(book.get()->title))); //authors table->elementAt(row, 2) ->addWidget(new WText(WString::fromUTF8("{1}") .arg((book.get()->author.get()->name)))); //genres table->elementAt(row, 3) ->addWidget(new WText(WString::fromUTF8("{1}") .arg((book.get()->genre.get()->genre)))); //add mark WLineEdit *editAddMark = new WLineEdit(table->elementAt(row,4)); editAddMark->setPlaceholderText("Add mark"); table->elementAt(row, 4) ->addWidget(editAddMark); table->elementAt(row, 4) ->addWidget(new WText("<br></br>")); WPushButton *button = new WPushButton("Add mark", table->elementAt(row,4)); button->setMargin(10, Top | Bottom); table->elementAt(row, 4) ->addWidget(button); /*button->clicked().connect(std::bind([] ( Dbo::ptr<Book> book) { BookManager bm; std::cout<<book.get()->title; int curMark=book.get()->mark; int curNumMarks=book.get()->numMarks; bm.refreshRate(book.get()->id, curMark+5, curNumMarks+1, session); },*i ));*/ row++; _pagecontent->addWidget(table); } }
void BasePage::printTop10( const Dbo::collection<Dbo::ptr<Book> >& top10){ //setContentText("top10"); // # creating table WTable *table = new WTable(); table->setHeaderCount(1); table->setStyleClass("tablestyle"); table->elementAt(0, 0)->addWidget(new WText("<p align='left'> # </p>")); table->elementAt(0, 1)->addWidget(new WText("<p align='left'> Title of book </p>")); table->elementAt(0, 2)->addWidget(new WText("<p align='left'> Author </p>")); table->elementAt(0, 3)->addWidget(new WText("<p align='left'> Genre </p>")); table->elementAt(0, 4)->addWidget(new WText("<p align='left'> Mark </p>")); _pagecontent->addWidget(table); int row=1; for (Dbo::collection<Dbo::ptr<Book> >::const_iterator i = top10.begin(); i != top10.end(); ++i){ Dbo::ptr<Book> Book = *i; table->setStyleClass("tablestyle th,td,tr"); //headers table->elementAt(row, 0) ->addWidget(new WText(WString::fromUTF8("{1}") .arg(row))); //titles table->elementAt(row, 1) ->addWidget(new WText(WString::fromUTF8("{1}") .arg(Book.get()->title))); //authors table->elementAt(row, 2) ->addWidget(new WText(WString::fromUTF8("{1}") .arg((Book.get()->author.get()->name)))); //genres table->elementAt(row, 3) ->addWidget(new WText(WString::fromUTF8("{1}") .arg((Book.get()->genre.get()->genre)))); //marks table->elementAt(row, 4) ->addWidget(new WText(WString::fromUTF8("{1}") .arg((Book.get()->mark)))); _pagecontent->addWidget(table); row++; } }
void BasePage::printGenres(const Dbo::collection<Dbo::ptr<Genre> >& listgenres){ WTable *genreTable = new WTable(); genreTable->setHeaderCount(1); genreTable->setStyleClass("tablestyle"); genreTable->elementAt(0, 0)->addWidget(new WText("<p align='left'> # </p>")); genreTable->elementAt(0, 1)->addWidget(new WText("<p align='left'> Types og genres </p>")); _pagecontent->addWidget(genreTable); int row=1; for (Dbo::collection<Dbo::ptr<Genre> >::const_iterator i = listgenres.begin(); i != listgenres.end(); ++i){ Dbo::ptr<Genre> Genre = *i; genreTable->setStyleClass("tablestyle th,td,tr"); //headers genreTable->elementAt(row, 0) ->addWidget(new WText(WString::fromUTF8("{1}") .arg(row))); //genre genreTable->elementAt(row, 1) ->addWidget(new WText(WString::fromUTF8(Genre.get()->genre))); _pagecontent->addWidget(genreTable); row++; } }
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); } }
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"); }
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); } }