Skip to content

Commit

Permalink
Merge branch 'devel/remove-bookmarks'
Browse files Browse the repository at this point in the history
vslavik committed Jan 29, 2024
2 parents 24f457a + cd9df92 commit 702bc22
Showing 12 changed files with 7 additions and 252 deletions.
8 changes: 0 additions & 8 deletions Poedit.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
@@ -130,10 +130,8 @@
B28F1D0016F629D30018AF7E /* export_html.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B28F1CE216F629D30018AF7E /* export_html.cpp */; };
B290F9E32166543800741842 /* DownvoteTemplate@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = B290F9E12166543800741842 /* DownvoteTemplate@2x.png */; };
B290F9E42166543800741842 /* DownvoteTemplate.png in Resources */ = {isa = PBXBuildFile; fileRef = B290F9E22166543800741842 /* DownvoteTemplate.png */; };
B292667321664C9500DC536C /* ItemBookmarkTemplate.png in Resources */ = {isa = PBXBuildFile; fileRef = B292666F21664C9500DC536C /* ItemBookmarkTemplate.png */; };
B292667421664C9500DC536C /* ItemCommentTemplate.png in Resources */ = {isa = PBXBuildFile; fileRef = B292667021664C9500DC536C /* ItemCommentTemplate.png */; };
B292667521664C9500DC536C /* ItemCommentTemplate@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = B292667121664C9500DC536C /* ItemCommentTemplate@2x.png */; };
B292667621664C9500DC536C /* ItemBookmarkTemplate@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = B292667221664C9500DC536C /* ItemBookmarkTemplate@2x.png */; };
B295C6021E2A81C200CD71CD /* extractor_legacy.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B295C5FE1E2A81C200CD71CD /* extractor_legacy.cpp */; };
B295C6031E2A81C200CD71CD /* extractor.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B295C6001E2A81C200CD71CD /* extractor.cpp */; };
B29A1C331A9F8C0A00BC3006 /* poedit-sync.png in Resources */ = {isa = PBXBuildFile; fileRef = B29A1C311A9F8C0A00BC3006 /* poedit-sync.png */; };
@@ -493,10 +491,8 @@
B28F1CE416F629D30018AF7E /* pl_evaluate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = pl_evaluate.h; path = pluralforms/pl_evaluate.h; sourceTree = "<group>"; };
B290F9E12166543800741842 /* DownvoteTemplate@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "DownvoteTemplate@2x.png"; sourceTree = "<group>"; };
B290F9E22166543800741842 /* DownvoteTemplate.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = DownvoteTemplate.png; sourceTree = "<group>"; };
B292666F21664C9500DC536C /* ItemBookmarkTemplate.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = ItemBookmarkTemplate.png; sourceTree = "<group>"; };
B292667021664C9500DC536C /* ItemCommentTemplate.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = ItemCommentTemplate.png; sourceTree = "<group>"; };
B292667121664C9500DC536C /* ItemCommentTemplate@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "ItemCommentTemplate@2x.png"; sourceTree = "<group>"; };
B292667221664C9500DC536C /* ItemBookmarkTemplate@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "ItemBookmarkTemplate@2x.png"; sourceTree = "<group>"; };
B295C5FE1E2A81C200CD71CD /* extractor_legacy.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = extractor_legacy.cpp; sourceTree = "<group>"; };
B295C5FF1E2A81C200CD71CD /* extractor_legacy.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = extractor_legacy.h; sourceTree = "<group>"; };
B295C6001E2A81C200CD71CD /* extractor.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = extractor.cpp; sourceTree = "<group>"; };
@@ -1073,8 +1069,6 @@
B2E836E21709ED2A00F31559 /* poedit-status-cat-mid.png */,
B2E836E31709ED2A00F31559 /* poedit-status-cat-no.png */,
B2E836E41709ED2A00F31559 /* poedit-status-cat-ok.png */,
B292666F21664C9500DC536C /* ItemBookmarkTemplate.png */,
B292667221664C9500DC536C /* ItemBookmarkTemplate@2x.png */,
B292667021664C9500DC536C /* ItemCommentTemplate.png */,
B292667121664C9500DC536C /* ItemCommentTemplate@2x.png */,
B267EAFB1E045959005541E7 /* StatusError.png */,
@@ -1305,7 +1299,6 @@
B290F9E42166543800741842 /* DownvoteTemplate.png in Resources */,
B29AE89017103992008D1F8A /* comment.xrc in Resources */,
B26E2C8F25A245BD008D6DF1 /* CloseButtonTemplate@2x.png in Resources */,
B292667621664C9500DC536C /* ItemBookmarkTemplate@2x.png in Resources */,
B2A012B321BEE4C5008051FD /* SuggestionTMTemplate@2x.png in Resources */,
B20F31D0216654DA005B7037 /* StatusWarningBlack.png in Resources */,
B20F31CC216654D2005B7037 /* StatusErrorBlack@2x.png in Resources */,
@@ -1333,7 +1326,6 @@
B2166F4B19AE4045000A6AA0 /* Prefs-General.png in Resources */,
B209005E19CAD64400D6382E /* SuggestionTMTemplate.png in Resources */,
B2166F4C19AE4045000A6AA0 /* Prefs-General@2x.png in Resources */,
B292667321664C9500DC536C /* ItemBookmarkTemplate.png in Resources */,
B25DB35D1E3E5102006D7228 /* ExtractorsGNUgettext.png in Resources */,
B2166F4D19AE4045000A6AA0 /* Prefs-TM.png in Resources */,
B2166F4E19AE4045000A6AA0 /* Prefs-TM@2x.png in Resources */,
Binary file removed artwork/ItemBookmarkTemplate.png
Binary file not shown.
Binary file removed artwork/ItemBookmarkTemplate@1.5x.png
Binary file not shown.
Binary file removed artwork/ItemBookmarkTemplate@2x.png
Binary file not shown.
1 change: 0 additions & 1 deletion artwork/Makefile.am
Original file line number Diff line number Diff line change
@@ -37,7 +37,6 @@ dist_uiicons_DATA = \
LocalazyLogo.png \
DownvoteTemplate.png \
ExtractorsGNUgettext.png \
ItemBookmarkTemplate.png \
ItemCommentTemplate.png \
SuggestionErrorTemplate.png \
SuggestionPerfectMatch.png \
64 changes: 2 additions & 62 deletions src/catalog.cpp
Original file line number Diff line number Diff line change
@@ -229,23 +229,9 @@ void Catalog::HeaderData::UpdateDict()
SetHeader("X-Poedit-KeywordsList", kw);
}

