<commit_before>/*
    knodeview.cpp

    KNode, the KDE newsreader
    Copyright (c) 1999-2001 the KNode authors.
    See file AUTHORS for details

    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 2 of the License, or
    (at your option) any later version.
    You should have received a copy of the GNU General Public License
    along with this program; if not, write to the Free Software Foundation,
    Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, US
*/

#include <qheader.h>
#include <qhbox.h>
#include <stdlib.h>

#include <klocale.h>
#include <kconfig.h>
#include <kglobal.h>
#include <kglobalsettings.h>
#include <kapp.h>
#include <kdebug.h>
#include <kmessagebox.h>

//GUI
#include "knodeview.h"
#include "knode.h"
#include "knarticlewidget.h"
#include "knarticlewindow.h"
#include "kncollectionviewitem.h"
#include "knhdrviewitem.h"
#include "knfocuswidget.h"
#include "kndnd.h"

//Core
#include "knglobals.h"
#include "knconfigmanager.h"
#include "knarticlemanager.h"
#include "knarticlefactory.h"
#include "kngroup.h"
#include "kngroupmanager.h"
#include "knnntpaccount.h"
#include "knaccountmanager.h"
#include "knnetaccess.h"
#include "knfiltermanager.h"
#include "knfoldermanager.h"
#include "knfolder.h"
#include "kncleanup.h"
#include "utilities.h"
#include "knscoring.h"
#include "knpgp.h"


