void MainWindow::setRightView() { QTableView *view = ui->m_rightTableInfo; view->setModel(m_dirsContentsModel); view->verticalHeader()->setSectionResizeMode(QHeaderView::ResizeToContents); view->horizontalHeader()->resizeSection(0, 280); // 'Name' section. User can resize view->horizontalHeader()->resizeSection(3, 130); // 'Type' section connect(view, SIGNAL(activated(QModelIndex)), view, SLOT(clearSelection())); // NOTE: must be the first connection connect(view, SIGNAL(activated(QModelIndex)), this, SLOT(slotSetLeftViewCurrentIndex(QModelIndex))); connect(view, SIGNAL(activated(QModelIndex)), this, SLOT(slotActivatedOnlyDirs(QModelIndex))); connect(view->selectionModel(), SIGNAL(selectionChanged(QItemSelection,QItemSelection)), this, SLOT(slotUpdateSelection(QItemSelection,QItemSelection))); }
KEquityPriceUpdateDlg::KEquityPriceUpdateDlg(QWidget *parent, const QString& securityId) : KEquityPriceUpdateDlgDecl(parent), m_fUpdateAll(false) { QStringList headerList; headerList << i18n("Symbol") << i18nc("Equity name", "Name") << i18n("Price") << i18n("Date"); lvEquityList->header()->setSortIndicator(0, Qt::AscendingOrder); lvEquityList->setColumnWidth(NAME_COL, 125); // This is a "get it up and running" hack. Will replace this in the future. headerList << i18nc("Internal identifier", "ID") << i18nc("Online quote source", "Source"); lvEquityList->setColumnWidth(ID_COL, 0); lvEquityList->setHeaderLabels(headerList); lvEquityList->setSelectionMode(QAbstractItemView::MultiSelection); lvEquityList->setAllColumnsShowFocus(true); btnUpdateAll->setEnabled(false); btnOK->setGuiItem(KStandardGuiItem::ok()); btnCancel->setGuiItem(KStandardGuiItem::cancel()); MyMoneyFile* file = MyMoneyFile::instance(); // // Add each price pair that we know about // // send in securityId == "XXX YYY" to get a single-shot update for XXX to YYY. // for consistency reasons, this accepts the same delimiters as WebPriceQuote::launch() QRegExp splitrx("([0-9a-z\\.]+)[^a-z0-9]+([0-9a-z\\.]+)", Qt::CaseInsensitive); MyMoneySecurityPair currencyIds; if (splitrx.indexIn(securityId) != -1) { currencyIds = MyMoneySecurityPair(splitrx.cap(1).toUtf8(), splitrx.cap(2).toUtf8()); } MyMoneyPriceList prices = file->priceList(); for (MyMoneyPriceList::ConstIterator it_price = prices.constBegin(); it_price != prices.constEnd(); ++it_price) { const MyMoneySecurityPair& pair = it_price.key(); if (file->security(pair.first).isCurrency() && (securityId.isEmpty() || (pair == currencyIds))) { const MyMoneyPriceEntries& entries = (*it_price); if (entries.count() > 0 && entries.begin().key() <= QDate::currentDate()) { addPricePair(pair); btnUpdateAll->setEnabled(true); } } } // // Add each investment // QList<MyMoneySecurity> securities = file->securityList(); for (QList<MyMoneySecurity>::const_iterator it = securities.constBegin(); it != securities.constEnd(); ++it) { if (!(*it).isCurrency() && (securityId.isEmpty() || ((*it).id() == securityId)) && !(*it).value("kmm-online-source").isEmpty() ) { addInvestment(*it); btnUpdateAll->setEnabled(true); } } // if list is empty, add the request price pair if (lvEquityList->invisibleRootItem()->childCount() == 0) { addPricePair(currencyIds, true); } connect(btnOK, SIGNAL(clicked()), this, SLOT(accept())); connect(btnCancel, SIGNAL(clicked()), this, SLOT(reject())); connect(btnUpdateSelected, SIGNAL(clicked()), this, SLOT(slotUpdateSelectedClicked())); connect(btnUpdateAll, SIGNAL(clicked()), this, SLOT(slotUpdateAllClicked())); connect(&m_webQuote, SIGNAL(quote(QString,QString,QDate,double)), this, SLOT(slotReceivedQuote(QString,QString,QDate,double))); connect(&m_webQuote, SIGNAL(failed(QString,QString)), this, SLOT(slotQuoteFailed(QString,QString))); connect(&m_webQuote, SIGNAL(status(QString)), this, SLOT(logStatusMessage(QString))); connect(&m_webQuote, SIGNAL(error(QString)), this, SLOT(logErrorMessage(QString))); connect(lvEquityList, SIGNAL(itemSelectionChanged()), this, SLOT(slotUpdateSelection())); // Not implemented yet. btnConfigure->hide(); //connect(btnConfigure, SIGNAL(clicked()), this, SLOT(slotConfigureClicked())); if (!securityId.isEmpty()) { btnUpdateSelected->hide(); btnUpdateAll->hide(); // delete layout1; QTimer::singleShot(100, this, SLOT(slotUpdateAllClicked())); } // Hide OK button until we have received the first update btnOK->setEnabled(false); slotUpdateSelection(); // previous versions of this dialog allowed to store a "Don't ask again" switch. // Since we don't support it anymore, we just get rid of it KSharedConfigPtr config = KGlobal::config(); KConfigGroup grp = config->group("Notification Messages"); grp.deleteEntry("KEquityPriceUpdateDlg::slotQuoteFailed::Price Update Failed"); }