1
0
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:
Anthony Bilinski 2020-04-05 01:30:27 -07:00
parent 6c34fad9b6
commit 31346423e1
No known key found for this signature in database
GPG Key ID: 2AA8E0DA1B31FB3C
4 changed files with 22 additions and 83 deletions

View File

@ -822,22 +822,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);
}
}
@ -1044,13 +1034,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()

View File

@ -66,15 +66,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);

View File

@ -33,17 +33,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);

View File

@ -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>