void LxQtWorldClock::updatePopupContent() { if (mPopupContent) { QDateTime now = QDateTime::currentDateTime(); QStringList allTimeZones; foreach (QString timeZoneName, mTimeZones) { QString formatted = formatDateTime(now, timeZoneName); switch (mFormatType) { case FORMAT_SHORT_TIMEONLY: case FORMAT_SHORT: formatted += QLatin1String("<br/>") + QString::fromLatin1(QTimeZone(timeZoneName.toLatin1()).id()); break; default:; } allTimeZones.append(formatted); } mPopupContent->setText(allTimeZones.join(QLatin1String("<hr/>"))); }
QString TextItem::formatFieldValue() { if (m_format.isEmpty()) { return m_varValue.toString(); } QVariant value = m_varValue; if (m_valueType != Default) { switch (m_valueType) { case DateTime: { QDateTime dt = QDateTime::fromString(value.toString(), Qt::ISODate); value = (dt.isValid() ? QVariant(dt) : m_varValue); break; } case Double: { bool bOk = false; double dbl = value.toDouble(&bOk); value = (bOk ? QVariant(dbl) : m_varValue); } default: break; } } switch (value.type()) { case QVariant::Date: case QVariant::DateTime: return formatDateTime(value.toDateTime()); case QVariant::Double: return formatNumber(value.toDouble()); default: return value.toString(); } }
void LXQtWorldClock::updatePopupContent() { if (mPopupContent) { QDateTime now = QDateTime::currentDateTime(); QStringList allTimeZones; bool hasTimeZone = formatHasTimeZone(mFormat); foreach (QString timeZoneName, mTimeZones) { if (timeZoneName == QLatin1String("local")) timeZoneName = QString::fromLatin1(QTimeZone::systemTimeZoneId()); QString formatted = formatDateTime(now, timeZoneName); if (!hasTimeZone) formatted += QLatin1String("<br/>") + QString::fromLatin1(QTimeZone(timeZoneName.toLatin1()).id()); allTimeZones.append(formatted); } mPopupContent->setText(allTimeZones.join(QLatin1String("<hr/>"))); } }
bool Syncer::setSyncTime() { QSqlQuery qry; int rows = 0; qry.exec(QString("select _f.ct, _f.cnt + 50*ifnull(_s.cnt, 0) as cnt from " "(select created_at as ct, count(row_id) as cnt from logs where ct > '%1' group by ct) as _f left join " "(select created_at as ct, count(row_id) as cnt from logs where table_name = 'files' and ct > '%1' group by ct) as _s on _f.ct = _s.ct order by _f.ct").arg(formatDateTime(lastSync))); while (qry.next()) { rows += qry.value(1).toInt(); if (rows >= maxRows) { syncTime = qry.value(0).toDateTime(); return false; } } // unsynced rows are less than limit syncTime = QDateTime::currentDateTime(); return true; }
bool AlarmView::updateAlarms() { bool playSound = false; QIcon aicon(":icon/audible"); QIcon sicon(":icon/silent"); mStandardModel->clear(); mAlarmCount = 0; QString localDT; QString tzDT; // Filter out occurrences that do not have an alarm for (int i=0; i < mModel->rowCount(); i++) { QOccurrence o = mModel->occurrence(i); QAppointment a = o.appointment(); if (a.hasAlarm() && (o.startInCurrentTZ() == mStartTime) && (o.alarmDelay() == mDelay)) { if (!playSound && (a.alarm() == QAppointment::Audible)) { playSound = true; } QStandardItem* item = new QStandardItem(); if (a.alarm() == QAppointment::Audible) item->setData(aicon, Qt::DecorationRole); else item->setData(sicon, Qt::DecorationRole); if (!a.description().isEmpty()) item->setData(a.description(), Qt::DisplayRole); else item->setData(tr("No description", "no description for appointment"), Qt::DisplayRole); QList< StringPair > subList; if (!a.location().isEmpty()) { subList.append(qMakePair(QString(), a.location())); } formatDateTime(o, true, localDT, tzDT); if (a.isAllDay()) { subList.append(qMakePair(tr("All day: "), localDT)); } else { subList.append(qMakePair(tr("Starts: "), localDT)); if (!tzDT.isEmpty()) subList.append(qMakePair(QString(""), tzDT)); formatDateTime(o, false, localDT, tzDT); subList.append(qMakePair(tr("Ends: "), localDT)); if (!tzDT.isEmpty()) subList.append(qMakePair(QString(""), tzDT)); } item->setData(QVariant::fromValue(subList), TwoLevelDelegate::SubLabelsRole); item->setData(i, TwoLevelDelegate::TwoLevelDelegateUserRole); mStandardModel->appendRow(item); } } int rowCount = mStandardModel->rowCount(); // Select the first item mAlarmList->setCurrentIndex(mStandardModel->index(0,0)); // XXX i18n boneheadedness. if (rowCount < 2) { setWindowTitle(tr("Reminder")); } else { setWindowTitle(tr("Reminders")); } mSnoozeButton->setFocus(); // If we actually got any matching alarms... if (rowCount > 0) { if (playSound) { Qtopia::soundAlarm(); mAlarmTimer.start(5000,this); } return true; } else { emit closeView(); return false; } }
void AIMInfo::fill() { ICQUserData *data = m_data; if (data == NULL) data = &m_client->data.owner; setText(edtScreen, data->Screen.ptr); setText(edtFirst, data->FirstName.ptr); setText(edtLast, data->LastName.ptr); setText(edtMiddle, data->MiddleName.ptr); setText(edtMaiden, data->Maiden.ptr); setText(edtNick, data->Nick.ptr); setText(edtStreet, data->Address.ptr); setText(edtCity, data->City.ptr); setText(edtState, data->State.ptr); setText(edtZip, data->Zip.ptr); initCombo(cmbCountry, (unsigned short)(data->Country.value), getCountries(), true, getCountryCodes()); if (m_data == NULL){ if (edtFirst->text().isEmpty()) edtFirst->setText(getContacts()->owner()->getFirstName()); if (edtLast->text().isEmpty()) edtLast->setText(getContacts()->owner()->getLastName()); } cmbStatus->clear(); unsigned status = STATUS_ONLINE; if (m_data){ unsigned s = m_data->Status.value; if (s == ICQ_STATUS_OFFLINE){ status = STATUS_OFFLINE; }else if (s & ICQ_STATUS_AWAY){ status = STATUS_AWAY; } }else{ status = m_client->getStatus(); } if ((status != STATUS_ONLINE) && (status != STATUS_OFFLINE) && m_data){ edtAutoReply->setText(m_client->toUnicode(m_data->AutoReply.ptr, m_data)); }else{ edtAutoReply->hide(); } int current = 0; const char *text = NULL; for (const CommandDef *cmd = m_client->protocol()->statusList(); cmd->id; cmd++){ if (cmd->flags & COMMAND_CHECK_STATE) continue; if (status == cmd->id){ current = cmbStatus->count(); text = cmd->text; } cmbStatus->insertItem(Pict(cmd->icon), i18n(cmd->text)); } cmbStatus->setCurrentItem(current); disableWidget(cmbStatus); if (status == STATUS_OFFLINE){ lblOnline->setText(i18n("Last online") + ":"); edtOnline->setText(formatDateTime(data->StatusTime.value)); lblNA->hide(); edtNA->hide(); }else{ if (data->OnlineTime.value){ edtOnline->setText(formatDateTime(data->OnlineTime.value)); }else{ lblOnline->hide(); edtOnline->hide(); } if ((status == STATUS_ONLINE) || (text == NULL)){ lblNA->hide(); edtNA->hide(); }else{ lblNA->setText(i18n(text)); edtNA->setText(formatDateTime(data->StatusTime.value)); } } if (data->IP.ptr){ edtExtIP->setText(formatAddr(data->IP, data->Port.value)); }else{ lblExtIP->hide(); edtExtIP->hide(); } if (data->RealIP.ptr && ((data->IP.ptr == NULL) || (get_ip(data->IP) != get_ip(data->RealIP)))){ edtIntIP->setText(formatAddr(data->RealIP, data->Port.value)); }else{ lblIntIP->hide(); edtIntIP->hide(); } if (m_data){ string client_name = m_client->clientName(data); if (client_name.length()){ edtClient->setText(client_name.c_str()); }else{ lblClient->hide(); edtClient->hide(); } }else{ string name = PACKAGE; name += " "; name += VERSION; #ifdef WIN32 name += "/win32"; #endif edtClient->setText(name.c_str()); } if (m_bInit) return; m_bInit = true; m_client->fillEncoding(cmbEncoding, data); }
QString KLocale::formatDateTime(const QDateTime &dateTime, KLocale::DateFormat format, bool includeSeconds) const { return d->formatDateTime(dateTime, format, includeSeconds); }
void ICQInfo::fill() { ICQUserData *data = m_data; if (data == NULL) data = &m_client->data.owner; edtUin->setText(QString::number(data->Uin)); edtFirst->setText(m_client->toUnicode(data->FirstName, data)); edtLast->setText(m_client->toUnicode(data->LastName, data)); edtNick->setText(m_client->toUnicode(data->Nick, data)); if (m_data == NULL){ if (edtFirst->text().isEmpty()) edtFirst->setText(getContacts()->owner()->getFirstName()); if (edtLast->text().isEmpty()) edtLast->setText(getContacts()->owner()->getLastName()); } cmbStatus->clear(); unsigned status = STATUS_ONLINE; if (m_data){ unsigned s = m_data->Status; if (s == ICQ_STATUS_OFFLINE){ status = STATUS_OFFLINE; }else if (s & ICQ_STATUS_DND){ status = STATUS_DND; }else if (s & ICQ_STATUS_OCCUPIED){ status = STATUS_OCCUPIED; }else if (s & ICQ_STATUS_NA){ status = STATUS_NA; }else if (s & ICQ_STATUS_AWAY){ status = STATUS_AWAY; }else if (s & ICQ_STATUS_FFC){ status = STATUS_FFC; } }else{ status = m_client->getStatus(); initCombo(cmbRandom, m_client->getRandomChatGroup(), chat_groups); } if ((status != STATUS_ONLINE) && (status != STATUS_OFFLINE) && m_data){ edtAutoReply->setText(m_client->toUnicode(m_data->AutoReply, m_data)); }else{ edtAutoReply->hide(); } int current = 0; const char *text = NULL; if (m_data && (status == STATUS_OFFLINE) && m_data->bInvisible){ cmbStatus->insertItem(Pict("ICQ_invisible"), i18n("Possibly invisible")); }else{ for (const CommandDef *cmd = m_client->protocol()->statusList(); cmd->id; cmd++){ if (cmd->flags & COMMAND_CHECK_STATE) continue; if (status == cmd->id){ current = cmbStatus->count(); text = cmd->text; } cmbStatus->insertItem(Pict(cmd->icon), i18n(cmd->text)); } } cmbStatus->setCurrentItem(current); disableWidget(cmbStatus); if (status == STATUS_OFFLINE){ lblOnline->setText(i18n("Last online") + ":"); edtOnline->setText(formatDateTime(data->StatusTime)); lblNA->hide(); edtNA->hide(); }else{ if (data->OnlineTime){ edtOnline->setText(formatDateTime(data->OnlineTime)); }else{ lblOnline->hide(); edtOnline->hide(); } if ((status == STATUS_ONLINE) || (text == NULL)){ lblNA->hide(); edtNA->hide(); }else{ lblNA->setText(i18n(text)); edtNA->setText(formatDateTime(data->StatusTime)); } } if (data->IP){ edtExtIP->setText(formatAddr(data->IP, data->Port)); }else{ lblExtIP->hide(); edtExtIP->hide(); } if ((data->RealIP) && ((data->IP == NULL) || (get_ip(data->IP) != get_ip(data->RealIP)))){ edtIntIP->setText(formatAddr(data->RealIP, data->Port)); }else{ lblIntIP->hide(); edtIntIP->hide(); } if (m_data){ string client_name = m_client->clientName(data); if (client_name.length()){ edtClient->setText(client_name.c_str()); }else{ lblClient->hide(); edtClient->hide(); } }else{ string name = PACKAGE; name += " "; name += VERSION; #ifdef WIN32 name += "/win32"; #endif edtClient->setText(name.c_str()); } if (m_bInit) return; m_bInit = true; current = 0; int n_item = 1; cmbEncoding->clear(); cmbEncoding->insertItem("Default"); QStringList l; const ENCODING *e; QStringList main; QStringList::Iterator it; for (e = ICQClient::encodings; e->language; e++){ if (!e->bMain) continue; main.append(i18n(e->language) + " (" + e->codec + ")"); } main.sort(); for (it = main.begin(); it != main.end(); ++it, n_item++){ QString str = *it; int n = str.find('('); str = str.mid(n + 1); n = str.find(')'); str = str.left(n); if (data->Encoding && !strcmp(data->Encoding, str.latin1())) current = n_item; cmbEncoding->insertItem(*it); } QStringList noMain; for (e = ICQClient::encodings; e->language; e++){ if (e->bMain) continue; noMain.append(i18n(e->language) + " (" + e->codec + ")"); } noMain.sort(); for (it = noMain.begin(); it != noMain.end(); ++it, n_item++){ QString str = *it; int n = str.find('('); str = str.mid(n + 1); n = str.find(')'); str = str.left(n); if (data->Encoding && !strcmp(data->Encoding, str.latin1())) current = n_item; cmbEncoding->insertItem(*it); } cmbEncoding->setCurrentItem(current); }
// ECMA 15.9.2 static EncodedJSValue JSC_HOST_CALL callDate(ExecState* exec) { GregorianDateTime ts; msToGregorianDateTime(exec, currentTimeMS(), false, ts); return JSValue::encode(jsNontrivialString(exec, formatDateTime(ts, DateTimeFormatDateAndTime, false))); }
/* 外部需要为buf分配内存空间 格式: yyMMddHHmmSS */ void getDateTimeInString(char *buf, int buf_size) { long timeL = getSystemTimeInSecs(); formatDateTime(timeL, buf, buf_size); }
//============================================================================= // Load the detail communication information of the person. //============================================================================= void CCommunication::loadData (QString id, bool readonly) { QString DBnull = "?", tip; unsigned int row = 0; //---------------------------------------------------------------------------- // Disconnect the slots during data load. //---------------------------------------------------------------------------- removeAllLines(); slotAddLine(); disconnectSlots(); //---------------------------------------------------------------------------- // Load the communication types. //---------------------------------------------------------------------------- QSqlQuery query ("SELECT comm_id, type, number, created, last_modified " "FROM contacts_communications " "WHERE person_id = " + id + " ORDER BY type"); if (!query.isActive()) { SHOW_DB_ERROR(tr ("Error during database query"), query); return; } while (query.next()) { if (row >= mLine.count()) { slotAddLine(); disconnectSlots(); } mIDs << query.value(0).toString(); mLine.at(row)->setID (query.value(0).toString()); mLine.at(row)->setType (query.value(1).toInt()); mLine.at(row)->setValue (query.value(2).toString()); mLine.at(row)->setToolTip (tr ("Created:\t\t\t") + formatDateTime (query.value(3).toString()) + tr ("\nLast Modified:\t\t") + formatDateTime (query.value(4).toString())); mLine.at(row)->setChanged (false); row++; } //---------------------------------------------------------------------------- // Store the ID of the currently loaded person. //---------------------------------------------------------------------------- mCurrent = id; mReadonly = readonly; //---------------------------------------------------------------------------- // Connect the slots after data load is complete. //---------------------------------------------------------------------------- connectSlots(); setReadonly (readonly); emit contentLoaded (true); emit contentChanged (false); }
/** * Saves investigations to a table workspace. * @param response :: A vector containing the results of the search query. * @param outputws :: Shared pointer to output workspace. */ void ICat4Catalog::saveInvestigations(std::vector<xsd__anyType *> response, API::ITableWorkspace_sptr &outputws) { if (outputws->getColumnNames().empty()) { // Add rows headers to the output workspace. outputws->addColumn("long64", "DatabaseID"); outputws->addColumn("str", "InvestigationID"); outputws->addColumn("str", "Facility"); outputws->addColumn("str", "Title"); outputws->addColumn("str", "Instrument"); outputws->addColumn("str", "Run range"); outputws->addColumn("str", "Start date"); outputws->addColumn("str", "End date"); outputws->addColumn("str", "SessionID"); } // Add data to each row in the output workspace. std::vector<xsd__anyType *>::const_iterator iter; for (iter = response.begin(); iter != response.end(); ++iter) { // Cast from xsd__anyType to subclass (xsd__string). ns1__investigation *investigation = dynamic_cast<ns1__investigation *>(*iter); if (investigation) { API::TableRow table = outputws->appendRow(); // Used to insert an empty string into the cell if value does not exist. std::string emptyCell; // Now add the relevant investigation data to the table (They always // exist). savetoTableWorkspace(investigation->id, table); savetoTableWorkspace(investigation->name, table); savetoTableWorkspace(investigation->facility->name, table); savetoTableWorkspace(investigation->title, table); savetoTableWorkspace( investigation->investigationInstruments.at(0)->instrument->name, table); // Verify that the run parameters vector exist prior to doing anything. // Since some investigations may not have run parameters. if (!investigation->parameters.empty()) { savetoTableWorkspace(investigation->parameters[0]->stringValue, table); } else { savetoTableWorkspace(&emptyCell, table); } // Again, we need to check first if start and end date exist prior to // insertion. if (investigation->startDate) { std::string startDate = formatDateTime(*investigation->startDate, "%Y-%m-%d"); savetoTableWorkspace(&startDate, table); } else { savetoTableWorkspace(&emptyCell, table); } if (investigation->endDate) { std::string endDate = formatDateTime(*investigation->endDate, "%Y-%m-%d"); savetoTableWorkspace(&endDate, table); } else { savetoTableWorkspace(&emptyCell, table); } std::string sessionID = m_session->getSessionId(); savetoTableWorkspace(&sessionID, table); } else { throw std::runtime_error("ICat4Catalog::saveInvestigations expected an " "investigation. Please contact the Mantid " "development team."); } } }
/** * Creates a search query string based on inputs provided by the user. * @param inputs :: reference to a class contains search inputs. * @return a query string constructed from user input. */ std::string ICat4Catalog::buildSearchQuery(const CatalogSearchParam &inputs) { // Contain the related where and join clauses for the search query based on // user-input. std::vector<std::string> whereClause, joinClause; // Format the timestamps in order to compare them. std::string startDate = formatDateTime(inputs.getStartDate(), "%Y-%m-%d %H:%M:%S"); std::string endDate = formatDateTime(inputs.getEndDate() + ((23 * 60 * 60) + (59 * 60) + 59), "%Y-%m-%d %H:%M:%S"); // Investigation startDate if endDate is not selected if (inputs.getStartDate() != 0 && inputs.getEndDate() == 0) { whereClause.emplace_back("inves.startDate >= '" + startDate + "'"); } // Investigation endDate if startdate is not selected if (inputs.getEndDate() != 0 && inputs.getStartDate() == 0) { whereClause.emplace_back("inves.endDate <= '" + endDate + "'"); } // Investigation Start and end date if both selected if (inputs.getStartDate() != 0 && inputs.getEndDate() != 0) { whereClause.emplace_back("inves.startDate BETWEEN '" + startDate + "' AND '" + endDate + "'"); } // Investigation name (title) if (!inputs.getInvestigationName().empty()) { whereClause.emplace_back("inves.title LIKE '%" + inputs.getInvestigationName() + "%'"); } // Investigation id if (!inputs.getInvestigationId().empty()) { whereClause.emplace_back("inves.name = '" + inputs.getInvestigationId() + "'"); } // Investigation type if (!inputs.getInvestigationType().empty()) { joinClause.emplace_back("JOIN inves.type itype"); whereClause.emplace_back("itype.name = '" + inputs.getInvestigationType() + "'"); } // Instrument name if (!inputs.getInstrument().empty()) { joinClause.emplace_back("JOIN inves.investigationInstruments invInst"); joinClause.emplace_back("JOIN invInst.instrument inst"); whereClause.emplace_back("inst.fullName = '" + inputs.getInstrument() + "'"); } // Keywords if (!inputs.getKeywords().empty()) { joinClause.emplace_back("JOIN inves.keywords keywords"); whereClause.emplace_back("keywords.name IN ('" + inputs.getKeywords() + "')"); } // Sample name if (!inputs.getSampleName().empty()) { joinClause.emplace_back("JOIN inves.samples sample"); whereClause.emplace_back("sample.name LIKE '%" + inputs.getSampleName() + "%'"); } // If the user has selected the "My data only" button. // (E.g. they want to display or search through all the data they have access // to. if (inputs.getMyData()) { joinClause.emplace_back("JOIN inves.investigationUsers users"); joinClause.emplace_back("JOIN users.user user"); whereClause.emplace_back("user.name = :user"); } // Investigators complete name. if (!inputs.getInvestigatorSurName().empty()) { // We join another investigationUsers & user tables as we need two aliases. joinClause.emplace_back("JOIN inves.investigationUsers usrs"); joinClause.emplace_back("JOIN usrs.user usr"); whereClause.emplace_back("usr.fullName LIKE '%" + inputs.getInvestigatorSurName() + "%'"); } // Similar to above. We check if either has been input, // join the related table and add the specific WHERE clause. if (!inputs.getDatafileName().empty() || (inputs.getRunStart() > 0 && inputs.getRunEnd() > 0)) { joinClause.emplace_back("JOIN inves.datasets dataset"); joinClause.emplace_back("JOIN dataset.datafiles datafile"); if (!inputs.getDatafileName().empty()) { whereClause.emplace_back("datafile.name LIKE '%" + inputs.getDatafileName() + "%'"); } if (inputs.getRunStart() > 0 && inputs.getRunEnd() > 0) { joinClause.emplace_back("JOIN datafile.parameters datafileparameters"); joinClause.emplace_back("JOIN datafileparameters.type dtype"); whereClause.emplace_back("dtype.name='run_number' AND " "datafileparameters.numericValue BETWEEN " + Strings::toString(inputs.getRunStart()) + " AND " + Strings::toString(inputs.getRunEnd()) + ""); } } std::string query; // This prevents the user searching the entire archive (E.g. there is no // "default" query). if (!whereClause.empty() || !joinClause.empty()) { std::string from, join, where, orderBy, includes; from = " FROM Investigation inves "; join = Strings::join(joinClause.begin(), joinClause.end(), " "); where = Strings::join(whereClause.begin(), whereClause.end(), " AND "); orderBy = " ORDER BY inves.id DESC"; includes = " INCLUDE inves.facility, " "inves.investigationInstruments.instrument, inves.parameters"; // As we joined all WHERE clause with AND we need to include the WHERE at // the start of the where segment. where.insert(0, " WHERE "); // Build the query from the result. query = from + join + where + orderBy + includes; } return (query); }
void ICQInfo::fill() { ICQUserData *data = m_data; if (data == NULL) data = &m_client->data.owner; edtUin->setText(QString::number(data->Uin.value)); Contact *contact = getContacts()->contact(m_contact); edtFirst->setText(getContacts()->toUnicode(contact, data->FirstName.ptr)); edtLast->setText(getContacts()->toUnicode(contact, data->LastName.ptr)); edtNick->setText(getContacts()->toUnicode(contact, data->Nick.ptr)); if (m_data == NULL){ if (edtFirst->text().isEmpty()) { QString firstName = getContacts()->owner()->getFirstName(); firstName = getToken(firstName, '/'); edtFirst->setText(firstName); } if (edtLast->text().isEmpty()) { QString lastName = getContacts()->owner()->getLastName(); lastName = getToken(lastName, '/'); edtLast->setText(lastName); } password->setEnabled(m_client->getState() == Client::Connected); } cmbStatus->clear(); unsigned status = STATUS_ONLINE; if (m_data){ unsigned s = m_data->Status.value; if (s == ICQ_STATUS_OFFLINE){ status = STATUS_OFFLINE; }else if (s & ICQ_STATUS_DND){ status = STATUS_DND; }else if (s & ICQ_STATUS_OCCUPIED){ status = STATUS_OCCUPIED; }else if (s & ICQ_STATUS_NA){ status = STATUS_NA; }else if (s & ICQ_STATUS_AWAY){ status = STATUS_AWAY; }else if (s & ICQ_STATUS_FFC){ status = STATUS_FFC; } }else{ status = m_client->getStatus(); initCombo(cmbRandom, m_client->getRandomChatGroup(), chat_groups); } if ((status != STATUS_ONLINE) && (status != STATUS_OFFLINE) && m_data){ edtAutoReply->setText(getContacts()->toUnicode(getContacts()->contact(m_contact), m_data->AutoReply.ptr)); }else{ edtAutoReply->hide(); } int current = 0; const char *text = NULL; if (m_data && (status == STATUS_OFFLINE) && m_data->bInvisible.bValue){ cmbStatus->insertItem(Pict("ICQ_invisible"), i18n("Possibly invisible")); }else{ for (const CommandDef *cmd = ICQPlugin::m_icq->statusList(); cmd->id; cmd++){ if (cmd->flags & COMMAND_CHECK_STATE) continue; if (status == cmd->id){ current = cmbStatus->count(); text = cmd->text; } cmbStatus->insertItem(Pict(cmd->icon), i18n(cmd->text)); } } cmbStatus->setCurrentItem(current); disableWidget(cmbStatus); if (status == STATUS_OFFLINE){ lblOnline->setText(i18n("Last online") + ":"); edtOnline->setText(formatDateTime(data->StatusTime.value)); lblNA->hide(); edtNA->hide(); }else{ if (data->OnlineTime.value){ edtOnline->setText(formatDateTime(data->OnlineTime.value)); }else{ lblOnline->hide(); edtOnline->hide(); } if ((status == STATUS_ONLINE) || (text == NULL)){ lblNA->hide(); edtNA->hide(); }else{ lblNA->setText(i18n(text)); edtNA->setText(formatDateTime(data->StatusTime.value)); } } if (data->IP.ptr){ edtExtIP->setText(formatAddr(data->IP, data->Port.value)); }else{ lblExtIP->hide(); edtExtIP->hide(); } if ((data->RealIP.ptr) && ((data->IP.ptr == NULL) || (get_ip(data->IP) != get_ip(data->RealIP)))){ edtIntIP->setText(formatAddr(data->RealIP, data->Port.value)); }else{ lblIntIP->hide(); edtIntIP->hide(); } if (m_data){ string client_name = m_client->clientName(data); if (client_name.length()){ edtClient->setText(client_name.c_str()); }else{ lblClient->hide(); edtClient->hide(); } }else{ string name = PACKAGE; name += " "; name += VERSION; #ifdef WIN32 name += "/win32"; #endif edtClient->setText(name.c_str()); } }
QString KLocale::formatDateTime(const KDateTime &dateTime, KLocale::DateFormat format, DateTimeFormatOptions options) const { return d->formatDateTime(dateTime, format, options); }
QString YahooClient::contactTip(void *_data) { YahooUserData *data = (YahooUserData*)_data; unsigned long status = STATUS_UNKNOWN; unsigned style = 0; const char *statusIcon = NULL; contactInfo(data, status, style, statusIcon); QString res; res += "<img src=\"icon:"; res += statusIcon; res += "\">"; QString statusText; for (const CommandDef *cmd = protocol()->statusList(); cmd->text; cmd++) { if (!strcmp(cmd->icon, statusIcon)) { res += " "; statusText = i18n(cmd->text); res += statusText; break; } } res += "<br>"; res += QString::fromUtf8(data->Login.ptr); res += "</b>"; if (data->Status.value == YAHOO_STATUS_OFFLINE) { if (data->StatusTime.value) { res += "<br><font size=-1>"; res += i18n("Last online"); res += ": </font>"; res += formatDateTime(data->StatusTime.value); } } else { if (data->OnlineTime.value) { res += "<br><font size=-1>"; res += i18n("Online"); res += ": </font>"; res += formatDateTime(data->OnlineTime.value); } if (data->Status.value != YAHOO_STATUS_AVAILABLE) { res += "<br><font size=-1>"; res += statusText; res += ": </font>"; res += formatDateTime(data->StatusTime.value); QString msg; switch (data->Status.value) { case YAHOO_STATUS_BRB: msg = i18n("Be right back"); break; case YAHOO_STATUS_NOTATHOME: msg = i18n("Not at home"); break; case YAHOO_STATUS_NOTATDESK: msg = i18n("Not at my desk"); break; case YAHOO_STATUS_NOTINOFFICE: msg = i18n("Not in the office"); break; case YAHOO_STATUS_ONPHONE: msg = i18n("On the phone"); break; case YAHOO_STATUS_ONVACATION: msg = i18n("On vacation"); break; case YAHOO_STATUS_OUTTOLUNCH: msg = i18n("Out to lunch"); break; case YAHOO_STATUS_STEPPEDOUT: msg = i18n("Stepped out"); break; case YAHOO_STATUS_CUSTOM: if (data->AwayMessage.ptr) msg = QString::fromUtf8(data->AwayMessage.ptr); } if (!msg.isEmpty()) { res += "<br>"; res += quoteString(msg); } } } return res; }
void YahooInfo::fill() { YahooUserData *data = m_data; if (data == NULL) data = &m_client->data.owner; edtLogin->setText(QString::fromUtf8(data->Login.ptr)); edtNick->setText(data->Nick.ptr ? QString::fromUtf8(data->Nick.ptr) : QString("")); edtFirst->setText(data->First.ptr ? QString::fromUtf8(data->First.ptr) : QString("")); edtLast->setText(data->Last.ptr ? QString::fromUtf8(data->Last.ptr) : QString("")); int current = 0; const char *text = NULL; unsigned long status = STATUS_OFFLINE; if (m_data == NULL){ if (m_client->getState() == Client::Connected){ const char *statusIcon = NULL; unsigned style = 0; m_client->contactInfo(&m_client->data.owner, status, style, statusIcon); } }else{ const char *statusIcon = NULL; unsigned style = 0; m_client->contactInfo(data, status, style, statusIcon); } for (const CommandDef *cmd = m_client->protocol()->statusList(); cmd->id; cmd++){ if (cmd->flags & COMMAND_CHECK_STATE) continue; if (status == cmd->id){ current = cmbStatus->count(); text = cmd->text; } cmbStatus->insertItem(Pict(cmd->icon), i18n(cmd->text)); } cmbStatus->setCurrentItem(current); disableWidget(cmbStatus); if (status == STATUS_OFFLINE){ if (data->StatusTime.value){ lblOnline->setText(i18n("Last online") + ":"); edtOnline->setText(formatDateTime(data->StatusTime.value)); lblOnline->show(); edtOnline->show(); }else{ lblOnline->hide(); edtOnline->hide(); } lblNA->hide(); edtNA->hide(); }else{ if (data->OnlineTime.value){ edtOnline->setText(formatDateTime(data->OnlineTime.value)); }else{ lblOnline->hide(); edtOnline->hide(); } if ((status == STATUS_ONLINE) || (text == NULL)){ lblNA->hide(); edtNA->hide(); }else{ lblNA->setText(i18n(text)); edtNA->setText(formatDateTime(data->StatusTime.value)); } } if (m_bInit) return; m_bInit = true; fillEncoding(data); }