File indexing completed on 2024-04-28 05:08:21

0001 /***************************************************************************
0002     Copyright (C) 2003-2009 Robby Stephenson <robby@periapsis.org>
0003  ***************************************************************************/
0004 
0005 /***************************************************************************
0006  *                                                                         *
0007  *   This program is free software; you can redistribute it and/or         *
0008  *   modify it under the terms of the GNU General Public License as        *
0009  *   published by the Free Software Foundation; either version 2 of        *
0010  *   the License or (at your option) version 3 or any later version        *
0011  *   accepted by the membership of KDE e.V. (or its successor approved     *
0012  *   by the membership of KDE e.V.), which shall act as a proxy            *
0013  *   defined in Section 14 of version 3 of the license.                    *
0014  *                                                                         *
0015  *   This program is distributed in the hope that it will be useful,       *
0016  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
0017  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
0018  *   GNU General Public License for more details.                          *
0019  *                                                                         *
0020  *   You should have received a copy of the GNU General Public License     *
0021  *   along with this program.  If not, see <http://www.gnu.org/licenses/>. *
0022  *                                                                         *
0023  ***************************************************************************/
0024 
0025 #ifndef TELLICO_FETCHDIALOG_H
0026 #define TELLICO_FETCHDIALOG_H
0027 
0028 #include "datavectors.h"
0029 
0030 #include <QDialog>
0031 #include <QPointer>
0032 #include <QEvent>
0033 #include <QList>
0034 #include <QHash>
0035 
0036 namespace Tellico {
0037   class EntryView;
0038   namespace Fetch {
0039     class Fetcher;
0040     class FetchResult;
0041   }
0042   namespace GUI {
0043     class ComboBox;
0044     class ListView;
0045   }
0046 }
0047 
0048 namespace barcodeRecognition {
0049   class barcodeRecognitionThread;
0050 }
0051 
0052 class KComboBox;
0053 class KTextEdit;
0054 
0055 class QStatusBar;
0056 class QPushButton;
0057 class QLineEdit;
0058 class QLabel;
0059 class QProgressBar;
0060 class QTimer;
0061 class QCheckBox;
0062 class QTreeWidget;
0063 
0064 namespace Tellico {
0065 
0066 /**
0067  * @author Robby Stephenson
0068  */
0069 class FetchDialog : public QDialog {
0070 Q_OBJECT
0071 
0072 public:
0073   /**
0074    * Constructor
0075    */
0076   FetchDialog(QWidget* parent);
0077   ~FetchDialog();
0078 
0079 public Q_SLOTS:
0080   void slotResetCollection();
0081 
0082 protected:
0083   void closeEvent(QCloseEvent* event) Q_DECL_OVERRIDE;
0084 
0085 private Q_SLOTS:
0086   void slotSearchClicked();
0087   void slotClearClicked();
0088   void slotAddEntry();
0089   void slotMoreClicked();
0090   void slotShowEntry();
0091   void slotMoveProgress();
0092 
0093   void slotStatus(const QString& status);
0094   void slotUpdateStatus();
0095 
0096   // for slot connection, can't use a default value for checkIsbn
0097   void slotFetchDone();
0098   void slotResultFound(Tellico::Fetch::FetchResult* result);
0099   void slotKeyChanged(int);
0100   void slotSourceChanged(const QString& source);
0101   void slotMultipleISBN(bool toggle);
0102   void slotEditMultipleISBN();
0103   void slotInit();
0104   void slotLoadISBNList();
0105   void slotISBNTextChanged();
0106   void slotUPC2ISBN();
0107   void columnResized(int column);
0108 
0109   void slotBarcodeRecognized(const QString&);
0110   void slotBarcodeGotImage(const QImage&);
0111 
0112 private:
0113   void fetchDone(bool checkISBN);
0114   void startProgress();
0115   void stopProgress();
0116   void setStatus(const QString& text);
0117 
0118   void openBarcodePreview();
0119   void closeBarcodePreview();
0120 
0121   void customEvent(QEvent* event) Q_DECL_OVERRIDE;
0122 
0123   class FetchResultItem;
0124 
0125   KComboBox* m_sourceCombo;
0126   GUI::ComboBox* m_keyCombo;
0127   QLineEdit* m_valueLineEdit;
0128   QPushButton* m_searchButton;
0129   QCheckBox* m_multipleISBN;
0130   QPushButton* m_editISBN;
0131   QTreeWidget* m_treeWidget;
0132   EntryView* m_entryView;
0133   QPushButton* m_addButton;
0134   QPushButton* m_moreButton;
0135   QStatusBar* m_statusBar;
0136   QLabel* m_statusLabel;
0137   QProgressBar* m_progress;
0138   QTimer* m_timer;
0139   QPointer<KTextEdit> m_isbnTextEdit;
0140 
0141   bool m_started;
0142   int m_resultCount;
0143   QString m_oldSearch;
0144   QStringList m_isbnList;
0145   QStringList m_statusMessages;
0146   QHash<int, Data::EntryPtr> m_entries;
0147   QList<Fetch::FetchResult*> m_results;
0148   int m_collType;
0149   bool m_treeWasResized;
0150 
0151   QLabel* m_barcodePreview;
0152   barcodeRecognition::barcodeRecognitionThread* m_barcodeRecognitionThread;
0153 };
0154 
0155 } //end namespace
0156 
0157 #endif