Ejemplo n.º 1
0
void REPL(Context &context) {
  while (1) {
    //read
    Node *n = read_node(); //this is freed when node_atom is destroyed
    if (n == NULL) {
      return;
    }
    
    //eval
    Atom node_atom = Atom::create(n);
    context.run(node_atom);
    
    //print
    EvalAction action = context.action();
    Atom &result = context.result();
    if (result.isType(NONE)) {
      if (action != RESULT) {
        std::wcout << bold(eval_action_name(action));
      }
      std::wcout << std::endl;
    }
    else {
      if (action == RESULT) {
        std::wcout << L"→ ";
      }
      else {
        std::wcout << bold(eval_action_name(action)) << ": ";
      }
      std::wcout << type_name(result.getType()) << L" ";
      std::wcout << result.toString(context) << std::endl;
    }
    
    //Go looping! Hayo!
  }
}
Ejemplo n.º 2
0
Archivo: main.c Proyecto: jsdario/rysca
int main() {

	bold("This sends and empty payload, length should be 64\n");
	printf("Opening eth0\n");

	eth_iface_t * iface = eth_open( "eth0" );

	printf("Sending empty payload (1 byte) to 00:11:22:33:44:55\n");
	mac_addr_t dst;
	mac_str_addr("00:11:22:33:44:55", dst);
	uint8_t byte = 1;

	
	printf("With type IPV4_OVER_ETH_TYPE\n");
	
	int bytes_sent = eth_send( iface, dst, 0x0800, &byte, 1 );

	printf(BOLDCYAN "bytes_sent = %d\n" RESET, bytes_sent); 



	bold("Now we try to send 128 bits, for exmple: \n");
	printf(" Now we try 128 bytes to 00:11:22:33:44:55\n");

	int i;
	unsigned char word[128];
	for( i=0; i < 128; i++ ) word[i] = i;
		
	bytes_sent = eth_send( iface, dst, 0x0800, word, 128 );

	printf(BOLDCYAN "bytes_sent = %d\n" RESET, bytes_sent); 

	return 0;
}
Ejemplo n.º 3
0
void Assert::assertEqualsEpsilon( const double& expected, const double& result, const double& epsilon,
		const char* file, int linia )
{
	if (isNaN(expected) && isNaN(result) ) return;
	if (!isNaN(expected) && !isNaN(result) && fuzzyEquals(expected, result, epsilon) ) return;

	TestsListener::theInstance().errorsLog() 
			<< errmsgTag_testFailedIn() << file
			<< errmsgTag_inLine() << linia << "\n" 
			<< errmsgTag_expected()
			<< bold() << expected << normal() << " "
			<< errmsgTag_butWas() 
			<< bold() << result << normal() << "\n";
	TestsListener::theInstance().testHasFailed();
}
Ejemplo n.º 4
0
void run_file(const char *name, Context &context, bool do_file_error = true) {
  StringStream contents;
  contents << L"";
  std::wifstream file(name);
  if (!file.is_open()) {
    if (do_file_error) {
      StringStream msg;
      msg << L"File does not exist: " << name;
      throw HectateError(msg.str());
    }
    return;
  }
  
  contents << file.rdbuf();
  file.close();
  

  Atom node_atom;
  try {
    node_atom = Atom::create(Parser().parseFile(contents.str()));
  }
  catch (ParseError &e) {
    std::wcout << bold(L"parse failed") << L" in file " << name << L": " << e.get_msg();
    return;
  }
  context.run(node_atom);
}
Ejemplo n.º 5
0
int cgidemo()
{
  cxxtools::Cgi q;  // this parses all input-parameters

  // print standard-header
  std::cout << cxxtools::Cgi::header();

  cxxtools::Xmltag html("html");  // start html-block
  cxxtools::Xmltag body("body");  // start body-block

  cxxtools::Xmltag form("form");  // start form
  std::cout << "<input type=\"text\" name=\"v\">"
               "<br>"
               "<input type=\"submit\">";
  form.close(); // alternative 1: explicitly trigger closing form-tag

  std::cout << "<hr>\n"
               "you entered: ";

  {
    cxxtools::Xmltag bold("b");  // bold here in an embedded scope
    std::cout << q["v"];
  } // alternative 2: implicitly closing bold-tag by leaving scope

  // automatically close body and html by leaving scope

  return 0;
}
Ejemplo n.º 6
0
static void createAndAppendFontSubMenu(const HitTestResult& result, ContextMenuItem& fontMenuItem)
{
    ContextMenu fontMenu(result);

#if PLATFORM(MAC)
    ContextMenuItem showFonts(ActionType, ContextMenuItemTagShowFonts, contextMenuItemTagShowFonts());
#endif
    ContextMenuItem bold(CheckableActionType, ContextMenuItemTagBold, contextMenuItemTagBold());
    ContextMenuItem italic(CheckableActionType, ContextMenuItemTagItalic, contextMenuItemTagItalic());
    ContextMenuItem underline(CheckableActionType, ContextMenuItemTagUnderline, contextMenuItemTagUnderline());
    ContextMenuItem outline(ActionType, ContextMenuItemTagOutline, contextMenuItemTagOutline());
#if PLATFORM(MAC)
    ContextMenuItem styles(ActionType, ContextMenuItemTagStyles, contextMenuItemTagStyles());
    ContextMenuItem showColors(ActionType, ContextMenuItemTagShowColors, contextMenuItemTagShowColors());
#endif

#if PLATFORM(MAC)
    fontMenu.appendItem(showFonts);
#endif
    fontMenu.appendItem(bold);
    fontMenu.appendItem(italic);
    fontMenu.appendItem(underline);
    fontMenu.appendItem(outline);
#if PLATFORM(MAC)
    fontMenu.appendItem(styles);
    fontMenu.appendItem(*separatorItem());
    fontMenu.appendItem(showColors);
#endif

    fontMenuItem.setSubMenu(&fontMenu);
}
Ejemplo n.º 7
0
static void starfield(void) {
    static int init = 0;
    static char sf1[22];
    int x, y;

    if (!init) {
        init ^= 1;
        for (y=0; y<22; y++) {
            sf1[y] = rnd()%79 + 1;
        }
    }

    bold(); setfg(white); setbg(black);
    for (y=2; y<=23; y++) {
        x = sf1[y-2];
        if (! (y>=7 && y<=18 && x>=20 && x<=60) ) {
            moveto(x, y);
            printf(" ");
        }
        x++;
        if (x>79) x = 1;
        if (! (y>=7 && y<=18 && x>=20 && x<=60) ) {
            moveto(x, y);
            printf(".");
        }
        sf1[y-2] = x;
    }
    normal();
    flush();
}
Ejemplo n.º 8
0
pxStaticText &pxStaticText::Bold()
{
    wxFont bold(GetFont());
    bold.SetWeight(wxFONTWEIGHT_BOLD);
    SetFont(bold);
    return *this;
}
Ejemplo n.º 9
0
int cmd_exits() {
   int loop;
   mapping exits;
   string short;

   if (!TP->query_vision()) {
      write("It's too dark for you to see the exits!\n");
      return 1;
   }
   
   exits = (mapping) environment(previous_object()) -> query("exits");
   
   if (!exits || !mapp(exits)) {
      notify_fail("There are no exits here, from what you can tell.\n");
      return 0;
   }
   
   write("Exits for " + bold(environment(previous_object()) -> 
         query("short")) + ":\n");
   
   for( loop = 0; loop < sizeof(keys(exits)); loop++ ) {
      if( catch(values(exits)[loop] -> XXX())) {
         if (wizardp(previous_object()))
            write("Unloadable room : " + identify(keys(exits)[loop]) +
            "\t-> " + identify(values(exits)[loop]) + "\n");
         continue;
       }
      write("  " + pad(capitalize(keys(exits)[loop]), 13) + ":   " +
         (string) values(exits)[loop] -> query("short") + "\n");
   }
   return 1;
}
Ejemplo n.º 10
0
void CRTFBuilder::normal()
{
	bold(false);
	italic(false);
	underline(false);
	strike(false);
}
Ejemplo n.º 11
0
void FontResource::updateModelFromLogFont(const LOGFONT& logFont) {
	auto newFont = createFont (logFont);
	mFont->fontName (newFont->fontName());
	mFont->size (newFont->size());
	mFont->bold (newFont->bold());
	mFont->italic (newFont->italic());
	mFont->underline (newFont->underline());
}
Ejemplo n.º 12
0
void print_issue(struct json_object* issue, char* token, char* repo) {
    struct json_object* comments;
    struct json_object* comment;
    char* comment_user;
    char* comment_body;
    int len;
    int i;

    char* title = jsonh_get_string(issue, "title");
    char* body = jsonh_get_string(issue, "body");
    char* user = jsonh_get_string(issue, "user.login");
    char* assignee = jsonh_get_string(issue, "assignee.login");
    char* milestone = jsonh_get_string(issue, "milestone.title");
    char* url = jsonh_get_string(issue, "pull_request.html_url");
    char* status = jsonh_get_string(issue, "state");
    char* type = url == NULL ? "Issue" : "Pull Request";
    char* issue_id = jsonh_get_string(issue, "number");
    int comment_count = jsonh_get_int(issue, "comments");

    printf("%s: %s\t\t%s: %s\t\t%s: %s\t\t%s: %s\n", bold("Title"), title, bold("Opened by"), user, bold("Assigned to"), assignee, bold("Milestone"), milestone);
    printf("%s: %s\t\t%s: %s\t\t%s: %s\n", bold("URL"), url, bold("Type"), type, bold("Status"), status);
    printf("%s: %s\n\n", bold("Body"), body);

    if (comment_count > 0) {
        comments = github_get_comments(repo, issue_id, token);
        len = json_object_array_length(comments);
        for (i = 0; i < len; i++) {
            comment = json_object_array_get_idx(comments, i);
            comment_user = jsonh_get_string(comment, "user.login");
            comment_body = jsonh_get_string(comment, "body");
            printf("%s:\t%s\n\n", bold(comment_user), comment_body);
        }
    }
}
Ejemplo n.º 13
0
static void 
create() 
{
    ::create();
    set_name("Helmet of True Sight");
    set_short("a visored helmet");
    set_long("A visored helmet made of the finest steel.");
    set_info("This helmet will grant its wearer " + 
             bold("true") + " sight.");
    add_id(({"helmet","visored helmet"}));    
Ejemplo n.º 14
0
void decode_ip6(const u_char * packet) {
  char str_sip[INET6_ADDRSTRLEN];
  char str_dip[INET6_ADDRSTRLEN];
  char buffer[128];

  char * yellow_plen, *yellow_nxt, *b_sip, *b_dip;
	const struct ip6_hdr * ip_t;
	ip_t = (struct ip6_hdr *)(packet);

  inet_ntop(AF_INET6, &(ip_t->ip6_src), str_sip, INET6_ADDRSTRLEN);
  inet_ntop(AF_INET6, &(ip_t->ip6_dst), str_dip, INET6_ADDRSTRLEN);

  b_sip = bold(str_sip);
  b_dip = bold(str_dip);

  sprintf(buffer, "%d", htons(ip_t->ip6_ctlun.ip6_un1.ip6_un1_plen));
  yellow_plen = yellow(buffer);
  sprintf(buffer, "%x", ip_t->ip6_ctlun.ip6_un1.ip6_un1_plen);
  yellow_nxt = yellow(buffer);

	V(1, "IPv6 - %s --> %s\n", b_sip, b_dip);
	uint32_t flow = htonl(ip_t->ip6_ctlun.ip6_un1.ip6_un1_flow);
	VV(1, "Payload Length : %s - Next Header : %s\n", yellow_plen, yellow_nxt);
			/* htons(ip_t->ip6_ctlun.ip6_un1.ip6_un1_plen), ip_t->ip6_ctlun.ip6_un1.ip6_un1_nxt); */
	VVV(1,"Version : %d - Traffic Class : %x - Flow Label : %x - Hop Limit : %d\n",
			flow >> 28, (flow & 0x0ff00000) >> 20, flow & 0x000fffff,	ip_t->ip6_ctlun.ip6_un1.ip6_un1_hlim);

	int offset = sizeof(struct ip6_hdr);
	switch(ip_t->ip6_ctlun.ip6_un1.ip6_un1_nxt) {
		case 0x06:
			decode_tcp(packet + offset);
			break;
		case 0x11:
			decode_udp(packet + offset);
			break;
	}

  free(yellow_plen);
  free(yellow_nxt);
  free(b_sip);
  free(b_dip);
}
Ejemplo n.º 15
0
/**
 * This is a utility method to copy all the attributes of this
 * TextItem to \a other TextItem.
 */
void TextItem::copyAttributesTo(TextItem *other) const
{
    other->setDefaultTextColor(defaultTextColor());
    other->setHoverBrush(hoverBrush());
    other->setAcceptHoverEvents(acceptHoverEvents());
    other->setAlignment(alignment());
    other->setFont(font());
    other->setBold(bold());
    other->setItalic(italic());
    other->setUnderline(underline());
    other->setBackgroundBrush(backgroundBrush());
}
Ejemplo n.º 16
0
void Assert::assertTrue(char* strExpression, bool expression,
		const char* file, int linia)
{
	if (!expression)
	{
		TestsListener::theInstance().errorsLog() << "\n"
			<< errmsgTag_testFailedIn() << file 
			<< errmsgTag_inLine() << linia << "\n" 
			<< errmsgTag_failedExpression() 
			<< bold() << strExpression << normal() << "\n";
		TestsListener::theInstance().testHasFailed();
	}
}
Ejemplo n.º 17
0
void * delegate(void *arg) {
  bold("Started delegate");
  delegate_t *data = (delegate_t*)arg;
  while(!data->do_exit) {
    int exit_on_signal = 0;
    int ret = 0;
    if((ret = double_queue_listen(mQ, delegate_server, data, &exit_on_signal, museum_ip)) == -1) {
      error("Error during listening for queries in delegate.");
      panic();
    }
  }
  data->zajety = 0;
  return NULL;
}
Ejemplo n.º 18
0
void ClientLogBox::appendLog(const QString &type, const QString &from_general, const QStringList &tos,
    QString card_str, QString arg, QString arg2) {
    if (Self->hasFlag("marshalling")) return;

    if (type == "$AppendSeparator") {
        append(QString(tr("<font color='%1'>------------------------------</font>")).arg(Config.TextEditColor.name()));
        return;
    }

    QString from;
    if (!from_general.isEmpty()) {
        from = ClientInstance->getPlayerName(from_general);
        from = bold(from, Qt::green);
    }

    QString to;
    if (!tos.isEmpty()) {
        QStringList to_list;
        foreach (const QString &to, tos)
            to_list << ClientInstance->getPlayerName(to);
        to = to_list.join(", ");
        to = bold(to, Qt::red);
    }
Ejemplo n.º 19
0
QString ViFont::styleSheet()
{
	QString result = "";
	
	result += "color: " + mColor.name() + ";";
    result += "font-size: " + QString::number(pointSize()) + "px;";
	result += "font-family: " + family() + ";";
    if(bold())
    {
        result += "font-weight: bold;";
    }

	return result;
}
Ejemplo n.º 20
0
void * worker(void *arg) {
  // TODO
  worker_t *global;
  worker_init_t *wrk_init = (worker_init_t*)arg;

  bold("Starting worker %d of company %d.", wrk_init->idx, wrk_init->cidx);
  /*
  if(double_queue_init(global->bQ, bank_key1, bank_key2, 0700|IPC_CREAT, 0700|IPC_CREAT) == -1) {
    error("Failed creating message queue.");
    cleanup_company(global);
    return NULL;
  }
  */
  return NULL;
}
Ejemplo n.º 21
0
QFont State::font(QFont base)
{
    if (bold())
        base.setBold(true);
    if (italic())
        base.setItalic(true);
    if (underline())
        base.setUnderline(true);
    if (strikeOut())
        base.setStrikeOut(true);
    if (!fontName().isEmpty())
        base.setFamily(fontName());
    if (fontSize() > 0)
        base.setPointSize(fontSize());
    return base;
}
Ejemplo n.º 22
0
void
Format::copyTo (Format * to)
{
	if ( isBackgroundSet() )
		to->setBackground( background() );
	if ( isForegroundSet() )
		to->setForeground( foreground() );
	if ( isFontSet() )
		to->setFont( font() );
	if ( isItalicSet() )
		to->setItalic( italic() );
	if ( isPointsSet() )
		to->setPoints( points() );
	if ( isBoldSet() )
		to->setBold ( bold() );
}
Ejemplo n.º 23
0
int main(int argc, char *argv[])
{
    QApplication a(argc, argv);
    for(int i =0 ; i< argc ; i++)
    {
        QString arg(argv[i]);
        if(arg == "rotate" || arg == "-rotate" || arg == "-r")
        {
            //CHECK Value
            if(i < argc-1)
            {
                QString value(argv[i+1]);
                bool success;
                int v = value.toInt(&success);
                if(success){
                    QTransform trans;
                    trans.translate(180,120);
                    trans.rotate(v);
                    trans.translate(-180,-120);
                    Configuration::getInstance()->transform = trans;
                }else
                {
                    qDebug() <<"WARNING: Invalid value for rotate";
                }
            }else
            {
                qDebug()<<"WARNING: You must provide an angle (degrees) after rotate";
            }
        }
    }
    QApplication::setOverrideCursor(Qt::BlankCursor);

    Output *w = new Output(24);
    qDebug()<<w->cursor().pos();
    w->cursor().setPos(320,240);
    SplashScreen *splash = new SplashScreen(3000);

    QFile bold(":fonts/Bold");
    bold.open(QIODevice::ReadOnly);
    int id = QFontDatabase::addApplicationFontFromData(bold.readAll());
    QFont f(QFontDatabase::applicationFontFamilies(id).first());
    QApplication::setFont(f);
    splash->showFullScreen();
    splash->connect(splash,SIGNAL(startApp()),w,SLOT(start()));

  return a.exec();
}
Ejemplo n.º 24
0
        // caller locks
        void doLockedStuff(stringstream& ss) {
            ss << "# databases: " << dbHolder.size() << '\n';

            ss << bold(ClientCursor::byLocSize()>10000) << "Cursors byLoc.size(): " << ClientCursor::byLocSize() << bold() << '\n';
            ss << "\n<b>replication</b>\n";
            ss << "master: " << replSettings.master << '\n';
            ss << "slave:  " << replSettings.slave << '\n';
            if ( replPair ) {
                ss << "replpair:\n";
                ss << replPair->getInfo();
            }
            bool seemCaughtUp = getInitialSyncCompleted();
            if ( !seemCaughtUp ) ss << "<b>";
            ss <<   "initialSyncCompleted: " << seemCaughtUp;
            if ( !seemCaughtUp ) ss << "</b>";
            ss << '\n';
            
            auto_ptr<SnapshotDelta> delta = statsSnapshots.computeDelta();
            if ( delta.get() ){
                ss << "\n<b>DBTOP  (occurences|percent of elapsed)</b>\n";
                ss << "<table border=1>";
                ss << "<tr align='left'>";
                ss << "<th>NS</th>"
                      "<th colspan=2>total</th>"
                      "<th colspan=2>Reads</th>"
                      "<th colspan=2>Writes</th>"
                      "<th colspan=2>Queries</th>"
                      "<th colspan=2>GetMores</th>"
                      "<th colspan=2>Inserts</th>"
                      "<th colspan=2>Updates</th>"
                      "<th colspan=2>Removes</th>";
                ss << "</tr>";
                
                display( ss , (double) delta->elapsed() , "GLOBAL" , delta->globalUsageDiff() );
                
                Top::UsageMap usage = delta->collectionUsageDiff();
                for ( Top::UsageMap::iterator i=usage.begin(); i != usage.end(); i++ ){
                    display( ss , (double) delta->elapsed() , i->first , i->second );
                }
                
                ss << "</table>";
            }

            statsSnapshots.outputLockInfoHTML( ss );

            BackgroundOperation::dump(ss);
        }
Ejemplo n.º 25
0
void TextZone::keyPressEvent(QKeyEvent *event)
{
    //    sounds->startSoundKeyAny();


    if(event->matches(QKeySequence::Italic))
        italic(!italicAct->isChecked());
    else if(event->matches(QKeySequence::Bold))
        bold(!boldAct->isChecked());
    //    else if(event->modifiers() == (Qt::ControlModifier|Qt::ShiftModifier) && event->key() == QKeySequence(tr("L")))    //: L for Left
    //        leftAlign(true);
    //    else if(event->modifiers() == (Qt::ControlModifier|Qt::ShiftModifier) && event->key() == QKeySequence(tr("R"))) //: R for Right
    //        rightAlign(true);
    //    else if(event->modifiers() == Qt::ControlModifier && event->key() == Qt::Key_E)
    //        center(true);
    //    else if(event->modifiers() == Qt::ControlModifier && event->key() == Qt::Key_J)
    //        justify(true);

#if QT_VERSION >= 0x050000
    else if(event->modifiers() == (Qt::ShiftModifier|Qt::ControlModifier) && event->key() == QVariant(QKeySequence(tr("V", "paste unformated"))).toInt())
        pasteWithoutFormatting();

#else
    else if(event->modifiers() == (Qt::ControlModifier | Qt::ShiftModifier) && event->key() == QKeySequence(tr("V", "paste unformated")))
        pasteWithoutFormatting();

#endif


    else if(event->key() == Qt::Key_Space){
        if(preventDoubleSpaceOption == true)
            preventDoubleSpace();
        else
            QTextEdit::keyPressEvent(event);

    }
    else{
        QTextEdit::keyPressEvent(event);
    }

}
Ejemplo n.º 26
0
static void splash(void) {
    int r;

    clrscr();
    setbg(blue);
    horizontal(1,79,1);
    horizontal(1,79,24);
    setfg(white); setbg(white);
    rect(20,7, 60,18);
    setbg(red);
    frect(21,8, 59,17);
    bold();
    moveto(28,9);  printf("tctetris - version 0.90");
    normal(); setbg(red); setfg(white);
    moveto(23,10);  printf("Copyright (c) 2006, Ivo van Poorten");
    moveto(MENUX,12); printf("n - new game");
    moveto(MENUX,14); printf("s - speed [%02d]", sspeed);
    moveto(MENUX,16); printf("q - quit");
    moveto(1,23);
    flush();
}
Ejemplo n.º 27
0
    void recacheToolTip()
    {
        QString name = text (0);

        bool dateTimeToday = mTimestamp.date() == QDate::currentDate();
        QString dateTime = dateTimeToday ?
                           mTimestamp.time().toString (Qt::LocalDate) :
                           mTimestamp.toString (Qt::LocalDate);

        QString details;

        if (!mSnapshot.isNull())
        {
            /* The current snapshot is always bold */
            if (bold())
                details = VBoxSnapshotsWgt::tr (" (current, ", "Snapshot details");
            else
                details = " (";
            details += mOnline ? VBoxSnapshotsWgt::tr ("online)", "Snapshot details")
                               : VBoxSnapshotsWgt::tr ("offline)", "Snapshot details");

            if (dateTimeToday)
                dateTime = VBoxSnapshotsWgt::tr ("Taken at %1", "Snapshot (time)").arg (dateTime);
            else
                dateTime = VBoxSnapshotsWgt::tr ("Taken on %1", "Snapshot (date + time)").arg (dateTime);
        }
        else
        {
            dateTime = VBoxSnapshotsWgt::tr ("%1 since %2", "Current State (time or date + time)")
                .arg (gpConverter->toString (mMachineState)).arg (dateTime);
        }

        QString toolTip = QString ("<nobr><b>%1</b>%2</nobr><br><nobr>%3</nobr>")
            .arg (name) .arg (details).arg (dateTime);

        if (!mDesc.isEmpty())
            toolTip += "<hr>" + mDesc;

        setToolTip (0, toolTip);
    }
Ejemplo n.º 28
0
/*
   This function returns almost absolute path of the directory of the incoming path.
   It does not follow the last symbolic link.

   dirname and basename may modify their argument, so make a copy of the path.
*/
char * almostRealPath( const char * in_path ) {
    char * file_copy_path = strdup(in_path) ;
    char * dir_copy_path = strdup(in_path) ;
    char * file = basename(file_copy_path) ;
    char * dir = dirname(dir_copy_path) ;
    char * resolved_path = NULL ;
    char * final_path = NULL ;
    resolved_path = realpath( dir , resolved_path) ;
    if ( resolved_path != NULL ) {
        final_path = (char *)malloc(strlen(resolved_path) + strlen(file) + 2) ;
        sprintf(final_path,"%s/%s", resolved_path , file ) ;
        free(resolved_path) ;
    }
    free(file_copy_path) ;
    free(dir_copy_path) ;

    if (!final_path) {
        std::cout << bold(color(WARNING, "Warning")) << "    ICG could not resolve realpath of " << quote(bold(in_path)) << std::endl;
    }

    return final_path ;
}
Ejemplo n.º 29
0
    QVariant data(const QModelIndex &index, int role) const
    {
        if (!m_descriptions || !m_scheme)
            return QVariant();

        const FormatDescription &description = m_descriptions->at(index.row());

        switch (role) {
        case Qt::DisplayRole:
            return description.displayName();
        case Qt::ForegroundRole: {
            QColor foreground = m_scheme->formatFor(description.id()).foreground();
            if (foreground.isValid())
                return foreground;
            else
                return m_scheme->formatFor(C_TEXT).foreground();
        }
        case Qt::BackgroundRole: {
            QColor background = m_scheme->formatFor(description.id()).background();
            if (background.isValid())
                return background;
            else
                break;
        }
        case Qt::FontRole: {
            QFont font = m_baseFont;
            auto format = m_scheme->formatFor(description.id());
            font.setBold(format.bold());
            font.setItalic(format.italic());
            font.setUnderline(format.underlineStyle() != QTextCharFormat::NoUnderline);
            return font;
        }
        case Qt::ToolTipRole: {
            return description.tooltipText();
        }
        }
        return QVariant();
    }
Ejemplo n.º 30
0
        // caller locks
        void doLockedStuff(stringstream& ss) {
            ss << "# databases: " << dbHolder.size() << '\n';
            if ( cc().database() ) {
                ss << "curclient: " << cc().database()->name; // TODO: isn't this useless?
                ss << '\n';
            }
            ss << bold(ClientCursor::byLocSize()>10000) << "Cursors byLoc.size(): " << ClientCursor::byLocSize() << bold() << '\n';
            ss << "\n<b>replication</b>\n";
            ss << "master: " << master << '\n';
            ss << "slave:  " << slave << '\n';
            if ( replPair ) {
                ss << "replpair:\n";
                ss << replPair->getInfo();
            }
            bool seemCaughtUp = getInitialSyncCompleted();
            if ( !seemCaughtUp ) ss << "<b>";
            ss <<   "initialSyncCompleted: " << seemCaughtUp;
            if ( !seemCaughtUp ) ss << "</b>";
            ss << '\n';

            ss << "\n<b>DBTOP</b>\n";
            ss << "<table border=1><tr align='left'><th>Namespace</th><th>%</th><th>Reads</th><th>Writes</th><th>Calls</th><th>Time</th>";
            vector< Top::Usage > usage;
            Top::usage( usage );
            for( vector< Top::Usage >::iterator i = usage.begin(); i != usage.end(); ++i )
                ss << setprecision( 2 ) << fixed << "<tr><td>" << i->ns << "</td><td>" << i->pct << "</td><td>"
                   << i->reads << "</td><td>" << i->writes << "</td><td>" << i->calls << "</td><td>" << i->time << "</td></tr>\n";
            ss << "</table>";
            
            ss << "\n<b>dt\ttlocked</b>\n";
            unsigned i = q;
            while ( 1 ) {
                ss << lockStats[i] << '\n';
                i = (i-1)%NStats;
                if ( i == q )
                    break;
            }
        }