@@ -37,6 +37,7 @@ History::History(QWidget *parent) : QDockWidget(parent), ui(new Ui::History)
37
37
connect (this ->timerRetrievePageInformation , SIGNAL (timeout ()), this , SLOT (Tick ()));
38
38
this ->ui ->tableWidget ->setContextMenuPolicy (Qt::CustomContextMenu);
39
39
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)));
40
41
this ->ui ->tableWidget ->setColumnCount (5 );
41
42
QStringList header;
42
43
header << _l (" [[id]]" ) << _l (" [[type]]" ) << _l (" [[target]]" ) << _l (" result" ) << _l (" project" );
@@ -156,57 +157,7 @@ void History::ContextMenu(const QPoint &position)
156
157
this ->Undo (nullptr );
157
158
} else if (selection == show)
158
159
{
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 ();
210
161
} else if (selection == clean)
211
162
{
212
163
this ->DeleteItems ();
@@ -380,3 +331,64 @@ void History::on_tableWidget_itemSelectionChanged()
380
331
return ;
381
332
this ->CurrentItem = this ->ui ->tableWidget ->selectedItems ().at (0 )->row ();
382
333
}
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
+ }
0 commit comments