Commit Graph

32 Commits

Author SHA1 Message Date
Charles Kerr f59118d1fe
feat: add torrent-get 'primary-mime-type' to RPC. (#1464)
* feat: add torrent-get 'primary-mime-type' to RPC.

This is a cheap way for RPC clients to know what type of content is in a
torrent. This info can be used to display the torrent, e.g. by using an
icon that corresponds to the mime type.

* use size_t for content byte count

Co-authored-by: Mike Gelfand <mikedld@users.noreply.github.com>

* explicit boolean expressions

Co-authored-by: Mike Gelfand <mikedld@users.noreply.github.com>

* use uint64_t for content byte counts

Co-authored-by: Mike Gelfand <mikedld@users.noreply.github.com>

* avoid unnecessary logic branches

Co-authored-by: Mike Gelfand <mikedld@users.noreply.github.com>

* explicit cast

Co-authored-by: Mike Gelfand <mikedld@users.noreply.github.com>

* refactor: add an autogenerated mime-type.h header

* chore: maybe fix the win32 FTBFS

* chore: add mime-types.[ch] to xcode

* Squashed commit of the following:

commit 4c7153fa48
Author: Mike Gelfand <mikedld@users.noreply.github.com>
Date:   Tue Oct 13 03:15:19 2020 +0300

    Remove autotools-based build system (#1465)

    * Support .git files (e.g. for worktrees, submodules)
    * Fix symlinks in source tarball, switch to TXZ, adjust non-release name
    * Remove autotools stuff

Co-authored-by: Mike Gelfand <mikedld@users.noreply.github.com>
2020-10-13 10:33:56 -05:00
Charles Kerr 542feef77d
refactor: make torrents' mime icons lazy-loaded. (#1433)
* refactor: make torrents' mime icons lazy-loaded.

Another "small wins" patch, this time on CPU: icon loading is expensive,
so calculating them for every torrent all at once on startup isn't the
smartest way to do it.
2020-09-08 11:51:33 -05:00
Charles Kerr b156f55dca
refactor: use a vector for FavIcon cache keys (#1432)
* refactor: use a vector for FavIcon cache keys

Third of three PRs focused on small memory wins in transmission-qt.
This one saves 1-2 M off RES in my 15K torrent testbed. Not a major
improvement, but nice enough.

Previously we held the torrent's tracker keys in an unordered_set.
That container type is overkill for this field: the list is usually
short and almost never changes, so we don't need fast insertion time.
We can keep the same log N lookup by using a sorted vector and avoid
the excess container size & memory allocations of an unordered_set.
2020-09-08 08:58:14 -05:00
Charles Kerr b3c3168f16
refactor: intern repeated strings e.g. downloadDir (#1430)
* refactor: intern repeated strings e.g. downloadDir

Add an app-wide interned QString cache for commonly-repeated
strings. Currently used for download_dir, announce_url, comment,
creator, error_string.
2020-09-07 22:52:29 -05:00
Charles Kerr 9f7c865454
refactor: don't store torrent hashes in QStrings (#1428)
* refactor: keep torrent hash in std::array<char,20>

This replaces the hashString QString allocation with a compile-time
array that's included in sizeof the Torrent struct that owns it.
2020-09-07 16:19:10 -05:00
Charles Kerr 0bd915c34c fixup! refactor: speed up FaviconCache::add() again. (#1402) 2020-09-02 19:28:36 -05:00
Charles Kerr 68920f5fa6
refactor: remove exit-time destructors from transmission-qt (#1395)
* refactor: remove exit-time destructors from transmission-qt
2020-08-15 10:42:51 -05:00
Charles Kerr 677dc73eac
refactor: use GTest for running tests (#1383)
* refactor: use google-test on libtransmission tests
2020-08-11 13:11:55 -05:00
Charles Kerr 00be8d00d7
refactor: make variant_headers reusable to qt app. (#1369)
* refactor: make variant_headers reusable to qt app.

Torrent.cc's `change()` template methods are generically useful to deal
with tr_variant wrangling, but previously were only used in Torrent.cc.
This PR moves them into a new API `VariantHelpers.h` for use by Prefs,
Session, TorrentModel, etc.
2020-07-26 23:30:58 -05:00
Charles Kerr 7e1da2d8fe
refactor: only update favicon when tracker changes (#1336)
* refactor: make Favicon's Key a semi-opaque type and update a Torrent's icon only when the announce_url changes.
2020-06-24 13:28:54 -05:00
Charles Kerr f37253a3ab
feat: Torrent::update() returns a bitset of changed properties (#1334)
* refactor: Torrent::update() returns a delta bitset

Setting up for followup PRs where, instead of doing expensive work every
time there is a change, we can be more fine-grained and do the work only
if the relevant Torrent properties changed.

* chore: make uncrustify happy

* chore: fix #includes
2020-06-23 16:11:16 -05:00
Charles Kerr 8fcfc1e4ae
feat: add 'edit-date' support to qt client (#1322)
edit-date got added to the backend in 3.00, but I never finished adding
it properly to the Qt client. This PR rectifies that. When a torrent is
edited, the Application and DetailsDialogs will re-query the backend to
update the torrent properties that are needed.
2020-06-18 15:34:11 -05:00
Charles Kerr 51573a3c1e
chore: clang-tidy cleanups (#1287)
* chore: fix syntax error in clang-tidy config file
2020-06-05 14:02:11 -05:00
Charles Kerr 070a7f2ffc
refactor: use snake_case field naming in qt client (#1262)
* refactor: use snake_case field naming in qt client

* fix: some missed symbols

* chore: make uncrustify happy

* fixup! refactor: use snake_case field naming in qt client
2020-05-27 16:53:12 -05:00
Charles Kerr 6aa559f12f
refactor: remove QVariants from torrent (#1234)
* chore: remove qvariants from torrent class

* chore: remove unused Q_DECLARE macro calls

* refactor: remove unused includes from Torrent.h

* chore: make clang-tidy and linter happy

* refactor: rename 'setValue()' to 'change()'

* refactor: make tr_variant function paramters const

* chore: remove devel scaffolding

* refactor: rename peer_limit_ to peerLimit_

* refactor: do not use bitwise logic on booleans
2020-05-19 18:42:17 -05:00
Charles Kerr fa6df52d58
chore: remove unused methods (#1207)
* chore: remove unused methods in qt client

* chore: remove unused libtransmission methods

* chore: remove unused gtk methods

* chore: remove more unused libtransmission methods

* chore: remove more unused code found by @reardonia
2020-05-11 17:20:46 -05:00
Mike Gelfand 20119f006c
Fixup recent Qt client changes (#1107)
* Add EDIT_DATE torrent property declaration (Qt client)

Switch to static assertion to help avoid similar issues in the future.

* Only declare std::hash<QString> for Qt < 5.14

* Pass main window as context when connecting lambdas to torrents model signals (Qt client)

This helps to automatically disconnect from signals on main window
destruction. If not done, use after free is possible since main window is
destroyed before torrents model.

Fixes: #1106
2020-01-14 23:28:34 +02:00
Charles Kerr 44fc571a67
feat: add editDate to RPC (#1056)
* feat: add tr_stat.infoDate to note tr_info changes

The last time during this session that any tr_info field changed
(e.g. trackers/filenames edited or magnet torrent got metadata).
RPC clients can monitor this to know when to reload fields which
don't usually change.
2019-11-12 17:13:42 -06:00
Charles Kerr c62cb35fd4
qt client speedups
* faster updating of trackers combobox.
* generate trackerDisplayNames just once per torrent
* refactor: cache torrent delegate's warning emblem
* refactor: change mainwin refresh debounce to 200ms
* refactor: do not store trackers, hosts in QVariant
* refactor: don't use `virtual` when it's not needed
* refactor: faster counting torrents-matching-filter
* refactor: faster tracker handling in filterbar
* refactor: improve json parser's prealloc heuristic
* refactor: make Torrent::hasError() faster
* refactor: remove redundant speed stats collection
* refactor: remove unnecessary tor->isQueued() calls
* refactor: use unordered containers where possible
* scale favicons only once, when adding to the cache
2019-11-11 19:37:05 -06:00
Charles Kerr 96f76999aa
feat: add "table" format in torrent-get RPC (#1049)
* feat: add optional "format" arg to torrent-get RPC

If the "format" request was "objects" (default), "torrents" will be an
array of objects, each of which contains the key/value pairs matching
the request's "fields" arg. This is unchanged from previous versions.

If the format was "table", then "torrents" will be an array of arrays.
The first row holds the keys and each remaining row holds a torrent's
values for those keys. This format is more efficient in terms of JSON
generation and JSON parsing.
2019-11-09 17:02:23 -06:00
Charles Kerr d857a5821a
refractor: simplify torrent model signal emissions (#1044)
refractor: simplify torrent model signal emissions

The Torrent->Application signal connections make up for about 5% of the
app's memory use. Move this to the TorrentModel so that there are only a
handful of signal connections.

Moving signals to TorrentModel means batch change signals can be emitted
instead of per-change-per-torrent emissions and can be handled that way.
2019-11-09 08:44:40 -06:00
Charles Kerr 973afda057
refactor: keep torrent's time properties as time_t (#1042)
* refactor: keep torrent's time properties as time_t

Comparing QDateTimes is expensive. Keep the torrents' time properties in
the time_t form that we got them from RPG in; difftime() is cheaper.
2019-11-06 17:31:41 -06:00
Charles Kerr aa9b752cd9
refactor: don't load the same stock more than once (#1041)
* refactor: don't load the same stock more than once

Some actions share an icon -- for example, "start all", "start now", and
"start" each use "media-playback-start". When this happens, get the icon
once and cache it to avoid hitting the disk more often than necessary.

In addition, the statusbar's network transfer icon was being reloaded in
a periodic upkeep timer, reloading with QIcon::fromTheme each time. Only
give icons are needed, so load them once and cache them.

* refactor: better lookup of torrent mime-type icons

filename-to-mime-type and mime-type-to-icon lookups are both expensive,
so do a better job of detecting top-level folders and caching the icons
based on file suffixes.

This also lets find a good mime icon even if the torrent doesn't have
its 'files' property populated yet from RPC.
2019-11-06 15:09:04 -06:00
Mike Gelfand eef4799388 Update Uncrustify config to 0.69 2019-07-15 02:30:41 +03:00
Mike Gelfand a762c770f2 Make conditional expressions explicitly boolean 2017-04-30 19:26:01 +03:00
Mike Gelfand 6da99c05e2 Use nullptr consistencty instead of 0 and NULL (Qt client) 2017-04-30 19:26:01 +03:00
Mike Gelfand dadffa2c0f Align type qualifiers to the right (code style)
This way all the qualifiers (`const`, `volatile`, `mutable`) are grouped
together, e.g. `T const* const x` vs. `const T* const x`. Also helps reading
types right-to-left, e.g. "constant pointer to constant T" vs. "constant
pointer to T which is constant".
2017-04-20 19:53:20 +03:00
Mike Gelfand d7930984ef Adjust uncrustify config, reformat all but Mac client
There're places where manual intervention is still required as uncrustify
is not ideal (unfortunately), but at least one may rely on it to do the
right thing most of the time (e.g. when sending in a patch).

The style itself is quite different from what we had before but making it
uniform across all the codebase is the key. I also hope that it'll make the
code more readable (YMMV) and less sensitive to further changes.
2017-04-20 10:01:22 +03:00
Mike Gelfand 2248d3670f Get rid of $Id$ SVN keywords in source files 2016-09-02 23:10:15 +03:00
Jordan Lee 1b67e9b266 in Torrent::setDouble(), don't compare doubles directly as a bool 2015-12-06 18:02:37 +00:00
Mike Gelfand 5120fc0f2c Unify/prettify Qt client headers style 2015-06-12 22:12:12 +00:00
Mike Gelfand 07912d230b Use PascalCase for Qt client filenames
Split FileTree.{h,cc} and FilterBar.{h,cc} files so that each class
is in its own file.

This breaks translations (some classes got renamed => context changed),
to be fixed by next commit (along with Tx sync).
2015-06-10 21:27:11 +00:00
Renamed from qt/torrent.cc (Browse further)