Пример #1
0
void KSim::Sysinfo::clockUptimeUpdate()
{
  TQString time;
  static bool updateDate = true;

  if (m_timeLabel) {
    TQTime now = TQTime::currentTime();
    time = TDEGlobal::locale()->formatTime(now, true);
    if ( now == TQTime(0, 0) )
      updateDate = true;

    m_timeLabel->setText(time);
  }

  // only update the date when necessary
  if (m_dateLabel) {
    if (updateDate) {
      m_dateLabel->setText(TDEGlobal::locale()->formatDate(TQDate::currentDate()));
      updateDate = false;
    }
  }
  else {
    updateDate = true;
  }

  if (m_uptimeLabel) {
    TQString uptime = m_config->uptimeFormat();
    ++m_totalUptime;
    long uptimeDays, uptimeHours, uptimeMins, uptimeSecs;

    uptimeHours = m_totalUptime / 3600;
    uptimeDays = uptimeHours / 24;
    uptimeMins = (m_totalUptime - uptimeHours * 3600) / 60;
    uptimeSecs = m_totalUptime % 60;

    TQString days;
    TQString hours;
    TQString minutes;
    TQString seconds;

    // found days so we have to modify hours
    if (uptime.find(TQRegExp("%d" ), 0) >= 0)
      uptimeHours -= (uptimeDays * 24);

    days.sprintf("%02li", uptimeDays);
    hours.sprintf("%02li", uptimeHours);
    minutes.sprintf("%02li", uptimeMins);
    seconds.sprintf("%02li", uptimeSecs);

    uptime.replace(TQRegExp("%d"), days);
    uptime.replace(TQRegExp("%h"), hours);
    uptime.replace(TQRegExp("%m"), minutes);
    uptime.replace(TQRegExp("%s"), seconds);
    m_uptimeLabel->setText(uptime);
  }
}
Пример #2
0
void HTMLLayerElement::setLeft( long _left )
{
    if(!impl) return;

    TQString aStr;
    aStr.sprintf("%ld", _left);
    DOMString value(aStr);
    ((ElementImpl *)impl)->setAttribute(ATTR_LEFT, value);
}
Пример #3
0
void HTMLLayerElement::setTop( long _top )
{
    if(!impl) return;

    TQString aStr;
    aStr.sprintf("%ld", _top);
    DOMString value(aStr);
    ((ElementImpl *)impl)->setAttribute(ATTR_TOP, value);
}
Пример #4
0
void HTMLPreElement::setWidth( long _width )
{
    if(!impl) return;

    TQString aStr;
    aStr.sprintf("%ld", _width);
    DOMString value(aStr);
    ((ElementImpl *)impl)->setAttribute(ATTR_WIDTH, value);
}
Пример #5
0
// new items go on top
TQString KonqSidebarHistoryGroupItem::key( int column, bool ascending ) const
{
    if ( !m_lastVisited.isValid() || MYMODULE->sortsByName() )
	return KonqSidebarTreeItem::key( column, ascending );

    TQString tmp;
    tmp.sprintf( "%08x", m_lastVisited.secsTo( MYMODULE->currentTime() ));
    return tmp;
}
Пример #6
0
void KColorDialog::setHtmlEdit( const KColor &col )
{
  if (d->bEditHtml) return;
  int r, g, b;
  col.rgb( &r, &g, &b );
  TQString num;

  num.sprintf("#%02X%02X%02X", r,g,b);
  d->htmlName->setText( num );
}
Пример #7
0
//---------------------------------------------------------------------------
void KXSConfigDialog::slotPreviewExited(KProcess *)
{
    if ( mKilled ) {
	mKilled = false;
	mPreviewProc->clearArguments();
	TQString saver;
	saver.sprintf( "%s -window-id 0x%lX", mFilename.latin1(), long(mPreview->winId()) );
	saver += command();
	kdDebug() << "Command: " <<  saver << endl;

	unsigned int i = 0;
	TQString word;
	saver = saver.stripWhiteSpace();
	while ( !saver[i].isSpace() ) word += saver[i++];
	//work around a KStandarDirs::findExe() "feature" where it looks in $KDEDIR/bin first no matter what and sometimes finds the wrong executable
	TQFileInfo checkExe;
	TQString saverdir = TQString("%1/%2").tqarg(XSCREENSAVER_HACKS_DIR).tqarg(word);
	TQString path;
	checkExe.setFile(saverdir);
	if (checkExe.exists() && checkExe.isExecutable() && checkExe.isFile())
	{
		path = saverdir;
	}
	if (!path.isEmpty()) {
	    (*mPreviewProc) << path;

	    bool inQuotes = false;
	    while ( i < saver.length() ) {
		word = "";
		while ( saver[i].isSpace() && i < saver.length() ) i++;
		while ( (!saver[i].isSpace() || inQuotes) && i < saver.length() ) {
		    if ( saver[i] == '\"' ) {
			inQuotes = !inQuotes;
		    } else {
			word += saver[i];
		    }
		    i++;
		}
		if (!word.isEmpty()) {
		    (*mPreviewProc) << word;
		}
	    }

	    mPreviewProc->start();
	}
    } else {
	// stops us from spawning the hack really fast, but still not the best
	TQString path = KStandardDirs::findExe(mFilename, XSCREENSAVER_HACKS_DIR);
	if ( TQFile::exists(path) ) {
	    mKilled = true;
	    slotChanged();
	}
    }
}
Пример #8
0
void TarListingThread::processDir( const KTarDirectory *tardir, const TQString & root )
{
	TQStringList list = tardir->entries();
	
	TQStringList::const_iterator itEnd = list.constEnd();

	for ( TQStringList::const_iterator it = list.constBegin(); it != itEnd; ++it )
	{
		const KTarEntry* tarEntry = tardir->entry((*it));
		if (!tarEntry)
			continue;

		TQStringList col_list;
		TQString name;
		if (root.isEmpty() || root.isNull())
			name = tarEntry->name();
		else
			name = root + tarEntry->name();
		if ( !tarEntry->isFile() )
			name += '/';
		col_list.append( name );
		TQString perms = makeAccessString(tarEntry->permissions());
		if (!tarEntry->isFile())
			perms = "d" + perms;
		else if (!tarEntry->symlink().isEmpty())
			perms = "l" + perms;
		else
			perms = "-" + perms;
		col_list.append(perms);
		col_list.append( tarEntry->user() );
		col_list.append( tarEntry->group() );
		TQString strSize = "0";
		if (tarEntry->isFile())
		{
			strSize.sprintf("%d", ((KTarFile *)tarEntry)->size());
		}
		col_list.append(strSize);
		TQString timestamp = tarEntry->datetime().toString(Qt::ISODate);
		col_list.append(timestamp);
		col_list.append(tarEntry->symlink());
		
		ListingEvent *ev = new ListingEvent( col_list );
		tqApp->postEvent( m_parent, ev );

		// if it's a directory, process it.
		// remember that name is root + / + the name of the directory
		if ( tarEntry->isDirectory() )
		{
			processDir( static_cast<const KTarDirectory *>( tarEntry ), name );
		}
	}
}
Пример #9
0
TQString ArkUtils::getTimeStamp(const TQString &_month,
                            const TQString &_day,
                            const TQString &_yearOrTime)
{
  // Make the date format sortable.
  // Month is in _month, day is in _day.
  // In _yearOrTime is either a year or a time.
  // If it's March, we'll see the year for all dates up to October 1999.
  // (five months' difference - e.g., if it's Apr, then get years up to Nov)

  char month[4];
  strncpy(month, _month.ascii(), 3);
  month[3] = '\0';
  int nMonth = getMonth(month);
  int nDay = _day.toInt();

  kdDebug(1601) << "Month is " << nMonth << ", Day is " << nDay << endl;

  time_t t = time(0);
  if (t == -1)
    exit(1);
  struct tm *now = localtime(&t);
  int thisYear = now->tm_year + 1900;
  int thisMonth = now->tm_mon + 1;

  TQString year, timestamp;

  if (_yearOrTime.contains(":"))
    // it has a timestamp so we have to figure out the year
    {
      year.sprintf("%d", ArkUtils::getYear(nMonth, thisYear, thisMonth));
      timestamp = _yearOrTime;
    }
  else
    {
      year = _yearOrTime;
      if (year.right(1) == " ")
        year = year.left(4);
      if (year.left(1) == " ")
        year = year.right(4);

      timestamp = "??:??";
    }

  TQString retval;
  retval.sprintf("%s-%.2d-%.2d %s",
                 year.utf8().data(), nMonth, nDay,
                 timestamp.utf8().data());
  return retval;
}
Пример #10
0
void EvaUserSetting::loadMsgToSql(const TQString fullName,const bool isQunMsg)
{
	TQFile file(fullName);
	if(!file.open(IO_ReadOnly))
		return ;
	TQString fullNameSql = getEvaUserDir() + "/"+SqlFileName;
	int result;
	char * errmsg = NULL;
	char **dbResult;
	int nRow, nColumn,i=0;
	sqlite3 *db=NULL;
	result=sqlite3_open(fullNameSql.data(),&db);
	if( result != SQLITE_OK ) return;
	TQString sql;
	sqlite3_exec( db,"begin transaction;",0,0,&errmsg);

	TQ_UINT32 r_buddy;
	TQ_UINT32 sender;
	TQString  sNick;
	TQ_UINT32 receiver;
	TQString  rNick;
	TQ_UINT8  type; // 0 auto reply,  1 normal
	TQString  message;
	TQ_UINT32  intTime;
	TQDateTime time;
	TQ_UINT8   fontSize;
	TQ_UINT8   flag; // start from right.  bit 0: u, bit 1: i, bit 2: b
	TQ_UINT8   blue;
	TQ_UINT8   green;
	TQ_UINT8   red;
	TQDataStream stream(&file);
	std::list<chatMessage>srclist;
	while(!stream.atEnd()){
		stream>>r_buddy;
		stream>>sender;
		stream>>sNick;
		stream>>receiver;
		stream>>rNick;
		stream>>type;
		stream>>message;
		stream>>intTime;
		stream>>fontSize;
		stream>>flag;
		stream>>blue;
		stream>>green;
		stream>>red;
		sql.sprintf("select sender from chat where sender=%d and receiver=%d and time=%d and isQunMsg=%d ",sender,receiver,intTime,isQunMsg);
		result = sqlite3_get_table(db,sql.utf8().data(), &dbResult,&nRow, &nColumn, &errmsg);
		if( SQLITE_OK != result ) 
		{
			sqlite3_exec( db,"commit  transaction;",0,0,&errmsg);
			return;
		}
		if(nRow>0) continue; //找到重复的记录
		i++;
		sql.sprintf("insert into chat values (%d,%d,'%s', %d,'%s',%d, '%s', %d,%d, %d, %d,%d,%d,%d)",r_buddy,sender,sNick.local8Bit().data(),receiver,rNick.local8Bit().data(),type,message.local8Bit().data(),intTime,fontSize,flag,blue,green,red,isQunMsg);
		sqlite3_exec( db , sql.utf8().data() , 0 , 0 , &errmsg );
	}
	printf("load %s %i条\n",fullName.data(),i);
	sqlite3_exec( db,"commit transaction;",0,0,&errmsg);
	file.close();
	TQString newfile;
	newfile=fullName+".old";
	unlink(newfile.local8Bit().data());
	rename(fullName.local8Bit().data(),newfile.local8Bit().data());
	return ;
}