Changeset d97bcab for src/gui


Ignore:
Timestamp:
04/15/10 14:49:59 (12 years ago)
Author:
kirilma <kirilma@…>
Branches:
master, qt5
Children:
04acaf9
Parents:
f5b68a4
Message:

implement deleting a conference

pass event about it to mainwindow to update select control
fix Conference::activeConference() to work when first conference is removed

Location:
src/gui
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • src/gui/importschedulewidget.cpp

    rf5b68a4 rd97bcab  
    2727#include <QNetworkAccessManager>
    2828#include <QNetworkReply>
     29#include <QMessageBox>
    2930#include <QDebug>
    3031#include <appsettings.h>
     
    167168void ImportScheduleWidget::on_delete()
    168169{
    169     // TODO: implement
     170    int active_id = Conference::activeConference();
     171    Conference active_conference = Conference::getById(active_id);
     172
     173    QMessageBox::StandardButton answer =
     174        QMessageBox::question(0
     175            , "Deletion confirmation"
     176            , QString("Really delete the %1 conference").arg(active_conference.title())
     177            , QMessageBox::Yes | QMessageBox::No
     178            , QMessageBox::No);
     179
     180    if (answer == QMessageBox::Yes) {
     181        QString title = active_conference.title();
     182        Conference::deleteConference(active_id);
     183        emit(scheduleDeleted(title));
     184    }
    170185}
    171186
  • src/gui/importschedulewidget.h

    rf5b68a4 rd97bcab  
    4444    signals:
    4545        void scheduleImported(int confId);
     46        void scheduleDeleted(const QString& title);
    4647    private:
    4748        void importFromNetwork(const QString& url);
  • src/gui/mainwindow.cpp

    rf5b68a4 rd97bcab  
    7575
    7676    connect(importScheduleWidget, SIGNAL(scheduleImported(int)), SLOT(scheduleImported(int)));
     77    connect(importScheduleWidget, SIGNAL(scheduleDeleted(const QString&)), SLOT(scheduleDeleted(const QString&)));
    7778
    7879    // event details have changed
     
    161162}
    162163
     164void MainWindow::scheduleDeleted(const QString& title)
     165{
     166    int idx = selectConference->findText(title);
     167
     168    if (idx == -1) {
     169        // should not happen
     170        qWarning() << __PRETTY_FUNCTION__ << "removed non-existent item:" << title;
     171    } else {
     172        // will it signal "changed"?
     173        selectConference->removeItem(idx);
     174    }
     175}
     176
    163177void MainWindow::aboutApp()
    164178{
  • src/gui/mainwindow.h

    rf5b68a4 rd97bcab  
    3434private slots:
    3535    void scheduleImported(int aConfId);
     36    void scheduleDeleted(const QString& title);
    3637    void aboutApp();
    3738    void conferenceMapClicked();
Note: See TracChangeset for help on using the changeset viewer.