- make ClientModel::formatClientStartupTime() return a QString
Note: Logged time in debug.log differs by a few seconds from the one displayed in the Debug window because of different initialisation times.
Note: Logged time in debug.log differs by a few seconds from the one displayed in the Debug window because of different initialisation times.
I dont see any reason to make nClientStartupTime yet another global, throwing in one more call to GetTime() seems cleaner to me, but maybe I just hate globals.
The global is used by the GUI Debug window and IS present in the current code. It only moved from clientmodel.cpp to util.cpp, to allow usage in the debug.log entry.
Putting something in util.h is very different from qt/clientmodel.cpp, but Im probably just overly global-hating.
Luke-Jr encouraged me to use a global ... seems like it's hard sometimes to get to the best approach. If no one thinks this is beneficial, just close the pull.
I don't see why you need a global for this? You only use it once...
I think its beneficial, and have no problem with it in general, my point was simply to remove the global definitions, and replace the single use in init.cpp with a call to GetTime().
I checked the GUI code and yes, I can safely remove the whole global ;). Will update tomorrow!
128 | @@ -130,9 +129,9 @@ QString ClientModel::clientName() const 129 | return QString::fromStdString(CLIENT_NAME); 130 | } 131 | 132 | -QDateTime ClientModel::formatClientStartupTime() const 133 | +QString ClientModel::formatGetTime() const
Doesn't Qt have it's own format time function? There's no need to put this in clientmodel as this requests nothing from the client.
When removing the constant, I did not consider to remove this, will update.
Ah I get it. I guess you want to store the time when the ClientModel is created. Better to add a QDateTime field to the structure, fill it in the constructor, then return that?
I would say it's even sufficient to add the time once in the RPCConsole constructor, via ui->startupTime->setText(QDateTime::fromTime_t(GetTime()).toString());, or should that stay in RPCConsole::setClientModel()?
IMO it should stay in ClientModel. Don't put such state in views, better not to rely on it that RPCConsole is created once at the beginning of the program and kept around forever. This may change later.
I now only changed the code in ClientModel to return a QString, to not rely on RPCConsole object persistence.
Yeah that's fine... though officially it'd be better to return a datetime as that leaves formatting to the view instead of the model... in this case this is the same as we do for the other datetimes. It's only a minor thing anyway.
Alright, updated and final now.
ACK
Yeah, while a global makes sense for what you were doing before, this one-time use doesn't need it ;)
Looks good, but I only ACK stuff after I have actually tested it myself. ;)