KNodeView::KNodeView(KNMainWindow *w, const char * name)
  : QSplitter(w, name), l_ongView(true), b_lockui(false), a_ctions(w->actionCollection())
{
  //------------------------------- <CONFIG> ----------------------------------
  c_fgManager=new KNConfigManager();
  knGlobals.cfgManager=c_fgManager;
  //------------------------------- </CONFIG> ----------------------------------

  //-------------------------------- <GUI> ------------------------------------
  setOpaqueResize(true);

  //collection view
  c_olFocus=new KNFocusWidget(this,"colFocus");
  c_olView=new KNListView(c_olFocus,"collectionView", new KNCollectionDragHandler() );
  c_olView->setAcceptDrops(true);
  c_olView->viewport()->setAcceptDrops(true);
  c_olView->setSelectionMode(QListView::Single);
  c_olFocus->setWidget(c_olView);
  setResizeMode(c_olFocus, QSplitter::KeepSize);

  c_olView->setFrameStyle(QFrame::Panel | QFrame::Sunken);
  c_olView->setTreeStepSize(12);
  c_olView->setRootIsDecorated(true);
  c_olView->setShowSortIndicator(true);
  c_olView->addColumn(i18n("Name"),162);
  c_olView->addColumn(i18n("Total"),36);
  c_olView->addColumn(i18n("Unread"),48);
  c_olView->setColumnAlignment(1,AlignCenter);
  c_olView->setColumnAlignment(2,AlignCenter);

  connect(c_olView, SIGNAL(itemSelected(QListViewItem*)),
    this, SLOT(slotCollectionSelected(QListViewItem*)));
  connect(c_olView, SIGNAL(rightButtonPressed(QListViewItem*, const QPoint&, int)),
    this, SLOT(slotCollectionRMB(QListViewItem*, const QPoint&, int)));
  connect(c_olView, SIGNAL(dropReceived(const char*, QListViewItem*)),
    this, SLOT(slotCollectionViewDrop(const char*, QListViewItem*)));

  //secondary splitter
  s_ecSplitter=new QSplitter(QSplitter::Vertical,this,"secSplitter");
  s_ecSplitter->setOpaqueResize(true);

  //header view
  h_drFocus=new KNFocusWidget(s_ecSplitter,"hdrFocus");
  h_drView=new KNListView(h_drFocus,"hdrView", new KNArticleDragHandler());
  h_drFocus->setWidget(h_drView);
  s_ecSplitter->setResizeMode(h_drFocus, QSplitter::KeepSize);

  h_drView->setFrameStyle(QFrame::Panel | QFrame::Sunken);
  h_drView->setShowSortIndicator(true);
  h_drView->setRootIsDecorated(true);
  h_drView->addColumn(i18n("Subject"),207);
  h_drView->addColumn(i18n("From"),115);
  h_drView->addColumn(i18n("Score"),42);
  h_drView->addColumn(i18n("Lines"),42);
  h_drView->addColumn(i18n("Date"),102);

  connect(h_drView, SIGNAL(itemSelected(QListViewItem*)),
    this, SLOT(slotArticleSelected(QListViewItem*)));
  connect(h_drView, SIGNAL(selectionChanged()),
    this, SLOT(slotArticleSelectionChanged()));
  connect(h_drView, SIGNAL(rightButtonPressed(QListViewItem*, const QPoint&, int)),
    this, SLOT(slotArticleRMB(QListViewItem*, const QPoint&, int)));
  connect(h_drView, SIGNAL(mouseButtonPressed(int, QListViewItem *, const QPoint &, int)),
    this, SLOT(slotArticleMousePressed(int, QListViewItem *, const QPoint &, int)));
  connect(h_drView, SIGNAL(sortingChanged(int)),
    this, SLOT(slotHdrViewSortingChanged(int)));
  connect(h_drView, SIGNAL(dropReceived(const char*, QListViewItem*)),
    this, SLOT(slotHeaderViewDrop(const char*, QListViewItem*)));


  //article view
  a_rtFocus=new KNFocusWidget(s_ecSplitter,"artFocus");
  a_rtView=new KNArticleWidget(a_ctions, a_rtFocus,"artView");
  a_rtFocus->setWidget(a_rtView);

  //tab order
  setTabOrder(h_drView, a_rtView);
  setTabOrder(a_rtView, c_olView);

  //actions
  initActions();

  //-------------------------------- </GUI> ------------------------------------


  //-------------------------------- <CORE> ------------------------------------

  //Network
  n_etAccess=new KNNetAccess();
  connect(n_etAccess, SIGNAL(netActive(bool)), this, SLOT(slotNetworkActive(bool)));
  knGlobals.netAccess=n_etAccess;

  //Filter Manager
  f_ilManager=new KNFilterManager(a_ctArtFilter, a_ctArtFilterKeyb);
  knGlobals.filManager=f_ilManager;

  //Article Manager
  a_rtManager=new KNArticleManager(h_drView, f_ilManager);
  knGlobals.artManager=a_rtManager;

  //Group Manager
  g_rpManager=new KNGroupManager(a_rtManager);
  knGlobals.grpManager=g_rpManager;

  //Folder Manager
  f_olManager=new KNFolderManager(c_olView, a_rtManager);
  knGlobals.folManager=f_olManager;

  //Account Manager
  a_ccManager=new KNAccountManager(g_rpManager, c_olView);
  knGlobals.accManager=a_ccManager;

  //Article Factory
  a_rtFactory=new KNArticleFactory();
  knGlobals.artFactory=a_rtFactory;

  // Score Manager
  s_coreManager = new KNScoringManager();
  knGlobals.scoreManager = s_coreManager;

  // create a global pgp instance
  new KNpgp();

  //-------------------------------- <GUI again> -------------------------------
  connect(s_coreManager, SIGNAL(changedRules()), SLOT(slotGrpReorganize()));
  //-------------------------------- </GUI again> ------------------------------

  //-------------------------------- </CORE> -----------------------------------

  //apply saved options
  readOptions();

  //apply configuration
  configChanged();

  // open all accounts that were open on the last shutdown
  KNNntpAccount *acc;
  for (acc=knGlobals.accManager->first(); acc; acc=knGlobals.accManager->next())
    if( acc->wasOpen() && acc->listItem() )
      acc->listItem()->setOpen(true);
}



