Revision 1788

trunk/nntpgrab_core/core_signals.c (revision 1788)
181 181

                
182 182
static GTrashStack *signal_data_stack = NULL;
183 183
static GStaticMutex mutex = G_STATIC_MUTEX_INIT;
184
static volatile int num_queued_part_progress_events = 0;
184 185

                
185 186
static SignalData *
186 187
pop_signal_data(void)
... ...
609 610

                
610 611
    push_signal_data(signal_data);
611 612

                
613
    g_atomic_int_add(&num_queued_part_progress_events, -1);
614

                
612 615
    return FALSE;
613 616
}
614 617

                
... ...
621 624
        return;
622 625
    }
623 626

                
627
    /* Prevent too many queued events */
628
    if (num_queued_part_progress_events >= 20) {
629
        static time_t stamp_last_been_here = 0;
630

                
631
        if (stamp_last_been_here != time(NULL)) {
632
            g_print(__FILE__ ":%i %i Skipping part_progress_update event because too many events are already queued\n", __LINE__, (int) stamp_last_been_here);
633
            stamp_last_been_here = time(NULL);
634
        }
635

                
636
        return;
637
    }
638

                
624 639
    data = pop_signal_data();
625 640
    strncpy(data->part_progress_data.servername, servername, sizeof(data->part_progress_data.servername) - 1);
626 641
    data->part_progress_data.conn_id = conn_id;
... ...
630 645
    data->part_progress_data.bytes_downloaded = bytes_downloaded;
631 646
    data->part_progress_data.bytes_total = bytes_total;
632 647

                
648
    g_atomic_int_inc(&num_queued_part_progress_events);
