Skip to content

Commit 75dc705

Browse files
committed
minor refactoring
fixed unclear naming
1 parent bdf4c97 commit 75dc705

File tree

7 files changed

+89
-88
lines changed

7 files changed

+89
-88
lines changed

src/huggle_ui/history.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,7 @@ void History::Display()
277277
if (!this->DisplayedEdit->IsPostProcessed())
278278
return;
279279

280-
MainWindow::HuggleMain->ProcessEdit(this->DisplayedEdit);
280+
MainWindow::HuggleMain->DisplayEdit(this->DisplayedEdit);
281281
this->DisplayedEdit.Delete();
282282
this->timerDisplayEditFromHistLs->stop();
283283
}
@@ -383,7 +383,7 @@ void History::ShowEdit()
383383
} else
384384
{
385385
// let's display it
386-
MainWindow::HuggleMain->ProcessEdit(edit);
386+
MainWindow::HuggleMain->DisplayEdit(edit);
387387
}
388388
}
389389

src/huggle_ui/historyform.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ void HistoryForm::onTick01()
138138
{
139139
if (this->RetrievedEdit->IsPostProcessed())
140140
{
141-
MainWindow::HuggleMain->ProcessEdit(this->RetrievedEdit, false, true);
141+
MainWindow::HuggleMain->DisplayEdit(this->RetrievedEdit, false, true);
142142
this->RetrievingEdit = false;
143143
this->RetrievedEdit = nullptr;
144144
this->t1->stop();
@@ -387,7 +387,7 @@ void HistoryForm::GetEdit(long revid, QString prev, QString user, QString html,
387387
Collectable_SmartPtr<WikiEdit> edit = WikiEdit::FromCacheByRevID(revid, prev);
388388
if (edit != nullptr)
389389
{
390-
MainWindow::HuggleMain->ProcessEdit(edit, false, true);
390+
MainWindow::HuggleMain->DisplayEdit(edit, false, true);
391391
this->RetrievingEdit = false;
392392
this->MakeSelectedRowBold();
393393
MainWindow::HuggleMain->wEditBar->RefreshPage();

src/huggle_ui/hugglequeueitemlabel.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ void HuggleQueueItemLabel::SetLabelToolTip(QString text)
5656

5757
void HuggleQueueItemLabel::Process(QLayoutItem *qi)
5858
{
59-
MainWindow::HuggleMain->ProcessEdit(this->Edit);
59+
MainWindow::HuggleMain->DisplayEdit(this->Edit);
6060
this->Remove(qi);
6161
}
6262

src/huggle_ui/huggletool.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ void HuggleTool::finishEdit()
230230
return;
231231
this->tick->stop();
232232
this->ui->pushButtonLoad->setEnabled(true);
233-
MainWindow::HuggleMain->ProcessEdit(this->edit, false, false, false, true);
233+
MainWindow::HuggleMain->DisplayEdit(this->edit, false, false, false, true);
234234
}
235235

236236
QString HuggleTool::getColor(QString color)

src/huggle_ui/mainwindow.cpp

Lines changed: 72 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -496,10 +496,10 @@ QAction *MainWindow::GetMenuItem(int menu_item)
496496
}
497497
}
498498

499-
void MainWindow::ProcessEdit(WikiEdit *e, bool IgnoreHistory, bool KeepHistory, bool KeepUser, bool ForcedJump)
499+
void MainWindow::DisplayEdit(WikiEdit *edit, bool ignore_history, bool keep_history, bool keep_user, bool forced_jump)
500500
{
501501
HUGGLE_PROFILER_INCRCALL(BOOST_CURRENT_FUNCTION);
502-
if (e == nullptr || this->ShuttingDown)
502+
if (edit == nullptr || this->ShuttingDown)
503503
{
504504
// Huggle is either shutting down or edit is nullptr so we can't do anything here
505505
return;
@@ -509,7 +509,7 @@ void MainWindow::ProcessEdit(WikiEdit *e, bool IgnoreHistory, bool KeepHistory,
509509
// we need to delete this because it's related to an old edit
510510
this->qNext.Delete();
511511
}
512-
if (e->Page == nullptr || e->User == nullptr)
512+
if (edit->Page == nullptr || edit->User == nullptr)
513513
{
514514
throw new Huggle::NullPointerException("WikiEdit *e->Page || WikiEdit *e->User", BOOST_CURRENT_FUNCTION);
515515
}
@@ -519,47 +519,47 @@ void MainWindow::ProcessEdit(WikiEdit *e, bool IgnoreHistory, bool KeepHistory,
519519
this->OnNext_EvPage = nullptr;
520520
}
521521
// we need to safely delete the edit later
522-
e->IncRef();
522+
edit->IncRef();
523523
// if there are actually some totally old edits in history that we need to delete
524524
while (this->Historical.count() > Configuration::HuggleConfiguration->SystemConfig_HistorySize)
525525
{
526526
WikiEdit *prev = this->Historical.at(0);
527-
if (prev == e)
527+
if (prev == edit)
528528
break;
529529

530530
this->Historical.removeAt(0);
531531
prev->RemoveFromHistoryChain();
532532
prev->UnregisterConsumer(HUGGLECONSUMER_MAINFORM_HISTORICAL);
533533
}
534-
if (!this->Historical.contains(e))
534+
if (!this->Historical.contains(edit))
535535
{
536-
e->RegisterConsumer(HUGGLECONSUMER_MAINFORM_HISTORICAL);
537-
this->Historical.append(e);
536+
edit->RegisterConsumer(HUGGLECONSUMER_MAINFORM_HISTORICAL);
537+
this->Historical.append(edit);
538538
if (this->CurrentEdit != nullptr)
539539
{
540-
if (!IgnoreHistory)
540+
if (!ignore_history)
541541
{
542-
e->RemoveFromHistoryChain();
542+
edit->RemoveFromHistoryChain();
543543
// now we need to get to last edit in chain
544544
WikiEdit *latest = this->CurrentEdit;
545545
while (latest->Next != nullptr)
546546
latest = latest->Next;
547-
latest->Next = e;
548-
e->Previous = latest;
547+
latest->Next = edit;
548+
edit->Previous = latest;
549549
}
550550
}
551551
}
552-
this->Queue1->ChangeSite(e->GetSite());
553-
e->User->Resync();
554-
Configuration::HuggleConfiguration->ForceNoEditJump = ForcedJump;
555-
this->CurrentEdit = e;
552+
this->Queue1->ChangeSite(edit->GetSite());
553+
edit->User->Resync();
554+
Configuration::HuggleConfiguration->ForceNoEditJump = forced_jump;
555+
this->CurrentEdit = edit;
556556
this->editLoadDateTime = QDateTime::currentDateTime();
557-
this->Browser->DisplayDiff(e);
558-
this->Render(KeepHistory, KeepUser);
559-
e->DecRef();
557+
this->Browser->DisplayDiff(edit);
558+
this->Render(keep_history, keep_user);
559+
edit->DecRef();
560560
}
561561

562-
void MainWindow::Render(bool KeepHistory, bool KeepUser)
562+
void MainWindow::Render(bool keep_history, bool keep_user)
563563
{
564564
HUGGLE_PROFILER_INCRCALL(BOOST_CURRENT_FUNCTION);
565565
if (this->CurrentEdit != nullptr)
@@ -569,13 +569,13 @@ void MainWindow::Render(bool KeepHistory, bool KeepUser)
569569

570570
this->ui->actionFinal->setVisible(this->GetCurrentWikiSite()->GetProjectConfig()->InstantWarnings);
571571
this->wEditBar->RemoveAll();
572-
if (!KeepUser)
572+
if (!keep_user)
573573
{
574574
this->wUserInfo->ChangeUser(this->CurrentEdit->User);
575575
if (Configuration::HuggleConfiguration->UserConfig->HistoryLoad)
576576
this->wUserInfo->Read();
577577
}
578-
if (!KeepHistory)
578+
if (!keep_history)
579579
{
580580
this->wHistory->Update(this->CurrentEdit);
581581
if (Configuration::HuggleConfiguration->UserConfig->HistoryLoad)
@@ -765,14 +765,14 @@ void MainWindow::GoForward()
765765
{
766766
if (this->CurrentEdit == nullptr || this->CurrentEdit->Next == nullptr)
767767
return;
768-
this->ProcessEdit(this->CurrentEdit->Next, true);
768+
this->DisplayEdit(this->CurrentEdit->Next, true);
769769
}
770770

771771
void MainWindow::GoBackward()
772772
{
773773
if (this->CurrentEdit == nullptr || this->CurrentEdit->Previous == nullptr)
774774
return;
775-
this->ProcessEdit(this->CurrentEdit->Previous, true);
775+
this->DisplayEdit(this->CurrentEdit->Previous, true);
776776
}
777777

778778
void MainWindow::ShowToolTip(const QString& text)
@@ -1189,18 +1189,18 @@ QString MainWindow::WikiScriptURL()
11891189
Collectable_SmartPtr<RevertQuery> MainWindow::Revert(const QString& summary, bool next, bool single_rv)
11901190
{
11911191
bool rollback = true;
1192-
Collectable_SmartPtr<RevertQuery> ptr_;
1192+
Collectable_SmartPtr<RevertQuery> revert_query;
11931193
if (this->CurrentEdit == nullptr)
11941194
{
11951195
Syslog::HuggleLogs->ErrorLog(_l("main-revert-null"));
1196-
return ptr_;
1196+
return revert_query;
11971197
}
11981198
if (!this->CheckRevertable())
1199-
return ptr_;
1199+
return revert_query;
12001200
if (this->CurrentEdit->NewPage)
12011201
{
12021202
UiGeneric::pMessageBox(this, _l("main-revert-newpage-title"), _l("main-revert-newpage"), MessageBoxStyleNormal, true);
1203-
return ptr_;
1203+
return revert_query;
12041204
}
12051205
if (!this->CurrentEdit->IsPostProcessed())
12061206
{
@@ -1210,7 +1210,7 @@ Collectable_SmartPtr<RevertQuery> MainWindow::Revert(const QString& summary, boo
12101210

12111211
// We need to keep this check until that bug is fixed, translation of this is probably not necessary
12121212
Syslog::HuggleLogs->ErrorLog("This edit is still being processed, please wait");
1213-
return ptr_;
1213+
return revert_query;
12141214
}
12151215
if (this->CurrentEdit->GetSite()->GetProjectConfig()->Token_Rollback.isEmpty())
12161216
{
@@ -1224,29 +1224,29 @@ Collectable_SmartPtr<RevertQuery> MainWindow::Revert(const QString& summary, boo
12241224
Hooks::OnRevert(this->CurrentEdit);
12251225
if (hcfg->UserConfig->InsertEditsOfRolledUserToQueue)
12261226
this->insertRelatedEditsToQueue();
1227-
ptr_ = WikiUtil::RevertEdit(this->CurrentEdit, summary, false, rollback);
1228-
if (single_rv) { ptr_->SetLast(); }
1227+
revert_query = WikiUtil::RevertEdit(this->CurrentEdit, summary, false, rollback);
1228+
if (single_rv) { revert_query->SetLast(); }
12291229
if (Configuration::HuggleConfiguration->SystemConfig_InstantReverts)
12301230
{
1231-
ptr_->Process();
1231+
revert_query->Process();
12321232
} else
12331233
{
1234-
ptr_->Date = QDateTime::currentDateTime();
1235-
ptr_->IncRef();
1236-
this->RevertStack.append(ptr_);
1234+
revert_query->Date = QDateTime::currentDateTime();
1235+
revert_query->IncRef();
1236+
this->RevertStack.append(revert_query);
12371237
}
12381238
if (next)
1239-
this->DisplayNext(ptr_);
1239+
this->DisplayNext(revert_query);
12401240
}
1241-
return ptr_;
1241+
return revert_query;
12421242
}
12431243

1244-
bool MainWindow::preflightCheck(WikiEdit *_e)
1244+
bool MainWindow::preflightCheck(WikiEdit *edit)
12451245
{
12461246
HUGGLE_PROFILER_INCRCALL(BOOST_CURRENT_FUNCTION);
1247-
if (!Hooks::RevertPreflight(_e))
1247+
if (!Hooks::RevertPreflight(edit))
12481248
{
1249-
HUGGLE_DEBUG("Hook prevented revert of " + _e->Page->PageName, 2);
1249+
HUGGLE_DEBUG("Hook prevented revert of " + edit->Page->PageName, 2);
12501250
return false;
12511251
}
12521252
if (this->qNext != nullptr)
@@ -1255,28 +1255,28 @@ bool MainWindow::preflightCheck(WikiEdit *_e)
12551255
MessageBoxStyleNormal, true);
12561256
return false;
12571257
}
1258-
if (_e == nullptr)
1258+
if (edit == nullptr)
12591259
throw new Huggle::NullPointerException("WikiEdit *_e", BOOST_CURRENT_FUNCTION);
1260-
bool Warn = false;
1260+
bool warn = false;
12611261
QString type = _l("main-revert-type-unknown");
1262-
if (hcfg->SystemConfig_WarnUserSpaceRoll && _e->Page->IsUserpage())
1262+
if (hcfg->SystemConfig_WarnUserSpaceRoll && edit->Page->IsUserpage())
12631263
{
12641264
type = _l("main-revert-type-in-userspace");
1265-
Warn = true;
1266-
} else if (hcfg->ProjectConfig->ConfirmOnSelfRevs && (_e->User->Username.toLower() == hcfg->SystemConfig_UserName.toLower()))
1265+
warn = true;
1266+
} else if (hcfg->ProjectConfig->ConfirmOnSelfRevs && (edit->User->Username.toLower() == hcfg->SystemConfig_UserName.toLower()))
12671267
{
12681268
type = _l("main-revert-type-made-by-you");
1269-
Warn = true;
1270-
} else if (hcfg->ProjectConfig->ConfirmTalk && _e->Page->IsTalk())
1269+
warn = true;
1270+
} else if (hcfg->ProjectConfig->ConfirmTalk && edit->Page->IsTalk())
12711271
{
12721272
type = _l("main-revert-type-made-on-talk-page");
1273-
Warn = true;
1274-
} else if (hcfg->ProjectConfig->ConfirmWL && _e->User->IsWhitelisted())
1273+
warn = true;
1274+
} else if (hcfg->ProjectConfig->ConfirmWL && edit->User->IsWhitelisted())
12751275
{
12761276
type = _l("main-revert-type-made-white-list");
1277-
Warn = true;
1277+
warn = true;
12781278
}
1279-
if (Warn)
1279+
if (warn)
12801280
{
12811281
int q = UiGeneric::pMessageBox(this, _l("shortcut-revert"), _l("main-revert-warn", type), MessageBoxStyleQuestion);
12821282
if (q == QMessageBox::No)
@@ -1552,39 +1552,39 @@ void MainWindow::OnMainTimerTick()
15521552
if (this->PendingEdits.count() > 0)
15531553
{
15541554
// postprocessed edits can be added to queue
1555-
int c = 0;
1556-
while (c < this->PendingEdits.count())
1555+
int edit_id = 0;
1556+
while (edit_id < this->PendingEdits.count())
15571557
{
1558-
if (this->PendingEdits.at(c)->IsReady() && this->PendingEdits.at(c)->IsPostProcessed())
1558+
if (this->PendingEdits.at(edit_id)->IsReady() && this->PendingEdits.at(edit_id)->IsPostProcessed())
15591559
{
1560-
WikiEdit *edit = this->PendingEdits.at(c);
1560+
WikiEdit *edit = this->PendingEdits.at(edit_id);
15611561
Hooks::WikiEdit_ScoreJS(edit);
15621562
// We need to check the edit against filter once more, because some of the checks work
15631563
// only on post processed edits
15641564
if (edit->GetSite()->CurrentFilter->Matches(edit))
15651565
this->Queue1->AddItem(edit);
1566-
this->PendingEdits.removeAt(c);
1566+
this->PendingEdits.removeAt(edit_id);
15671567
edit->UnregisterConsumer(HUGGLECONSUMER_MAINPEND);
15681568
} else
15691569
{
1570-
c++;
1570+
edit_id++;
15711571
}
15721572
}
15731573
}
15741574
// let's refresh the edits that are being post processed
15751575
if (QueryPool::HugglePool->ProcessingEdits.count() > 0)
15761576
{
1577-
int Edit = 0;
1578-
while (Edit < QueryPool::HugglePool->ProcessingEdits.count())
1577+
int edit_id = 0;
1578+
while (edit_id < QueryPool::HugglePool->ProcessingEdits.count())
15791579
{
1580-
WikiEdit *e = QueryPool::HugglePool->ProcessingEdits.at(Edit);
1581-
if (e->finalizePostProcessing())
1580+
WikiEdit *edit = QueryPool::HugglePool->ProcessingEdits.at(edit_id);
1581+
if (edit->finalizePostProcessing())
15821582
{
1583-
QueryPool::HugglePool->ProcessingEdits.removeAt(Edit);
1584-
e->UnregisterConsumer(HUGGLECONSUMER_CORE_POSTPROCESS);
1583+
QueryPool::HugglePool->ProcessingEdits.removeAt(edit_id);
1584+
edit->UnregisterConsumer(HUGGLECONSUMER_CORE_POSTPROCESS);
15851585
} else
15861586
{
1587-
Edit++;
1587+
edit_id++;
15881588
}
15891589
}
15901590
}
@@ -1637,9 +1637,9 @@ void MainWindow::TruncateReverts()
16371637
}
16381638
while (QueryPool::HugglePool->RevertBuffer.count() > 10)
16391639
{
1640-
WikiEdit *we = QueryPool::HugglePool->RevertBuffer.at(0);
1640+
WikiEdit *edit = QueryPool::HugglePool->RevertBuffer.at(0);
16411641
QueryPool::HugglePool->RevertBuffer.removeAt(0);
1642-
we->UnregisterConsumer(HUGGLECONSUMER_QP_REVERTBUFFER);
1642+
edit->UnregisterConsumer(HUGGLECONSUMER_QP_REVERTBUFFER);
16431643
}
16441644
}
16451645

@@ -1729,9 +1729,10 @@ void MainWindow::OnTimerTick0()
17291729
MessageBoxStyleQuestion, true) == QMessageBox::No)
17301730
continue;
17311731
}
1732-
Collectable_SmartPtr<EditQuery> temp = WikiUtil::EditPage(site, page, site->GetUserConfig()->MakeLocalUserConfig(site->GetProjectConfig()), _l("saveuserconfig-progress"), true);
1733-
temp->IncRef();
1734-
this->storageQueries.insert(site, temp.GetPtr());
1732+
Collectable_SmartPtr<EditQuery> edit_query = WikiUtil::EditPage(site, page, site->GetUserConfig()->MakeLocalUserConfig(site->GetProjectConfig()),
1733+
_l("saveuserconfig-progress"), true);
1734+
edit_query->IncRef();
1735+
this->storageQueries.insert(site, edit_query.GetPtr());
17351736
}
17361737
return;
17371738
}
@@ -2269,7 +2270,7 @@ static void DisplayRevid_Finish(WikiEdit *edit, void *source, QString er)
22692270
// this is true hack as it's async call, but we don't really need to have the edit post processed for it
22702271
// to be rendered, let's just call it to be safe, as having unprocessed edits in buffer is a bad thing
22712272
QueryPool::HugglePool->PostProcessEdit(edit);
2272-
window->ProcessEdit(edit);
2273+
window->DisplayEdit(edit);
22732274
}
22742275

22752276
static void DisplayRevid_Error(WikiEdit *edit, void *source, const QString& error)
@@ -2287,7 +2288,7 @@ void MainWindow::DisplayRevid(revid_ht revid, WikiSite *site)
22872288
Collectable_SmartPtr<WikiEdit> edit = WikiEdit::FromCacheByRevID(revid);
22882289
if (edit != nullptr)
22892290
{
2290-
this->ProcessEdit(edit);
2291+
this->DisplayEdit(edit);
22912292
this->wEditBar->RefreshPage();
22922293
return;
22932294
}

0 commit comments

Comments
 (0)