Exemplo n.º 1
0
//***********************************************
//* Permanently delete all notes
//***********************************************
void NTrashTree::expungeAll() {
    QMessageBox msgBox;
    msgBox.setWindowTitle(tr("Verify Delete"));
    msgBox.setText(tr("Are you sure you want to permanently delete these notes?"));
    msgBox.setStandardButtons(QMessageBox::Yes|QMessageBox::No);
    msgBox.setIcon(QMessageBox::Question);
    msgBox.setDefaultButton(QMessageBox::Yes);
    int rc = msgBox.exec();
    if (rc != QMessageBox::Yes)
        return;

    NoteTable ntable(global.db);
    QList<qint32> lids;
    ntable.getAllDeleted(lids);
    for (int i=0; i<lids.size(); i++) {

        Note n;
        ntable.get(n,lids[i],false,false);
        ntable.expunge(lids[i]);
        delete global.cache[lids[i]];
        global.cache.remove(lids[i]);

        // Check to see if the note is synchronized.  If so, we
        // need to keep it to let Evernote to delete it.
        if (n.updateSequenceNum.isSet() && n.updateSequenceNum>0) {
            ntable.addToDeleteQueue(lids[i],n);
        }
    }
    emit(updateSelectionRequested());
}
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 NTrashTree::buildSelection() {
    QLOG_TRACE() << "Inside NTrashTree::buildSelection()";

    // 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 (root->isSelected())
        newFilter->setDeletedOnly(true);
    else
        newFilter->setDeletedOnly(false);
    newFilter->resetSavedSearch = true;
    newFilter->resetDeletedOnly = true;
    newFilter->resetAttribute = true;
    newFilter->resetFavorite = true;
    newFilter->resetNotebook =true;
    newFilter->resetTags = true;
    newFilter->resetSearchString = true;

    emit updateSelectionRequested();

    QLOG_TRACE() << "Leaving NTrashTree::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 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.º 4
0
// A tag was selected so a new FilterCriteria is created and the
// filtered table will display the results.
void NTagView::buildSelection() {
    QLOG_TRACE() << "Inside NTagView::buildSelection()";

    QList<QTreeWidgetItem*> selectedItems = this->selectedItems();
    if (selectedItems.size() > 0 && selectedItems[0]->data(0,Qt::UserRole) == "root")
        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();
    }

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

    if (selectedItems.size() > 0) {
        newFilter->setTags(selectedItems);
    }
    newFilter->resetAttribute = true;
    newFilter->resetDeletedOnly = true;
    newFilter->resetSavedSearch = true;
    newFilter->resetFavorite = true;
    newFilter->resetTags = true;

    emit updateSelectionRequested();

    QLOG_TRACE() << "Leaving NTagView::buildSelection()";
}
Exemplo n.º 5
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 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);
    }

    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()";
}
Exemplo n.º 6
0
//***********************************************
//* Restore all notes from the trash
//***********************************************
void NTrashTree::restoreAll() {
    NoteTable ntable(global.db);
    QList<qint32> lids;
    ntable.getAllDeleted(lids);
    for (int i=0; i<lids.size(); i++) {
        ntable.restoreNote(lids[i], true);
        delete global.cache[lids[i]];
        global.cache.remove(lids[i]);
    }

    emit(updateSelectionRequested());
}
Exemplo n.º 7
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()";
}
Exemplo n.º 8
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 NAttributeTree::buildSelection() {
    QLOG_TRACE() << "Inside NNotebookView::buildSelection()";

    QList<QTreeWidgetItem*> selectedItems = this->selectedItems();
    if (selectedItems.size() > 0 && selectedItems[0]->data(0,Qt::UserRole) == "root") {
        blockSignals(true);
        root->setSelected(false);
        blockSignals(false);
        return;
    }

    for (int i=0; i<selectedItems.size(); i++) {
        QTreeWidgetItem *item = selectedItems[i];
        if (item->data(0, Qt::UserRole) == 0 || item->data(0,Qt::UserRole) == "root") {
            item->setSelected(false);
        }
    }

    selectedItems = this->selectedItems();
    if (selectedItems.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())
            global.filterCriteria.removeLast();
    }

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

    if (selectedItems.size() > 0) {
        newFilter->setAttribute(*(selectedItems[0]));
    }
    newFilter->resetSavedSearch = true;
    newFilter->resetDeletedOnly = true;
    newFilter->resetNotebook =true;
    newFilter->resetTags = true;
    newFilter->resetAttribute = true;
    newFilter->resetFavorite = true;
    newFilter->resetSearchString = true;

    emit updateSelectionRequested();

    QLOG_TRACE() << "Leaving NNotebookView::buildSelection()";
}
Exemplo n.º 9
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 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()";
}
Exemplo n.º 10
0
//***********************************************
//* Permanently delete all notes
//***********************************************
void NTrashTree::expungeAll() {
    QMessageBox msgBox;
    msgBox.setWindowTitle(tr("Verify Delete"));
    msgBox.setText(tr("Are you sure you want to permanently delete these notes?"));
    msgBox.setStandardButtons(QMessageBox::Yes|QMessageBox::No);
    msgBox.setIcon(QMessageBox::Question);
    msgBox.setDefaultButton(QMessageBox::Yes);
    int rc = msgBox.exec();
    if (rc != QMessageBox::Yes)
        return;

    NoteTable ntable;
    QList<qint32> lids;
    ntable.getAllDeleted(lids);
    for (int i=0; i<lids.size(); i++) {
        ntable.expunge(lids[i]);
        delete global.cache[lids[i]];
        global.cache.remove(lids[i]);
    }
    emit(updateSelectionRequested());
}