KNodeView::~KNodeView()
{
  h_drView->clear(); //avoid some random crashes in KNHdrViewItem::~KNHdrViewItem()
<commit_msg>don't reorganize groups, just rescore them<commit_after>/*
    knodeview.cpp

    KNode, the KDE newsreader
    Copyright (c) 1999-2001 the KNode authors.
    See file AUTHORS for details

    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 2 of the License, or
    (at your option) any later version.
    You should have received a copy of the GNU General Public License
    along with this program; if not, write to the Free Software Foundation,
    Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, US
*/

#include <qheader.h>
#include <qhbox.h>
#include <stdlib.h>

#include <klocale.h>
#include <kconfig.h>
#include <kglobal.h>
#include <kglobalsettings.h>
#include <kapp.h>
#include <kdebug.h>
#include <kmessagebox.h>

//GUI
#include "knodeview.h"
#include "knode.h"
#include "knarticlewidget.h"
#include "knarticlewindow.h"
#include "kncollectionviewitem.h"
#include "knhdrviewitem.h"
#include "knfocuswidget.h"
#include "kndnd.h"

//Core
#include "knglobals.h"
#include "knconfigmanager.h"
#include "knarticlemanager.h"
#include "knarticlefactory.h"
#include "kngroup.h"
#include "kngroupmanager.h"
#include "knnntpaccount.h"
#include "knaccountmanager.h"
#include "knnetaccess.h"
#include "knfiltermanager.h"
#include "knfoldermanager.h"
#include "knfolder.h"
#include "kncleanup.h"
#include "utilities.h"
#include "knscoring.h"
#include "knpgp.h"


KNodeView::KNodeView(KNMainWindow *w, const char * name)
  : QSplitter(w, name), l_ongView(true), b_lockui(false), a_ctions(w->actionCollection())
{
  //------------------------------- <CONFIG> ----------------------------------
  c_fgManager=new KNConfigManager();
  knGlobals.cfgManager=c_fgManager;
  //------------------------------- </CONFIG> ----------------------------------

  //-------------------------------- <GUI> ------------------------------------
  setOpaqueResize(true);

  //collection view
  c_olFocus=new KNFocusWidget(this,"colFocus");
  c_olView=new KNListView(c_olFocus,"collectionView", new KNCollectionDragHandler() );
  c_olView->setAcceptDrops(true);
  c_olView->viewport()->setAcceptDrops(true);
  c_olView->setSelectionMode(QListView::Single);
  c_olFocus->setWidget(c_olView);
  setResizeMode(c_olFocus, QSplitter::KeepSize);

  c_olView->setFrameStyle(QFrame::Panel | QFrame::Sunken);
  c_olView->setTreeStepSize(12);
  c_olView->setRootIsDecorated(true);
  c_olView->setShowSortIndicator(true);
  c_olView->addColumn(i18n("Name"),162);
  c_olView->addColumn(i18n("Total"),36);
  c_olView->addColumn(i18n("Unread"),48);
  c_olView->setColumnAlignment(1,AlignCenter);
  c_olView->setColumnAlignment(2,AlignCenter);

  connect(c_olView, SIGNAL(itemSelected(QListViewItem*)),
    this, SLOT(slotCollectionSelected(QListViewItem*)));
  connect(c_olView, SIGNAL(rightButtonPressed(QListViewItem*, const QPoint&, int)),
    this, SLOT(slotCollectionRMB(QListViewItem*, const QPoint&, int)));
  connect(c_olView, SIGNAL(dropReceived(const char*, QListViewItem*)),
    this, SLOT(slotCollectionViewDrop(const char*, QListViewItem*)));

  //secondary splitter
  s_ecSplitter=new QSplitter(QSplitter::Vertical,this,"secSplitter");
  s_ecSplitter->setOpaqueResize(true);

  //header view
  h_drFocus=new KNFocusWidget(s_ecSplitter,"hdrFocus");
  h_drView=new KNListView(h_drFocus,"hdrView", new KNArticleDragHandler());
  h_drFocus->setWidget(h_drView);
  s_ecSplitter->setResizeMode(h_drFocus, QSplitter::KeepSize);

  h_drView->setFrameStyle(QFrame::Panel | QFrame::Sunken);
  h_drView->setShowSortIndicator(true);
  h_drView->setRootIsDecorated(true);
  h_drView->addColumn(i18n("Subject"),207);
  h_drView->addColumn(i18n("From"),115);
  h_drView->addColumn(i18n("Score"),42);
  h_drView->addColumn(i18n("Lines"),42);
  h_drView->addColumn(i18n("Date"),102);

  connect(h_drView, SIGNAL(itemSelected(QListViewItem*)),
    this, SLOT(slotArticleSelected(QListViewItem*)));
  connect(h_drView, SIGNAL(selectionChanged()),
    this, SLOT(slotArticleSelectionChanged()));
  connect(h_drView, SIGNAL(rightButtonPressed(QListViewItem*, const QPoint&, int)),
    this, SLOT(slotArticleRMB(QListViewItem*, const QPoint&, int)));
  connect(h_drView, SIGNAL(mouseButtonPressed(int, QListViewItem *, const QPoint &, int)),
    this, SLOT(slotArticleMousePressed(int, QListViewItem *, const QPoint &, int)));
  connect(h_drView, SIGNAL(sortingChanged(int)),
    this, SLOT(slotHdrViewSortingChanged(int)));
  connect(h_drView, SIGNAL(dropReceived(const char*, QListViewItem*)),
    this, SLOT(slotHeaderViewDrop(const char*, QListViewItem*)));


  //article view
  a_rtFocus=new KNFocusWidget(s_ecSplitter,"artFocus");
  a_rtView=new KNArticleWidget(a_ctions, a_rtFocus,"artView");
  a_rtFocus->setWidget(a_rtView);

  //tab order
  setTabOrder(h_drView, a_rtView);
  setTabOrder(a_rtView, c_olView);

  //actions
  initActions();

  //-------------------------------- </GUI> ------------------------------------


  //-------------------------------- <CORE> ------------------------------------

  //Network
  n_etAccess=new KNNetAccess();
  connect(n_etAccess, SIGNAL(netActive(bool)), this, SLOT(slotNetworkActive(bool)));
  knGlobals.netAccess=n_etAccess;

  //Filter Manager
  f_ilManager=new KNFilterManager(a_ctArtFilter, a_ctArtFilterKeyb);
  knGlobals.filManager=f_ilManager;

  //Article Manager
  a_rtManager=new KNArticleManager(h_drView, f_ilManager);
  knGlobals.artManager=a_rtManager;

  //Group Manager
  g_rpManager=new KNGroupManager(a_rtManager);
  knGlobals.grpManager=g_rpManager;

  //Folder Manager
  f_olManager=new KNFolderManager(c_olView, a_rtManager);
  knGlobals.folManager=f_olManager;

  //Account Manager
  a_ccManager=new KNAccountManager(g_rpManager, c_olView);
  knGlobals.accManager=a_ccManager;

  //Article Factory
  a_rtFactory=new KNArticleFactory();
  knGlobals.artFactory=a_rtFactory;

  // Score Manager
  s_coreManager = new KNScoringManager();
  knGlobals.scoreManager = s_coreManager;

  // create a global pgp instance
  new KNpgp();

  //-------------------------------- <GUI again> -------------------------------
  connect(s_coreManager, SIGNAL(changedRules()), SLOT(slotReScore()));
  //-------------------------------- </GUI again> ------------------------------

  //-------------------------------- </CORE> -----------------------------------

  //apply saved options
  readOptions();

  //apply configuration
  configChanged();

  // open all accounts that were open on the last shutdown
  KNNntpAccount *acc;
  for (acc=knGlobals.accManager->first(); acc; acc=knGlobals.accManager->next())
    if( acc->wasOpen() && acc->listItem() )
      acc->listItem()->setOpen(true);
}



KNodeView::~KNodeView()
{
  h_drView->clear(); //avoid some random crashes in KNHdrViewItem::~KNHdrViewItem()

{'fraction_non_alphanumeric': 0.2024061246810062, 'fraction_numerical': 0.009187021509296392, 'mean_word_length': 3.7134020618556702, 'pattern_counts': {'":': 0, '<': 39, '<?xml version=': 0, '>': 107, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4781062', 'n_tokens_mistral': 4755, 'n_tokens_neox': 4531, 'n_words': 823}