Example #1
0
void ChatTextEdit::updateServer(const ServerProperties& srvprop)
{
    appendPlainText("");

    QString dt = getTimeStamp();
    
    QTextCharFormat format = textCursor().charFormat();
    QTextCharFormat original = format;
    QTextCursor cursor = textCursor();
    
    //show 'joined new channel' in bold
    QFont font = format.font();
    font.setBold(true);
    format.setFont(font);
    cursor.setCharFormat(format);
    QString line = dt + tr("Server Name: %1").arg(_Q(srvprop.szServerName));;
    setTextCursor(cursor);
    appendPlainText(line);

    line = dt + tr("Message of the Day: %1").arg(_Q(srvprop.szMOTD)) + "\r\n";
    format.setForeground(QBrush(Qt::darkCyan));
    cursor.setCharFormat(format);
    setTextCursor(cursor);
    appendPlainText(line);

    //revert bold
    font.setBold(false);
    format.setFont(font);

    //revert to original
    cursor.setCharFormat(original);
    setTextCursor(cursor);
    limitText();
}
Example #2
0
void ChatTextEdit::joinedChannel(int channelid)
{
    TTCHAR buff[TT_STRLEN];
    Channel chan;
    if(!TT_GetChannel(ttInst, channelid, &chan))
        return;
    if(!TT_GetChannelPath(ttInst, channelid, buff))
        return;

    appendPlainText("");

    QString dt = getTimeStamp();
    
    QTextCharFormat format = textCursor().charFormat();
    QTextCharFormat original = format;
    QTextCursor cursor = textCursor();
    
    //show 'joined new channel' in bold
    QFont font = format.font();
    font.setBold(true);
    format.setFont(font);
    cursor.setCharFormat(format);
    QString line = dt + tr("Joined new channel");
    setTextCursor(cursor);
    appendPlainText(line);
    //revert bold
    font.setBold(false);
    format.setFont(font);
    
    //show channel name in green
    line = tr("Channel: %1").arg(_Q(buff));
    format.setForeground(QBrush(Qt::darkGreen));
    cursor.setCharFormat(format);
    setTextCursor(cursor);
    appendPlainText(line);

    //show topic in blue
    line = tr("Topic: %1").arg(_Q(chan.szTopic));
    format.setForeground(QBrush(Qt::darkBlue));
    cursor.setCharFormat(format);
    setTextCursor(cursor);
    appendPlainText(line);

    //show disk quota in red
    line = tr("Disk quota: %1 KBytes").arg(chan.nDiskQuota/1024);
    format.setForeground(QBrush(Qt::darkRed));
    cursor.setCharFormat(format);
    setTextCursor(cursor);
    appendPlainText(line);

    //revert to original
    cursor.setCharFormat(original);
    setTextCursor(cursor);
    limitText();
}
Example #3
0
QString ChatTextEdit::addTextMessage(const TextMessage& msg)
{
    User user;
    if(!TT_GetUser(ttInst, msg.nFromUserID, &user))
        return QString();

    QString dt = getTimeStamp();
    QString line = dt;

    switch(msg.nMsgType)
    {
    case MSGTYPE_USER :
        line += QString("<%1> %2").arg(getDisplayName(user)).arg(_Q(msg.szMessage));
        break;
    case MSGTYPE_CHANNEL :
        if(msg.nChannelID != TT_GetMyChannelID(ttInst))
        {
            TTCHAR chpath[TT_STRLEN] = {};
            TT_GetChannelPath(ttInst, msg.nChannelID, chpath);
            line += QString("<%1->%2> %3").arg(getDisplayName(user))
                           .arg(_Q(chpath)).arg(_Q(msg.szMessage));
        }
        else
            line += QString("<%1> %2").arg(getDisplayName(user))
                           .arg(_Q(msg.szMessage));
        break;
    case MSGTYPE_BROADCAST :
        line += QString("<%1->BROADCAST> %2").arg(getDisplayName(user))
                       .arg(_Q(msg.szMessage));
        break;
    case MSGTYPE_CUSTOM : break;
    }

    if(TT_GetMyUserID(ttInst) == msg.nFromUserID)
    {
        QTextCharFormat format = textCursor().charFormat();
        QTextCharFormat original = format;
        format.setForeground(QBrush(Qt::darkGray));
        QTextCursor cursor = textCursor();
        cursor.setCharFormat(format);
        setTextCursor(cursor);
        appendPlainText(line);
        cursor.setCharFormat(original);
        setTextCursor(cursor);
    }
    else
        appendPlainText(line);
    limitText();

    return line;
}
Example #4
0
void ChatTextEdit::addLogMessage(const QString& msg)
{
    QString line = QString("%1 * %2").arg(getTimeStamp()).arg(msg);
    QTextCharFormat format = textCursor().charFormat();
    QTextCharFormat original = format;
    format.setForeground(QBrush(Qt::gray));
    QTextCursor cursor = textCursor();
    cursor.setCharFormat(format);
    setTextCursor(cursor);
    appendPlainText(line);
    cursor.setCharFormat(original);
    setTextCursor(cursor);
    limitText();
}
Example #5
0
void doSubmitUserRegions(struct sqlConnection *conn)
/* Process submit in set regions page. */
{
char *idText = trimSpaces(cartString(cart, hgtaEnteredUserRegions));
char *userRegionFile = trimSpaces(cartString(cart, hgtaEnteredUserRegionFile));
boolean hasData = (idText != NULL && idText[0] != 0) ||
    (userRegionFile != NULL && userRegionFile[0] != 0);

/* beware, the string pointers from cartString() point to strings in the
 * cart hash.  If they are manipulated and changed, they will get saved
 * back to the cart in their changed form.  You don't want to be
 * altering them like that.  Thus, the idText is duplicated below with
 * the cloneString(idText)
 */
htmlOpen("Table Browser (Region definitions)");

/* presence of fileName text overrides previously existing text area
 *	contents
 */
if (userRegionFile != NULL && userRegionFile[0] != 0)
    {
    idText = cloneString(userRegionFile);
    cartRemove(cart, hgtaEnteredUserRegions);
    cartRemove(cart, hgtaUserRegionsFile);
    cartSetString(cart, hgtaEnteredUserRegions, idText);
    }
else
    idText = cloneString(idText);

char *lineLimitText = limitText(idText);
if ( (strlen(lineLimitText) > 0) && (strlen(lineLimitText) != strlen(idText)) )
    {
    freeMem(idText);
    idText = lineLimitText;
    cartSetString(cart, hgtaEnteredUserRegions, lineLimitText);
    }
else
    freeMem(lineLimitText);

if (hasData)
    {
    struct tempName tn;
    FILE *f;
    struct bed *bedEl;
    struct bed *bedList = parseRegionInput(idText);

    if (NULL == bedList)
	errAbort("no valid data points found in input");

    trashDirFile(&tn, "hgtData", "user", ".region");
    f = mustOpen(tn.forCgi, "w");
    for (bedEl = bedList; bedEl; bedEl = bedEl->next )
	{
	if (bedEl->name)
	    fprintf(f, "%s\t%d\t%d\t%s\n",
		bedEl->chrom, bedEl->chromStart, bedEl->chromEnd, bedEl->name);
	else
	    fprintf(f, "%s\t%d\t%d\n",
		bedEl->chrom, bedEl->chromStart, bedEl->chromEnd);
	}
    carefulClose(&f);
    cartSetString(cart, hgtaUserRegionsDb, database);
    cartSetString(cart, hgtaUserRegionsTable, curTable);
    cartSetString(cart, hgtaUserRegionsFile, tn.forCgi);
    cartSetString(cart, hgtaRegionType, hgtaRegionTypeUserRegions);
    if (strlen(idText) > 64 * 1024)
         cartRemove(cart, hgtaEnteredUserRegions);
    }
else
    {
    cartRemove(cart, hgtaUserRegionsFile);
    cartRemove(cart, hgtaEnteredUserRegionFile);
    cartRemove(cart, hgtaRegionType);
    }
mainPageAfterOpen(conn);
htmlClose();
}