649

                
633 650
    if (direct) {
634 651
        do_emit_part_progress_update(data);
635 652
    } else {
trunk/plugins/unpack/plugin_unpack.c (revision 1788)
83 83
    ng_plugin_create_event(plugin_data, "unpack_progress_update", 3);
84 84
    ng_plugin_create_event(plugin_data, "unpack_message_received", 3);
85 85
    ng_plugin_create_event(plugin_data, "unpack_working_archive_changed", 3);
86
    ng_plugin_create_event(plugin_data, "unpack_success", 2);
87
    ng_plugin_create_event(plugin_data, "unpack_failure", 3);
86 88

                
87 89
    /* Add a dependency on the NNTPGrab Core and the PAR2 plugin */
88 90
    ng_plugin_set_required_event(plugin_data, "collection_downloaded");
... ...
242 244
    unpack_data->error_type = error->type;
243 245
    unpack_data->error_occured = (error->status != 0 || error->type != 0);
244 246

                
245
    if (error->gerror && error->gerror->message) {
247
    if (error->gerror && error->gerror->message && strlen(error->gerror->message) > 0) {
246 248
        strncpy(unpack_data->errmsg, error->gerror->message, sizeof(unpack_data->errmsg) - 1);
247 249
    } else if (error->status != 0) {
248 250
        snprintf(unpack_data->errmsg, sizeof(unpack_data->errmsg) - 1, "Unknown error occured while unpacking, error->status = %i, error->type = %i", error->status, error->type);
... ...
492 494
    while (list) {
493 495
        UnpackFile *file = (UnpackFile*) list->data;
494 496
        char *total_filename = g_build_filename(target_directory, file->filename, NULL);
495

                
496 497
        ng_plugin_emit_log_msg(plugin_data, NG_LOG_LEVEL_INFO, _("Now unpacking '%s'"), file->filename);
497 498

                
498 499
        if (!unpack_do_unpack(plugin_data, collection_name, total_filename, target_directory, &errmsg)) {
500
            char *params[4];
501

                
502
            if (!errmsg || strlen(errmsg) == 0) {
503
                errmsg = g_strdup_printf(_("process stopped unexpectedly"));
504
            }
505

                
506
            params[0] = collection_name;
507
            params[1] = file->filename;
508
            params[2] = errmsg;
509
            params[3] = NULL;
510
            ng_plugin_emit_event(plugin_data, "unpack_failure", params);
511

                
499 512
            ng_plugin_emit_log_msg(plugin_data, NG_LOG_LEVEL_WARNING, _("Automatic unpack failed due to an error: %s"), errmsg);
500 513
            g_free(errmsg);
514
        } else {
515
            char *params[3];
516
            params[0] = collection_name;
517
            params[1] = file->filename;
518
            params[2] = NULL;
519
            ng_plugin_emit_event(plugin_data, "unpack_success", params);
501 520
        }
502 521

                
503 522
        ng_plugin_emit_log_msg(plugin_data, NG_LOG_LEVEL_INFO, _("Unpack of '%s' finished"), file->filename);
trunk/plugins/unpack/marshall.list (revision 1788)
8 8
# void unpack_message_received(NGPlugin *plugin_data, const char *collection_name, const char *filename, const char *message);
9 9
# void unpack_working_archive_changed(NGPlugin *plugin_data, const char *collection_name, const char *filename, const char *working_archive);
10 10
VOID:STRING,STRING,STRING
11

                
11
# void unpack_success(NGPlugin *plugin_data, const char *collection_name, const char *filename);
12
VOID:STRING,STRING
13
# void unpack_failure(NGPlugin *plugin_data, const char *collection_name, const char *filename, const char *reason);
14
VOID:STRING,STRING,STRING
trunk/client/gui/par2.c (revision 1788)
574 574
            unpack_message_received(glue, values[0], values[1], values[2], data);
575 575
        } else if (!strcmp(event_name, "unpack_working_archive_changed")) {
576 576
            unpack_working_archive_changed(glue, values[0], values[1], values[2], data);
577
        } else if (!strcmp(event_name, "unpack_success")) {
578
            // already handled in unpack_progress_update
579
        } else if (!strcmp(event_name, "unpack_failure")) {
580
            // already handled in unpack_progress_update
577 581
        } else {
578 582
            g_warning("Unknown plugin event received from %s plugin: %s\n", plugin_name, event_name);
579 583
        }
trunk/client/gui_qt/WidgetNZBCreator.cpp (revision 1788)
214 214
        collection_name = ui->entryQuery->text();
215 215
    }
216 216

                
217
    ui->btnImport->setEnabled(false);
218
    ui->treeWidget->setEnabled(false);
219

                
217 220
    future_import = QtConcurrent::run(this, &WidgetNZBCreator::performImport, file_ids);
218 221
    watcher_import.setFuture(future_import);
219 222
}
... ...
236 239

                
237 240
    DialogImportNZB d(glue);
238 241
    d.quickImport(collection_name, res.nzb_data, true);
242

                
243
    ui->btnImport->setEnabled(true);
244
    ui->treeWidget->setEnabled(true);
239 245
}
240 246

                
241 247
void WidgetNZBCreator::btnSelectAll_clicked()
trunk/client/gui_qt/WidgetDownloadQueue.cpp (revision 1788)
9 9

                
10 10
#include "nntpgrab_utils.h"
11 11

                
12
#ifdef MODEL_TEST
13
#include "modeltest/modeltest.h"
14
#endif
15

                
12 16
WidgetDownloadQueue::WidgetDownloadQueue(QNNTPGrabGlue *glue, QAction *actionRemoveSelectedFiles, QWidget *parent) :
13 17
        QWidget(parent),
14 18
        ui(new Ui::WidgetDownloadQueue)
... ...
18 22

                
19 23
    ui->setupUi(this);
20 24

                
21
    ui->treeView->header()->setResizeMode(QHeaderView::ResizeToContents);
22

                
23 25
    this->model = new DownloadQueueModel(glue);
26
#ifdef MODEL_TEST
27
    new ModelTest(this->model, this);
28
#endif
24 29
    ui->treeView->setModel(this->model);
25 30

                
26 31
    progressbarDelegate = new ProgressBarDelegateDownloadQueue(this);
... ...
46 51
    connect(ui->treeView, SIGNAL(customContextMenuRequested(const QPoint &)), SLOT(showContextMenu(const QPoint &)));
47 52

                
48 53
    /* Add custom fields to the list */
49
    //ui->treeView->setColumnCount(DownloadQueueItem::NUM_FIELDS);
50 54
    ui->treeView->setColumnHidden(DownloadQueueItem::FIELD_PROGRESS, true);
51 55
    ui->treeView->setColumnHidden(DownloadQueueItem::FIELD_FILE_SIZE, true);
52 56
    ui->treeView->setColumnHidden(DownloadQueueItem::FIELD_FILE_SIZE_REMAINING, true);
53 57
    ui->treeView->setColumnHidden(DownloadQueueItem::FIELD_REAL_FILENAME, true);
