void accountingYearPeriods::sPopulateMenu(QMenu *pMenu, QTreeWidgetItem *pSelected) { QAction *menuItem; int altId = ((XTreeWidgetItem *)pSelected)->altId(); if (altId == 0) { menuItem = pMenu->addAction(tr("Edit..."), this, SLOT(sEdit())); menuItem->setEnabled(_privileges->check("MaintainAccountingPeriods")); } menuItem = pMenu->addAction(tr("View..."), this, SLOT(sView())); if (altId == 0) { menuItem = pMenu->addAction(tr("Delete..."), this, SLOT(sDelete())); menuItem->setEnabled(_privileges->check("MaintainAccountingPeriods")); } pMenu->addSeparator(); if (altId == 0) { menuItem = pMenu->addAction(tr("Close..."), this, SLOT(sClosePeriod())); } else if (altId == 1) { menuItem = pMenu->addAction(tr("Open..."), this, SLOT(sOpenPeriod())); } }
accountingYearPeriods::accountingYearPeriods(QWidget* parent, const char* name, Qt::WindowFlags fl) : XWidget(parent, name, fl) { setupUi(this); connect(_period, SIGNAL(populateMenu(QMenu*,QTreeWidgetItem*)), this, SLOT(sPopulateMenu(QMenu*,QTreeWidgetItem*))); connect(_edit, SIGNAL(clicked()), this, SLOT(sEdit())); connect(_view, SIGNAL(clicked()), this, SLOT(sView())); connect(_delete, SIGNAL(clicked()), this, SLOT(sDelete())); connect(_print, SIGNAL(clicked()), this, SLOT(sPrint())); connect(_new, SIGNAL(clicked()), this, SLOT(sNew())); connect(_closePeriod, SIGNAL(clicked()), this, SLOT(sClosePeriod())); connect(_copyPeriod, SIGNAL(clicked()), this, SLOT(sCopyPeriod())); _period->addColumn(tr("Start"), _dateColumn, Qt::AlignCenter, true, "yearperiod_start"); _period->addColumn(tr("End"), _dateColumn, Qt::AlignCenter, true, "yearperiod_end"); _period->addColumn(tr("Closed"), -1 , Qt::AlignCenter, true, "closed"); if (_privileges->check("MaintainAccountingPeriods")) { connect(_period, SIGNAL(valid(bool)), _edit, SLOT(setEnabled(bool))); connect(_period, SIGNAL(valid(bool)), _delete, SLOT(setEnabled(bool))); connect(_period, SIGNAL(itemSelected(int)), _edit, SLOT(animateClick())); } else { _new->setEnabled(false); connect(_period, SIGNAL(itemSelected(int)), _view, SLOT(animateClick())); } sFillList(); }
void accountingPeriods::sPopulateMenu(QMenu *pMenu, QTreeWidgetItem *pSelected) { int menuItem; int altId = ((XTreeWidgetItem *)pSelected)->altId(); if (altId == 0) { menuItem = pMenu->insertItem(tr("Edit..."), this, SLOT(sEdit()), 0); if (!_privleges->check("MaintainAccountingPeriods")) pMenu->setItemEnabled(menuItem, FALSE); } menuItem = pMenu->insertItem(tr("View..."), this, SLOT(sView()), 0); if (altId == 0) { menuItem = pMenu->insertItem(tr("Delete..."), this, SLOT(sDelete()), 0); if (!_privleges->check("MaintainAccountingPeriods")) pMenu->setItemEnabled(menuItem, FALSE); } pMenu->insertSeparator(); if (altId == 0) { menuItem = pMenu->insertItem(tr("Close..."), this, SLOT(sClosePeriod()), 0); #if 0 if (!_privleges->check("MaintainItemMasters")) pMenu->setItemEnabled(menuItem, FALSE); #endif } else if (altId == 1) { menuItem = pMenu->insertItem(tr("Open..."), this, SLOT(sOpenPeriod()), 0); #if 0 if (!_privleges->check("MaintainItemMasters")) pMenu->setItemEnabled(menuItem, FALSE); #endif menuItem = pMenu->insertItem(tr("Freeze..."), this, SLOT(sFreezePeriod()), 0); #if 0 if (!_privleges->check("MaintainItemMasters")) pMenu->setItemEnabled(menuItem, FALSE); #endif } else if (altId == 2) { menuItem = pMenu->insertItem(tr("Thaw..."), this, SLOT(sThawPeriod()), 0); #if 0 if (!_privleges->check("MaintainItemMasters")) pMenu->setItemEnabled(menuItem, FALSE); #endif } }
accountingPeriods::accountingPeriods(QWidget* parent, const char* name, Qt::WFlags fl) : XWidget(parent, name, fl) { setupUi(this); connect(_period, SIGNAL(populateMenu(QMenu*,QTreeWidgetItem*)), this, SLOT(sPopulateMenu(QMenu*, QTreeWidgetItem *))); connect(_edit, SIGNAL(clicked()), this, SLOT(sEdit())); connect(_view, SIGNAL(clicked()), this, SLOT(sView())); connect(_delete, SIGNAL(clicked()), this, SLOT(sDelete())); connect(_print, SIGNAL(clicked()), this, SLOT(sPrint())); connect(_new, SIGNAL(clicked()), this, SLOT(sNew())); connect(_closePeriod, SIGNAL(clicked()), this, SLOT(sClosePeriod())); connect(_freezePeriod, SIGNAL(clicked()), this, SLOT(sFreezePeriod())); _period->addColumn(tr("Name"), -1, Qt::AlignLeft, true, "period_name"); _period->addColumn(tr("Start"), _dateColumn, Qt::AlignCenter, true, "period_start"); _period->addColumn(tr("End"), _dateColumn, Qt::AlignCenter, true, "period_end"); _period->addColumn(tr("Number"), _ynColumn, Qt::AlignRight, false, "period_number"); _period->addColumn(tr("Qtr"), _statusColumn, Qt::AlignCenter, true, "qtr"); _period->addColumn(tr("Year"), _dateColumn, Qt::AlignCenter, true, "year"); _period->addColumn(tr("Closed"), _ynColumn+3, Qt::AlignCenter, true, "closed"); _period->addColumn(tr("Frozen"), _ynColumn+3, Qt::AlignCenter, true, "frozen"); if (_privileges->check("MaintainAccountingPeriods")) { connect(_period, SIGNAL(valid(bool)), _edit, SLOT(setEnabled(bool))); connect(_period, SIGNAL(valid(bool)), _delete, SLOT(setEnabled(bool))); connect(_period, SIGNAL(itemSelected(int)), _edit, SLOT(animateClick())); } else { _new->setEnabled(FALSE); connect(_period, SIGNAL(itemSelected(int)), _view, SLOT(animateClick())); } connect(_period, SIGNAL(valid(bool)), _closePeriod, SLOT(setEnabled(bool))); connect(_period, SIGNAL(valid(bool)), _freezePeriod, SLOT(setEnabled(bool))); sFillList(); }