unsigned i;
bool noBookmarkSet = true;
wxString bk;
for (i = 0; i < BOOKMARK_LAST ; i++)
{
noBookmarkSet = noBookmarkSet && (Bookmarks[i] == NO_BOOKMARK);
bk += wxString() << Bookmarks[i] << _T(',');
}
bk.RemoveLast();
if (noBookmarkSet)
DeleteHeader("X-Poedit-Bookmarks");
else
SetHeader("X-Poedit-Bookmarks", bk);

SetHeaderNotEmpty("X-Poedit-Basepath", BasePath);

i = 0;
unsigned i = 0;
while (true)
{
wxString path;
@@ -379,27 +365,8 @@ void Catalog::HeaderData::ParseDict()
}
}

int i;
for(i = 0; i < BOOKMARK_LAST; i++)
{
Bookmarks[i] = NO_BOOKMARK;
}
wxString bk = GetHeader("X-Poedit-Bookmarks");
if (!bk.empty())
{
wxStringTokenizer tkn(bk, ",");
i=0;
long int val;
while (tkn.HasMoreTokens() && i<BOOKMARK_LAST)
{
tkn.GetNextToken().ToLong(&val);
Bookmarks[i] = (int)val;
i++;
}
}

SearchPaths.clear();
i = 0;
int i = 0;
while (true)
{
wxString path;
@@ -503,12 +470,7 @@ Catalog::HeaderData::Find(const wxString& key) const
Catalog::Catalog(Type type)
{
m_fileType = type;

m_header.BasePath = wxEmptyString;
for(int i = BOOKMARK_0; i < BOOKMARK_LAST; i++)
{
m_header.Bookmarks[i] = -1;
}
}


@@ -589,28 +551,6 @@ int Catalog::FindItemIndexByLine(int lineno)
return last;
}

int Catalog::SetBookmark(int id, Bookmark bookmark)
{
int previous = (bookmark==NO_BOOKMARK)?-1:m_header.Bookmarks[bookmark];
if (previous >= (int)m_items.size())
previous = -1;

// unset previous bookmarks, if any
Bookmark bk = m_items[id]->GetBookmark();
if (bk != NO_BOOKMARK)
m_header.Bookmarks[bk] = -1;
if (previous > -1)
m_items[previous]->SetBookmark(NO_BOOKMARK);

// set new bookmark
m_items[id]->SetBookmark(bookmark);
if (bookmark != NO_BOOKMARK)
m_header.Bookmarks[bookmark] = id;

// return id of previous item for that bookmark
return previous;
}


