void SearchEditor::onLoad() { EditorBase::onLoad(); String path = utils::makeFilePath(utils::makeFolderPath(g_componentsPath, _S("search")), _S("search_editor.xsl")); shared_ptr<XMLStylesheet> stylesheet(OS_NEW XMLStylesheet()); // Inizializza le funzioni del template getPage()->initStylesheet(stylesheet); // Carica l'xsl if(stylesheet->parseFile(path)) { // URGENT devo per forza creare un documento? // Se il secondo parametro della XSLControl nullptr non crea il controllo, // e non posso passare una "getDocument()" perch se una nuova istanza nullptr pure lui... shared_ptr<XMLDocument> document(OS_NEW XMLDocument()); shared_ptr<XMLNode> root = document->create(OS_MODULES_SEARCH_ROOT); shared_ptr<HtmlXSLControl> templ(OS_NEW HtmlXSLControl(stylesheet, document)); templ->addChildParam(m_globalParams); templ->addChildParam(m_showParams); templ->addChildParam(m_directRun); templ->addChildParam(m_allowRss); templ->addChildParam(m_rssDescription); templ->addChildParam(m_rssBody); getControls()->add(templ); } }
bool testXslt() { printf("######### XSLT Sheet ############\n"); Inkscape::URI xsltSheetUri(xslpath); Inkscape::IO::UriInputStream xsltSheetIns(xsltSheetUri); Inkscape::IO::XsltStyleSheet stylesheet(xsltSheetIns); xsltSheetIns.close(); Inkscape::URI sourceUri(xmlpath); Inkscape::IO::UriInputStream xmlIns(sourceUri); printf("######### XSLT Input ############\n"); Inkscape::URI destUri("test.html"); Inkscape::IO::UriOutputStream xmlOuts(destUri); Inkscape::IO::XsltInputStream xsltIns(xmlIns, stylesheet); pipeStream(xsltIns, xmlOuts); xsltIns.close(); xmlOuts.close(); printf("######### XSLT Output ############\n"); Inkscape::IO::UriInputStream xmlIns2(sourceUri); Inkscape::URI destUri2("test2.html"); Inkscape::IO::UriOutputStream xmlOuts2(destUri2); Inkscape::IO::XsltOutputStream xsltOuts(xmlOuts2, stylesheet); pipeStream(xmlIns2, xsltOuts); xmlIns2.close(); xsltOuts.close(); return true; }
int main( int argc, char *argv[] ) { QApplication application( argc, argv ); // Stylesheet QFile stylesheet( ":/SystemMenu/BorderlessWindow.css" ); if ( stylesheet.open( QFile::ReadOnly ) ) { QString styleSheet = stylesheet.readAll(); application.setStyleSheet( styleSheet ); } // Font QFont mainFont = application.font(); mainFont.setStyleStrategy( QFont::PreferAntialias ); application.setFont( mainFont ); // Background color // This is only for WinApi window, Qt widgets use BorderlessWindow.css stylesheet HBRUSH windowBackground = CreateSolidBrush( RGB( 255, 255, 255 ) ); // Create window BorderlessWindow window( &application, windowBackground, 100, 100, 1024, 768 ); window.setMinimumSize( 800, 600 ); // Launch application.exec(); }
VisualBoard::VisualBoard(QWidget *parent, int inverted) : QWidget(parent),forcedMove(false) { gridLayout=new QGridLayout(this); VisualBoardSquare *square; estadoActual=WAITING_SOURCE; for(int fila=0;fila<BOARD_SIZE;fila++) for(int columna=0;columna<BOARD_SIZE;columna++) { square= squares[fila][columna]=new(std::nothrow) VisualBoardSquare(fila,columna); QString color; ((fila%2==0&&columna%2==0)||(fila%2!=0&&columna%2!=0))? color="red":color="black"; square->setProperty("color",color); if(inverted)gridLayout->addWidget(square, BOARD_SIZE-fila-1, BOARD_SIZE-columna-1); else gridLayout->addWidget(square,fila,columna); } progressDialogWaitingOponent=new QProgressDialog( tr("Esperando Movimiento del oponente"),"",0,0,this ); progressDialogWaitingOponent->setCancelButton(nullptr); progressDialogWaitingOponent->setWindowFlags(Qt::Window | Qt::CustomizeWindowHint); QFile stylesheet(":style/buttonStyle.css"); stylesheet.open(QIODevice::ReadOnly); QTextStream ts(&stylesheet); setStyleSheet(ts.readAll()); }
std::auto_ptr<Stylesheet> compile(SAX::InputSource<std::string>& source) { error_ = ""; std::auto_ptr<CompiledStylesheet> stylesheet(new CompiledStylesheet()); StylesheetParser parser; CompilationContext context(parser, *stylesheet.get()); StylesheetHandler stylesheetHandler(context); parser.setContentHandler(stylesheetHandler); //parser.setErrorHandler(*this); //if(entityResolver_) // parser.setEntityResolver(*entityResolver_); try { parser.parse(source); } // try catch(std::exception& ex) { error_ = ex.what(); //std::cerr << "Compilation Failed : " << ex.what() << std::endl; stylesheet.reset(); } // catch return std::auto_ptr<Stylesheet>(stylesheet.release()); } // compile
void CSSMutableStyleDeclaration::addSubresourceStyleURLs(ListHashSet<KURL>& urls) { CSSStyleSheet* sheet = static_cast<CSSStyleSheet*>(stylesheet()); size_t size = m_properties.size(); for (size_t i = 0; i < size; ++i) m_properties[i].value()->addSubresourceStyleURLs(urls, sheet); }
void WebKitCSSKeyframesRule::setName(const String& name) { m_name = name; // Since the name is used in the keyframe map list in CSSStyleSelector, we need // to recompute the style sheet to get the updated name. stylesheet()->styleSheetChanged(); }
QString getStylesheet(QString location) { QFile stylesheet(location); if (stylesheet.open(QFile::ReadOnly)) { QString styleSheet = stylesheet.readAll(); return styleSheet; } return ""; }
void MainWindow::loadStyle() { QDir::setCurrent(MainWindow::appPath); // make sure we are in the app's dir QFile style("style.css"); if(!style.open(QIODevice::ReadOnly | QIODevice::Text)) { qDebug() << "[app] could not open stylesheet"; return; } QString stylesheet(style.readAll()); qApp->setStyleSheet(stylesheet); }
void CSSMediaRule::deleteRule(unsigned index, ExceptionCode& ec) { if (index >= m_lstCSSRules->length()) { // INDEX_SIZE_ERR: Raised if the specified index does not correspond to a // rule in the media rule list. ec = INDEX_SIZE_ERR; return; } m_lstCSSRules->deleteRule(index); // stylesheet() can only return 0 for computed style declarations. stylesheet()->styleSheetChanged(); }
QwtGraphFrame::QwtGraphFrame(QWidget *parent) : QwtPlot(parent) { QFile stylesheet("/home/pi/qt/SmartKegerator/qwtStyle.css"); stylesheet.open(QFile::ReadOnly); QString styleString(stylesheet.readAll()); this->setStyleSheet(styleString); curve = new QwtPlotCurve(); //data = new QwtPointArrayData(8igv `); curve->setSamples(data); curve->attach(this); }
int main(int argc, char* argv[]) { QApplication app(argc, argv); QtInterfaceInspector core; ProcessListDialog dialog; QObject::connect(&dialog, &ProcessListDialog::processChosen, &core, &QtInterfaceInspector::attachTo); QObject::connect(&dialog, &ProcessListDialog::close, &app, &QApplication::quit); QFile stylesheet(":/qdarkstyle/style.qss"); if (!stylesheet.open(QFile::ReadOnly | QFile::Text)) qWarning() << "[QII]" << "Failed to open style.qss"; dialog.setStyleSheet(QTextStream(&stylesheet).readAll()); dialog.show(); return app.exec(); }
void Settings::SetCurrentUserStyle(const QString& stylesheet_path) { QString stylesheet_contents; if (!stylesheet_path.isEmpty() && AreUserStylesEnabled()) { // Load custom user stylesheet QFile stylesheet(stylesheet_path); if (stylesheet.open(QFile::ReadOnly)) stylesheet_contents = QString::fromUtf8(stylesheet.readAll().data()); } qApp->setStyleSheet(stylesheet_contents); GetQSettings().setValue(QStringLiteral("userstyle/path"), stylesheet_path); }
int main(int argc, char* argv[]) { QApplication::setStyle("fusion"); QApplication* application = new QApplication(argc, argv); bool dbExists = QFile("horizon.db").exists(); DRMSetupWizard* wiz = new DRMSetupWizard(); #ifndef Q_OS_WIN // dynamic loading of the icon under Linux/UNIX application->setWindowIcon(QIcon(":/SystemMenu/Icons/Horizon.ico")); #endif // Global stylesheet QFile stylesheet(":/Styles/Horizon.css"); if (stylesheet.open(QFile::ReadOnly)) { QString styleSheet = stylesheet.readAll(); application->setStyleSheet(styleSheet); } entryPoint::initSettings(*application); entryPoint::initFonts(*application); #ifdef Q_OS_WIN // Background color // This is only for WinApi window, Qt widgets use BorderlessWindow.css stylesheet HBRUSH windowBackground = CreateSolidBrush(RGB(15, 15, 15)); // Create a Win window BorderlessWindow window(application, windowBackground, 1152, 648); window.setMinimumSize(830, 550); #else // Create a Unix window UnixWindow window; window.setMinimumSize(830, 550); #endif // Launch if (!dbExists) { wiz->show(); } application->exec(); return 0; }
QString Charm::reportStylesheet( const QPalette& palette ) { QString style; QFile stylesheet( ":/Charm/report_stylesheet.sty" ); if ( stylesheet.open( QIODevice::ReadOnly | QIODevice::Text ) ) { style = stylesheet.readAll(); style.replace(QLatin1String("@header_row_background_color@"), palette.highlight().color().name()); style.replace(QLatin1String("@header_row_foreground_color@"), palette.highlightedText().color().name()); style.replace(QLatin1String("@alternate_row_background_color@"), palette.alternateBase().color().name()); style.replace(QLatin1String("@event_attributes_row_background_color@"), palette.midlight().color().name()); if ( style.isEmpty() ) { qWarning() << "reportStylesheet: default style sheet is empty, too bad"; } } else { qCritical() << "reportStylesheet: cannot load report style sheet:" << stylesheet.errorString(); } return style; }
bool Core::applyStylesheet(QDir &themeDir) { QString themeDirPath = themeDir.absolutePath(); QFile stylesheet(themeDirPath + "/stylesheet.qss"); if (!stylesheet.open(QFile::ReadOnly)) { msg("[" PLUGIN_NAME "] Unable to load stylesheet file.\n"); return false; } QString data = stylesheet.readAll(); preprocessStylesheet(data, themeDirPath); qApp->setStyleSheet(data); request_refresh(IWID_ALL); msg("[" PLUGIN_NAME "] Skin file successfully applied!\n"); return true; }
int main(int argc, char *argv[]) { QApplication::setStyle(new QCommonStyle); QApplication a(argc, argv); QFile stylesheet("../UXDesign/StyleSheet.qss"); if (!stylesheet.open(QFile::ReadOnly)) return 0; a.setStyleSheet(stylesheet.readAll()); stylesheet.close(); MainWindow w; w.show(); QFontDatabase database; qDebug() << database.families(); return a.exec(); }
EntityInViewer::EntityInViewer(Model& model, Level* level, EntityInLevel* entity, QWidget* parent):QWidget(parent),entity_(entity),model_(model), level_(level){ line_ = new QLineEdit(this); layout_ = new QHBoxLayout(this); QFont font; font.setPointSize(10); QString stylesheet("" "background-color:#AFAFAF;" "border: 1px outset grey;" "border-radius: 1px;" ""); line_->setStyleSheet(stylesheet); line_->setText(entity->name.c_str()); line_->setFrame(false); line_->setFont(font); layout_->addWidget(line_); connect(line_, SIGNAL(textChanged(const QString&)), this, SLOT(changeName(const QString&))); }
int main(int argc, char* argv[]) { QApplication::setStyle("fusion"); QApplication* application = new QApplication(argc, argv); #ifndef Q_OS_WIN // dynamic loading of the icon under Linux/UNIX application->setWindowIcon(QIcon(":/SystemMenu/Icons/Ascension_Icon.ico")); #endif // Stylesheet QFile stylesheet(":/Styles/PAClient.css"); if (stylesheet.open(QFile::ReadOnly)) { QString styleSheet = stylesheet.readAll(); application->setStyleSheet(styleSheet); } entryPoint::initSettings(application); entryPoint::initFonts(application); #ifdef Q_OS_WIN // Background color // This is only for WinApi window, Qt widgets use BorderlessWindow.css stylesheet HBRUSH windowBackground = CreateSolidBrush(RGB(34, 38, 47)); // Create a Win window BorderlessWindow window(application, windowBackground, 1152, 648); window.setMinimumSize(830, 550); #else // Create a Unix window UnixWindow window; window.setMinimumSize(830, 550); #endif // Launch application->exec(); return 0; }
void AOSAdminCommand_display::_insertStylesheet(AOSAdminCommandContext& context) { AString stylesheet("/xsl/_command/display",21); AString objectName; if (context.useRequestHeader().useUrl().useParameterPairs().get("object", objectName)) { stylesheet.append('_'); stylesheet.append(objectName); } stylesheet.append(".xsl",4); AFilename fn(m_Services.useConfiguration().getAdminBaseHttpDir(), stylesheet, false); if (!AFileSystem::exists(fn)) { //a_Fallback on default stylesheet.assign("/xsl/_command/display.xsl",25); } context.useModel().addInstruction(AXmlInstruction::XML_STYLESHEET) .addAttribute(ASW("type",4), ASW("text/xsl",8)) .addAttribute(ASW("href",4), stylesheet); }
Channel::Channel(const QString &name, int id, Client *parent) : QObject(parent), state(Inactive), client(parent), myname(name), myid(id), readyToQuit(false), stillLoading(true) { /* Those will actually be gotten back by the client itself, when he adds the channel */ mymainchat = new PokeTextEdit(); myplayers = new QTreeWidget(); battleList = new QTreeWidget(); mymainchat->setObjectName("MainChat"); mymainchat->setOpenExternalLinks(false); QFile stylesheet(Theme::path("mainchat.css")); stylesheet.open(QIODevice::ReadOnly); mymainchat->document()->setDefaultStyleSheet(stylesheet.readAll()); connect(mymainchat, SIGNAL(anchorClicked(QUrl)), SLOT(anchorClicked(QUrl))); myplayers->setColumnCount(2); myplayers->setColumnHidden(1, true); myplayers->header()->hide(); myplayers->setIconSize(QSize(18,18)); myplayers->setIndentation(13); myplayers->setObjectName("PlayerList"); myplayers->setContextMenuPolicy(Qt::CustomContextMenu); battleList->setColumnCount(2); battleList->setHeaderLabels(QStringList() << tr("Player 1") << tr("Player 2")); battleList->setSortingEnabled(true); battleList->resizeColumnToContents(0); battleList->setIndentation(0); events = -1; restoreEventSettings(); connect(myplayers, SIGNAL(customContextMenuRequested(QPoint)), SLOT(showContextMenu(QPoint))); connect(myplayers, SIGNAL(itemActivated(QTreeWidgetItem*, int)), client, SLOT(seeInfo(QTreeWidgetItem*))); connect(battleList, SIGNAL(itemActivated(QTreeWidgetItem*,int)), client, SLOT(battleListActivated(QTreeWidgetItem*))); }
unsigned CSSMediaRule::insertRule(const String& rule, unsigned index, ExceptionCode& ec) { if (index > m_lstCSSRules->length()) { // INDEX_SIZE_ERR: Raised if the specified index is not a valid insertion point. ec = INDEX_SIZE_ERR; return 0; } CSSParser p(useStrictParsing()); RefPtr<CSSRule> newRule = p.parseRule(parentStyleSheet(), rule); if (!newRule) { // SYNTAX_ERR: Raised if the specified rule has a syntax error and is unparsable. ec = SYNTAX_ERR; return 0; } if (newRule->isImportRule()) { // FIXME: an HIERARCHY_REQUEST_ERR should also be thrown for a @charset or a nested // @media rule. They are currently not getting parsed, resulting in a SYNTAX_ERR // to get raised above. // HIERARCHY_REQUEST_ERR: Raised if the rule cannot be inserted at the specified // index, e.g., if an @import rule is inserted after a standard rule set or other // at-rule. ec = HIERARCHY_REQUEST_ERR; return 0; } newRule->setParent(this); unsigned returnedIndex = m_lstCSSRules->insertRule(newRule.get(), index); // stylesheet() can only return 0 for computed style declarations. stylesheet()->styleSheetChanged(); return returnedIndex; }
int main (int argc, char const * argv []) { static char const * optv [] = { "print sparse matrix table", PUTOPTV_S_FUNNEL, "de:hl:m:st:", "d\tprint DOCBOOK table on stdout", "e s\tempty label is (s) [" LITERAL (EMPTY) "]", "h\tprint HTML table on stdout", "l n\tindent level is (n) [" LITERAL (LEVEL) "]", "m s\tmatch label is (s) [" LITERAL (MATCH) "]", "s\tprint CSS2 stylesheet on stdout", "t s\ttitle is (s) [" LITERAL (TITLE) "]", (char const *) (0) }; unsigned (* table) (unsigned, char const *, struct column *) = table1; unsigned margin = LEVEL; char const * header = TITLE; struct column column = { (struct column *) (0), (char const *) (0), (char const *) (0), (char *) (0) }; signed c; while (~ (c = getoptv (argc, argv, optv))) { switch (c) { case 'd': table = table2; break; case 'e': label_empty = optarg; break; case 'h': table = table1; break; case 'l': margin = (unsigned) (uintspec (optarg, 0, 16)); break; case 'm': label_match = optarg; break; case 's': stylesheet (margin); return (0); case 't': header = optarg; break; default: break; } } argc -= optind; argv += optind; if (! argc) { margin = table (margin, header, & column); } while ((argc) && (* argv)) { if (efreopen (* argv, "rb", stdin)) { margin = table (margin, header, & column); } argc--; argv++; } return (0); }
int main(int argc, char *argv[]) { set_env_vars_if_needed(); MainApplication app(argc, argv); #if USING_QT_5 QCommandLineParser parser; parser.setApplicationDescription("Video mapping editor"); // --help option const QCommandLineOption helpOption = parser.addHelpOption(); // --version option const QCommandLineOption versionOption = parser.addVersionOption(); // --fullscreen option QCommandLineOption fullscreenOption(QStringList() << "F" << "fullscreen", "Display the output window and make it fullscreen."); parser.addOption(fullscreenOption); // --file option QCommandLineOption fileOption(QStringList() << "f" << "file", "Load project from <file>.", "file", ""); parser.addOption(fileOption); // --reset-settings option QCommandLineOption resetSettingsOption(QStringList() << "R" << "reset-settings", "Reset MapMap settings, such as GUI properties."); parser.addOption(resetSettingsOption); // --osc-port option QCommandLineOption oscPortOption(QStringList() << "p" << "osc-port", "Use OSC port number <osc-port>.", "osc-port", ""); parser.addOption(oscPortOption); // Positional argument: file parser.addPositionalArgument("file", "Load project from that file."); parser.process(app); if (parser.isSet(versionOption) || parser.isSet(helpOption)) { return 0; } if (parser.isSet(resetSettingsOption)) { Util::eraseSettings(); } #endif // USING_QT_5 if (! QGLFormat::hasOpenGL()) qFatal("This system has no OpenGL support."); // Create splash screen. QPixmap pixmap("splash.png"); QSplashScreen splash(pixmap); // Show splash. splash.show(); splash.showMessage(" " + QObject::tr("Initiating program..."), Qt::AlignLeft | Qt::AlignTop, MM::WHITE); bool FORCE_FRENCH_LANG = false; // set_language_to_french(app); if (FORCE_FRENCH_LANG) // XXX FIXME this if seems wrong { std::cerr << "This system has no OpenGL support" << std::endl; return 1; } // Let splash for at least one second. I::sleep(1); // Create window. MainWindow* win = MainWindow::instance(); QFontDatabase db; Q_ASSERT( QFontDatabase::addApplicationFont(":/base-font") != -1); app.setFont(QFont(":/base-font", 10, QFont::Bold)); // Load stylesheet. QFile stylesheet("mapmap.qss"); stylesheet.open(QFile::ReadOnly); app.setStyleSheet(QLatin1String(stylesheet.readAll())); //win.setLocale(QLocale("fr")); #if USING_QT_5 // read positional argument: const QStringList args = parser.positionalArguments(); QString projectFileValue = QString(); // there are two ways to specify the project file name. // The 2nd overrides the first: // read the file option value: (overrides the positional argument) projectFileValue = parser.value("file"); // read the first positional argument: if (! args.isEmpty()) { projectFileValue = args.first(); } // finally, load the project file. if (projectFileValue != "") { win->loadFile(projectFileValue); } QString oscPortNumberValue = parser.value("osc-port"); if (oscPortNumberValue != "") { win->setOscPort(oscPortNumberValue); } #endif // Terminate splash. splash.showMessage(" " + QObject::tr("Done."), Qt::AlignLeft | Qt::AlignTop, MM::WHITE); splash.finish(win); splash.raise(); // Launch program. win->show(); #if USING_QT_5 if (parser.isSet(fullscreenOption)) { qDebug() << "TODO: Running in fullscreen mode"; win->startFullScreen(); } #endif // Start app. int result = app.exec(); delete win; return result; }
String::C xdoc2buf(Request& r, VXdoc& vdoc, XDocOutputOptions& oo, const String* file_spec, bool use_source_charset_to_render_and_client_charset_to_write_to_header=false) { Charset* render=0; Charset* header=0; if(use_source_charset_to_render_and_client_charset_to_write_to_header) { render=&r.charsets.source(); header=&r.charsets.client(); } else { header=render=&charsets.get(oo.encoding->change_case(r.charsets.source(), String::CC_UPPER)); } const char* render_encoding=render->NAME_CSTR(); const char* header_encoding=header->NAME_CSTR(); xmlCharEncodingHandler *renderer=xmlFindCharEncodingHandler(render_encoding); // UTF-8 renderer contains empty input/output converters, // which is wrong for xmlOutputBufferCreateIO // while zero renderer goes perfectly if(render->isUTF8()) renderer=0; xmlOutputBuffer_auto_ptr outputBuffer(xmlAllocOutputBuffer(renderer)); xsltStylesheet_auto_ptr stylesheet(xsltNewStylesheet()); if(!stylesheet.get()) throw Exception(0, 0, "xsltNewStylesheet failed"); #define OOSTRING2STYLE(name) \ stylesheet->name=oo.name?BAD_CAST xmlMemStrdup((const char*)r.transcode(*oo.name)):0 #define OOBOOL2STYLE(name) \ if(oo.name>=0) stylesheet->name=oo.name OOSTRING2STYLE(method); OOSTRING2STYLE(encoding); OOSTRING2STYLE(mediaType); // OOSTRING2STYLE(doctypeSystem); // OOSTRING2STYLE(doctypePublic); OOBOOL2STYLE(indent); OOSTRING2STYLE(version); OOBOOL2STYLE(standalone); OOBOOL2STYLE(omitXmlDeclaration); xmlDoc& xmldoc=vdoc.get_xmldoc(); xmldoc.encoding=BAD_CAST xmlMemStrdup(render_encoding); if(header_encoding) stylesheet->encoding=BAD_CAST xmlMemStrdup(header_encoding); if(xsltSaveResultTo(outputBuffer.get(), &xmldoc, stylesheet.get())<0 || xmlHaveGenericErrors()) throw XmlException(0, r); // write out result char *gnome_str; size_t gnome_length; #ifdef LIBXML2_NEW_BUFFER if(outputBuffer->conv) { gnome_length=xmlBufUse(outputBuffer->conv); gnome_str=(char *)xmlBufContent(outputBuffer->conv); } else { gnome_length=xmlOutputBufferGetSize(&(*outputBuffer)); gnome_str=(char *)xmlOutputBufferGetContent(&(*outputBuffer)); } #else if(outputBuffer->conv) { gnome_length=outputBuffer->conv->use; gnome_str=(char *)outputBuffer->conv->content; } else { gnome_length=outputBuffer->buffer->use; gnome_str=(char *)outputBuffer->buffer->content; } #endif if(file_spec){ file_write(r.charsets, *file_spec, gnome_str, gnome_length, true/*as_text*/); return String::C(); // actually, we don't need this output at all } else return String::C(gnome_length ? pa_strdup(gnome_str, gnome_length) : 0, gnome_length); }
void ActivityReport::slotUpdate() { const QString DateFormat( "yyyy/MM/dd" ); const QString TimeFormat( "HH:mm" ); const QString DateTimeFormat( "yyyy/MM/dd HH:mm" ); // retrieve matching events: EventIdList matchingEvents = DATAMODEL->eventsThatStartInTimeFrame( m_start, m_end ); matchingEvents = eventIdsSortedByStartTime( matchingEvents ); if ( m_rootTask != 0 ) { matchingEvents = filteredBySubtree( matchingEvents, m_rootTask ); } // filter unproductive events: if ( m_rootExcludeTask != 0 ) { matchingEvents = filteredBySubtree( matchingEvents, m_rootExcludeTask, true ); } // calculate total: int totalSeconds = 0; Q_FOREACH( EventId id, matchingEvents ) { const Event& event = DATAMODEL->eventForId( id ); Q_ASSERT( event.isValid() ); totalSeconds += event.duration(); } QTextDocument* report = new QTextDocument( this ); QDomDocument doc = createReportTemplate(); QDomElement root = doc.documentElement(); QDomElement body = root.firstChildElement( "body" ); // create the caption: { QDomElement headline = doc.createElement( "h1" ); QDomText text = doc.createTextNode( tr( "Activity Report" ) ); headline.appendChild( text ); body.appendChild( headline ); } { QDomElement headline = doc.createElement( "h3" ); QString content = tr( "Report for %1, from %2 to %3" ) .arg( CONFIGURATION.user.name() ) .arg( m_start.toString( Qt::TextDate ) ) .arg( m_end.toString( Qt::TextDate ) ); QDomText text = doc.createTextNode( content ); headline.appendChild( text ); body.appendChild( headline ); { QDomElement paragraph = doc.createElement( "h4" ); QString totalsText = tr( "Total: %1" ).arg( hoursAndMinutes( totalSeconds ) ); QDomText totalsElement = doc.createTextNode( totalsText ); paragraph.appendChild( totalsElement ); body.appendChild( paragraph ); } if ( m_rootTask != 0 ) { QDomElement paragraph = doc.createElement( "p" ); const Task& task = DATAMODEL->getTask( m_rootTask ); QString rootTaskText = tr( "Activity under task %1" ).arg( DATAMODEL->fullTaskName( task ) ); QDomText rootText = doc.createTextNode( rootTaskText ); paragraph.appendChild( rootText ); body.appendChild( paragraph ); } QDomElement paragraph = doc.createElement( "br" ); body.appendChild( paragraph ); } { const QString Headlines[] = { tr( "Date and Time, Task, Description" ) }; const int NumberOfColumns = sizeof Headlines / sizeof Headlines[0]; // now for a table QDomElement table = doc.createElement( "table" ); table.setAttribute( "width", "100%" ); table.setAttribute( "align", "left" ); table.setAttribute( "cellpadding", "3" ); table.setAttribute( "cellspacing", "0" ); body.appendChild( table ); // table header QDomElement tableHead = doc.createElement( "thead" ); table.appendChild( tableHead ); QDomElement headerRow = doc.createElement( "tr" ); headerRow.setAttribute( "class", "header_row" ); tableHead.appendChild( headerRow ); // column headers for ( int i = 0; i < NumberOfColumns; ++i ) { QDomElement header = doc.createElement( "th" ); QDomText text = doc.createTextNode( Headlines[i] ); header.appendChild( text ); headerRow.appendChild( header ); } QDomElement tableBody = doc.createElement( "tbody" ); table.appendChild( tableBody ); // rows Q_FOREACH( EventId id, matchingEvents ) { const Event& event = DATAMODEL->eventForId( id ); Q_ASSERT( event.isValid() ); const TaskTreeItem& item = DATAMODEL->taskTreeItem( event.taskId() ); const Task& task = item.task(); Q_ASSERT( task.isValid() ); const QString row1Texts[] = { tr( "%1 %2-%3 (%4) -- [%5] %6" ) .arg( event.startDateTime().date().toString( Qt::SystemLocaleShortDate ).trimmed() ) .arg( event.startDateTime().time().toString( Qt::SystemLocaleShortDate ).trimmed() ) .arg( event.endDateTime().time().toString( Qt::SystemLocaleShortDate ).trimmed() ) .arg( hoursAndMinutes( event.duration() ) ) .arg( QString().setNum( task.id() ).trimmed(), Configuration::instance().taskPaddingLength, '0' ) .arg( task.name().trimmed() ) }; QDomElement row1 = doc.createElement( "tr" ); row1.setAttribute( "class", "event_attributes_row" ); QDomElement row2 = doc.createElement( "tr" ); for ( int index = 0; index < NumberOfColumns; ++index ) { QDomElement cell = doc.createElement( "td" ); cell.setAttribute( "class", "event_attributes" ); QDomText text = doc.createTextNode( row1Texts[index] ); cell.appendChild( text ); row1.appendChild( cell ); } QDomElement cell2 = doc.createElement( "td" ); cell2.setAttribute( "class", "event_description" ); cell2.setAttribute( "align", "left" ); QDomElement preElement = doc.createElement( "pre" ); QDomText preText = doc.createTextNode( event.comment() ); preElement.appendChild( preText ); cell2.appendChild( preElement ); row2.appendChild( cell2 ); tableBody.appendChild( row1 ); tableBody.appendChild( row2 ); } } // NOTE: seems like the style sheet has to be set before the html // code is pushed into the QTextDocument QFile stylesheet( ":/Charm/report_stylesheet.sty" ); if ( stylesheet.open( QIODevice::ReadOnly | QIODevice::Text ) ) { QString style = stylesheet.readAll(); if ( !style.isEmpty() ) { report->setDefaultStyleSheet( style ); } else { qDebug() << "WeeklyTimeSheet::create: default style sheet is empty, too bad"; } } else { qDebug() << "WeeklyTimeSheet::create: cannot load report style sheet: " << stylesheet.errorString(); } report->setHtml( doc.toString() ); setDocument( report ); }
void GUI::FilterConfigurationBox::createUi() { filterPreview_=new FrameView; filterPreview_->setFixedSize(200,200); filterPreview_->setFrame(getDefaultImage()); button_apply_=new QPushButton("Apply"); QString stylesheet("QPushButton {" "color: rgb(0, 0, 0);" "background-color: QLinearGradient( x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #88d, stop: 0.1 #99e, stop: 0.49 #77c);" "background: rgb(220, 220, 220);" "border-width: 1px;" "border-color:rgb(0, 0, 0);" "border-style: outset;" "border-radius: 7px;" "font-size: 14px;" "}" "QPushButton:pressed {" "background-color: rgb(200, 200, 200);" "border-style: inset;" "}" ); button_apply_->setStyleSheet(stylesheet); button_apply_->setFixedSize(70,25); button_reset_=new QPushButton("Reset"); button_reset_->setStyleSheet(stylesheet); button_reset_->setFixedSize(70,25); label_filter_=new QLabel(tr("Filter options:")); QFont font("Arial",12,QFont::Bold); label_filter_->setFont(font); filterOptionsArea_=new QScrollArea; filterOptionsArea_->setFixedSize(330,160); filterOptionsArea_->setHorizontalScrollBarPolicy(Qt::ScrollBarPolicy::ScrollBarAlwaysOff); filterOptionsArea_->setObjectName("OptArea"); filterOptionsArea_->setStyleSheet("QScrollArea#OptArea {" "background-color:white;" "}"); QHBoxLayout* h_content=new QHBoxLayout; h_content->addWidget(filterPreview_); h_content->addSpacing(20); QVBoxLayout* v_caption_options=new QVBoxLayout; QHBoxLayout* h_label_butt=new QHBoxLayout; h_label_butt->addWidget(label_filter_); QSpacerItem* sp1=new QSpacerItem(0,0,QSizePolicy::Expanding,QSizePolicy::Minimum); h_label_butt->addSpacerItem(sp1); h_label_butt->addWidget(button_reset_); h_label_butt->addWidget(button_apply_); v_caption_options->addLayout(h_label_butt); QFrame* separator=new QFrame; separator->setFrameShape(QFrame::HLine); separator->setFrameShadow(QFrame::Sunken); v_caption_options->addWidget(separator); v_caption_options->addWidget(filterOptionsArea_); h_content->addLayout(v_caption_options); h_content->addSpacing(20); setLayout(h_content); setFixedWidth(600); setObjectName("BaseBox"); setStyleSheet("QFrame#BaseBox {" "border-width: 2px;" "border-color:rgb(0, 0, 0);" "border-style: outset;" "border-radius:5px;" "background-color:rgb(245,245,245);" "}"); }
bool XMLReaderBase::parse() { Buffer buffer; int c = get(); bool in_comment = false; while(c != EOF) { if (in_comment || c=='<') { buffer.append(c); // read start or end tag for(;;) { c = get(); if (c == EOF) break; buffer.append(c); if (c == '>') break; } const std::string& b = buffer.str(_utf8); const char* str = b.c_str(); if (in_comment || !strncmp(str+1, "!--", 3)) { // XML comment DefaultHandler(b); if (strcmp(str+b.length()-3, "-->")) in_comment = true; else in_comment = false; c = get(); } else if (str[1] == '/') { // end tag /*@TODO error handling const XS_String& tag = buffer.get_tag(); if (tag != last_opened_tag) { ERROR } */ EndElementHandler(); c = get(); } else if (str[1] == '?') { // XML declaration const XS_String& tag = buffer.get_tag(); if (tag == "?xml") { XMLNode::AttributeMap attributes; buffer.get_attributes(attributes); const std::string& version = attributes.get("version"); const std::string& encoding = attributes.get("encoding"); int standalone; XMLNode::AttributeMap::const_iterator found = // const_cast for ISO C++ compatibility error of GCC const_cast<const XMLNode::AttributeMap&>(attributes).find("standalone"); if (found != attributes.end()) standalone = !XS_icmp(found->second.c_str(), XS_TEXT("yes")); else standalone = -1; XmlDeclHandler(version.empty()?NULL:version.c_str(), encoding.empty()?NULL:encoding.c_str(), standalone); if (!encoding.empty() && !_stricmp(encoding.c_str(), "utf-8")) _utf8 = true; c = eat_endl(); } else if (tag == "?xml-stylesheet") { XMLNode::AttributeMap attributes; buffer.get_attributes(attributes); StyleSheet stylesheet(attributes.get("href"), attributes.get("type"), !XS_icmp(attributes.get("alternate"), XS_TEXT("yes"))); stylesheet._title = attributes.get("title"); stylesheet._media = attributes.get("media"); stylesheet._charset = attributes.get("charset"); _format._stylesheets.push_back(stylesheet); c = eat_endl(); } else { DefaultHandler(b); c = get(); } } else if (str[1] == '!') { if (!strncmp(str+2, "DOCTYPE ", 8)) { _format._doctype.parse(str+10); c = eat_endl(); } else if (!strncmp(str+2, "[CDATA[", 7)) { // see CDATA_START // parse <![CDATA[ ... ]]> strings while(!buffer.has_CDEnd()) { c = get(); if (c == EOF) break; buffer.append(c); } DefaultHandler(buffer.str(_utf8)); c = get(); } } else { // start tag const XS_String& tag = buffer.get_tag(); if (!tag.empty()) { XMLNode::AttributeMap attributes; buffer.get_attributes(attributes); StartElementHandler(tag, attributes); if (str[b.length()-2] == '/') EndElementHandler(); } c = get(); } } else { buffer.append(c); // read white space for(;;) { // check for the encoding of the first line end if (!_endl_defined) { if (c == '\n') { _format._endl = "\n"; _endl_defined = true; } else if (c == '\r') { _format._endl = "\r\n"; _endl_defined = true; } } c = get(); if (c == EOF) break; if (c == '<') break; buffer.append(c); } DefaultHandler(buffer.str(_utf8)); } buffer.reset(); } return true; //TODO return false on invalid XML }
static void html (char const * colors [], unsigned count, flag_t flags) { time_t now = time (& now); static char datetime [LOGTIME_LEN]; extern unsigned lineno; extern unsigned margin; extern unsigned offset; extern unsigned length; extern char * symbol; extern char * string; extern signed c; strftime (datetime, sizeof (datetime), LOGTIME, localtime (& now)); lineno = 1; offset = 0; length = 0; if (_anyset (flags, OFFSET_PAGE)) { indent (margin++, "<html>"); indent (margin++, "<title>"); indent (margin--, "</title>"); indent (margin++, "<head>"); indent (margin++, "<style>"); margin = stylesheet (margin); indent (margin--, "</style>"); indent (margin--, "</head>"); indent (margin++, "<body>"); indent (0, "<!-- BEGIN CONTENT -->"); } while ((c = getc (stdin)) != EOF) { unsigned index; if (isspace (c)) { if (c == '\n') { lineno++; } continue; } if ((c == '#') || (c == ';')) { do { c = getc (stdin); } while (nobreak (c)); lineno++; continue; } index = object () % count; if (!length) { if (offset) { indent (margin--, "</table>"); } indent (margin++, "<h2 class='%s'>", style); indent (margin, "%s %s", symbol, string); indent (margin--, "</h2>"); indent (margin++, "<table class='%s'>", style); indent (margin++, "<tr class='%s'>", style); indent (margin++, "<th class='%s'>", style_offset); indent (margin, "%s", label_offset); indent (margin--, "</th>"); indent (margin++, "<th class='%s'>", style_length); indent (margin, "%s", label_length); indent (margin--, "</th>"); indent (margin++, "<th class='%s'>", style_symbol); indent (margin, "%s", label_symbol); indent (margin--, "</th>"); indent (margin++, "<th class='%s'>", style_string); indent (margin, "%s", label_string); indent (margin--, "</th>"); indent (margin--, "</tr>"); } else { if (!offset) { indent (margin++, "<h2 class='%s'>", style); indent (margin, "No Title"); indent (margin--, "</h2>"); indent (margin++, "<table>"); indent (margin++, "<table class='%s'>", style); indent (margin++, "<tr class='%s'>", style); indent (margin++, "<th class='%s'>", style_offset); indent (margin, "%s", label_offset); indent (margin--, "</th>"); indent (margin++, "<th class='%s'>", style_length); indent (margin, "%s", label_length); indent (margin--, "</th>"); indent (margin++, "<th class='%s'>", style_symbol); indent (margin, "%s", label_symbol); indent (margin--, "</th>"); indent (margin++, "<th class='%s'>", style_string); indent (margin, "%s", label_string); indent (margin--, "</th>"); indent (margin--, "</tr>"); } indent (margin++, "<tr class='%s'>", style); indent (margin++, "<td class='%s' style='background: %s;'>", style_offset, colors [index]); indent (margin, "%08X", offset); indent (margin--, "</td>"); indent (margin++, "<td class='%s' style='background: %s;'>", style_length, colors [index]); indent (margin, "%6d", length); indent (margin--, "</td>"); indent (margin++, "<td class='%s' style='background: %s;'>", style_symbol, colors [index]); indent (margin, "%s", * symbol? symbol: " "); indent (margin--, "</td>"); indent (margin++, "<td class='%s' style='background: %s;'>", style_string, colors [index]); indent (margin, "%s", * string? string: " "); indent (margin--, "</td>"); indent (margin--, "</tr>"); } offset += length; lineno++; } if (offset) { indent (margin--, "</table>"); } indent (margin++, "<div class='%s'>", style_posted); indent (margin, "Posted %s on %s by %s", datetime, hostname (), username (getuid ())); indent (margin--, "</div>"); indent (0, "<!-- END CONTENT -->"); if (_anyset (flags, OFFSET_PAGE)) { indent (margin--, "</body>"); indent (margin--, "</html>"); } return; }
int main (int argc, char const * argv []) { extern unsigned margin; extern unsigned column; static char const * optv [] = { "bc:ehl:prstxz", PUTOPTV_S_FUNNEL, "print offset table", "b\tprint docbook format", "c n\talign descriptions to column (n) [" LITERAL (COLUMN) "]", "e\tprint efsu format", "h\tprint HTML table on stdout", "l n\tindent level is (n) [" LITERAL (MARGIN) "]", "p\tprint HTML page on stdout", "r\treset at headings", "s\tprint CSS2 stylesheet on stdout", "t\tprint text with TAB seperated columns", "x\thide unmarked objects", "z\tremove leading zeros", (char const *)(0) }; char const * colors [] = { "#FFFFFF", "#FFFF00", "#00FFFF", "#00FF00", "#FF00FF" }; flag_t flags = (flag_t)(0); signed c; while (~ (c = getoptv (argc, argv, optv))) { switch (c) { case 'b': _setbits (flags, OFFSET_BOOK); break; case 'c': column = uintspec (optarg, 0, UCHAR_MAX); break; case 'e': _setbits (flags, OFFSET_EFSU); break; case 'h': _setbits (flags, OFFSET_HTML); break; case 'p': _setbits (flags, OFFSET_PAGE); break; case 'l': margin = (unsigned) (uintspec (optarg, 0, 16)); break; case 'r': _setbits (flags, OFFSET_HOLE); break; case 's': stylesheet (margin); return (0); case 't': _setbits (flags, OFFSET_TEXT); break; case 'x': _setbits (flags, OFFSET_FOLD); break; case 'z': _setbits (flags, OFFSET_ZERO); break; default: break; } } argc -= optind; argv += optind; symbol = emalloc (SYMBOLSIZE); string = emalloc (STRINGSIZE); if (!argc) { function (colors, sizeof (colors) / sizeof (const char *), flags); } while ((argc) && (* argv)) { if (efreopen (* argv, "rb", stdin)) { function (colors, SIZEOF (colors), flags); } argc--; argv++; } return (0); }