54 58

                
55
//    ui->treeView->resizeColumnToContents(DownloadQueueItem::FIELD_PROGRESS);
59
    /* Resize the tree to the most optimal size */
60
    ui->treeView->resizeColumnToContents(DownloadQueueItem::FIELD_SUBJECT);
61
    ui->treeView->resizeColumnToContents(DownloadQueueItem::FIELD_POSTER);
62
    ui->treeView->resizeColumnToContents(DownloadQueueItem::FIELD_GROUPS);
63

                
64
    /* Manually set the size of various columns */
65
    ui->treeView->setColumnWidth(DownloadQueueItem::FIELD_STATE_STR, 150);
66
    ui->treeView->setColumnWidth(DownloadQueueItem::FIELD_FILE_SIZE_STR, 120);
67
    ui->treeView->setColumnWidth(DownloadQueueItem::FIELD_FILE_SIZE_REMAINING_STR, 120);
68
    ui->treeView->setColumnWidth(DownloadQueueItem::FIELD_STAMP, 200);
69
    ui->treeView->setColumnWidth(DownloadQueueItem::FIELD_ESTIMATED_TIME_REMAINING_STR, 230);
70
    ui->treeView->setColumnWidth(DownloadQueueItem::FIELD_ESTIMATED_TIME_TO_FINISH_STR, 200);
71

                
72
    /* Let the view indicate whenever a column resize is wanted */
73
    connect(model, SIGNAL(requestColumnResize(DownloadQueueItem::field)), SLOT(onRequestColumnResize(DownloadQueueItem::field)));
56 74
}
57 75

                
58 76
WidgetDownloadQueue::~WidgetDownloadQueue()
... ...
200 218
    processSelectionAndMoveItems(MOVE_DIRECTION_BOTTOM);
201 219
}
202 220

                
221
void WidgetDownloadQueue::onRequestColumnResize(DownloadQueueItem::field column)
222
{
223
    ui->treeView->resizeColumnToContents(column);
224
}
225

                
203 226
void WidgetDownloadQueue::onSelectionChanged(const QItemSelection &newSelection, const QItemSelection &oldSelection)
204 227
{
205 228
    Q_UNUSED(newSelection);
trunk/client/gui_qt/DownloadQueueModel.h (revision 1788)
20 20
    int rowCount(const QModelIndex &parent = QModelIndex()) const;
21 21
    int columnCount(const QModelIndex &parent = QModelIndex()) const;
22 22

                
23
    DownloadQueueItem *itemForIndex(const QModelIndex &index) const;
24

                
23 25
private:
24 26
    void loadDownloadQueue(QNNTPGrabGlue *glue);
25 27
    int calculateProgress(quint64 size, quint64 sizeRemaining);
... ...
44 46
    void onTrafficMonitorUpdate(int bytes_received1, int bytes_received2, int bytes_received3, int bytes_received4, int bytes_received5, int bytes_received6, int bytes_received7, int bytes_received8, int bytes_received9, int bytes_received10, QDateTime stamp, double average);
45 47

                
46 48
signals:
49
    void requestColumnResize(DownloadQueueItem::field column);
47 50

                
48 51
public slots:
49 52

                
trunk/client/gui_qt/WidgetDownloadQueue.ui (revision 1788)
31 31
     
32 32
      true
33 33
     
34
     
35
      true
36
     
34 37
    
35 38
   
36 39
   
trunk/client/gui_qt/WidgetDownloadQueue.h (revision 1788)
47 47
#endif
48 48

                
49 49
private slots:
50
    void onRequestColumnResize(DownloadQueueItem::field column);
51

                
50 52
    void btnQueueMoveToTop_clicked(void);
51 53
    void btnQueueMoveUp_clicked(void);
52 54
    void btnQueueMoveDown_clicked(void);
trunk/client/gui_qt/DownloadQueueModel.cpp (revision 1788)
29 29

                
30 30
int DownloadQueueModel::columnCount(const QModelIndex &parent) const
31 31
{
32
    if (parent.isValid())
33
        return static_cast(parent.internalPointer())->columnCount();
34
    else
35
        return rootItem->columnCount();
32
    return parent.isValid() && parent.column() != 0 ? 0 : DownloadQueueItem::NUM_FIELDS;
36 33
}
37 34

                
38 35
QVariant DownloadQueueModel::data(const QModelIndex &index, int role) const
... ...
123 120
    if (!index.isValid())
124 121
        return QModelIndex();
125 122

                
126
    DownloadQueueItem *childItem = static_cast(index.internalPointer());
127
    DownloadQueueItem *parentItem = childItem->parent();
123
    if (DownloadQueueItem *childItem = itemForIndex(index)) {
124
        if (DownloadQueueItem *parentItem = childItem->parent()) {
125
            if (parentItem == rootItem)
126
                return QModelIndex();
127
            if (DownloadQueueItem *grandParentItem = parentItem->parent()) {
128
                int row = grandParentItem->rowOfChild(parentItem);
129
                return createIndex(row, 0, parentItem);
130
            }
131
        }
132
    }
128 133

                
129
    if (parentItem == rootItem || !parentItem)
130
        return QModelIndex();
134
    return QModelIndex();
135
}
131 136

                
132
    return createIndex(parentItem->row(), 0, parentItem);
