forked from altairwei/WizNotePlus
-
Notifications
You must be signed in to change notification settings - Fork 0
/
WizInfoBar.cpp
executable file
·69 lines (56 loc) · 2.06 KB
/
WizInfoBar.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#include "WizInfoBar.h"
#include <QLabel>
#include <QHBoxLayout>
#include <sstream>
#include <string>
#include <QDebug>
#include "utils/WizStyleHelper.h"
#include "share/WizObject.h"
#include "database/WizDatabaseManager.h"
#include "database/WizDatabase.h"
#include "share/WizMisc.h"
#include "WizDef.h"
WizInfoBar::WizInfoBar(WizExplorerApp& app, QWidget *parent)
: QWidget(parent)
, m_app(app)
{
setContentsMargins(0, 0, 0, 6);
int nHeight = Utils::WizStyleHelper::infoBarHeight();
setFixedHeight(nHeight);
QHBoxLayout* layout = new QHBoxLayout();
layout->setContentsMargins(0, 0, 0, 0);
layout->setSpacing(10);
setLayout(layout);
m_labelCreatedTime = new QLabel(this);
m_labelModifiedTime = new QLabel(this);
m_labelOwner = new QLabel(this);
m_labelSize = new QLabel(this);
layout->addWidget(m_labelCreatedTime);
layout->addWidget(m_labelModifiedTime);
layout->addWidget(m_labelOwner);
layout->addWidget(m_labelSize);
layout->addStretch();
}
void WizInfoBar::setDocument(const WIZDOCUMENTDATA& data)
{
QString strCreateTime = QObject::tr("Create time: ") + data.tCreated.toString("yyyy/M/d");
m_labelCreatedTime->setText(strCreateTime);
QString strModifiedTime = QObject::tr("Update time: ") + data.tDataModified.toString("yyyy/M/d");
m_labelModifiedTime->setText(strModifiedTime);
WizDatabase& db = m_app.databaseManager().db(data.strKbGUID);
if (db.isGroup())
{
QString strOwner = db.getDocumentOwnerAlias(data);
strOwner = QObject::tr("Owner: ") + (strOwner.isEmpty() ? data.strOwner : strOwner);
strOwner = fontMetrics().elidedText(strOwner, Qt::ElideRight, 150);
m_labelOwner->setVisible(true);
m_labelOwner->setText(strOwner);
}
else
{
m_labelOwner->setVisible(false);
}
QString strFile = db.getDocumentFileName(data.strGUID);
QString strSize = QObject::tr("Size: ") + ::WizGetFileSizeHumanReadalbe(strFile);
m_labelSize->setText(strSize);
}