void todoList::sFillList() { if (!_todolist->isChecked() && !_incidents->isChecked() && !_projects->isChecked()) { _todoList->clear(); return; } MetaSQLQuery mql = mqlLoad("todolist", "detail"); ParameterList params; setParams(params); XSqlQuery itemQ = mql.toQuery(params); _todoList->populate(itemQ, true); if (itemQ.lastError().type() != QSqlError::NoError) { systemError(this, itemQ.lastError().databaseText(), __FILE__, __LINE__); return; } handlePrivs(); _total->setText(QString::number(_todoList->topLevelItemCount())); }
enum SetResponse todoList::set(const ParameterList& pParams) { QVariant param; bool valid; param = pParams.value("usr_id", &valid); if (valid) { _usr->setId(param.toInt()); handlePrivs(); sFillList(); } return NoError; }
todoList::todoList(QWidget* parent, const char* name, Qt::WFlags fl) : XWidget(parent, name, fl) { setupUi(this); QSqlDatabase db = QSqlDatabase::database(); _parameterWidget->setType(tr("CRM Account"), "crmAccountId", ParameterWidget::Crmacct); _parameterWidget->setType(tr("Assigned"), "assigned_username", ParameterWidget::User, db.userName()); _parameterWidget->setType(tr("Owner"), "owner_username", ParameterWidget::User); _parameterWidget->setType(tr("Assigned Pattern"), "assigned_usr_pattern", ParameterWidget::Text); _parameterWidget->setType(tr("Owner Pattern"), "owner_usr_pattern", ParameterWidget::Text); _parameterWidget->setType(tr("Start Date Before"), "startStartDate", ParameterWidget::Date); _parameterWidget->setType(tr("Start Date After"), "startEndDate", ParameterWidget::Date); _parameterWidget->setType(tr("Due Date Before"), "dueStartDate", ParameterWidget::Date); _parameterWidget->setType(tr("Due Date After"), "dueEndDate", ParameterWidget::Date); _parameterWidget->applyDefaultFilterSet(); _crmAccount->hide(); q.exec("SELECT current_user;"); if (q.lastError().type() != QSqlError::NoError) { systemError(this, q.lastError().databaseText(), __FILE__, __LINE__); close(); } connect(_parameterWidget, SIGNAL(updated()), this, SLOT(sFillList())); connect(_query, SIGNAL(clicked()), this, SLOT(sFillList())); connect(_autoUpdate, SIGNAL(toggled(bool)), this, SLOT(sHandleAutoUpdate(bool))); connect(_close, SIGNAL(clicked()), this, SLOT(sClose())); connect(_completed, SIGNAL(toggled(bool)), this, SLOT(sFillList())); connect(_delete, SIGNAL(clicked()), this, SLOT(sDelete())); connect(_todolist, SIGNAL(toggled(bool)), this, SLOT(sFillList())); connect(_incidents, SIGNAL(toggled(bool)), this, SLOT(sFillList())); connect(_projects, SIGNAL(toggled(bool)), this, SLOT(sFillList())); connect(_new, SIGNAL(clicked()), this, SLOT(sNew())); connect(_print, SIGNAL(clicked()), this, SLOT(sPrint())); connect(_todoList, SIGNAL(itemSelected(int)), _edit, SLOT(animateClick())); connect(_todoList, SIGNAL(populateMenu(QMenu*, QTreeWidgetItem*, int)), this, SLOT(sPopulateMenu(QMenu*))); connect(_todoList, SIGNAL(itemSelectionChanged()), this, SLOT(handlePrivs())); connect(_edit, SIGNAL(clicked()), this, SLOT(sEdit())); connect(_view, SIGNAL(clicked()), this, SLOT(sView())); _todoList->addColumn(tr("Type"), _userColumn, Qt::AlignCenter, true, "type"); _todoList->addColumn(tr("Seq"), _seqColumn, Qt::AlignRight, false, "seq"); _todoList->addColumn(tr("Priority"), _userColumn, Qt::AlignLeft, true, "priority"); _todoList->addColumn(tr("Assigned To"),_userColumn, Qt::AlignLeft, true, "usr"); _todoList->addColumn(tr("Name"), 100, Qt::AlignLeft, true, "name"); _todoList->addColumn(tr("Description"), -1, Qt::AlignLeft, true, "descrip"); _todoList->addColumn(tr("Status"), _statusColumn, Qt::AlignLeft, true, "status"); _todoList->addColumn(tr("Start Date"),_dateColumn, Qt::AlignLeft, false, "start"); _todoList->addColumn(tr("Due Date"), _dateColumn, Qt::AlignLeft, true, "due"); _todoList->addColumn(tr("Parent#"), _orderColumn, Qt::AlignLeft, true, "number"); _todoList->addColumn(tr("Customer#"),_orderColumn, Qt::AlignLeft, false, "cust"); _todoList->addColumn(tr("Account#"), _orderColumn, Qt::AlignLeft, false, "crmacct_number"); _todoList->addColumn(tr("Account Name"), 100, Qt::AlignLeft, true, "crmacct_name"); _todoList->addColumn(tr("Owner"), _userColumn, Qt::AlignLeft, false,"owner"); int menuItem; QMenu * todoMenu = new QMenu; menuItem = todoMenu->insertItem(tr("Incident"), this, SLOT(sNewIncdt())); if (!_privileges->check("MaintainIncidents")) todoMenu->setItemEnabled(menuItem, FALSE); menuItem = todoMenu->insertItem(tr("To-Do Item"), this, SLOT(sNew())); if (!_privileges->check("MaintainPersonalTodoList") && !_privileges->check("MaintainOtherTodoLists")) todoMenu->setItemEnabled(menuItem, FALSE); _new->setMenu(todoMenu); if (_preferences->boolean("XCheckBox/forgetful")) _incidents->setChecked(true); handlePrivs(); sHandleAutoUpdate(_autoUpdate->isChecked()); }
todoList::todoList(QWidget* parent, const char* name, Qt::WFlags fl) : XWidget(parent, name, fl) { setupUi(this); _crmAccount->hide(); _dueDates->setStartNull(tr("Earliest"), omfgThis->startOfTime(), TRUE); _dueDates->setEndNull(tr("Latest"), omfgThis->endOfTime(), TRUE); _startDates->setStartNull(tr("Earliest"), omfgThis->startOfTime(), TRUE); _startDates->setEndNull(tr("Latest"), omfgThis->endOfTime(), TRUE); _usrGroup->setEnabled(_privileges->check("MaintainOtherTodoLists")); q.exec("SELECT current_user;"); if (q.first()) _usr->setUsername(q.value("current_user").toString()); else if (q.lastError().type() != QSqlError::NoError) { systemError(this, q.lastError().databaseText(), __FILE__, __LINE__); close(); } connect(_autoUpdate, SIGNAL(toggled(bool)), this, SLOT(sHandleAutoUpdate(bool))); connect(_close, SIGNAL(clicked()), this, SLOT(sClose())); connect(_completed, SIGNAL(toggled(bool)), this, SLOT(sFillList())); connect(_delete, SIGNAL(clicked()), this, SLOT(sDelete())); connect(_dueDates, SIGNAL(updated()), this, SLOT(sFillList())); connect(_startDates, SIGNAL(updated()), this, SLOT(sFillList())); connect(_todolist, SIGNAL(toggled(bool)), this, SLOT(sFillList())); connect(_incidents, SIGNAL(toggled(bool)), this, SLOT(sFillList())); connect(_projects, SIGNAL(toggled(bool)), this, SLOT(sFillList())); connect(_new, SIGNAL(clicked()), this, SLOT(sNew())); connect(_print, SIGNAL(clicked()), this, SLOT(sPrint())); connect(_todoList, SIGNAL(itemSelected(int)), _edit, SLOT(animateClick())); connect(_todoList, SIGNAL(populateMenu(QMenu*, QTreeWidgetItem*, int)), this, SLOT(sPopulateMenu(QMenu*))); connect(_todoList, SIGNAL(itemSelectionChanged()), this, SLOT(handlePrivs())); connect(_all, SIGNAL(clicked()), this, SLOT(sFillList())); connect(_all, SIGNAL(clicked()), this, SLOT(handlePrivs())); connect(_selected, SIGNAL(clicked()), this, SLOT(sFillList())); connect(_selected, SIGNAL(clicked()), this, SLOT(handlePrivs())); connect(_usr, SIGNAL(newId(int)), this, SLOT(sFillList())); connect(_usr, SIGNAL(newId(int)), this, SLOT(handlePrivs())); connect(_pattern, SIGNAL(editingFinished()), this, SLOT(sFillList())); connect(_pattern, SIGNAL(editingFinished()), this, SLOT(handlePrivs())); connect(_edit, SIGNAL(clicked()), this, SLOT(sEdit())); connect(_view, SIGNAL(clicked()), this, SLOT(sView())); connect(_duedateGroup, SIGNAL(toggled(bool)), this, SLOT(sFillList())); connect(_startdateGroup, SIGNAL(toggled(bool)), this, SLOT(sFillList())); connect(_assignedTo, SIGNAL(toggled(bool)), this, SLOT(sFillList())); connect(_ownedBy, SIGNAL(toggled(bool)), this, SLOT(sFillList())); _todoList->addColumn(tr("Type"), _userColumn, Qt::AlignCenter, true, "type"); _todoList->addColumn(tr("Seq"), _seqColumn, Qt::AlignRight, false, "seq"); _todoList->addColumn(tr("Priority"), _userColumn, Qt::AlignLeft, true, "priority"); _todoList->addColumn(tr("Assigned To"),_userColumn, Qt::AlignLeft, true, "usr"); _todoList->addColumn(tr("Name"), 100, Qt::AlignLeft, true, "name"); _todoList->addColumn(tr("Description"), -1, Qt::AlignLeft, true, "descrip"); _todoList->addColumn(tr("Status"), _statusColumn, Qt::AlignLeft, true, "status"); _todoList->addColumn(tr("Start Date"),_dateColumn, Qt::AlignLeft, false, "start"); _todoList->addColumn(tr("Due Date"), _dateColumn, Qt::AlignLeft, true, "due"); _todoList->addColumn(tr("Parent#"), _orderColumn, Qt::AlignLeft, true, "number"); _todoList->addColumn(tr("Customer#"),_orderColumn, Qt::AlignLeft, false, "cust"); _todoList->addColumn(tr("Account#"), _orderColumn, Qt::AlignLeft, false, "crmacct_number"); _todoList->addColumn(tr("Account Name"), 100, Qt::AlignLeft, true, "crmacct_name"); _todoList->addColumn(tr("Owner"), _userColumn, Qt::AlignLeft, false,"owner"); int menuItem; QMenu * todoMenu = new QMenu; menuItem = todoMenu->insertItem(tr("Incident"), this, SLOT(sNewIncdt())); if (!_privileges->check("MaintainIncidents")) todoMenu->setItemEnabled(menuItem, FALSE); menuItem = todoMenu->insertItem(tr("To-Do Item"), this, SLOT(sNew())); if (!_privileges->check("MaintainPersonalTodoList") && !_privileges->check("MaintainOtherTodoLists")) todoMenu->setItemEnabled(menuItem, FALSE); _new->setMenu(todoMenu); if (_preferences->boolean("XCheckBox/forgetful")) _incidents->setChecked(true); handlePrivs(); sHandleAutoUpdate(_autoUpdate->isChecked()); }
todoList::todoList(QWidget* parent, const char* name, Qt::WFlags fl) : XWidget(parent, name, fl) { setupUi(this); _dueDates->setStartNull(tr("Earliest"), omfgThis->startOfTime(), TRUE); _dueDates->setEndNull(tr("Latest"), omfgThis->endOfTime(), TRUE); _dueDates->setStartCaption(tr("First Due Date:")); _dueDates->setEndCaption(tr("Last Due Date:")); _incdtDates->setStartNull(tr("Earliest"), omfgThis->startOfTime(), TRUE); _incdtDates->setEndNull(tr("Latest"), omfgThis->endOfTime(), TRUE); _incdtDates->setStartCaption(tr("First Incident Date:")); _incdtDates->setEndCaption(tr("Last Incident Date:")); _usr->setEnabled(_privileges->check("MaintainOtherTodoLists")); _usr->setType(ParameterGroup::User); q.prepare("SELECT usr_id " "FROM usr " "WHERE (usr_username=CURRENT_USER);"); q.exec(); if (q.first()) { _myUsrId = q.value("usr_id").toInt(); _usr->setId(_myUsrId); } else if (q.lastError().type() != QSqlError::NoError) { systemError(this, q.lastError().databaseText(), __FILE__, __LINE__); close(); } connect(_active, SIGNAL(toggled(bool)), this, SLOT(sFillList())); connect(_autoUpdate, SIGNAL(toggled(bool)), this, SLOT(sHandleAutoUpdate(bool))); connect(_close, SIGNAL(clicked()), this, SLOT(sClose())); connect(_completed, SIGNAL(toggled(bool)), this, SLOT(sFillList())); connect(_delete, SIGNAL(clicked()), this, SLOT(sDelete())); connect(_dueDates, SIGNAL(updated()), this, SLOT(sFillList())); connect(_edit, SIGNAL(clicked()), this, SLOT(sEdit())); connect(_incdtDates, SIGNAL(updated()), this, SLOT(sFillList())); connect(_incidents, SIGNAL(toggled(bool)), this, SLOT(sFillList())); connect(_new, SIGNAL(clicked()), this, SLOT(sNew())); connect(_print, SIGNAL(clicked()), this, SLOT(sPrint())); connect(_todoList, SIGNAL(itemSelected(int)), _edit, SLOT(animateClick())); connect(_todoList, SIGNAL(populateMenu(QMenu*, QTreeWidgetItem*, int)), this, SLOT(sPopulateMenu(QMenu*))); connect(_todoList, SIGNAL(itemSelectionChanged()), this, SLOT(handlePrivs())); connect(_usr, SIGNAL(updated()), this, SLOT(sFillList())); connect(_usr, SIGNAL(updated()), this, SLOT(handlePrivs())); connect(_view, SIGNAL(clicked()), this, SLOT(sView())); _todoList->addColumn(tr("Type"), _statusColumn, Qt::AlignCenter, true, "type"); _todoList->addColumn(tr("Seq"), _seqColumn, Qt::AlignRight, true, "seq"); _todoList->addColumn(tr("Priority"), _userColumn, Qt::AlignLeft, true, "priority"); _todoList->addColumn(tr("User"), _userColumn, Qt::AlignLeft, true, "usr"); _todoList->addColumn(tr("Name"), 100, Qt::AlignLeft, true, "name"); _todoList->addColumn(tr("Description"), -1, Qt::AlignLeft, true, "descrip"); _todoList->addColumn(tr("Status"), _statusColumn, Qt::AlignLeft, true, "status"); _todoList->addColumn(tr("Due Date"), _dateColumn, Qt::AlignLeft, true, "due"); _todoList->addColumn(tr("Incident"), _orderColumn, Qt::AlignLeft, true, "incdt"); _todoList->addColumn(tr("Customer"), _orderColumn, Qt::AlignLeft, true, "cust"); _todoList->addColumn(tr("Owner"), _userColumn, Qt::AlignLeft, false,"owner"); if (_preferences->boolean("XCheckBox/forgetful")) { _active->setChecked(true); _incidents->setChecked(true); } handlePrivs(); sFillList(); sHandleAutoUpdate(_autoUpdate->isChecked()); }
void todoList::sFillList() { QString sql = "SELECT todoitem_id AS id, todoitem_usr_id AS altId, todoitem_owner_username AS owner, " " 'T' AS type, incdtpriority_order AS seq, incdtpriority_name AS priority, " " todoitem_name AS name, " " firstLine(todoitem_description) AS descrip, " " todoitem_status AS status, todoitem_due_date AS due, " " usr_username AS usr, incdt_number AS incdt, cust_number AS cust, " " CASE WHEN (todoitem_status != 'C'AND " " todoitem_due_date < CURRENT_DATE) THEN 'expired'" " WHEN (todoitem_status != 'C'AND " " todoitem_due_date > CURRENT_DATE) THEN 'future'" " END AS due_qtforegroundrole " "FROM usr, todoitem LEFT OUTER JOIN incdt ON (incdt_id=todoitem_incdt_id) " " LEFT OUTER JOIN crmacct ON (crmacct_id=todoitem_crmacct_id) " " LEFT OUTER JOIN cust ON (cust_id=crmacct_cust_id) " " LEFT OUTER JOIN incdtpriority ON (incdtpriority_id=todoitem_priority_id) " "WHERE ( (todoitem_usr_id=usr_id)" " AND (todoitem_due_date BETWEEN <? value(\"startDate\") ?> " " AND <? value(\"endDate\") ?>) " " <? if not exists(\"completed\") ?>" " AND (todoitem_status != 'C')" " <? endif ?>" " <? if exists(\"usr_id\") ?> " " AND (todoitem_usr_id=<? value(\"usr_id\") ?>) " " <? elseif exists(\"usr_pattern\" ?>" " AND (todoitem_usr_id IN (SELECT usr_id " " FROM usr " " WHERE (usr_username ~ <? value(\"usr_pattern\") ?>))) " " <? endif ?>" " <? if exists(\"active\") ?>AND (todoitem_active) <? endif ?>" " ) " "<? if exists(\"incidents\")?>" "UNION " "SELECT incdt_id AS id, usr_id AS altId, " " 'I' AS type, incdtpriority_order AS seq, incdtpriority_name AS priority, " " incdt_summary AS name, " " firstLine(incdt_descrip) AS descrip, " " incdt_status AS status, NULL AS due, " " incdt_assigned_username AS usr, incdt_number AS incdt, cust_number AS cust, " " NULL AS due_qtforegroundrole " "FROM incdt LEFT OUTER JOIN usr ON (usr_username=incdt_assigned_username)" " LEFT OUTER JOIN crmacct ON (crmacct_id=incdt_crmacct_id) " " LEFT OUTER JOIN cust ON (cust_id=crmacct_cust_id) " " LEFT OUTER JOIN incdtpriority ON (incdtpriority_id=incdt_incdtpriority_id) " "WHERE ((incdt_timestamp BETWEEN <? value(\"incdtStartDate\") ?>" " AND <? value(\"incdtEndDate\") ?>)" " <? if not exists(\"completed\") ?> " " AND (incdt_status != 'L')" " <? endif ?>" " <? if exists(\"usr_id\") ?> " " AND (usr_id=<? value(\"usr_id\") ?>) " " <? elseif exists(\"usr_pattern\" ?>" " AND (usr_id IN (SELECT usr_id " " FROM usr " " WHERE (usr_username ~ <? value(\"usr_pattern\") ?>))) " " <? endif ?>" " ) " "<? endif ?>" "ORDER BY due, seq, usr;"; ParameterList params; setParams(params); MetaSQLQuery mql(sql); XSqlQuery itemQ = mql.toQuery(params); _todoList->populate(itemQ, true); if (itemQ.lastError().type() != QSqlError::NoError) { systemError(this, itemQ.lastError().databaseText(), __FILE__, __LINE__); return; } handlePrivs(); _total->setText(QString::number(_todoList->topLevelItemCount())); }