137
DownloadQueueItem *DownloadQueueModel::itemForIndex(const QModelIndex &index) const
138
{
139
    if (index.isValid()) {
140
        if (DownloadQueueItem *item = static_cast(index.internalPointer())) {
141
            return item;
142
        }
143
    }
144

                
145
    return rootItem;
133 146
}
134 147

                
135 148
int DownloadQueueModel::rowCount(const QModelIndex &parent) const
136 149
{
137
    DownloadQueueItem *parentItem;
138
    if (parent.column() > 0)
150
    if (parent.isValid() && parent.column() != 0)
139 151
        return 0;
140 152

                
141
    if (!parent.isValid())
142
        parentItem = rootItem;
143
    else
144
        parentItem = static_cast(parent.internalPointer());
145

                
146
    return parentItem->childCount();
153
    DownloadQueueItem *parentItem = itemForIndex(parent);
154
    return parentItem ? parentItem->childCount() : 0;
147 155
}
148 156

                
149 157
void DownloadQueueModel::loadDownloadQueue(QNNTPGrabGlue *glue)
... ...
244 252
    int ret = (((double)size - sizeRemaining) / size) * 100;
245 253

                
246 254
    if (ret < 0 || ret > 100) {
247
        qWarning("Invalid progress detected, size = %lli, size_remaining = %lli", size, sizeRemaining);
255
        qDebug("Invalid progress detected, size = %lli, size_remaining = %lli", size, sizeRemaining);
248 256
    }
249 257

                
250 258
    return qMin(100, ret);
... ...
409 417

                
410 418
    idx = createIndex(subject_node->row(), (int) DownloadQueueItem::FIELD_FILE_SIZE_REMAINING_STR, subject_node);
411 419
    emit dataChanged(idx, idx);
420

                
421
    emit requestColumnResize(DownloadQueueItem::FIELD_STATE_STR);
412 422
}
413 423

                
414 424
void DownloadQueueModel::onFileAdded(QString collection_name, QString subject, QString poster, QDateTime stamp, quint64 file_size, quint64 total_size, quint64 total_size_remaining, QNNTPGrabGlue::TaskState state, int num_parts, QList groups)
... ...
421 431
        return;
422 432
    }
423 433

                
434
    beginInsertRows(createIndex(collection_node->row(), 0, collection_node), collection_node->childCount(), collection_node->childCount());
435

                
424 436
    DownloadQueueItem *file_node = new DownloadQueueItem(collection_node);
425 437
    file_node->subject = subject;
426 438
    file_node->poster = poster;
... ...
447 459
        file_node->sizeRemainingStr = QNNTPGrabGlue::utilsCalculateFileSize(0);
448 460
    }
449 461

                
450
    QModelIndex idx_start = createIndex(file_node->row(), 0, file_node);
451
    QModelIndex idx_end = createIndex(file_node->row(), DownloadQueueItem::NUM_FIELDS - 1, file_node);
452
    emit dataChanged(idx_start, idx_end);
453

                
454 462
    /* Update the parent */
455 463
    collection_node->appendChild(file_node);
456 464

                
465
    endInsertRows();
466

                
457 467
    collection_node->size = total_size;
458 468
    collection_node->sizeStr = QNNTPGrabGlue::utilsCalculateFileSize(total_size);
459 469
    collection_node->sizeRemaining = total_size_remaining;
... ...
468 478

                
469 479
    idx = createIndex(collection_node->row(), (int) DownloadQueueItem::FIELD_FILE_SIZE_REMAINING_STR, collection_node);
