Exemplo n.º 1
0
void KNGroupBrowser::slotReceiveList(KNGroupListData* d)
{
  enableButton(User1,true);
  enableButton(User2,true);

  if (d) {  // d==0 if something has gone wrong...
    delete allList;
    allList = d->extractList();
    incrementalFilter=false;
    slotRefilter();
  }
}
// new groups
void KNGroupDialog::slotUser2()
{
  QDate lastDate = a_ccount->lastNewFetch();
  KDialog *dlg = new KDialog( this );
  dlg->setCaption( i18n("New Groups") );
  dlg->setButtons( Ok | Cancel );

  QGroupBox *btnGrp = new QGroupBox( i18n("Check for New Groups"), dlg );
  dlg->setMainWidget(btnGrp);
  QGridLayout *topL = new QGridLayout( btnGrp );

  QRadioButton *takeLast = new QRadioButton( i18n("Created since last check:"), btnGrp );
  topL->addWidget(takeLast, 0, 0, 1, 2 );

  QLabel *l = new QLabel(KGlobal::locale()->formatDate(lastDate, KLocale::LongDate),btnGrp);
  topL->addWidget(l, 1, 1, Qt::AlignLeft);

  connect(takeLast, SIGNAL(toggled(bool)), l, SLOT(setEnabled(bool)));

  QRadioButton *takeCustom = new QRadioButton( i18n("Created since this date:"), btnGrp );
  topL->addWidget(takeCustom, 2, 0, 1, 2 );

  dateSel = new KDatePicker( lastDate, btnGrp );
  dateSel->setMinimumSize(dateSel->sizeHint());
  topL->addWidget(dateSel, 3, 1, Qt::AlignLeft);

  connect(takeCustom, SIGNAL(toggled(bool)), this, SLOT(slotDatePickerEnabled(bool)));

  takeLast->setChecked(true);
  dateSel->setEnabled(false);

  topL->addItem( new QSpacerItem(30, 0 ), 0, 0 );

  if (dlg->exec()) {
    if (takeCustom->isChecked())
      lastDate = dateSel->date();
    a_ccount->setLastNewFetch(QDate::currentDate());
    leftLabel->setText(i18n("Checking for new groups..."));
    enableButton(User1,false);
    enableButton(User2,false);
    filterEdit->clear();
    subCB->setChecked(false);
    newCB->setChecked(true);
    emit(checkNew(a_ccount,lastDate));
    incrementalFilter=false;
    slotRefilter();
  }

  delete dlg;
}
Exemplo n.º 3
0
KNGroupBrowser::KNGroupBrowser(QWidget *parent, const QString &caption, KNNntpAccount *a,
                               ButtonCodes buttons, bool newCBact, const QString &user1, const QString &user2) :
  KDialog( parent ),
  incrementalFilter(false), a_ccount(a)
{
  setCaption( caption );
  setButtons( buttons | Help | Ok | Cancel );
  setButtonGuiItem( User1, KGuiItem(user1) );
  setButtonGuiItem( User2, KGuiItem(user2) );
  refilterTimer = new QTimer();
  refilterTimer->setSingleShot( true );

  allList=new QList<KNGroupInfo>;
  matchList=new QList<KNGroupInfo>;

  //create Widgets
  page=new QWidget(this);
  setMainWidget(page);

  filterEdit=new KLineEdit(page);
  QLabel *l=new QLabel(i18n("S&earch:"),page);
  l->setBuddy(filterEdit);
  filterEdit->setClearButtonShown( true );
  noTreeCB=new QCheckBox(i18n("Disable &tree view"), page);
  noTreeCB->setChecked(false);
  subCB=new QCheckBox(i18n("&Subscribed only"), page);
  subCB->setChecked(false);
  newCB=new QCheckBox(i18n("&New only"), page);
  if (!newCBact)
    newCB->hide();
  newCB->setChecked(false);
  KSeparator *sep = new KSeparator( Qt::Horizontal, page );

  QFont fnt=font();
  fnt.setBold(true);
  leftLabel=new QLabel(i18n("Loading groups..."),page);
  rightLabel=new QLabel(page);
  leftLabel->setFont(fnt);
  rightLabel->setFont(fnt);

  pmGroup=knGlobals.configManager()->appearance()->icon(KNode::Appearance::group);
  pmNew=knGlobals.configManager()->appearance()->icon(KNode::Appearance::redBall);
  pmRight=KIcon( QApplication::isRightToLeft()? "go-previous": "go-next");
  pmLeft=KIcon(  QApplication::isRightToLeft() ? "go-next" : "go-previous");

  arrowBtn1=new QPushButton(page);
  arrowBtn1->setEnabled(false);
  arrowBtn2=new QPushButton(page);
  arrowBtn2->setEnabled(false);
  arrowBtn1->setIcon(pmRight);
  arrowBtn2->setIcon(pmLeft);
  arrowBtn1->setFixedSize(35,30);
  arrowBtn2->setFixedSize(35,30);

  groupView=new Q3ListView(page);
  groupView->setRootIsDecorated(true);
  groupView->addColumn(i18n("Name"));
  groupView->addColumn(i18n("Description"));
  groupView->setTreeStepSize(15);

  connect(groupView, SIGNAL(doubleClicked(Q3ListViewItem*)),
          this, SLOT(slotItemDoubleClicked(Q3ListViewItem*)));

  //layout
  QGridLayout *topL=new QGridLayout(page);
  topL->setSpacing(5);
  topL->setMargin(0);
  QHBoxLayout *filterL=new QHBoxLayout();
  filterL->setSpacing(10);
  QVBoxLayout *arrL=new QVBoxLayout();
  arrL->setSpacing(10);
  listL=new QGridLayout();
  listL->setSpacing(5);

  topL->addLayout(filterL, 0,0);
  topL->addWidget(sep,1,0);
  topL->addLayout(listL, 2,0);

  filterL->addWidget(l);
  filterL->addWidget(filterEdit, 1);
  filterL->addWidget(noTreeCB);
  filterL->addWidget(subCB);
  if (newCBact)
    filterL->addWidget(newCB);

  listL->addWidget(leftLabel, 0,0);
  listL->addWidget(rightLabel, 0,2);
  listL->addWidget(groupView, 1,0);
  listL->addLayout(arrL, 1,1);
  listL->setRowStretch(1,1);
  listL->setColumnStretch(0,5);
  listL->setColumnStretch(2,2);

  arrL->addWidget( arrowBtn1, Qt::AlignCenter );
  arrL->addWidget( arrowBtn2, Qt::AlignCenter );

  //connect
  connect(filterEdit, SIGNAL(textChanged(const QString&)),
          SLOT(slotFilterTextChanged(const QString&)));
  connect(groupView, SIGNAL(expanded(Q3ListViewItem*)),
          SLOT(slotItemExpand(Q3ListViewItem*)));

  connect(refilterTimer, SIGNAL(timeout()), SLOT(slotRefilter()));
  connect(noTreeCB, SIGNAL(clicked()), SLOT(slotTreeCBToggled()));
  connect(subCB, SIGNAL(clicked()), SLOT(slotSubCBToggled()));
  connect(newCB, SIGNAL(clicked()), SLOT(slotNewCBToggled()));

  enableButton(User1,false);
  enableButton(User2,false);

  filterEdit->setFocus();

  QTimer::singleShot(2, this, SLOT(slotLoadList()));
}