Skip to content

Commit 518e2f4

Browse files
committed
double click in own history shows edit now
1 parent 9a4d18d commit 518e2f4

File tree

2 files changed

+65
-51
lines changed

2 files changed

+65
-51
lines changed

src/huggle_ui/history.cpp

Lines changed: 63 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ History::History(QWidget *parent) : QDockWidget(parent), ui(new Ui::History)
3737
connect(this->timerRetrievePageInformation, SIGNAL(timeout()), this, SLOT(Tick()));
3838
this->ui->tableWidget->setContextMenuPolicy(Qt::CustomContextMenu);
3939
connect(this->ui->tableWidget, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(ContextMenu(QPoint)));
40+
connect(this->ui->tableWidget, SIGNAL(doubleClicked(QModelIndex)), this, SLOT(on_tableWidget_doubleClicked(QModelIndex)));
4041
this->ui->tableWidget->setColumnCount(5);
4142
QStringList header;
4243
header << _l("[[id]]") << _l("[[type]]") << _l("[[target]]") << _l("result") << _l("project");
@@ -156,57 +157,7 @@ void History::ContextMenu(const QPoint &position)
156157
this->Undo(nullptr);
157158
} else if (selection == show)
158159
{
159-
if (this->DisplayedEdit != nullptr)
160-
{
161-
this->timerDisplayEditFromHistLs->stop();
162-
}
163-
// now the tricky part is here, we need to get an undo item and display it
164-
HistoryItem *hi;
165-
if (this->CurrentItem < 0)
166-
{
167-
Syslog::HuggleLogs->ErrorLog(_l("history-no-item-selected"));
168-
return;
169-
}
170-
hi = this->Items.at(this->CurrentItem);
171-
QString page = hi->Target;
172-
Collectable_SmartPtr<WikiEdit> edit;
173-
switch (hi->Type)
174-
{
175-
case HistoryMessage:
176-
page = "User_talk:" + page;
177-
case HistoryEdit:
178-
case HistoryRollback:
179-
// let's see if we know this edit
180-
edit = WikiEdit::FromCacheByRevID(hi->RevID);
181-
if (edit == nullptr)
182-
{
183-
// if we don't know it we need to create it
184-
edit = new WikiEdit();
185-
edit->Page = new WikiPage(page, hi->GetSite());
186-
edit->User = new WikiUser(hcfg->SystemConfig_UserName, hi->GetSite());
187-
edit->RevID = hi->RevID;
188-
}
189-
break;
190-
case HistoryUnknown:
191-
case HistoryBlock:
192-
case HistoryUndelete:
193-
case HistoryDelete:
194-
case HistoryProtect:
195-
return;
196-
}
197-
if (!edit->IsPostProcessed())
198-
{
199-
// now we need to display it
200-
QueryPool::HugglePool->PreProcessEdit(edit);
201-
QueryPool::HugglePool->PostProcessEdit(edit);
202-
this->DisplayedEdit = edit;
203-
// we need to enable the timer and display this edit as soon as it is post processed
204-
this->timerDisplayEditFromHistLs->start(200);
205-
} else
206-
{
207-
// let's display it
208-
MainWindow::HuggleMain->ProcessEdit(edit);
209-
}
160+
this->ShowEdit();
210161
} else if (selection == clean)
211162
{
212163
this->DeleteItems();
@@ -380,3 +331,64 @@ void History::on_tableWidget_itemSelectionChanged()
380331
return;
381332
this->CurrentItem = this->ui->tableWidget->selectedItems().at(0)->row();
382333
}
334+
335+
void History::ShowEdit()
336+
{
337+
if (this->DisplayedEdit != nullptr)
338+
{
339+
this->timerDisplayEditFromHistLs->stop();
340+
}
341+
// now the tricky part is here, we need to get an undo item and display it
342+
HistoryItem *hi;
343+
if (this->CurrentItem < 0)
344+
{
345+
Syslog::HuggleLogs->ErrorLog(_l("history-no-item-selected"));
346+
return;
347+
}
348+
hi = this->Items.at(this->CurrentItem);
349+
QString page = hi->Target;
350+
Collectable_SmartPtr<WikiEdit> edit;
351+
switch (hi->Type)
352+
{
353+
case HistoryMessage:
354+
page = "User_talk:" + page;
355+
case HistoryEdit:
356+
case HistoryRollback:
357+
// let's see if we know this edit
358+
edit = WikiEdit::FromCacheByRevID(hi->RevID);
359+
if (edit == nullptr)
360+
{
361+
// if we don't know it we need to create it
362+
edit = new WikiEdit();
363+
edit->Page = new WikiPage(page, hi->GetSite());
364+
edit->User = new WikiUser(hcfg->SystemConfig_UserName, hi->GetSite());
365+
edit->RevID = hi->RevID;
366+
}
367+
break;
368+
case HistoryUnknown:
369+
case HistoryBlock:
370+
case HistoryUndelete:
371+
case HistoryDelete:
372+
case HistoryProtect:
373+
return;
374+
}
375+
if (!edit->IsPostProcessed())
376+
{
377+
// now we need to display it
378+
QueryPool::HugglePool->PreProcessEdit(edit);
379+
QueryPool::HugglePool->PostProcessEdit(edit);
380+
this->DisplayedEdit = edit;
381+
// we need to enable the timer and display this edit as soon as it is post processed
382+
this->timerDisplayEditFromHistLs->start(200);
383+
} else
384+
{
385+
// let's display it
386+
MainWindow::HuggleMain->ProcessEdit(edit);
387+
}
388+
}
389+
390+
void History::on_tableWidget_doubleClicked(const QModelIndex &index)
391+
{
392+
this->CurrentItem = index.row();
393+
this->ShowEdit();
394+
}

src/huggle_ui/history.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,10 +56,12 @@ namespace Huggle
5656
void Display();
5757
void on_tableWidget_clicked(const QModelIndex &index);
5858
void on_tableWidget_itemSelectionChanged();
59+
void on_tableWidget_doubleClicked(const QModelIndex &index);
5960

6061
private:
6162
void DeleteItems();
6263
void Fail();
64+
void ShowEdit();
6365
QTimer *timerRetrievePageInformation;
6466
Collectable_SmartPtr<HistoryItem> RevertingItem;
6567
QTimer *timerDisplayEditFromHistLs;

0 commit comments

Comments
 (0)