-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathtabcommon.cpp
72 lines (61 loc) · 2.03 KB
/
tabcommon.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
70
71
72
#include "tabcommon.h"
#include "global.h"
tabCommon::tabCommon(MainWindow *p) :
SWidget(p)
{
installEventFilter(this);
connect(this, &tabCommon::tabClosed, p, &MainWindow::switchToLastUsedTab);
#ifdef QT_DEBUG
test_scheduler = new QTimer();
test_scheduler->setSingleShot(true);
test_scheduler2 = new QTimer();
test_scheduler2->setSingleShot(true);
QObject::connect(test_scheduler, SIGNAL(timeout()), this, SLOT(test_scheduler_handler()));
QObject::connect(test_scheduler2, SIGNAL(timeout()), this, SLOT(test_scheduler2_handler()));
#endif
}
tabCommon::~tabCommon()
{
userDbData->updateActivityTimestamp();
while(tabList.removeOne(this));
// если вкладка создана с другой вкладки (выбор клиента/ремонта/др.), то сработает механизм переключения на вызвавшую вкладку,
// иначе переключение на последнюю использованную вкладку
if(callerPtr == nullptr)
emit tabClosed();
#ifdef QT_DEBUG
delete test_scheduler;
delete test_scheduler2;
#endif
}
bool tabCommon::tabCloseRequest()
{
return 1;
}
void tabCommon::setTabTitle(const QString &title)
{
i_tabTitle = title;
emit updateTabTitle(this);
}
QIcon *tabCommon::tabIcon()
{
return i_tabIcon;
}
bool tabCommon::eventFilter(QObject*, QEvent *event)
{
// if(event->type() != QEvent::Paint)
// qDebug().nospace() << "[" << this << "] tabCommon::eventFilter() | event->type(): " << event->type();
if(event->type() == QEvent::HideToParent)
tabList.append(this);
return false;
}
void tabCommon::setCursorPositionsToZero()
{
QLineEdit *le;
QList<QLineEdit*> list = this->findChildren<QLineEdit*>(QRegularExpression(".*"));
foreach(le, list)
le->setCursorPosition(0);
}
void tabCommon::logUserActivity()
{
userActivityLog->appendRecord("Navigation " + tabTitle());
}