Пример #1
0
void BookmarksModel::AddBookmarks (const Bookmarks_t& bookmarks)
{
    Bookmarks_t bmss = bookmarks;
    for (int i = bmss.count () - 1; i >= 0; --i)
    {
        auto bms = bmss.at (i);
        auto it = std::find_if (Bookmarks_.begin (), Bookmarks_.end (),
                                [bms] (decltype (Bookmarks_.front ()) bookmark)
        {
            return bms->GetID () == bookmark->GetID ();
        });
        if (it != Bookmarks_.end ())
        {
            const int pos = std::distance (Bookmarks_.begin (), it);
            switch (bms->GetStatus ())
            {
            case Bookmark::SDeleted:
                RemoveBookmark (bms->GetID ());
                break;
            case Bookmark::SArchived:
            {
                Bookmark *bm = Bookmarks_ [pos];
                bm->SetIsRead (true);

                emit dataChanged (index (pos), index (pos));

                break;
            }
            default:
            {
                Bookmark *bm = Bookmarks_ [pos];
                bm->SetUrl (bms->GetUrl ());
                bm->SetTitle (bms->GetTitle ());
                bm->SetDescription (bms->GetDescription ());
                bm->SetIsFavorite (bms->IsFavorite ());
                bm->SetIsRead (bms->IsRead ());
                bm->SetAddTime (bms->GetAddTime ());
                bm->SetUpdateTime (bms->GetUpdateTime ());
                bm->SetTags (bms->GetTags ());
                bm->SetImageUrl (bms->GetImageUrl ());
                bm->SetStatus (bms->GetStatus ());

                emit dataChanged (index (pos), index (pos));

                break;
            }
            }

            bmss.takeAt (i)->deleteLater ();
        }
    }

    beginInsertRows (QModelIndex (), rowCount (),
                     rowCount () + bmss.count () - 1);
    Bookmarks_.append (bmss);
    endInsertRows ();
}
Пример #2
0
//---------------------------------------------------------------------------
void __fastcall TLocationProfilesDialog::ProfilesViewKeyDown(TObject * Sender,
  WORD & Key, TShiftState /*Shift*/)
{
  TTreeView * ProfilesView = GetProfilesView(Sender);

  if (!ProfilesView->IsEditing())
  {
    if ((ProfilesView->Selected != NULL) && (Key == VK_DELETE))
    {
      RemoveBookmark(Sender);
      Key = 0;
    }
    else if ((ProfilesView->Selected != NULL) && (Key == VK_F2))
    {
      RenameBookmark(Sender);
      Key = 0;
    }
  }
}
Пример #3
0
//---------------------------------------------------------------------------
void __fastcall TLocationProfilesDialog::RemoveBookmarkButtonClick(TObject * Sender)
{
  RemoveBookmark(Sender);
}