mirror of
https://github.com/qTox/qTox.git
synced 2024-03-22 14:00:36 +08:00
revert(chatlog): "edit function "Load chat history""
This reverts commit 6de1173c17
.
This commit is contained in:
parent
8e03aa4b17
commit
c75d8c8d3e
|
@ -805,22 +805,12 @@ void GenericChatForm::onLoadHistory()
|
|||
{
|
||||
LoadHistoryDialog dlg(&chatLog);
|
||||
if (dlg.exec()) {
|
||||
QDateTime time = dlg.getFromDate();
|
||||
auto idx = firstItemAfterDate(dlg.getFromDate().date(), chatLog);
|
||||
auto end = ChatLogIdx(idx.get() + 100);
|
||||
chatWidget->clear();
|
||||
messages.clear();
|
||||
|
||||
QDateTime time = dlg.getFromDate();
|
||||
auto type = dlg.getLoadType();
|
||||
|
||||
auto begin = firstItemAfterDate(dlg.getFromDate().date(), chatLog);
|
||||
auto end = ChatLogIdx(begin.get() + 1);
|
||||
|
||||
renderMessages(begin, end);
|
||||
|
||||
if (type == LoadHistoryDialog::from) {
|
||||
loadHistoryUpper();
|
||||
} else {
|
||||
loadHistoryLower();
|
||||
}
|
||||
renderMessages(idx, end);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -990,13 +980,15 @@ void GenericChatForm::renderMessages(ChatLogIdx begin, ChatLogIdx end,
|
|||
|
||||
void GenericChatForm::loadHistoryLower()
|
||||
{
|
||||
auto end = messages.begin()->first;
|
||||
auto begin = ChatLogIdx(0);
|
||||
if (end.get() > 100) {
|
||||
begin = ChatLogIdx(end.get() - 100);
|
||||
auto begin = messages.begin()->first;
|
||||
|
||||
if (begin.get() > 100) {
|
||||
begin = ChatLogIdx(begin.get() - 100);
|
||||
} else {
|
||||
begin = ChatLogIdx(0);
|
||||
}
|
||||
|
||||
renderMessages(begin, end);
|
||||
renderMessages(begin, chatLog.getNextIdx());
|
||||
}
|
||||
|
||||
void GenericChatForm::loadHistoryUpper()
|
||||
|
|
|
@ -62,15 +62,6 @@ QDateTime LoadHistoryDialog::getFromDate()
|
|||
return res;
|
||||
}
|
||||
|
||||
LoadHistoryDialog::LoadType LoadHistoryDialog::getLoadType()
|
||||
{
|
||||
if (ui->loadTypeComboBox->currentIndex() == 0) {
|
||||
return LoadType::from;
|
||||
}
|
||||
|
||||
return LoadType::to;
|
||||
}
|
||||
|
||||
void LoadHistoryDialog::setTitle(const QString& title)
|
||||
{
|
||||
setWindowTitle(title);
|
||||
|
|
|
@ -34,17 +34,11 @@ class LoadHistoryDialog : public QDialog
|
|||
Q_OBJECT
|
||||
|
||||
public:
|
||||
enum LoadType {
|
||||
from,
|
||||
to
|
||||
};
|
||||
|
||||
explicit LoadHistoryDialog(const IChatLog* chatLog, QWidget* parent = nullptr);
|
||||
explicit LoadHistoryDialog(QWidget* parent = nullptr);
|
||||
~LoadHistoryDialog();
|
||||
|
||||
QDateTime getFromDate();
|
||||
LoadType getLoadType();
|
||||
void setTitle(const QString& title);
|
||||
void setInfoLabel(const QString& info);
|
||||
|
||||
|
|
|
@ -6,8 +6,8 @@
|
|||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>410</width>
|
||||
<height>332</height>
|
||||
<width>347</width>
|
||||
<height>264</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
|
@ -16,60 +16,22 @@
|
|||
<property name="modal">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<layout class="QFormLayout" name="formLayout">
|
||||
<item row="0" column="0">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<widget class="QLabel" name="fromLabel">
|
||||
<property name="text">
|
||||
<string>Load history</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QComboBox" name="loadTypeComboBox">
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>from</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>to</string>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string>(about 100 messages are loaded)</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>17</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_3">
|
||||
<item>
|
||||
<widget class="QLabel" name="fromLabel">
|
||||
<property name="text">
|
||||
<string>Load history from:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<item>
|
||||
<widget class="QCalendarWidget" name="fromDate">
|
||||
<property name="gridVisible">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<item>
|
||||
<widget class="QDialogButtonBox" name="buttonBox">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
|
|
Loading…
Reference in New Issue
Block a user