Changeset View
Changeset View
Standalone View
Standalone View
src/alkonlinequoteswidget.cpp
Show All 40 Lines | |||||
41 | #include <knewstuff3/uploaddialog.h> | 41 | #include <knewstuff3/uploaddialog.h> | ||
42 | 42 | | |||
43 | #include <ui_alkonlinequoteswidget.h> | 43 | #include <ui_alkonlinequoteswidget.h> | ||
44 | 44 | | |||
45 | class AlkOnlineQuotesWidget::Private : public QWidget, public Ui::AlkOnlineQuotesWidget | 45 | class AlkOnlineQuotesWidget::Private : public QWidget, public Ui::AlkOnlineQuotesWidget | ||
46 | { | 46 | { | ||
47 | Q_OBJECT | 47 | Q_OBJECT | ||
48 | public: | 48 | public: | ||
49 | QWebView *m_webView; | | |||
50 | QString m_acceptLanguage; | 49 | QString m_acceptLanguage; | ||
51 | QList<AlkOnlineQuoteSource> m_resetList; | 50 | QList<AlkOnlineQuoteSource> m_resetList; | ||
52 | AlkOnlineQuoteSource m_currentItem; | 51 | AlkOnlineQuoteSource m_currentItem; | ||
53 | bool m_quoteInEditing; | 52 | bool m_quoteInEditing; | ||
54 | AlkOnlineQuotesProfile *m_profile; | 53 | AlkOnlineQuotesProfile *m_profile; | ||
55 | bool m_showProfiles; | 54 | bool m_showProfiles; | ||
56 | bool m_showUpload; | 55 | bool m_showUpload; | ||
57 | QPixmap m_emptyIcon; | 56 | QPixmap m_emptyIcon; | ||
Show All 31 Lines | 84 | public: | |||
89 | void initIcons(); | 88 | void initIcons(); | ||
90 | void setupIcons(const AlkOnlineQuote::Errors &errors); | 89 | void setupIcons(const AlkOnlineQuote::Errors &errors); | ||
91 | QString singleSymbol() const; | 90 | QString singleSymbol() const; | ||
92 | QStringList doubleSymbol() const; | 91 | QStringList doubleSymbol() const; | ||
93 | QString expandedUrl() const; | 92 | QString expandedUrl() const; | ||
94 | }; | 93 | }; | ||
95 | 94 | | |||
96 | AlkOnlineQuotesWidget::Private::Private(bool showProfiles, bool showUpload, QWidget *parent) | 95 | AlkOnlineQuotesWidget::Private::Private(bool showProfiles, bool showUpload, QWidget *parent) | ||
97 | : m_webView(nullptr) | 96 | : m_quoteInEditing(false) | ||
98 | , m_quoteInEditing(false) | | |||
99 | , m_profile(nullptr) | 97 | , m_profile(nullptr) | ||
100 | , m_showProfiles(showProfiles) | 98 | , m_showProfiles(showProfiles) | ||
101 | , m_showUpload(showUpload) | 99 | , m_showUpload(showUpload) | ||
tbaumgart: Why not
profilesGroupBox->setVisible(showProfiles); | |||||
102 | , m_inWorkIcon(BarIcon("view-refresh")) | 100 | , m_inWorkIcon(BarIcon("view-refresh")) | ||
103 | , m_okIcon(BarIcon("dialog-ok-apply")) | 101 | , m_okIcon(BarIcon("dialog-ok-apply")) | ||
tbaumgart: Why not
profilesGroupBox->setVisible(showUpload); | |||||
104 | , m_failIcon(BarIcon("dialog-cancel")) | 102 | , m_failIcon(BarIcon("dialog-cancel")) | ||
105 | { | 103 | { | ||
106 | setupUi(parent); | 104 | setupUi(parent); | ||
107 | 105 | | |||
108 | profilesGroupBox->setVisible(showProfiles); | 106 | profilesGroupBox->setVisible(showProfiles); | ||
109 | m_uploadButton->setVisible(showUpload); | 107 | m_uploadButton->setVisible(showUpload); | ||
110 | m_urlCheckLabel->setMinimumWidth(m_okIcon.width()); | 108 | m_urlCheckLabel->setMinimumWidth(m_okIcon.width()); | ||
111 | 109 | | |||
▲ Show 20 Lines • Show All 145 Lines • ▼ Show 20 Line(s) | 246 | { | |||
257 | foreach (AlkOnlineQuotesProfile *profile, list) { | 255 | foreach (AlkOnlineQuotesProfile *profile, list) { | ||
258 | if (m_profileList->currentItem()->text() == profile->name()) { | 256 | if (m_profileList->currentItem()->text() == profile->name()) { | ||
259 | m_profile = profile; | 257 | m_profile = profile; | ||
260 | loadQuotesList(); | 258 | loadQuotesList(); | ||
261 | m_installButton->setVisible(profile->hasGHNSSupport()); | 259 | m_installButton->setVisible(profile->hasGHNSSupport()); | ||
262 | } | 260 | } | ||
263 | } | 261 | } | ||
264 | } | 262 | } | ||
265 | 263 | | |||
Suggestion for code simplicity // the next line replaces all of the setEnabled calls in this method // (except the very last) detailsGroupBox->setEnabled(item != nullptr); m_editURL->clear(); // better and faster than ->setText(QString()) m_editSymbol->clear(); : : if(item) { : m_editURL->setText( ... ); : } m_updateButton->setEnabled(false); tbaumgart: Suggestion for code simplicity
// the next line replaces all of the setEnabled calls in… | |||||
266 | void AlkOnlineQuotesWidget::Private::slotLoadWidgets() | 264 | void AlkOnlineQuotesWidget::Private::slotLoadWidgets() | ||
267 | { | 265 | { | ||
268 | m_quoteInEditing = false; | 266 | m_quoteInEditing = false; | ||
269 | QListWidgetItem *item = m_quoteSourceList->currentItem(); | 267 | QListWidgetItem *item = m_quoteSourceList->currentItem(); | ||
270 | 268 | | |||
271 | m_editURL->setEnabled(item != nullptr); | 269 | m_editURL->setEnabled(item != nullptr); | ||
272 | m_editSymbol->setEnabled(item != nullptr); | 270 | m_editSymbol->setEnabled(item != nullptr); | ||
273 | m_editPrice->setEnabled(item != nullptr); | 271 | m_editPrice->setEnabled(item != nullptr); | ||
▲ Show 20 Lines • Show All 134 Lines • ▼ Show 20 Line(s) | |||||
408 | } | 406 | } | ||
409 | 407 | | |||
410 | void AlkOnlineQuotesWidget::Private::slotCheckEntry() | 408 | void AlkOnlineQuotesWidget::Private::slotCheckEntry() | ||
411 | { | 409 | { | ||
412 | AlkOnlineQuote quote(m_profile); | 410 | AlkOnlineQuote quote(m_profile); | ||
413 | m_logWindow->setVisible(true); | 411 | m_logWindow->setVisible(true); | ||
414 | m_logWindow->clear(); | 412 | m_logWindow->clear(); | ||
415 | clearIcons(); | 413 | clearIcons(); | ||
416 | quote.setWebView(m_webView); | | |||
417 | quote.setAcceptLanguage(m_acceptLanguage); | 414 | quote.setAcceptLanguage(m_acceptLanguage); | ||
418 | 415 | | |||
419 | connect("e, SIGNAL(status(QString)), this, SLOT(slotLogStatus(QString))); | 416 | connect("e, SIGNAL(status(QString)), this, SLOT(slotLogStatus(QString))); | ||
420 | connect("e, SIGNAL(error(QString)), this, SLOT(slotLogError(QString))); | 417 | connect("e, SIGNAL(error(QString)), this, SLOT(slotLogError(QString))); | ||
421 | connect("e, SIGNAL(failed(QString,QString)), this, SLOT(slotLogFailed(QString,QString))); | 418 | connect("e, SIGNAL(failed(QString,QString)), this, SLOT(slotLogFailed(QString,QString))); | ||
422 | connect("e, SIGNAL(quote(QString,QString,QDate,double)), this, | 419 | connect("e, SIGNAL(quote(QString,QString,QDate,double)), this, | ||
423 | SLOT(slotLogQuote(QString,QString,QDate,double))); | 420 | SLOT(slotLogQuote(QString,QString,QDate,double))); | ||
424 | initIcons(); | 421 | initIcons(); | ||
▲ Show 20 Lines • Show All 128 Lines • ▼ Show 20 Line(s) | 540 | { | |||
553 | QList<AlkOnlineQuoteSource>::iterator itr; | 550 | QList<AlkOnlineQuoteSource>::iterator itr; | ||
554 | for (itr = d->m_resetList.begin(); itr != d->m_resetList.end(); ++itr) { | 551 | for (itr = d->m_resetList.begin(); itr != d->m_resetList.end(); ++itr) { | ||
555 | (*itr).write(); | 552 | (*itr).write(); | ||
556 | } | 553 | } | ||
557 | 554 | | |||
558 | d->loadQuotesList(); | 555 | d->loadQuotesList(); | ||
559 | } | 556 | } | ||
560 | 557 | | |||
561 | void AlkOnlineQuotesWidget::setView(QWebView *view) | | |||
562 | { | | |||
563 | d->m_webView = view; | | |||
564 | } | | |||
565 | | ||||
566 | QString AlkOnlineQuotesWidget::acceptLanguage() const | 558 | QString AlkOnlineQuotesWidget::acceptLanguage() const | ||
567 | { | 559 | { | ||
568 | return d->m_acceptLanguage; | 560 | return d->m_acceptLanguage; | ||
569 | } | 561 | } | ||
570 | 562 | | |||
571 | void AlkOnlineQuotesWidget::setAcceptLanguage(const QString &text) | 563 | void AlkOnlineQuotesWidget::setAcceptLanguage(const QString &text) | ||
572 | { | 564 | { | ||
573 | d->m_acceptLanguage = text; | 565 | d->m_acceptLanguage = text; | ||
574 | } | 566 | } | ||
575 | 567 | | |||
576 | #include "alkonlinequoteswidget.moc" | 568 | #include "alkonlinequoteswidget.moc" |
Why not