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); LoadHistoryDialog dlg(&chatLog);
if (dlg.exec()) { if (dlg.exec()) {
QDateTime time = dlg.getFromDate();
auto idx = firstItemAfterDate(dlg.getFromDate().date(), chatLog);
auto end = ChatLogIdx(idx.get() + 100);
chatWidget->clear(); chatWidget->clear();
messages.clear(); messages.clear();
renderMessages(idx, end);
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();
}
} }
} }
@ -1044,13 +1034,15 @@ void GenericChatForm::renderMessages(ChatLogIdx begin, ChatLogIdx end,
void GenericChatForm::loadHistoryLower() void GenericChatForm::loadHistoryLower()
{ {
auto end = messages.begin()->first; auto begin = messages.begin()->first;
auto begin = ChatLogIdx(0);
if (end.get() > 100) { if (begin.get() > 100) {
begin = ChatLogIdx(end.get() - 100); begin = ChatLogIdx(begin.get() - 100);
} else {
begin = ChatLogIdx(0);
} }
renderMessages(begin, end); renderMessages(begin, chatLog.getNextIdx());
} }
void GenericChatForm::loadHistoryUpper() void GenericChatForm::loadHistoryUpper()

View File

@ -66,15 +66,6 @@ QDateTime LoadHistoryDialog::getFromDate()
return res; return res;
} }
LoadHistoryDialog::LoadType LoadHistoryDialog::getLoadType()
{
if (ui->loadTypeComboBox->currentIndex() == 0) {
return LoadType::from;
}
return LoadType::to;
}
void LoadHistoryDialog::setTitle(const QString& title) void LoadHistoryDialog::setTitle(const QString& title)
{ {
setWindowTitle(title); setWindowTitle(title);

View File

@ -33,17 +33,11 @@ class LoadHistoryDialog : public QDialog
Q_OBJECT Q_OBJECT
public: public:
enum LoadType {
from,
to
};
explicit LoadHistoryDialog(const IChatLog* chatLog, QWidget* parent = nullptr); explicit LoadHistoryDialog(const IChatLog* chatLog, QWidget* parent = nullptr);
explicit LoadHistoryDialog(QWidget* parent = nullptr); explicit LoadHistoryDialog(QWidget* parent = nullptr);
~LoadHistoryDialog(); ~LoadHistoryDialog();
QDateTime getFromDate(); QDateTime getFromDate();
LoadType getLoadType();
void setTitle(const QString& title); void setTitle(const QString& title);
void setInfoLabel(const QString& info); void setInfoLabel(const QString& info);

View File

@ -6,8 +6,8 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>410</width> <width>347</width>
<height>332</height> <height>264</height>
</rect> </rect>
</property> </property>
<property name="windowTitle"> <property name="windowTitle">
@ -16,60 +16,22 @@
<property name="modal"> <property name="modal">
<bool>true</bool> <bool>true</bool>
</property> </property>
<layout class="QFormLayout" name="formLayout"> <layout class="QVBoxLayout" name="verticalLayout_3">
<item row="0" column="0"> <item>
<layout class="QHBoxLayout" name="horizontalLayout"> <widget class="QLabel" name="fromLabel">
<item> <property name="text">
<widget class="QLabel" name="fromLabel"> <string>Load history from:</string>
<property name="text"> </property>
<string>Load history</string> </widget>
</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>
</item> </item>
<item row="1" column="0"> <item>
<widget class="QCalendarWidget" name="fromDate"> <widget class="QCalendarWidget" name="fromDate">
<property name="gridVisible"> <property name="gridVisible">
<bool>false</bool> <bool>false</bool>
</property> </property>
</widget> </widget>
</item> </item>
<item row="2" column="0"> <item>
<widget class="QDialogButtonBox" name="buttonBox"> <widget class="QDialogButtonBox" name="buttonBox">
<property name="orientation"> <property name="orientation">
<enum>Qt::Horizontal</enum> <enum>Qt::Horizontal</enum>