BiblioteQ

biblioteq.h
1 #ifndef _BIBLIOTEQ_H_
2 #define _BIBLIOTEQ_H_
3
4 #define BIBLIOTEQ_GUEST_ACCOUNT "xbook_guest"
5 #define BIBLIOTEQ_VERSION "2021.10.30"
6
7 #include "biblioteq_book.h"
8 #include "biblioteq_callnum_table_item.h"
9 #include "biblioteq_cd.h"
10 #include "biblioteq_dbenumerations.h"
11 #include "biblioteq_dvd.h"
12 #include "biblioteq_generic_thread.h"
13 #include "biblioteq_grey_literature.h"
14 #include "biblioteq_import.h"
15 #include "biblioteq_magazine.h"
16 #include "biblioteq_misc_functions.h"
17 #include "biblioteq_myqstring.h"
18 #include "biblioteq_numeric_table_item.h"
19 #include "biblioteq_photographcollection.h"
20 #include "biblioteq_videogame.h"
21 #include "ui_biblioteq_adminsetup.h"
22 #include "ui_biblioteq_allinfo.h"
23 #include "ui_biblioteq_branch_s.h"
24 #include "ui_biblioteq_customquery.h"
25 #include "ui_biblioteq_errordiag.h"
26 #include "ui_biblioteq_history.h"
27 #include "ui_biblioteq_mainwindow.h"
28 #include "ui_biblioteq_members_browser.h"
29 #include "ui_biblioteq_password.h"
30 #include "ui_biblioteq_userinfo.h"
31
32 #include <QMessageBox>
33
34 class biblioteq_files;
35 class biblioteq_otheroptions;
36
37 class userinfo_diag_class: public QDialog
38 {
39 Q_OBJECT
40
41 public:
42 userinfo_diag_class(QMainWindow *parent):QDialog(parent)
43 {
44 m_userinfo.setupUi(this);
45 }
46
47 ~userinfo_diag_class()
48 {
49 }
50
51 QHash<QString, QString> m_memberProperties;
52 Ui_UserInfo m_userinfo;
53
54 bool haveMemberChanges(QString &str)
55 {
56 QStringList list;
57
58 if(m_memberProperties.value("membersince") !=
59 m_userinfo.membersince->date().toString(Qt::ISODate))
60 list << "membersince";
61
62 if(m_memberProperties.value("dob") !=
63 m_userinfo.dob->date().toString(Qt::ISODate))
64 list << "dob";
65
66 if(m_memberProperties.value("sex") != m_userinfo.sex->currentText())
67 list << "sex";
68
69 if(m_memberProperties.value("first_name") != m_userinfo.firstName->text().
70 trimmed())
71 list << "first_name";
72
73 if(m_memberProperties.value("middle_init") != m_userinfo.middle->text().
74 trimmed())
75 list << "middle_init";
76
77 if(m_memberProperties.value("last_name") != m_userinfo.lastName->text().
78 trimmed())
79 list << "last_name";
80
81 if(m_memberProperties.value("telephone_num") !=
82 m_userinfo.telephoneNumber->text())
83 list << "telephone_num";
84
85 if(m_memberProperties.value("street") !=
86 m_userinfo.street->text().trimmed())
87 list << "street";
88
89 if(m_memberProperties.value("city") != m_userinfo.city->text().trimmed())
90 list << "city";
91
92 if(m_memberProperties.value("state_abbr") !=
93 m_userinfo.state->currentText())
94 list << "state_abbr";
95
96 if(m_memberProperties.value("zip") != m_userinfo.zip->text())
97 list << "zip";
98
99 if(m_memberProperties.value("email") != m_userinfo.email->text())
100 list << "email";
101
102 if(m_memberProperties.value("expiration_date") !=
103 m_userinfo.expirationdate->date().toString(Qt::ISODate))
104 list << "expiration_date";
105
106 if(m_memberProperties.value("overdue_fees") !=
107 m_userinfo.overduefees->text())
108 list << "overdue_fees";
109
110 if(m_memberProperties.value("comments") !=
111 m_userinfo.comments->toPlainText().
112 trimmed())
113 list << "comments";
114
115 if(m_memberProperties.value("general_registration_number") !=
116 m_userinfo.generalregistrationnumber->text().trimmed())
117 list << "general_registration_number";
118
119 if(m_memberProperties.value("memberclass") !=
120 m_userinfo.memberclass->text().trimmed())
121 list << "memberclass";
122
123 if(m_memberProperties.value("maximum_reserved_books") !=
124 m_userinfo.maximum_reserved_books->text())
125 list << "maximum_reserved_books";
126
127 for(int i = 0; i < list.size(); i++)
128 str += list.at(i) + ", ";
129
130 if(!str.isEmpty())
131 {
132 str.prepend("(");
133 str = str.mid(0, str.length() - 2);
134 str.append(")");
135 }
136
137 return !str.isEmpty();
138 }
139
140 private:
141 void changeEvent(QEvent *event)
142 {
143 if(event)
144 switch(event->type())
145 {
146 case QEvent::LanguageChange:
147 {
148 m_userinfo.retranslateUi(this);
149 break;
150 }
151 default:
152 break;
153 }
154
155 QDialog::changeEvent(event);
156 }
157
158 private slots:
159 void done(int r)
160 {
161 QString str("");
162
163 if(haveMemberChanges(str))
164 if(QMessageBox::
165 question(this, tr("BiblioteQ: Question"),
166 tr("Your changes have not been saved. Continue "
167 "closing?\n%1").arg(str),
168 QMessageBox::Yes | QMessageBox::No,
169 QMessageBox::No) == QMessageBox::No)
170 {
171 QApplication::processEvents();
172 return;
173 }
174
175 QDialog::done(r);
176 }
177 };
178
179 class biblioteq: public QMainWindow
180 {
181 Q_OBJECT
182
183 public:
184 static QString s_locale;
185 static QTranslator *s_appTranslator;
186 static const int CUSTOM_QUERY = 0;
187 static const int EDITABLE = 0;
188 static const int MAXIMUM_DEVICES_CONFIRMATION = 5;
189 static const int NEW_PAGE = 0;
190 static const int NEXT_PAGE = 1;
191 static const int POPULATE_ALL = 1;
192 static const int POPULATE_SEARCH = 2;
193 static const int POPULATE_SEARCH_BASIC = 3;
194 static const int PREVIOUS_PAGE = 2;
195 static const int VIEW_ONLY = 1;
196 biblioteq(void);
197 ~biblioteq();
198 QPointer<QMenu> m_configToolMenu;
199 QString m_unaccent;
200 QColor availabilityColor(const QString &itemType) const;
201 QHash<QString, QString> getAmazonHash(void) const;
202 QHash<QString, QString> getOpenLibraryImagesHash(void) const;
203 QHash<QString, QString> getOpenLibraryItemsHash(void) const;
204 QHash<QString, QString> getSRUHash(const QString &name) const;
205 QHash<QString, QString> getZ3950Hash(const QString &name) const;
206 QMainWindow *getMembersBrowser(void) const;
207 QSqlDatabase getDB(void) const;
208 QString getAdminID(void) const;
209 QString getPreferredSRUSite(void) const;
210 QString getPreferredZ3950Site(void) const;
211 QString getRoles(void) const;
212 QString getTypeFilterString(void) const;
213 QString publicationDateFormat(const QString &itemType) const;
214 QString unaccent(void) const;
215 QStringList getSRUNames(void) const;
216 QStringList getZ3950Names(void) const;
217 QVariant setting(const QString &name) const;
218 QVector<QString> getBBColumnIndexes(void) const;
219 Ui_mainWindow getUI(void) const;
220 Ui_membersBrowser getBB(void) const;
221 bool availabilityColors(void) const;
222 bool isGuest(void) const;
223 bool isPatron(void) const;
224 int pageLimit(void) const;
225 int populateTable(const QSqlQuery &query,
226 const QString &typefilter,
227 const int pagingType,
228 const int searchType);
229 int populateTable(const int search_type_arg,
230 const QString &typefilter,
231 const QString &searchstrArg,
232 const int pagingType = NEW_PAGE);
233 static QString homePath(void);
234 static void quit(const char *msg, const char *file, const int line);
235 static void quit(void);
236 void addError(const QString &type,
237 const QString &summary,
238 const QString &error = "",
239 const char *file = "",
240 const int line = 0);
241 void bookSearch(const QString &field, const QString &value);
242 void cdSearch(const QString &field, const QString &value);
243 void dvdSearch(const QString &field, const QString &value);
244 void greyLiteratureSearch(const QString &field, const QString &value);
245 void journSearch(const QString &field, const QString &value);
246 void magSearch(const QString &field, const QString &value);
247 void pcSearch(const QString &field, const QString &value);
248 void removeBook(biblioteq_book *book);
249 void removeCD(biblioteq_cd *cd);
250 void removeDVD(biblioteq_dvd *dvd);
251 void removeGreyLiterature(biblioteq_grey_literature *gl);
252 void removeJournal(biblioteq_journal *journal);
253 void removeMagazine(biblioteq_magazine *magazine);
254 void removePhotographCollection(biblioteq_photographcollection *pc);
255 void removeVideoGame(biblioteq_videogame *videogame);
256 void replaceBook(const QString &id, biblioteq_book *book);
257 void replaceCD(const QString &id, biblioteq_cd *cd);
258 void replaceDVD(const QString &id, biblioteq_dvd *dvd);
259 void replaceGreyLiterature(const QString &id, biblioteq_grey_literature *gl);
260 void replaceJournal(const QString &id, biblioteq_journal *journal);
261 void replaceMagazine(const QString &id, biblioteq_magazine *magazine);
262 void replacePhotographCollection(const QString &id,
263 biblioteq_photographcollection *photograph);
264 void replaceVideoGame(const QString &id, biblioteq_videogame *videogame);
265 void setGlobalFonts(const QFont &font);
266 void setSummaryImages(const QImage &back, const QImage &front);
267 void showMain(void);
268 void updateItemWindows(void);
269 void updateMembersBrowser(const QString &memberid);
270 void updateMembersBrowser(void);
271 void updateReservationHistoryBrowser(const QString &memberid,
272 const QString &ioid,
273 const QString &copyid,
274 const QString &itemType,
275 const QString &returnedDate);
276 void updateRows(const QString &oid, const int row, const QString &it);
277 void updateSceneItem(const QString &oid,
278 const QString &type,
279 const QImage &image);
280 void vgSearch(const QString &field, const QString &value);
281
282 public slots:
283 void slotDisplaySummary(void);
284 void slotResizeColumns(void);
285
286 private:
287 enum AdminSetupColumns
288 {
289 ADMINISTRATOR = 1,
290 CIRCULATION = 2,
291 ID = 0,
292 LIBRARIAN = 3,
293 MEMBERSHIP = 4
294 };
295
296 enum ErrorDialogColumns
297 {
298 EVENT_TIME = 0,
299 EVENT_TYPE = 1,
300 FILE = 4,
301 FULL_DESCRIPTION = 3,
302 LINE_NUMBER = 5,
303 SUMMARY = 2
304 };
305
306 enum HistoryColumns
307 {
308 BARCODE = 5,
309 DUE_DATE = 8,
310 FIRST_NAME = 1,
311 ID_NUMBER = 4,
312 LAST_NAME = 2,
313 LENDER = 10,
314 MEMBER_ID = 0,
315 MYOID = 11,
316 RESERVATION_DATE = 7,
317 RETURNED_DATE = 9,
318 TITLE = 3,
319 TYPE = 6
320 };
321
322 QActionGroup *m_menuCategoryActionGroup;
323 QDialog *m_branch_diag;
324 QDialog *m_pass_diag;
325 QHash<QString, QString> m_amazonImages;
326 QHash<QString, QString> m_openLibraryImages;
327 QHash<QString, QString> m_openLibraryItems;
328 QHash<QString, QString> m_selectedBranch;
329 QLabel *m_connected_bar_label;
330 QLabel *m_status_bar_label;
331 QMainWindow *m_admin_diag;
332 QMainWindow *m_all_diag;
333 QMainWindow *m_customquery_diag;
334 QMainWindow *m_error_diag;
335 QMainWindow *m_history_diag;
336 QMainWindow *m_members_diag;
337 QMap<QString, QHash<QString, QString> > m_branches;
338 QMap<QString, QHash<QString, QString> > m_sruMaps;
339 QMap<QString, QHash<QString, QString> > m_z3950Maps;
340 QPointer<QMenu> m_menu;
341 QPointer<biblioteq_dbenumerations> db_enumerations;
342 QSqlDatabase m_db;
343 QSqlQuery m_searchQuery;
344 QString m_engUserinfoTitle;
345 QString m_lastCategory;
346 QString m_lastSearchStr;
347 QString m_previousTypeFilter;
348 QString m_roles;
349 QStringList m_deletedAdmins;
350 QTextBrowser *m_printPreview;
351 QToolButton *m_error_bar_label;
352 QVector<QString> m_abColumnHeaderIndexes;
353 QVector<QString> m_bbColumnHeaderIndexes;
354 QVector<QString> m_historyColumnHeaderIndexes;
355 Ui_adminBrowser ab;
356 Ui_allDialog al;
357 Ui_branchSelect br;
358 Ui_customquery cq;
359 Ui_errordialog er;
360 Ui_historyDialog history;
361 Ui_mainWindow ui;
362 Ui_membersBrowser bb;
363 Ui_passSelect pass;
364 biblioteq_files *m_files;
365 biblioteq_import *m_import;
366 biblioteq_otheroptions *m_otheroptions;
367 bool m_allSearchShown;
368 int m_lastSearchType;
369 qint64 m_pages;
370 qint64 m_queryOffset;
371 quint64 m_idCt;
372 userinfo_diag_class *userinfo_diag;
373 QString dbUserName(void) const;
374 QString reservationHistoryHtml(void) const;
375 QString viewHtml(void) const;
376 QWidget *widgetForAction(QAction *action) const;
377 bool emptyContainers(void);
378 void addConfigOptions(const QString &typefilter);
379 void adminSetup(void);
380 void changeEvent(QEvent *event);
381 void cleanup(void);
382 void closeEvent(QCloseEvent *event);
383 void createConfigToolMenu(void);
384 void createSqliteMenuActions(void);
385 void deleteItem(const QString &oid, const QString &itemType);
386 void exportAsCSV(QTableWidget *table, const QString &title);
387 void initialUpdate(void);
388 void prepareContextMenus(void);
389 void prepareFilter(void);
390 void preparePhotographsPerPageMenu(void);
391 void prepareRequestToolButton(const QString &typefilter);
392 void prepareReservationHistoryMenu(void);
393 void readConfig(void);
394 void readGlobalSetup(void);
395 void resetAdminBrowser(void);
396 void resetMembersBrowser(void);
397
398 private slots:
399 void slotAbout(void);
400 void slotAddAdmin(void);
401 void slotAddBorrower(void);
402 void slotAdminCheckBoxClicked(int state);
403 void slotAdminContextMenu(const QPoint &point);
404 void slotAllGo(void);
405 void slotAllowAnyUserEmail(bool state);
406 void slotAutoPopOnFilter(QAction *action);
407 void slotBookSearch(void);
408 void slotBranchChanged(void);
409 void slotCDSearch(void);
410 void slotCancelAddUser(void);
411 void slotChangeView(bool checked);
412 void slotCheckout(void);
413 void slotClearSqliteMenu(bool state);
414 void slotCloseCustomQueryDialog(void);
415 void slotCloseMembersBrowser(void);
416 void slotClosePasswordDialog(void);
417 void slotConnectDB(void);
418 void slotContextMenu(const QPoint &point);
419 void slotCopyError(void);
420 void slotDVDSearch(void);
421 void slotDelete(void);
422 void slotDeleteAdmin(void);
423 void slotDisconnect(void);
424 void slotDisplayNewSqliteDialog(void);
425 void slotDuplicate(void);
426 void slotExecuteCustomQuery(void);
427 void slotExit(void);
428 void slotExportAsCSV(void);
429 void slotExportMembersAsCSV(void);
430 void slotGeneralSearchPublicationDateEnabled(bool state);
431 void slotGrantPrivileges(void);
432 void slotGraphicsSceneEnterKeyPressed(void);
433 void slotGreyLiteratureSearch(void);
434 void slotInsertBook(void);
435 void slotInsertCD(void);
436 void slotInsertDVD(void);
437 void slotInsertGreyLiterature(void);
438 void slotInsertJourn(void);
439 void slotInsertMag(void);
440 void slotInsertPhotograph(void);
441 void slotInsertVideoGame(void);
442 void slotItemChanged(QTableWidgetItem *item);
443 void slotJournSearch(void);
444 void slotLanguageChanged(void);
445 void slotLastWindowClosed(void);
446 void slotListOverdueItems(void);
447 void slotListReservedItems(void);
448 void slotMagSearch(void);
449 void slotMainTableEnterKeyPressed(void);
450 void slotMainWindowCanvasBackgroundColorChanged(const QColor &color);
451 void slotMembersContextMenu(const QPoint &point);
452 void slotModify(void);
453 void slotModifyBorrower(void);
454 void slotNextPage(void);
455 void slotOpenOnlineDocumentation(void);
456 void slotOpenPDFFiles(void);
457 void slotOtherOptionsSaved(void);
458 void slotPageClicked(const QString &link);
459 void slotPhotographSearch(void);
460 void slotPhotographsPerPageChanged(void);
461 void slotPopulateMembersBrowser(void);
462 void slotPreviewCanvasBackgroundColor(const QColor &color);
463 void slotPreviousPage(void);
464 void slotPrintPreview(QPrinter *printer);
465 void slotPrintReservationHistory(void);
466 void slotPrintReservationHistoryPreview(void);
467 void slotPrintReserved(void);
468 void slotPrintView(void);
469 void slotPrintViewPreview(void);
470 void slotRefresh(void);
471 void slotRefreshAdminList(void);
472 void slotRefreshCustomQuery(void);
473 void slotReloadBiblioteqConf(void);
474 void slotRemoveMember(void);
475 void slotRequest(void);
476 void slotReserveCopy(void);
477 void slotReset(void);
478 void slotResetAllSearch(void);
479 void slotResetErrorLog(void);
480 void slotResetLoginDialog(void);
481 void slotResizeColumnsAfterSort(void);
482 void slotRoleChanged(int index);
483 void slotSaveAdministrators(void);
484 void slotSaveConfig(void);
485 void slotSaveDnt(bool state);
486 void slotSavePassword(void);
487 void slotSaveUser(void);
488 void slotSceneSelectionChanged(void);
489 void slotSearch(void);
490 void slotSearchBasic(void);
491 void slotSectionResized(int logicalIndex, int oldSize, int newSize);
492 void slotSelectDatabaseFile(void);
493 void slotSetColumns(void);
494 void slotSetFonts(void);
495 void slotShowAdminDialog(void);
496 void slotShowChangePassword(void);
497 void slotShowConnectionDB(void);
498 void slotShowCustomQuery(void);
499 void slotShowDbEnumerations(void);
500 void slotShowErrorDialog(void);
501 void slotShowFiles(void);
502 void slotShowGrid(void);
503 void slotShowHistory(void);
504 void slotShowImport(void);
505 void slotShowMembersBrowser(void);
506 void slotShowMenu(void);
507 void slotShowNext(void);
508 void slotShowOtherOptions(void);
509 void slotShowPassword(bool state);
510 void slotShowPrev(void);
511 void slotSqliteFileSelected(bool state);
512 void slotUpdateIndicesAfterSort(int column);
513 void slotUpgradeSqliteScheme(void);
514 void slotVacuum(void);
515 void slotVideoGameSearch(void);
516 void slotViewDetails(void);
517 void slotViewFullOrNormalScreen(void);
518
519 signals:
520 void fontChanged(const QFont &font);
521 };
522
523 #endif
biblioteq_dvd
Definition: biblioteq_dvd.h:7
biblioteq_otheroptions
Definition: biblioteq_otheroptions.h:8
biblioteq_cd
Definition: biblioteq_cd.h:8
biblioteq_journal
Definition: biblioteq_magazine.h:104
userinfo_diag_class
Definition: biblioteq.h:37
biblioteq_book
Definition: biblioteq_book.h:15
biblioteq_photographcollection
Definition: biblioteq_photographcollection.h:10
biblioteq_import
Definition: biblioteq_import.h:9
biblioteq_videogame
Definition: biblioteq_videogame.h:7
biblioteq_magazine
Definition: biblioteq_magazine.h:13
biblioteq_files
Definition: biblioteq_files.h:8
biblioteq_grey_literature
Definition: biblioteq_grey_literature.h:7
biblioteq
Definition: biblioteq.h:179