namespace
{
41 changes: 2 additions & 39 deletions src/catalog.h
Original file line number Diff line number Diff line change
@@ -47,24 +47,6 @@ typedef std::shared_ptr<CatalogItem> CatalogItemPtr;
typedef std::shared_ptr<Catalog> CatalogPtr;


/// The possible bookmarks for a given item
typedef enum
{
NO_BOOKMARK = -1,
BOOKMARK_0,
BOOKMARK_1,
BOOKMARK_2,
BOOKMARK_3,
BOOKMARK_4,
BOOKMARK_5,
BOOKMARK_6,
BOOKMARK_7,
BOOKMARK_8,
BOOKMARK_9,
BOOKMARK_LAST
} Bookmark;


/**
Optional data attached to CatalogItem.
@@ -112,8 +94,8 @@ class CatalogItem
m_isTranslated(false),
m_isModified(false),
m_isPreTranslated(false),
m_lineNum(0),
m_bookmark(NO_BOOKMARK) {}
m_lineNum(0)
{}

CatalogItem(const CatalogItem&) = delete;

@@ -208,11 +190,6 @@ class CatalogItem
wxString GetOldMsgid() const;
bool HasOldMsgid() const { return !m_oldMsgid.empty(); }

/// Returns the bookmark for the item
Bookmark GetBookmark() const {return m_bookmark;}
/// Returns true if the item has a bookmark
bool HasBookmark() const {return (GetBookmark() != NO_BOOKMARK);}


// -------------------------------------------------------------------
// Setters for user-editable values:
@@ -240,8 +217,6 @@ class CatalogItem
void SetModified(bool modified) { m_isModified = modified; }
/// Sets pre-translated translation flag.
void SetPreTranslated(bool pre) { m_isPreTranslated = pre; }
/// Sets the bookmark
void SetBookmark(Bookmark bookmark) {m_bookmark = bookmark;}

/// Sets the comment.
void SetComment(const wxString& c) { m_comment = c; }
@@ -340,7 +315,6 @@ class CatalogItem
wxString m_moreFlags;
wxString m_comment;
int m_lineNum;
Bookmark m_bookmark;

std::shared_ptr<Issue> m_issue;
std::shared_ptr<SideloadedItemData> m_sideloaded;
@@ -431,7 +405,6 @@ class Catalog
Language Lang;

wxArrayString SearchPaths, SearchPathsExcluded, Keywords;
int Bookmarks[BOOKMARK_LAST];
wxString BasePath;

wxString Comment;
@@ -607,16 +580,6 @@ class Catalog
/// Finds catalog index by line number
int FindItemIndexByLine(int lineno);

/// Sets the given item to have the given bookmark and returns the index
/// of the item that previously had this bookmark (or -1)
int SetBookmark(int id, Bookmark bookmark);

/// Returns the index of the item that has the given bookmark or -1
int GetBookmarkIndex(Bookmark bookmark) const
{
return m_header.Bookmarks[bookmark];
}


/// Validates correctness of the translation by running msgfmt
/// Returns number of errors (i.e. 0 if no errors).
19 changes: 0 additions & 19 deletions src/catalog_po.cpp
Original file line number Diff line number Diff line change
@@ -951,23 +951,6 @@ void POCatalog::Load(const wxString& po_file, int flags)

m_sourceLanguage = parser.GetSpecifiedMsgidLanguage(); // may be, and likely will, invalid

// now that the catalog is loaded, update its items with the bookmarks
for (unsigned i = BOOKMARK_0; i < BOOKMARK_LAST; i++)
{
if (m_header.Bookmarks[i] == -1)
continue;

if (m_header.Bookmarks[i] < (int)m_items.size())
{
m_items[m_header.Bookmarks[i]]->SetBookmark(
static_cast<Bookmark>(i));
}
else // invalid bookmark
{
m_header.Bookmarks[i] = -1;
}
}

m_fileCRLF = GetFileCRLFFormat(f);
m_fileWrappingWidth = parser.GetWrappingWidth();
wxLogTrace("poedit", "detect line wrapping: %d", m_fileWrappingWidth);
@@ -1055,8 +1038,6 @@ void POCatalog::Clear()
{
// Catalog base class fields:
m_items.clear();
for (int i = BOOKMARK_0; i < BOOKMARK_LAST; i++)
m_header.Bookmarks[i] = -1;

// PO-specific fields:
m_deletedItems.clear();
Loading

0 comments on commit 702bc22

Please sign in to comment.