diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/mainwindow.cpp | 16 | ||||
| -rw-r--r-- | src/mainwindow.h | 14 |
2 files changed, 30 insertions, 0 deletions
diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 2443ead..4c37a83 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -770,6 +770,17 @@ void MainWindow::buildUi() m_queryEdit->installEventFilter(this); m_queryCompleter = new QueryCompleter(m_queryEdit, m_config, this); + // The address book, read once for the whole session. A vdirsyncer + // directory is a handful of small vCards, so the parse is paid at startup + // rather than per keystroke, and a restart is the refresh route: watching + // the directory would be a live-index feature nobody asked for. An empty + // contactsDir() is the feature switched off, so the loader is not even + // called, and no warning is raised for a machine with no address book. + if (!m_config.contactsDir().isEmpty()) { + m_contacts = ContactStore::loadDirectory(m_config.contactsDir()); + m_queryCompleter->setContacts(m_contacts); + } + m_markReadTimer = new QTimer(this); // Named so a test can observe whether it is armed without the window // having to expose the timer or the decision that armed it. @@ -1254,6 +1265,11 @@ void MainWindow::openComposer(const ComposeContext &context) composer->setAttribute(Qt::WA_DeleteOnClose); m_composers.append(QPointer<ComposeWindow>(composer)); + // The same list the query bar offers, from the once-per-session load. The + // composer builds its own model over it, so a recipient field completes on + // the address book the query bar completes from. + composer->setContacts(m_contacts); + // Compaction, and ONLY compaction. The QPointer above is what keeps // composersBlockingQuit() safe against a destroyed window, since it nulls // on destruction; this drops the entry so the list does not accumulate diff --git a/src/mainwindow.h b/src/mainwindow.h index c3395c9..4fb19e4 100644 --- a/src/mainwindow.h +++ b/src/mainwindow.h @@ -48,6 +48,10 @@ // asserted through it without reaching into the delegate. #include "businesssenders.h" +// Held by value, like the business-senders list above: the parsed contact list +// is a member, so its size must be known here. +#include "contactstore.h" + class QAction; class QLineEdit; class QMenu; @@ -1836,6 +1840,16 @@ private: /// completer does not yet offer, without a round trip. QStringList m_knownTags; + /// The address book, loaded ONCE when the window is built and handed to + /// both consumers: the query-bar completer and every composer. + /// + /// Held here so the list is read from disk a single time per session. A + /// vdirsyncer directory can change while the application runs, but a + /// QFileSystemWatcher would be speculative: a restart picks up the new + /// file, and the store is 117 files of two fields, not a live index. + /// Empty when contactsDir() is unset, which is the feature being off. + QList<Contact> m_contacts; + quint64 m_generation = 0; /// True once the running query has reported its total, so the model holds |