470 480
    emit dataChanged(idx, idx);
481

                
482
    emit requestColumnResize(DownloadQueueItem::FIELD_STATE_STR);
471 483
}
472 484

                
473 485
void DownloadQueueModel::onFileRemoved(QString collection_name, QString subject, quint64 total_size, quint64 total_size_remaining)
... ...
482 494
        return;
483 495
    }
484 496

                
497
    beginRemoveRows(createIndex(collection_node->row(), 0, collection_node), subject_node->row(), subject_node->row());
498

                
485 499
    collection_node->size = total_size;
486 500
    collection_node->sizeStr = QNNTPGrabGlue::utilsCalculateFileSize(total_size);
487 501
    collection_node->sizeRemaining = total_size_remaining;
... ...
489 503
    collection_node->progress = calculateProgress(total_size, total_size_remaining);
490 504

                
491 505
    collection_node->removeChild(subject_node);
506
    delete subject_node;
492 507

                
493
    QModelIndex idx_start = createIndex(subject_node->row(), 0, subject_node);
494
    QModelIndex idx_end = createIndex(subject_node->row(), DownloadQueueItem::NUM_FIELDS - 1, subject_node);
495
    emit dataChanged(idx_start, idx_end);
508
    endRemoveRows();
496 509

                
497
    delete subject_node;
498

                
499 510
    QModelIndex idx = createIndex(collection_node->row(), (int) DownloadQueueItem::FIELD_STATE_STR, collection_node);
500 511
    emit dataChanged(idx, idx);
501 512

                
... ...
541 552

                
542 553
void DownloadQueueModel::onCollectionAdded(QString collection_name, QString poster)
543 554
{
555
    beginInsertRows(QModelIndex(), rootItem->childCount(), rootItem->childCount());
556

                
544 557
    DownloadQueueItem *collection_node = new DownloadQueueItem(rootItem);
545 558
    collection_node->subject = collection_name;
546 559
    collection_node->poster = poster;
560

                
547 561
    rootItem->appendChild(collection_node);
548 562

                
549
    QModelIndex idx_start = createIndex(collection_node->row(), 0, collection_node);
550
    QModelIndex idx_end = createIndex(collection_node->row(), DownloadQueueItem::NUM_FIELDS - 1, collection_node);
551
    emit dataChanged(idx_start, idx_end);
563
    endInsertRows();
564

                
565
    QModelIndex idx_begin = createIndex(collection_node->row(), (int) DownloadQueueItem::FIELD_STATE_STR, collection_node);
566
    QModelIndex idx_end = createIndex(collection_node->row(), (int) DownloadQueueItem::NUM_FIELDS, collection_node);
567
    emit dataChanged(idx_begin, idx_end);
568

                
569
    emit requestColumnResize(DownloadQueueItem::FIELD_SUBJECT);
552 570
}
553 571

                
554 572
void DownloadQueueModel::onCollectionRemoved(QString collection_name)
... ...
560 578
        return;
561 579
    }
562 580

                
581
    /* Does the collection still contain files? */
582
    if (collection_node->childCount() != 0) {
583
        qWarning("Request received to remove collection, but collection is not empty");
584
        return;
585
    }
586

                
587
    beginRemoveRows(createIndex(rootItem->row(), 0, rootItem), collection_node->row(), collection_node->row());
588

                
563 589
    rootItem->removeChild(collection_node);
590
    //delete collection_node;       /* Disabled for now as this causes a segfault later on */
564 591

                
565
    QModelIndex idx_start = createIndex(collection_node->row(), 0, collection_node);
566
    QModelIndex idx_end = createIndex(collection_node->row(), DownloadQueueItem::NUM_FIELDS - 1, collection_node);
567
    emit dataChanged(idx_start, idx_end);
568

                
569
    delete collection_node;
592
    endRemoveRows();
570 593
}
571 594

                
572 595
void DownloadQueueModel::onCollectionModified(QString collection_name, QString poster)
... ...
603 626

                
604 627
    QModelIndex parent_idx = createIndex(rootItem->row(), 0, rootItem);
605 628
    int new_pos_in_model = qMin(rootItem->childCount(), ((old_position < new_position) ? new_position + 1 : new_position));
