//************************************************************* // 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()"; }
void FilterCriteria::duplicate(FilterCriteria &newFilter) { if (attributeIsSet) newFilter.setAttribute(*attribute); if (contentIsSet) newFilter.setContent(content); 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.resetContent = resetContent; newFilter.resetSearchString = resetSearchString; }
//************************************************************* // 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; }
// Do the alter. If the notebook is not found we create it. // If a tag is not found for an add, we add it. If a tag is // not found for a deleteTag, we just ignore it. int AlterNote::alterNote() { // If a query is specified, we find the matching notes. if (query != "") { FilterCriteria *filter = new FilterCriteria(); global.filterCriteria.append(filter); global.filterPosition = 0; FilterEngine engine; filter->setSearchString(query); QList<qint32> lids; engine.filter(filter, &lids); this->lids.append(lids); } NotebookTable bookTable(global.db); TagTable tagTable(global.db); NoteTable noteTable(global.db); // Loop through each note requested. for (int i=0; i<lids.size(); i++) { qint32 lid = lids[i]; // Do the notebook request if (notebook != "") { qint32 notebookLid = bookTable.findByName(notebook); if (notebookLid<0) { Notebook book; book.name = notebook; NUuid uuid; book.guid = uuid.create(); notebookLid = bookTable.add(0,book,true,true); } if (noteTable.getNotebookLid(lid) != notebookLid) noteTable.updateNotebook(lid, notebookLid, true); } // Add the tags for (int j=0; j<addTagNames.size(); j++) { qint32 tagLid = tagTable.findByName(addTagNames[j],0); if (tagLid <= 0) { Tag t; t.name = addTagNames[j]; NUuid uuid; t.guid = uuid.create(); tagLid = tagTable.add(0,t,true,0); } if (!noteTable.hasTag(lid,tagLid)) noteTable.addTag(lid, tagLid, true); } // Remove any tags specified for (int j=0; j<delTagNames.size(); j++) { qint32 tagLid = tagTable.findByName(delTagNames[j],0); if (tagLid > 0 && noteTable.hasTag(lid,tagLid)) { noteTable.removeTag(lid, tagLid, true); } } if (reminderCompleted) { noteTable.setReminderCompleted(lid, true); } if (clearReminder) { noteTable.removeReminder(lid); } } return 0; }