Exemplo n.º 1
0
// The note list changed, so we need to reselect any valid notes.
void NTableView::refreshSelection() {

    this->blockSignals(true);
    FilterCriteria *criteria = global.filterCriteria[global.filterPosition];
    QList<qint32> historyList;
    criteria->getSelectedNotes(historyList);

    QLOG_TRACE() << "Highlighting selected rows after refresh";
    // Check the highlighted LIDs from the history selection.
    for (int i=0; i<historyList.size(); i++) {
        if (proxy->lidMap->contains(historyList[i])) {
            int rowLocation = proxy->lidMap->value(historyList[i]);
            if (rowLocation > 0) {
                QModelIndex modelIndex = model()->index(rowLocation,NOTE_TABLE_LID_POSITION);
                QModelIndex proxyIndex = proxy->mapFromSource(modelIndex);
                rowLocation = proxyIndex.row();
                selectRow(rowLocation);
            }
        }
    }
    QLOG_TRACE() << "Highlighting complete";

    // Make sure at least one thing is selected
    QLOG_TRACE() << "Selecting one item if nothing else is selected";
    QModelIndexList l = selectedIndexes();
    if (l.size() == 0) {
        qint32 rowLid = selectAnyNoteFromList();
        criteria->setLid(rowLid);
    }

    QLOG_TRACE() << "refleshSelection() complete";
    this->blockSignals(false);
}
Exemplo n.º 2
0
 //*************************************************************
 // This function is called when a user selects something
 // within this tree.  It also emits a signal that will
 // be picked up by the main nixnote program.
 //*************************************************************
 void LineEdit::buildSelection() {
     QLOG_TRACE() << "Inside LineEdit::buildSelection()";
     savedText = text().trimmed();

     // First, find out if we're already viewing history.  If we are we
     // chop off the end of the history & start a new one
     if (global.filterPosition+1 < global.filterCriteria.size()) {
         while (global.filterPosition+1 < global.filterCriteria.size())
             global.filterCriteria.removeLast();
     }

     filterPosition++;
     FilterCriteria *newFilter = new FilterCriteria();
     global.filterCriteria.push_back(newFilter);
     FilterCriteria *oldFilter = global.filterCriteria[global.filterPosition];
     global.filterPosition++;

     newFilter->setSearchString(text());
     newFilter->resetNotebook = true;
     newFilter->resetTags = true;
     newFilter->resetAttribute = true;
     newFilter->resetFavorite = true;
     newFilter->resetDeletedOnly = true;
     newFilter->resetSavedSearch = true;
     QList<qint32> oldLids;
     oldFilter->getSelectedNotes(oldLids);
     newFilter->setSelectedNotes(oldLids);
     newFilter->setLid(oldFilter->getLid());

     emit updateSelectionRequested();

     QLOG_TRACE() << "Leaving LineEdit::buildSelection()";
 }
Exemplo n.º 3
0
//*************************************************************
// This function is called when a user selects something
// within this tree.  It also emits a signal that will
// be picked up by the main nixnote program.
//*************************************************************
void NNotebookView::buildSelection() {
    QLOG_TRACE() << "Inside NNotebookView::buildSelection()";

    QList<QTreeWidgetItem*> selectedItems = this->selectedItems();
    if (selectedItems.size() > 0 && selectedItems[0]->data(0,Qt::UserRole).toString().startsWith("root"), Qt::CaseInsensitive)
        return;

    // First, find out if we're already viewing history.  If we are we
    // chop off the end of the history & start a new one
    if (global.filterPosition+1 < global.filterCriteria.size()) {
        while (global.filterPosition+1 < global.filterCriteria.size())
            global.filterCriteria.removeLast();
    }

    int currentCount = global.filterCriteria.size();
    FilterCriteria *newFilter = new FilterCriteria();
    if (currentCount > 0) {
        FilterCriteria *currentFilter = global.filterCriteria[currentCount-1];
        if (currentFilter->isLidSet()) {
            newFilter->setLid(currentFilter->getLid());
        }
        if (currentFilter->isSelectedNotesSet()) {
            QList<qint32> lids;
            currentFilter->getSelectedNotes(lids);
            newFilter->setSelectedNotes(lids);
        }
    }
    global.filterCriteria.push_back(newFilter);
    filterPosition++;
    global.filterPosition++;

    if (selectedItems.size() > 0) {
        newFilter->setNotebook(*(selectedItems[0]));
    }
    qint32 notebookLid = 0;
    if (selectedItems.size() > 0)
        notebookLid = selectedItems[0]->data(NAME_POSITION, Qt::UserRole).toInt();
    newFilter->resetAttribute = true;
    newFilter->resetDeletedOnly = true;
    newFilter->resetFavorite = true;
    newFilter->resetNotebook = true;
    newFilter->resetSavedSearch = true;
    newFilter->resetTags = true;
    newFilter->resetSearchString = true;

    emit updateSelectionRequested();
    emit notebookSelectionChanged(notebookLid);

    QLOG_TRACE() << "Leaving NNotebookView::buildSelection()";
}