606
    if (!beginMoveRows(parent_idx, old_position, old_position, parent_idx, new_pos_in_model)) {
629
    if (!beginMoveRows(QModelIndex(), old_position, old_position, QModelIndex(), new_pos_in_model)) {
607 630
        qWarning("beginMoveRows failed\n");
608 631
        return;
609 632
    }
trunk/client/gui_qt/WidgetRepairAndUnpack.h (revision 1788)
40 40
    void unpackProgressUpdate(QString collection_name, QString filename, double progress);
41 41
    void unpackMessageReceived(QString collection_name, QString filename, QString message);
42 42
    void unpackWorkingArchiveChanged(QString collection_name, QString filename, QString working_archive);
43
    void unpackSuccess(QString collection_name, QString filename);
44
    void unpackFailure(QString collection_name, QString filename, QString reason);
43 45

                
44 46
private slots:
45 47
    void configChanged();
trunk/client/gui_qt/DownloadQueueItem.h (revision 1788)
21 21
    int row() const;
22 22
    DownloadQueueItem *parent();
23 23
    DownloadQueueItem *lookupSubject(QString subject);
24
    int rowOfChild(DownloadQueueItem *child) const;
24 25

                
25 26
    QString subject;
26 27
    QString poster;
trunk/client/gui_qt/DownloadQueueSelectionModel.cpp (revision 1788)
16 16
    /* Is the current row selected? */
17 17
    QModelIndex idx = sourceParent.child(sourceStart, 0);
18 18
    if (!idx.isValid()) {
19
        qWarning("Invalid index");
19
        idx = model()->index(sourceStart, 0);
20
        if (!idx.isValid()) {
21
            qWarning("DownloadQueueSelectionModel::onRowsAboutToBeMoved: Invalid index (sourceParent)");
22
        }
20 23
    }
24

                
21 25
    if (isSelected(idx)) {
22 26
        /* Deselect the row and keep track of it so we can re-select it after the move has completed */
23
        select(sourceParent.child(sourceStart, 0), Toggle | Rows);
27
        select(idx, Toggle | Rows);
24 28
        deselectedSourceParent = sourceParent;
25 29
        deselectedSourceStart = sourceStart;
26 30

                
... ...
30 34

                
31 35
        QModelIndex idx = destinationParent.child(destinationRow, 0);
32 36
        if (!idx.isValid()) {
33
            qWarning("Invalid index");
37
            idx = model()->index(destinationRow, 0);
38
            if (!idx.isValid()) {
39
                qWarning("DownloadQueueSelectionModel::onRowsAboutToBeMoved: Invalid index (destinationParent)");
40
            }
34 41
        }
35 42
        select(idx, Toggle | Rows);
36 43
    } else {
... ...
42 49
void DownloadQueueSelectionModel::onRowsMoved(const QModelIndex &sourceParent, int sourceStart, int sourceEnd, const QModelIndex &destinationParent, int destinationRow)
43 50
{
44 51
    Q_UNUSED(sourceEnd);
52
    Q_UNUSED(destinationParent);
53
    Q_UNUSED(destinationRow);
45 54

                
46 55
    /* Was the original row selected? */
47 56
    if (deselectedSourceParent != sourceParent ||
... ...
50 59
        return;
51 60
    }
52 61

                
53
    //QModelIndex idx = destinationParent.child(destinationRow, 0);
54
    //if (!idx.isValid()) {
55
    //    qWarning("Invalid index");
56
    //}
57
    //select(idx, Toggle | Rows);
62
//    QModelIndex idx = destinationParent.child(destinationRow, 0);
63
//    if (!idx.isValid()) {
64
//        idx = model()->index(destinationRow, 0);
65
//        if (!idx.isValid()) {
66
//            qWarning("DownloadQueueSelectionModel::onRowsMoved: Invalid index (destinationParent)");
67
//        }
68
//    }
69
//    select(idx, Toggle | Rows);
58 70
}
trunk/client/gui_qt/WidgetRepairAndUnpack.cpp (revision 1788)
301 301

                
302 302
    collection_item->setText(FIELD_PROGRESS, "75");
303 303
    file_item->setText(FIELD_PROGRESS, QString("%1").arg((int) (progress * 100)));
304

                
305
    if (progress == 1.0) {
306
        collection_item->setText(FIELD_PROGRESS, "100");
307
        collection_item->setText(FIELD_PROGRESS_STR, tr("Unpack completed"));
308
        file_item->setText(FIELD_PROGRESS, "100");
309
        file_item->setText(FIELD_PROGRESS_STR, tr("Unpack completed"));
310
    }
311 304
}
312 305

                
313 306
void WidgetRepairAndUnpack::unpackMessageReceived(QString collection_name, QString filename, QString message)
... ...
332 325
    ui->treeWidget->scrollToBottom();
333 326
}
334 327

                
328
void WidgetRepairAndUnpack::unpackSuccess(QString collection_name, QString filename)
329
{
330
    QTreeWidgetItem *collection_item = NULL;
331
    QTreeWidgetItem *file_item = NULL;
332

                
333
    lookupCollectionAndFilename(collection_name, filename, &collection_item, &file_item);
334

                
335
    collection_item->setText(FIELD_PROGRESS, "100");
336
    collection_item->setText(FIELD_PROGRESS_STR, tr("Unpack completed"));
337
    file_item->setText(FIELD_PROGRESS, "100");
338
    file_item->setText(FIELD_PROGRESS_STR, tr("Unpack completed"));
339
}
340

                
341
void WidgetRepairAndUnpack::unpackFailure(QString collection_name, QString filename, QString reason)
342
{
343
    QTreeWidgetItem *collection_item = NULL;
344
    QTreeWidgetItem *file_item = NULL;
345

                
346
    lookupCollectionAndFilename(collection_name, filename, &collection_item, &file_item);
347

                
348
    collection_item->setText(FIELD_PROGRESS, "100");
349
    collection_item->setText(FIELD_PROGRESS_STR, tr("Unpack failed due to an error"));
350
    file_item->setText(FIELD_PROGRESS, "100");
351
    file_item->setText(FIELD_PROGRESS_STR, tr("Unpack failed due to an error: ") + reason);
352
}
353

                
335 354
void WidgetRepairAndUnpack::configChanged()
336 355
{
337 356
    this->opts = glue->configGetOpts();
... ...
366 385
            unpackMessageReceived(values[0], values[1], values[2]);
367 386
        } else if (event_name == "unpack_working_archive_changed") {
368 387
            unpackWorkingArchiveChanged(values[0], values[1], values[2]);
388
        } else if (event_name == "unpack_success") {
389
            unpackSuccess(values[0], values[1]);
390
        } else if (event_name == "unpack_failure") {
391
            unpackFailure(values[0], values[1], values[2]);
369 392
        } else {
370 393
            qWarning(QString("Unknown plugin event received from plugin '%1': %2").arg(plugin_name, event_name).toUtf8());
371 394
        }
