void Window::setupGui() { todoEditor = new TodoEditor; listWidget = new QListWidget; stackedWidget = new QStackedWidget; newTodoButton = new QPushButton(tr("New Todo")); deletTodoButton = new QPushButton(tr("Delete Todo")); calendarWidget = new QCalendarWidget; connect(newTodoButton, SIGNAL(clicked()), this, SLOT(editNewTodo())); connect(todoEditor, SIGNAL(editingFinished(QOrganizerTodo &)), this, SLOT(saveTodo(QOrganizerTodo &))); connect(listWidget, SIGNAL(itemDoubleClicked(QListWidgetItem*)), this, SLOT(editTodo(QListWidgetItem*))); connect(calendarWidget, SIGNAL(selectionChanged()), this, SLOT(refreshList())); connect(deletTodoButton, SIGNAL(clicked()), this, SLOT(deleteTodo())); QVBoxLayout *mainLayout = new QVBoxLayout; mainLayout->addWidget(calendarWidget); mainLayout->addWidget(listWidget); QHBoxLayout *buttonLayout = new QHBoxLayout; buttonLayout->addWidget(newTodoButton); buttonLayout->addWidget(deletTodoButton); mainLayout->addLayout(buttonLayout); QWidget *frontPage = new QWidget; frontPage->setLayout(mainLayout); stackedWidget->addWidget(frontPage); stackedWidget->addWidget(todoEditor); // Adding a scroll area to allow proper rendering of the UI on small screens QScrollArea *scrollArea = new QScrollArea; scrollArea->setWidgetResizable(true); scrollArea->setWidget(stackedWidget); QSize suggestedSize; suggestedSize = stackedWidget->sizeHint(); stackedWidget->setMinimumSize(suggestedSize); QGridLayout *layout = new QGridLayout; layout->addWidget(scrollArea); setLayout(layout); }
void Window::setupGui() { todoEditor = new TodoEditor; listWidget = new QListWidget; stackedWidget = new QStackedWidget; newTodoButton = new QPushButton(tr("New Todo")); deletTodoButton = new QPushButton(tr("Delete Todo")); calendarWidget = new QCalendarWidget; connect(newTodoButton, SIGNAL(clicked()), this, SLOT(editNewTodo())); connect(todoEditor, SIGNAL(editingFinished(QOrganizerTodo &)), this, SLOT(saveTodo(QOrganizerTodo &))); connect(listWidget, SIGNAL(itemDoubleClicked(QListWidgetItem*)), this, SLOT(editTodo(QListWidgetItem*))); connect(calendarWidget, SIGNAL(selectionChanged()), this, SLOT(refreshList())); connect(deletTodoButton, SIGNAL(clicked()), this, SLOT(deleteTodo())); QVBoxLayout *mainLayout = new QVBoxLayout; mainLayout->addWidget(calendarWidget); mainLayout->addWidget(listWidget); QHBoxLayout *buttonLayout = new QHBoxLayout; buttonLayout->addWidget(newTodoButton); buttonLayout->addWidget(deletTodoButton); mainLayout->addLayout(buttonLayout); QWidget *frontPage = new QWidget; frontPage->setLayout(mainLayout); stackedWidget->addWidget(frontPage); stackedWidget->addWidget(todoEditor); QGridLayout *layout = new QGridLayout; layout->addWidget(stackedWidget); setLayout(layout); }
TodoView::TodoView(CalObject *cal, QWidget *parent, const char *name) : KTabListBox(parent, name, 5) { calendar = cal; // set up filter for events lbox.installEventFilter(this); // set up the widget to have 4 columns (one hidden), and // only a vertical scrollbar clearTableFlags(Tbl_hScrollBar); clearTableFlags(Tbl_autoHScrollBar); // BL: autoscrollbar in not working... setTableFlags(Tbl_hScrollBar); setAutoUpdate(TRUE); adjustColumns(); // insert pictures for use to show a checked/not checked todo dict().insert("CHECKED", new QPixmap(Icon("checkedbox.xpm"))); dict().insert("EMPTY", new QPixmap(Icon("emptybox.xpm"))); dict().insert("CHECKEDMASK", new QPixmap(Icon("checkedbox-mask.xpm"))); dict().insert("EMPTYMASK", new QPixmap(Icon("emptybox-mask.xpm"))); // this is the thing that lets you edit the todo text. editor = new QLineEdit(this); editor->hide(); connect(editor, SIGNAL(returnPressed()), this, SLOT(updateSummary())); connect(editor, SIGNAL(returnPressed()), editor, SLOT(hide())); connect(editor, SIGNAL(textChanged(const char *)), this, SLOT(changeSummary(const char *))); connect(this, SIGNAL(selected(int, int)), this, SLOT(updateItem(int, int))); connect(this, SIGNAL(highlighted(int, int)), this, SLOT(hiliteAction(int, int))); priList = new QListBox(this); priList->hide(); priList->insertItem("1"); priList->insertItem("2"); priList->insertItem("3"); priList->insertItem("4"); priList->insertItem("5"); priList->setFixedHeight(priList->itemHeight()*5+5); priList->setFixedWidth(priList->maxItemWidth()+5); connect(priList, SIGNAL(highlighted(int)), priList, SLOT(hide())); connect(priList, SIGNAL(highlighted(int)), this, SLOT(changePriority(int))); QPixmap pixmap; rmbMenu1 = new QPopupMenu; pixmap = Icon("checkedbox.xpm"); rmbMenu1->insertItem(pixmap, i18n("New Todo"), this, SLOT(newTodo())); pixmap = Icon("delete.xpm"); rmbMenu1->insertItem(pixmap, i18n("Purge Completed "), this, SLOT(purgeCompleted())); rmbMenu2 = new QPopupMenu; pixmap = Icon("checkedbox.xpm"); rmbMenu2->insertItem(pixmap, i18n("New Todo"), this, SLOT (newTodo())); rmbMenu2->insertItem(i18n("Edit Todo"), this, SLOT (editTodo())); pixmap = Icon("delete.xpm"); rmbMenu2->insertItem(pixmap, i18n("Delete Todo"), this, SLOT (deleteTodo())); rmbMenu2->insertItem(i18n("Purge Completed "), this, SLOT(purgeCompleted())); editingFlag = FALSE; connect(this, SIGNAL(headerClicked(int)), this, SLOT(headerAction(int))); updateConfig(); prevRow = updatingRow = -1; }
TodoEditDialog::TodoEditDialog(QWidget *parent, CTodo *todo) : ComponentEditDialog(parent), ui(new Ui::TodoEditDialog), saveDue(true) { ui->setupUi(this); if (todo && !todo->getId().empty()) { todo = CWrapper::details(todo); this->setWindowTitle(tr("Edit task")); this->setupDeleteButton(ui->buttonBox, SLOT(deleteTodo())); } else { this->setWindowTitle(tr("New task")); } QSettings settings; // Set up date picker DatePickSelector *dps = new DatePickSelector(); ui->dateButton->setPickSelector(dps); // Set up time zone picker ZonePickSelector *zps; if (settings.value("TimeZones", false).toBool()) { zps = new ZonePickSelector(); ui->zoneButton->setPickSelector(zps); } else { zps = NULL; ui->zoneButton->hide(); } // Set up calendar picker CalendarPickSelector *cps = new CalendarPickSelector(); ui->calendarButton->setPickSelector(cps); // Set up alarm picker AlarmPickSelector *aps = new AlarmPickSelector(E_AM_EXACTDATETIME); ui->alarmButton->setPickSelector(aps); // Make sure that AlarmPickSelector's reference date is set onDateChanged(); connect(dps, SIGNAL(selected(QString)), this, SLOT(onDateChanged())); if (todo) { // Do not change the default settings when editing an existing todo saveDefaults = false; // Configure time QString zone; QDateTime due; if (zps) { // Display time in the selected time zone zone = todo->getTzid().c_str(); due = Date::toRemote(todo->getDue(), zone); zps->setCurrentZone(todo->getTzid().c_str()); } else { // Display local time due = QDateTime::fromTime_t(todo->getDue()); } ui->summaryEdit->setText(QString::fromUtf8(todo->getSummary().c_str())); ui->descriptionEdit->setPlainText(QString::fromUtf8(todo->getDescription().c_str())); ui->doneBox->setChecked(todo->getStatus()); dps->setCurrentDate(due.date()); cps->setCalendar(todo->getCalendarId()); aps->setAlarm(todo->getAlarm(), zone); } else { todo = new CTodo(); saveDefaults = true; // Load last used settings settings.beginGroup("TodoEditDialog"); cps->setCalendar(settings.value("Calendar", 1).toInt()); aps->setSecondsBefore(settings.value("Alarm", -1).toInt()); // Prepre to calculate the due date const time_t dueOffset = settings.value("DueOffset", 0).toInt() * 24*60*60; time_t currentStamp = QDateTime::currentDateTime().toTime_t(); QDateTime due; // Some additional processing for time zones if (zps) { const QString zone = settings.value("TimeZone", QString()).toString(); if (!zone.isEmpty()) { // Display time in the selected time zone currentStamp = Date::toRemote(currentStamp, zone).toTime_t(); // Load last used setting zps->setCurrentZone(zone); } } // Calculate the due date in an under/overflow-proof way if (dueOffset > 0) { due = QDateTime::fromTime_t(currentStamp > std::numeric_limits<time_t>::max() - dueOffset ? std::numeric_limits<time_t>::max() : currentStamp + dueOffset); } else { due = QDateTime::fromTime_t(currentStamp < -dueOffset ? 0 : currentStamp + dueOffset); } dps->setCurrentDate(due.date()); ui->doneBox->hide(); ui->summaryEdit->setFocus(); } this->setupSaveButton(ui->buttonBox, SLOT(saveTodo())); ui->editArea->widget()->layout()->activate(); this->setFeatures(ui->dialogLayout, ui->buttonBox); this->todo = todo; }