~roadmr/ubuntu/precise/checkbox/0.13.7

« back to all changes in this revision

Viewing changes to qt/frontend/treemodel.cpp

  • Committer: Package Import Robot
  • Author(s): Jeff Lane, Jeff Lane, Marc Tardif, Daniel Manrique, Brendan Donegan, Javier Collado, Tiago Salem Herrmann, Sylvain Pineau
  • Date: 2012-02-15 00:11:21 UTC
  • Revision ID: package-import@ubuntu.com-20120215001121-coleoewpi1wl0i56
Tags: 0.13.2
New upstream release (LP: #933090):

[Jeff Lane]
* Added a Hard Disk Stats Test that was part of a much older merge request
  for server test suite.
* Modified apport-directory to provide feedback
* Added new optical_write_test script and created appropriate jobs to refine
  optical drive testing
* Created new resource job that creates an optical.{CD-R,DVD-R} resource to
  determine if a machine's optical drive supports writing or is read-only.
* Added virt-check test to determine if a server will work as an OpenStack
  Compute Node.
* Moved apport-directory changes from an old branch to checkbox where the
  job now resides.

[Marc Tardif]
* Removed trailing directories from the devpath of disk devices (LP: #925582)
* Fixed awk regular expression in max_diskspace_used script (LP: #926312)
* Implemented anonymous submissions to Launchpad with a dummy e-mail
  address.
* Qt: Moved widgets around in Results window.
* Changed options and arguments passed to show_tree method, and related UI
  changes.
* Simplified running checkbox-qt from source tree, by compiling if needed.
* Added support for decimals and multiple partitions in max_diskspace_used.
* Fixed reference to xrandr_detect_modes replaced by VESA_drivers_not_in_use.
* Fixed depends in debian/control file for checkbox-qt.

[Daniel Manrique]
* Changed way of obtaining preferred browser to ensure we honor the user's
  preference rather than Chromium's clobbering of
  /etc/alternatives/gnome-www-browser (LP: #925603) 
* Added submission_path_prompt config variable; if set, it will be shown to
  the user before the test selection screen, and the value entered will
  override the default filename for the xml report.
* plugins/suites_prompt.py: Fixed jobs being run despite being deselected. 
* Qt: Changed color of the step bubbles to Ubuntu Orange, and made it
  parametrizable.
* Qt: View report functionality.
* Qt: Set the runtime application icon.
* Fixed typo in network/info.
* Fixed typo in create_connection.

[Brendan Donegan]
* Changed checkbox-cli text to clearly explain what + does (LP: #926417)
* Changed progress bar of Qt UI to standard rather than custom one,
  prettified tabs and updated Launchpad email text amongst other UI tweaks
  in qt/frontend/qtfront.ui
* Fixed some oversights in the mediacard job files regarding test 
  descriptions and card types.
* Tweaked the memory_compare script a bit to make it easier to maintain.
* Used regexes in default whitelist.

[ Javier Collado ]
* Removed job that installed ipmitool by default (LP: #931954)

[Tiago Salem Herrmann]
* Implementation of Qt frontend for checkbox.
* Qt-related features and bugfixes:
* Qt: Added welcome screen image and background color.
* Qt: Removed maximize/restore button.
* Qt: added select/deselect all popup menu.
* Qt: Status screen
* Qt: Antialiasing hint for step numbers and question mark.

[Sylvain Pineau]
* Tests will run in in order specified by the whitelist.
* JobStore caches most of a job's attributes in memory to speed up sorting.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#include "treemodel.h"
 
2
#include <QErrorMessage>
 
3
TreeModel::TreeModel() : m_messageBox(0) 
 
4
{
 
5
 
 
6
}
 
7
 
 
8
void TreeModel::warn()
 
9
{
 
10
    if (!m_messageBox)
 
11
        m_messageBox = new QErrorMessage();
 
12
    m_messageBox->showMessage("Changeme: If you deselect this, the result wont be submitted to Ubuntu Friendly!");
 
13
}
 
14
 
 
15
bool TreeModel::setData(const QModelIndex &index, const QVariant &value, int role)
 
16
{
 
17
        QStandardItem *item = QStandardItemModel::itemFromIndex(index);
 
18
        if(!item)
 
19
            return false;
 
20
 
 
21
        // do not warn when the item is checked
 
22
        if ( value == QVariant(Qt::Unchecked) && role == Qt::CheckStateRole)
 
23
            warn();
 
24
 
 
25
        if (item->parent()) {
 
26
            QStandardItemModel::setData(item->index(), value, role);
 
27
            // we are a child, and we have to update parent's status
 
28
            int selected = 0;
 
29
            for(int i=0; i< item->parent()->rowCount(); i++) {
 
30
                QStandardItem *childItem = item->parent()->child(i);
 
31
                if (childItem->checkState() == Qt::Checked) {
 
32
                    selected++;
 
33
                }
 
34
            }
 
35
            if (selected == item->parent()->rowCount()) {
 
36
                item->parent()->setCheckState(Qt::Checked);
 
37
            } else if (selected == 0) {
 
38
                item->parent()->setCheckState(Qt::Unchecked);
 
39
            } else {
 
40
                item->parent()->setCheckState(Qt::PartiallyChecked);
 
41
            }
 
42
        } else {
 
43
            // if we dont have a parent, then we are root. Deselect/select children
 
44
            for(int i=0; i< item->rowCount(); i++) {
 
45
                QStandardItem *childItem = item->child(i);
 
46
                QStandardItemModel::setData(childItem->index(), value, role);
 
47
            }
 
48
        }
 
49
        return QStandardItemModel::setData(index, value, role);
 
50
}
 
51
 
 
52
void TreeModel::setInteraction(bool value)
 
53
{
 
54
    for(int i=0; i< rowCount(); i++) {
 
55
        QStandardItem  *item = this->item(i, 0);
 
56
        if(!item)
 
57
            continue;
 
58
        item->setEnabled(value);
 
59
        for(int j=0; j< item->rowCount(); j++) {
 
60
            QStandardItem *childItem = item->child(j);
 
61
            if(!childItem)
 
62
                continue;
 
63
            childItem->setEnabled(value);
 
64
        }
 
65
    }
 
66
}
 
67
 
 
68
void TreeModel::selectAll(bool select)
 
69
{
 
70
    Qt::CheckState state = select ? Qt::Checked : Qt::Unchecked;
 
71
    for(int i=0; i< rowCount(); i++) {
 
72
        QStandardItem  *item = this->item(i, 0);
 
73
        if(!item)
 
74
            continue;
 
75
        item->setCheckState(state);
 
76
        for(int j=0; j< item->rowCount(); j++) {
 
77
            QStandardItem *childItem = item->child(j);
 
78
            if(!childItem)
 
79
                continue;
 
80
            childItem->setCheckState(state);
 
81
        }
 
82
    }
 
83
}