trunk/client/gui_qt/ProgressBarDelegateDownloadQueue.cpp (revision 1788)
30 30
    if (txt.isEmpty()) {
31 31
        return QSize(60,16);
32 32
    } else {
33
        return QSize(100,16);
33
        return QSize(120,16);
34 34
    }
35 35
}
36 36

                
trunk/client/gui_qt/DownloadQueueItem.cpp (revision 1788)
1
#include 
1 2
#include "DownloadQueueItem.h"
2 3

                
3 4
DownloadQueueItem::DownloadQueueItem(DownloadQueueItem *parent)
... ...
75 76
            return sizeRemainingStr;
76 77

                
77 78
        case FIELD_STAMP:
78
            return stamp;
79
        {
80
            char stamp_str[32];
81
            struct tm *stamp_tm;
82
            time_t stamp_time_t;
79 83

                
84
            memset(&stamp_str, 0, sizeof(stamp_str));
85
            stamp_time_t = stamp.toTime_t();
86
            if ((stamp_tm = localtime(&stamp_time_t)) == NULL) {
87
                /* Date could not be parsed */
88
                return stamp.toString();
89
            }
90

                
91
            if (strftime(stamp_str, sizeof(stamp_str) - 1, "%c", stamp_tm) == 0) {
92
                qWarning(__FILE__ ":%i buffer too small", __LINE__);
93
            }
94

                
95
            return QString(stamp_str);
96
        }
97

                
80 98
        case FIELD_ESTIMATED_TIME_REMAINING_STR:
81 99
            return estimatedTimeRemainingStr;
82 100

                
... ...
124 142

                
125 143
    return NULL;
126 144
}
145

                
146
int DownloadQueueItem::rowOfChild(DownloadQueueItem *child) const
147
{
148
    return childItems.indexOf(child);
149
}

Also available in: Unified diff