Exemple #1
0
void ADLS::slotChangeButtonClicked(){
    ADLSItem *item = getItem();

    if (!item)
        return;

    StrMap mapcheck;
    mapcheck["SSTRING"] = item->data(COLUMN_SSTRING).toString();
    mapcheck["DIRECTORY"] = item->data(COLUMN_DIRECTORY).toString();
    VectorSize i = findEntry(mapcheck);
    ADLSEditor editor;
    ADLSearchManager::SearchCollection &collection = ADLSearchManager::getInstance()->collection;
    ADLSearch search = collection[i];

        StrMap map;

        getParams(search, map);
        initEditor(editor, map);

        if (editor.exec() == QDialog::Accepted){
            getParams(editor, map);
            updateItem(item, map);
            updateEntry(search, map);
            if (i < collection.size())
                collection[i] = search;

        }

}
QVariant ADLSModel::data(const QModelIndex &index, int role) const
{
    if (!index.isValid())
        return QVariant();

    if (index.column() > columnCount(QModelIndex()))
        return QVariant();

    ADLSItem *item = static_cast<ADLSItem*>(index.internalPointer());

    switch(role) {
        case Qt::DecorationRole: // icon
            break;
        case Qt::DisplayRole:
            if (index.column() != COLUMN_CHECK)
                return item->data(index.column());
            break;
        case Qt::TextAlignmentRole:
            break;
        case Qt::ForegroundRole:
            break;
        case Qt::ToolTipRole:
            break;
        case Qt::CheckStateRole:
            if (index.column() == COLUMN_CHECK)
                return item->data(COLUMN_CHECK);
            break;
    }

    return QVariant();
}
int ADLSModel::rowCount(const QModelIndex &parent) const
{
    ADLSItem *parentItem;
    if (parent.column() > 0)
        return 0;

    if (!parent.isValid())
        parentItem = rootItem;
    else
        parentItem = static_cast<ADLSItem*>(parent.internalPointer());

    return parentItem->childCount();
}
QModelIndex ADLSModel::parent(const QModelIndex &index) const
{
    if (!index.isValid())
        return QModelIndex();

    ADLSItem *childItem = static_cast<ADLSItem*>(index.internalPointer());
    ADLSItem *parentItem = childItem->parent();

    if (parentItem == rootItem)
        return QModelIndex();

    return createIndex(parentItem->row(), 0, parentItem);
}
Exemple #5
0
void ADLS::slotRemoveButtonClicked(){
    ADLSItem *item = getItem();

    if (!item)
        return;
    StrMap mapcheck;
    mapcheck["SSTRING"] = item->data(COLUMN_SSTRING).toString();
    mapcheck["DIRECTORY"] = item->data(COLUMN_DIRECTORY).toString();
    VectorSize i = findEntry(mapcheck);
    ADLSearchManager::SearchCollection &collection = ADLSearchManager::getInstance()->collection;
        if (i < collection.size()) {
            collection.erase(collection.begin() + i);
            model->removeItem(item);
        }
}
QModelIndex ADLSModel::index(int row, int column, const QModelIndex &parent)
            const
{
    if (!hasIndex(row, column, parent))
        return QModelIndex();

    ADLSItem *parentItem;

    if (!parent.isValid())
        parentItem = rootItem;
    else
        parentItem = static_cast<ADLSItem*>(parent.internalPointer());

    ADLSItem *childItem = parentItem->child(row);
    if (childItem)
        return createIndex(row, column, childItem);
    else
        return QModelIndex();
}
bool ADLSModel::removeItem(const QModelIndex &el){
    if (!el.isValid())
        return false;

    ADLSItem *item = static_cast<ADLSItem*>(el.internalPointer());

    if (!item || !rootItem->childItems.contains(item))
        return false;

    beginRemoveRows(QModelIndex(), item->row(), item->row());
    rootItem->childItems.removeAt(rootItem->childItems.indexOf(item));
    endRemoveRows();

    delete item;

    emit layoutChanged();

    return true;
}
Exemple #8
0
void ADLS::slotClicked(const QModelIndex &index){
    if (!index.isValid() || index.column() != COLUMN_CHECK || !index.internalPointer())
        return;

    ADLSItem *item = reinterpret_cast<ADLSItem*>(index.internalPointer());
    ADLSearchManager::SearchCollection &collection = ADLSearchManager::getInstance()->collection;
    StrMap mapcheck;
    mapcheck["SSTRING"] = item->data(COLUMN_SSTRING).toString();
    mapcheck["DIRECTORY"] = item->data(COLUMN_DIRECTORY).toString();
    VectorSize i = findEntry(mapcheck);
    ADLSearch entry = collection[i];

        bool check = !item->data(COLUMN_CHECK).toBool();

        entry.isActive = check;
        item->updateColumn(COLUMN_CHECK, check);
        if (i < collection.size())
            collection[i] = entry;
        model->repaint();

        ADLSearchManager::getInstance()->Save();
}