//************************************************************* // 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()"; }
// Open a selected note. This is not done via the context menu. void NTableView::openSelectedLids(bool newWindow) { QList<qint32> lids; getSelectedLids(lids); if (lids.size() == 0) 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()) delete global.filterCriteria.takeAt(global.filterCriteria.size()-1); } FilterCriteria *newFilter = new FilterCriteria(); global.filterCriteria.at(global.filterPosition)->duplicate(*newFilter); newFilter->setSelectedNotes(lids); if (lids.size() > 0) newFilter->setLid(lids.at(0)); global.filterCriteria.push_back(newFilter); global.filterPosition++; if (lids.size() > 0) { emit openNote(newWindow); } }
// 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); }
//************************************************************* // 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()"; }
//************************************************************* // 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 FavoritesView::buildSelection() { QLOG_TRACE() << "Inside FavoritesView::buildSelection()"; QList<QTreeWidgetItem*> selectedItems = this->selectedItems(); // 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); global.filterPosition++; if (selectedItems.size() > 0) { qint32 lid = selectedItems[0]->data(NAME_POSITION, Qt::UserRole).toInt(); if (lid>0) { newFilter->setFavorite(lid); FavoritesViewItem *item = (FavoritesViewItem*)selectedItems[0]; if (item->record.type == FavoritesRecord::Note) { newFilter->setLid(item->record.target.toInt()); } if (item->record.type == FavoritesRecord::Search) { SavedSearch search; SearchTable table(global.db); QLOG_DEBUG() << item->record.target.toInt(); table.get(search, item->record.target.toInt()); if (search.query.isSet()) newFilter->setSearchString(search.query); } } } newFilter->resetAttribute = true; newFilter->resetDeletedOnly = true; newFilter->resetNotebook =true; newFilter->resetTags = true; newFilter->resetSavedSearch = true; newFilter->resetSearchString = true; newFilter->resetSelectedNotes = true; emit updateSelectionRequested(); QLOG_TRACE() << "Leaving FavoritesView::buildSelection()"; }
void FilterCriteria::duplicate(FilterCriteria &newFilter) { if (attributeIsSet) newFilter.setAttribute(*attribute); if (contentIsSet) newFilter.setLid(content); for (int i=0; i<selectedNotes.size(); i++) { newFilter.selectedNotes.append(selectedNotes[i]); } if (deletedOnlyIsSet) newFilter.setDeletedOnly(deletedOnly); if (selectedNotesIsSet) newFilter.setSelectedNotes(selectedNotes); if (tagsIsSet) newFilter.setTags(tags); if (savedSearch) newFilter.setSavedSearch(*savedSearch); if (searchStringIsSet) newFilter.setSearchString(searchString); if (attributeIsSet) newFilter.setAttribute(*attribute); newFilter.resetNotebook = resetNotebook; newFilter.resetTags = resetTags; newFilter.resetSavedSearch = resetSavedSearch; newFilter.resetAttribute = resetAttribute; newFilter.resetDeletedOnly = resetDeletedOnly; newFilter.resetLid = resetLid; newFilter.resetSearchString = resetSearchString; }
// A user asked to open new notes via the context menu. void NTableView::openNoteContextMenuTriggered() { QList<qint32> lids; getSelectedLids(lids); if (lids.size() == 0) 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()) delete global.filterCriteria.takeAt(global.filterCriteria.size()-1); } for (int i=0; i<lids.size(); i++) { FilterCriteria *newFilter = new FilterCriteria(); global.filterCriteria.at(global.filterPosition)->duplicate(*newFilter); newFilter->setSelectedNotes(lids); newFilter->setLid(lids.at(i)); global.filterCriteria.push_back(newFilter); global.filterPosition++; emit openNote(true); } }