本文整理汇总了C++中QDateTime::fromMSecsSinceEpoch方法的典型用法代码示例。如果您正苦于以下问题:C++ QDateTime::fromMSecsSinceEpoch方法的具体用法?C++ QDateTime::fromMSecsSinceEpoch怎么用?C++ QDateTime::fromMSecsSinceEpoch使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QDateTime
的用法示例。
在下文中一共展示了QDateTime::fromMSecsSinceEpoch方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: dataRX
void cChannelSession::dataRX(const QVector<QByteArray> &data)
{
if (data.count() < 2)
{
qDebug() << "[ERROR]cChannelSession::dataRX-> Pocos campos... :" << data.count();
return;
}
int cmd = data[1].toInt();
//qDebug() << "[INFO]cChannelSession::dataRX-> Comando:" << cmd;
if(cmd == CMD_JOIN_SESSION)
{
QString id = data[2];
emit join_session(id);
}
else if (cmd == CMD_SESSION_STATUS)
{
QString id = data[2];
bool status = data[3].toInt();
QString reason = data[4];
emit session_status(id,status,reason);
}
else if (cmd == CMD_GET_SESSION_USERLIST)
{
QString id = data[2];
emit get_session_userlist(id);
}
else if (cmd == CMD_SESSION_USERLIST)
{
QString id = data[2];
QByteArray array = data[3];
cUsersInfoList userslist(array);
emit session_userlist(id,userslist);
}
else if (cmd == CMD_GET_CHATROOM_LIST)
{
QString id = data[2];
emit get_chatroom_list(id);
}
else if (cmd == CMD_CHATROOM_LIST)
{
QString id = data[2];
QVector<cChatInfo> chats;
for ( int i = 3 ; i < data.count() ; i+=3 )
{
cChatInfo chatroom(data[i],data[i+1],data[i+2].toInt());
chats.append(chatroom);
}
emit chatroom_list(id,chats);
}
else if(cmd == CMD_JOIN_CHATROOM)
{
QString id = data[2];
emit join_chatroom(id);
}
else if(cmd == CMD_CHATROOM_STATUS)
{
QString id = data[2];
bool status = data[3].toInt();
QString reason = data[4];
emit chatroom_status(id,status,reason);
}
else if(cmd == CMD_GET_CHATROOM_USERLIST)
{
QString chatroom_id = data[2];
emit get_chatroom_userlist(chatroom_id);
}
else if(cmd == CMD_CHATROOM_USERLIST)
{
QString id = data[2];
QByteArray array = data[3];
cUsersInfoList userslist(array);
emit chatroom_userlist(id,userslist);
}
else if(cmd == CMD_CREATE_CHATROOM)
{
QString name = data[2];
bool persistent = data[3].toInt();
emit create_chatroom(name,persistent);
}
else if(cmd == CMD_CHATROOM_MSG)
{
QVector<cChatMsg> msgs;
QString id = data[2];
for ( int i = 3 ; i < data.count() ; i+=3 )
{
QDateTime timestamp;
timestamp.fromMSecsSinceEpoch(data[i+2].toInt());
cChatMsg msg(data[i],data[i+1],timestamp);
msgs.append(msg);
}
emit chatroom_msg(id,msgs);
}
else if(cmd == CMD_GET_FILELIST)
{
QString id = data[2];
emit get_file_list(id);
}
else if(cmd == CMD_FILELIST)
{
QString id = data[2];
//.........这里部分代码省略.........
示例2: Load
void TEventsLog::Load()
{
#ifdef __linux__
QDir::setCurrent("/mnt/localdisk/oscs");
#endif
qDebug() << tr("Read EvLog-file...");
EventsList_Model.setRowCount(0);
int row=0;
QFile EvLogFile(EVLOG_FILENAME);
if (!EvLogFile.open(QIODevice::ReadOnly | QIODevice::Text)) qDebug() << tr("File open error!");
else
{
#define LINE_IN_CP1251_LEN_MAX 1024
char line_in_cp1251[LINE_IN_CP1251_LEN_MAX];
while (!EvLogFile.atEnd())
{
int len=EvLogFile.readLine(line_in_cp1251, LINE_IN_CP1251_LEN_MAX);
if(len)
{
char *buf=new char[len*4+1];
cp1251_to_utf8(buf, line_in_cp1251);
QStringList fields = QString(buf).split(";");
delete buf;
if(fields.size() == EventsList_Model.columnCount())
{
//Если список полный - удаление превой строки
if(row==EVLOG_NUM_MAX)
{
row--;
EventsList_Model.removeRow(0);
}
for(int column=0; column<EventsList_Model.columnCount(); column++)
{
QString text=fields[column];
/*
//Дата и время на разных строках...
if(column==0)
{
QStringList datetime = QString(text).split(" ");
if(datetime.count()>1)
{
text=datetime[0]+"\n"+datetime[1];
}
}*/
QStandardItem *item = new QStandardItem(text);
item->setEditable(false);
EventsList_Model.setItem(row, column, item);
}
row++;
}
}
}
EvLogFile.close();
qDebug() << tr("Events count: ") << QString("%1").number(EventsList_Model.rowCount());
}
qDebug() << tr("Search for index of last oscillogram...");
QDir dir;
//QApplication::processEvents();
QFileInfoList listFiles = dir.entryInfoList(QStringList("*.OSD"), QDir::Files);
QDateTime last;
last.fromMSecsSinceEpoch(0);
foreach(QFileInfo file, listFiles)
{
QString name = QStringList(file.fileName().split(".")).at(0);
bool ok;
name.remove(QRegExp("[A-Za-z]"));
int i=name.toInt(&ok);
if(ok && (file.lastModified()>last))
{
last = file.lastModified();
OscIndex=i+1;
}
}