コード例 #1
0
ファイル: notebook.cpp プロジェクト: fredollinger/libktomgirl
// BEGIN Notebook::get_template_note()
Note::Ptr Notebook::get_template_note() const {
    std::cout << "Notebook:: get template note()";
    NoteManager & noteManager = Gnote::obj().default_note_manager();
    Note::Ptr note = noteManager.find (m_template_note_title);
    std::cout << "Notebook:: find note";
    if (!note) {
    std::cout << "Notebook:: no note";
      // FIXME: need to get a unique name as well as uuid
      // we should have a default create() function which fills all this junk in...
      note = noteManager.create_new_note("New Note", "");
      //note = noteManager.create (m_template_note_title,
       //                     NoteManager::get_note_template_content (
        //                      m_template_note_title));
          
      // Flag this as a template note
    //qDebug() << "Notebook:: get or create sys tag 2";
      Tag::Ptr tag = TagManager::obj().get_or_create_system_tag (TagManager::TEMPLATE_NOTE_SYSTEM_TAG);
      note->add_tag (tag);

      // Add on the notebook system tag so Tomboy
      // will persist the tag/notebook across sessions
      // if no other notes are added to the notebook.
    //qDebug() << "Notebook:: get or create sys tag 3";
      tag = TagManager::obj().get_or_create_system_tag (NOTEBOOK_TAG_PREFIX + get_name());
      note->add_tag (tag);
        
      //note->queue_save (Note::CONTENT_CHANGED);
    }
    else
      std::cout << "Notebook:: note found";

    return note;
} // END Notebook::get_template_note()
コード例 #2
0
ファイル: notebookmanager.cpp プロジェクト: ludovico/gnote
    /// <summary>
    /// Place the specified note into the specified notebook.  If the
    /// note already belongs to a notebook, it will be removed from that
    /// notebook first.
    /// </summary>
    /// <param name="note">
    /// A <see cref="Note"/>
    /// </param>
    /// <param name="notebook">
    /// A <see cref="Notebook"/>.  If Notebook is null, the note will
    /// be removed from its current notebook.
    /// </param>
    /// <returns>True if the note was successfully moved.</returns>
    bool NotebookManager::move_note_to_notebook (const Note::Ptr & note, 
                                                 const Notebook::Ptr & notebook)
    {
      if (!note) {
        return false;
      }

      // NOTE: In the future we may want to allow notes
      // to exist in multiple notebooks.  For now, to
      // alleviate the confusion, only allow a note to
      // exist in one notebook at a time.

      Notebook::Ptr currentNotebook = get_notebook_from_note (note);
      if (currentNotebook == notebook)
        return true; // It's already there.

      if(currentNotebook) {
        note->remove_tag (currentNotebook->get_tag());
        m_note_removed_from_notebook(*note, currentNotebook);
      }

      // Only attempt to add the notebook tag when this
      // menu item is not the "No notebook" menu item.
      if(notebook) {
        note->add_tag(notebook->get_tag());
        m_note_added_to_notebook(*note, notebook);
      }

      return true;
    }
コード例 #3
0
ファイル: remotecontrol.cpp プロジェクト: haobug/gnote
 bool RemoteControl::AddTagToNote(const std::string& uri, const std::string& tag_name)
 {
   Note::Ptr note = m_manager.find_by_uri (uri);
   if (!note) {
     return false;
   }
   Tag::Ptr tag = TagManager::obj().get_or_create_tag (tag_name);
   note->add_tag (tag);
   return true;
 }
コード例 #4
0
ファイル: notebookmanager.cpp プロジェクト: haobug/gnote
    Notebook::Ptr NotebookManager::get_or_create_notebook(const std::string & notebookName)
    {
      if (notebookName.empty())
        throw sharp::Exception ("NotebookManager.GetNotebook () called with a null name.");
      
      Notebook::Ptr notebook = get_notebook (notebookName);
      if (notebook) {
        return notebook;
      }
      
      Gtk::TreeIter iter;
//      lock (locker) {
        notebook = get_notebook (notebookName);
        if (notebook)
          return notebook;
        
        try {
          m_adding_notebook = true;
          notebook = Notebook::Ptr(new Notebook (notebookName));
        } 
        catch(...)
        {
          // set flag to fast and rethrow
          m_adding_notebook = false;
          throw;
        }
        m_adding_notebook = false;
        iter = m_notebooks->append ();
        iter->set_value(0, notebook);
        m_notebookMap [notebook->get_normalized_name()] = iter;
        
        // Create the template note so the system tag
        // that represents the notebook actually gets
        // saved to a note (and persisted after Tomboy
        // is shut down).
        Note::Ptr templateNote = notebook->get_template_note ();
        
        // Make sure the template note has the notebook tag.
        // Since it's possible for the template note to already
        // exist, we need to make sure it gets tagged.
        templateNote->add_tag (notebook->get_tag());
        m_note_added_to_notebook (*templateNote, notebook);
//      }

      return notebook;
    }