Esempio n. 1
0
 virtual void slotRemove()
 {
     if (itemSelection().isEmpty()) {
         return;
     }
     // get the actions/collections, indexes will change when things are removed
     QList<Kross::Action*> actions;
     QList<Kross::ActionCollection*> collections;
     foreach (const QModelIndex &idx, itemSelection().indexes()) {
         Kross::Action *a =  model()->action(idx);
         if (a) {
             actions << a;
         } else {
             Kross::ActionCollection *c = model()->collection(idx);
             if (c) {
                 collections << c;
             }
         }
     }
     foreach (Kross::Action *action, actions) {
         QModelIndex idx = model()->indexForAction(action);
         if (idx.isValid()) {
             //kDebug(32010)<<"action:"<<action->name();
             delete action;
         }
     }
Esempio n. 2
0
void tst_QColumnView::visualRegionForSelection()
{
    ColumnView view;
    QItemSelection emptyItemSelection;
    QCOMPARE(QRegion(), view.visualRegionForSelection(emptyItemSelection));

    // a region that isn't empty
    QDirModel model;
    view.setModel(&model);

    // On Windows CE the home directory might actually be empty.
#ifndef Q_OS_WINCE
    QString location = QDir::homePath();
#else
    QString location = QLatin1String("/Windows");
#endif

    QModelIndex home = model.index(location);
    QVERIFY(model.rowCount(home) > 1);
    QItemSelection itemSelection(model.index(0, 0, home), model.index(model.rowCount(home) - 1, 0, home));
    QVERIFY(QRegion() != view.visualRegionForSelection(itemSelection));
}