Thesaurus::Thesaurus() { m_standAlone = false; m_thesProc = new KProcess; m_wnProc = new KProcess; m_dialog = new KoDialog(0); m_dialog->setButtons(KoDialog::Help | KoDialog::Ok | KoDialog::Cancel); m_dialog->setDefaultButton(KoDialog::Ok); m_dialog->setHelp(QString(), "thesaurus"); m_dialog->resize(600, 400); KConfigGroup cfg = KSharedConfig::openConfig()->group(""); m_dataFile = cfg.readEntry("datafile"); if (m_dataFile.isEmpty()) m_dataFile = KoResourcePaths::findResource("data", "calligra/thesaurus/thesaurus.txt"); setCaption(); m_noMatch = i18n("(No match)"); m_historyPos = 1; QWidget *page = new QWidget(); m_dialog->setMainWidget(page); QVBoxLayout *topLayout = new QVBoxLayout(page); QHBoxLayout *row1 = new QHBoxLayout; topLayout->addLayout(row1); m_edit = new KHistoryComboBox(page); QLabel editLabel(i18n("&Search for:"), page); editLabel.setBuddy(m_edit); m_search = new KPushButton(i18n("S&earch"), page); connect(m_search, SIGNAL(clicked()), this, SLOT(slotFindTerm())); row1->addWidget(&editLabel, 0); row1->addWidget(m_edit, 1); row1->addWidget(m_search, 0); m_back = new QToolButton(page); m_back->setIcon(koIcon("go-previous")); m_back->setToolTip(i18nc("@action:button Go back to the previous word in history", "Back")); row1->addWidget(m_back, 0); m_forward = new QToolButton(page); m_forward->setIcon(koIcon("go-next")); m_forward->setToolTip(i18nc("@action:button Go forward to the next word in history", "Forward")); row1->addWidget(m_forward, 0); KPushButton *lang = new KPushButton(i18n("Change Language..."), page); connect(lang, SIGNAL(clicked()), this, SLOT(slotChangeLanguage())); row1->addWidget(lang, 0); connect(m_back, SIGNAL(clicked()), this, SLOT(slotBack())); connect(m_forward, SIGNAL(clicked()), this, SLOT(slotForward())); m_tabWidget = new KTabWidget(page); topLayout->addWidget(m_tabWidget); // // Thesaurus Tab // QWidget *thesWidget = new QWidget(m_tabWidget); m_tabWidget->addTab(thesWidget, i18n("&Thesaurus")); QHBoxLayout *thesLayout = new QHBoxLayout; thesWidget->setLayout(thesLayout); QGroupBox *synGroupBox = new QGroupBox(i18n("Synonyms"), thesWidget); QHBoxLayout *synLayout = new QHBoxLayout(); synGroupBox->setLayout(synLayout); m_synListWidget = new QListWidget(synGroupBox); synLayout->addWidget(m_synListWidget); thesLayout->addWidget(synGroupBox); QGroupBox *hyperGroupBox = new QGroupBox(i18n("More General Words"), thesWidget); QHBoxLayout *hyperLayout = new QHBoxLayout(); hyperGroupBox->setLayout(hyperLayout); m_hyperListWidget = new QListWidget(hyperGroupBox); hyperLayout->addWidget(m_hyperListWidget); thesLayout->addWidget(hyperGroupBox); QGroupBox *hypoGroupBox = new QGroupBox(i18n("More Specific Words"), thesWidget); QHBoxLayout *hypoLayout = new QHBoxLayout(); hypoGroupBox->setLayout(hypoLayout); m_hypoListWidget = new QListWidget(hypoGroupBox); hypoLayout->addWidget(m_hypoListWidget); thesLayout->addWidget(hypoGroupBox); // single click -- keep display unambiguous by removing other selections: connect(m_synListWidget, SIGNAL(itemClicked(QListWidgetItem *)), this, SLOT(slotSetReplaceTermSyn(QListWidgetItem *))); connect(m_hyperListWidget, SIGNAL(itemClicked(QListWidgetItem *)), this, SLOT(slotSetReplaceTermHyper(QListWidgetItem *))); connect(m_hypoListWidget, SIGNAL(itemClicked(QListWidgetItem *)), this, SLOT(slotSetReplaceTermHypo(QListWidgetItem *))); // double click -- set the double clicked item as the new search term connect(m_synListWidget, SIGNAL(itemDoubleClicked(QListWidgetItem *)), this, SLOT(slotFindTermFromList(QListWidgetItem *))); connect(m_hyperListWidget, SIGNAL(itemDoubleClicked(QListWidgetItem *)), this, SLOT(slotFindTermFromList(QListWidgetItem *))); connect(m_hypoListWidget, SIGNAL(itemDoubleClicked(QListWidgetItem *)), this, SLOT(slotFindTermFromList(QListWidgetItem *))); // // WordNet Tab // QWidget *wnWidget = new QWidget(m_tabWidget); m_tabWidget->addTab(wnWidget, i18n("&Wordnet")); QVBoxLayout *wnLayout = new QVBoxLayout; wnWidget->setLayout(wnLayout); m_wnComboBox = new KComboBox(wnWidget); m_wnComboBox->setEditable(false); wnLayout->addWidget(m_wnComboBox); connect(m_wnComboBox, SIGNAL(activated(int)), this, SLOT(slotFindTerm())); m_resultTextBrowser = new QTextBrowser(wnWidget); m_resultTextBrowser->setReadOnly(true); connect(m_resultTextBrowser, SIGNAL(anchorClicked(const QUrl &)), this, SLOT(slotFindTermFromUrl(const QUrl &))); wnLayout->addWidget(m_resultTextBrowser); // Connect for the history box m_edit->setTrapReturnKey(true); // Do not use Return as default key... connect(m_edit, SIGNAL(returnPressed()), this, SLOT(slotFindTerm())); connect(m_edit, SIGNAL(activated(int)), this, SLOT(slotGotoHistory(int))); QHBoxLayout *row2 = new QHBoxLayout( /*m_top_layout*/ ); topLayout->addLayout(row2); m_replaceLineEdit = new QLineEdit(page); m_replaceLabel = new QLabel(i18n("&Replace with:"), page); m_replaceLabel->setBuddy(m_replaceLineEdit); row2->addWidget(m_replaceLabel, 0); row2->addWidget(m_replaceLineEdit, 1); // Set focus m_edit->setFocus(); updateNavButtons(); connect(m_dialog, SIGNAL(accepted()), this, SLOT(process())); connect(m_dialog, SIGNAL(rejected()), this, SLOT(dialogClosed())); }
TransactionView::TransactionView(QWidget *parent) : QWidget(parent), model(0), transactionProxyModel(0), transactionView(0) { // Build filter row setContentsMargins(0,0,0,0); QHBoxLayout *hlayout = new QHBoxLayout(); hlayout->setContentsMargins(0,0,0,0); #ifdef Q_OS_MAC hlayout->setSpacing(5); hlayout->addSpacing(26); #else hlayout->setSpacing(0); hlayout->addSpacing(23); #endif dateWidget = new QComboBox(this); #ifdef Q_OS_MAC dateWidget->setFixedWidth(121); #else dateWidget->setFixedWidth(120); #endif dateWidget->addItem(tr("All"), All); dateWidget->addItem(tr("Today"), Today); dateWidget->addItem(tr("This week"), ThisWeek); dateWidget->addItem(tr("This month"), ThisMonth); dateWidget->addItem(tr("Last month"), LastMonth); dateWidget->addItem(tr("This year"), ThisYear); dateWidget->addItem(tr("Range..."), Range); hlayout->addWidget(dateWidget); typeWidget = new QComboBox(this); #ifdef Q_OS_MAC typeWidget->setFixedWidth(121); #else typeWidget->setFixedWidth(120); #endif typeWidget->addItem(tr("All"), TransactionFilterProxy::ALL_TYPES); typeWidget->addItem(tr("Received with"), TransactionFilterProxy::TYPE(TransactionRecord::RecvWithAddress) | TransactionFilterProxy::TYPE(TransactionRecord::RecvFromOther)); typeWidget->addItem(tr("Sent to"), TransactionFilterProxy::TYPE(TransactionRecord::SendToAddress) | TransactionFilterProxy::TYPE(TransactionRecord::SendToOther)); typeWidget->addItem(tr("To yourself"), TransactionFilterProxy::TYPE(TransactionRecord::SendToSelf)); typeWidget->addItem(tr("Mined"), TransactionFilterProxy::TYPE(TransactionRecord::Generated)); typeWidget->addItem(tr("Name operation"), TransactionFilterProxy::TYPE(TransactionRecord::NameOp)); typeWidget->addItem(tr("Game: player death"), TransactionFilterProxy::TYPE(TransactionRecord::GameDeath)); typeWidget->addItem(tr("Game reward"), TransactionFilterProxy::TYPE(TransactionRecord::GameReward)); typeWidget->addItem(tr("Other"), TransactionFilterProxy::TYPE(TransactionRecord::Other)); hlayout->addWidget(typeWidget); addressWidget = new QLineEdit(this); #if QT_VERSION >= 0x040700 /* Do not move this to the XML file, Qt before 4.7 will choke on it */ addressWidget->setPlaceholderText(tr("Enter address or label to search")); #endif hlayout->addWidget(addressWidget); amountWidget = new QLineEdit(this); #if QT_VERSION >= 0x040700 /* Do not move this to the XML file, Qt before 4.7 will choke on it */ amountWidget->setPlaceholderText(tr("Min amount")); #endif #ifdef Q_OS_MAC amountWidget->setFixedWidth(97); #else amountWidget->setFixedWidth(100); #endif amountWidget->setValidator(new QDoubleValidator(0, 1e20, 8, this)); hlayout->addWidget(amountWidget); QVBoxLayout *vlayout = new QVBoxLayout(this); vlayout->setContentsMargins(0,0,0,0); vlayout->setSpacing(0); QTableView *view = new QTableView(this); vlayout->addLayout(hlayout); vlayout->addWidget(createDateRangeWidget()); vlayout->addWidget(view); vlayout->setSpacing(0); int width = view->verticalScrollBar()->sizeHint().width(); // Cover scroll bar width with spacing #ifdef Q_OS_MAC hlayout->addSpacing(width+2); #else hlayout->addSpacing(width); #endif // Always show scroll bar view->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn); view->setTabKeyNavigation(false); view->setContextMenuPolicy(Qt::CustomContextMenu); transactionView = view; // Actions QAction *copyAddressAction = new QAction(tr("Copy address"), this); QAction *copyLabelAction = new QAction(tr("Copy label"), this); QAction *copyAmountAction = new QAction(tr("Copy amount"), this); QAction *editLabelAction = new QAction(tr("Edit label"), this); QAction *showDetailsAction = new QAction(tr("Show transaction details"), this); contextMenu = new QMenu(); contextMenu->addAction(copyAddressAction); contextMenu->addAction(copyLabelAction); contextMenu->addAction(copyAmountAction); contextMenu->addAction(editLabelAction); contextMenu->addAction(showDetailsAction); // Connect actions connect(dateWidget, SIGNAL(activated(int)), this, SLOT(chooseDate(int))); connect(typeWidget, SIGNAL(activated(int)), this, SLOT(chooseType(int))); connect(addressWidget, SIGNAL(textChanged(QString)), this, SLOT(changedPrefix(QString))); connect(amountWidget, SIGNAL(textChanged(QString)), this, SLOT(changedAmount(QString))); connect(view, SIGNAL(doubleClicked(QModelIndex)), this, SIGNAL(doubleClicked(QModelIndex))); connect(view, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(contextualMenu(QPoint))); connect(copyAddressAction, SIGNAL(triggered()), this, SLOT(copyAddress())); connect(copyLabelAction, SIGNAL(triggered()), this, SLOT(copyLabel())); connect(copyAmountAction, SIGNAL(triggered()), this, SLOT(copyAmount())); connect(editLabelAction, SIGNAL(triggered()), this, SLOT(editLabel())); connect(showDetailsAction, SIGNAL(triggered()), this, SLOT(showDetails())); }
AddressEditDialog::AddressEditDialog( const KABC::Address::List &list, int selected, QWidget *parent, const char *name ) : KDialogBase( Plain, i18n( "street/postal", "Edit Address" ), Ok | Cancel, Ok, parent, name, true, true ), mPreviousAddress( 0 ) { mAddressList = list; QWidget *page = plainPage(); QGridLayout *topLayout = new QGridLayout( page, 8, 2 ); topLayout->setSpacing( spacingHint() ); mTypeCombo = new AddressTypeCombo( mAddressList, page ); topLayout->addMultiCellWidget( mTypeCombo, 0, 0, 0, 1 ); QLabel *label = new QLabel( i18n( "<streetLabel>:", "%1:" ).arg( KABC::Address::streetLabel() ), page ); label->setAlignment( Qt::AlignTop | Qt::AlignLeft ); topLayout->addWidget( label, 1, 0 ); mStreetTextEdit = new QTextEdit( page ); mStreetTextEdit->setTextFormat( Qt::PlainText ); label->setBuddy( mStreetTextEdit ); topLayout->addWidget( mStreetTextEdit, 1, 1 ); TabPressEater *eater = new TabPressEater( this ); mStreetTextEdit->installEventFilter( eater ); label = new QLabel( i18n( "<postOfficeBoxLabel>:", "%1:" ).arg( KABC::Address::postOfficeBoxLabel() ), page ); topLayout->addWidget( label, 2 , 0 ); mPOBoxEdit = new KLineEdit( page ); label->setBuddy( mPOBoxEdit ); topLayout->addWidget( mPOBoxEdit, 2, 1 ); label = new QLabel( i18n( "<localityLabel>:", "%1:" ).arg( KABC::Address::localityLabel() ), page ); topLayout->addWidget( label, 3, 0 ); mLocalityEdit = new KLineEdit( page ); label->setBuddy( mLocalityEdit ); topLayout->addWidget( mLocalityEdit, 3, 1 ); label = new QLabel( i18n( "<regionLabel>:", "%1:" ).arg( KABC::Address::regionLabel() ), page ); topLayout->addWidget( label, 4, 0 ); mRegionEdit = new KLineEdit( page ); label->setBuddy( mRegionEdit ); topLayout->addWidget( mRegionEdit, 4, 1 ); label = new QLabel( i18n( "<postalCodeLabel>:", "%1:" ).arg( KABC::Address::postalCodeLabel() ), page ); topLayout->addWidget( label, 5, 0 ); mPostalCodeEdit = new KLineEdit( page ); label->setBuddy( mPostalCodeEdit ); topLayout->addWidget( mPostalCodeEdit, 5, 1 ); label = new QLabel( i18n( "<countryLabel>:", "%1:" ).arg( KABC::Address::countryLabel() ), page ); topLayout->addWidget( label, 6, 0 ); mCountryCombo = new KComboBox( page ); mCountryCombo->setEditable( true ); mCountryCombo->setDuplicatesEnabled( false ); #if KDE_IS_VERSION(3,3,0) QPushButton *labelButton = new QPushButton( i18n( "Edit Label..." ), page ); topLayout->addMultiCellWidget( labelButton, 7, 7, 0, 1 ); connect( labelButton, SIGNAL( clicked() ), SLOT( editLabel() ) ); #endif fillCountryCombo(); label->setBuddy( mCountryCombo ); topLayout->addWidget( mCountryCombo, 6, 1 ); mPreferredCheckBox = new QCheckBox( i18n( "street/postal", "This is the preferred address" ), page ); topLayout->addMultiCellWidget( mPreferredCheckBox, 8, 8, 0, 1 ); KSeparator *sep = new KSeparator( KSeparator::HLine, page ); topLayout->addMultiCellWidget( sep, 9, 9, 0, 1 ); QHBox *buttonBox = new QHBox( page ); buttonBox->setSpacing( spacingHint() ); topLayout->addMultiCellWidget( buttonBox, 10, 10, 0, 1 ); QPushButton *addButton = new QPushButton( i18n( "New..." ), buttonBox ); connect( addButton, SIGNAL( clicked() ), SLOT( addAddress() ) ); mRemoveButton = new QPushButton( i18n( "Remove" ), buttonBox ); connect( mRemoveButton, SIGNAL( clicked() ), SLOT( removeAddress() ) ); mChangeTypeButton = new QPushButton( i18n( "Change Type..." ), buttonBox ); connect( mChangeTypeButton, SIGNAL( clicked() ), SLOT( changeType() ) ); mTypeCombo->updateTypes(); mTypeCombo->setCurrentItem( selected ); updateAddressEdits(); connect( mTypeCombo, SIGNAL( activated( int ) ), SLOT( updateAddressEdits() ) ); connect( mStreetTextEdit, SIGNAL( textChanged() ), SLOT( modified() ) ); connect( mPOBoxEdit, SIGNAL( textChanged( const QString& ) ), SLOT( modified() ) ); connect( mLocalityEdit, SIGNAL( textChanged( const QString& ) ), SLOT( modified() ) ); connect( mRegionEdit, SIGNAL( textChanged( const QString& ) ), SLOT( modified() ) ); connect( mPostalCodeEdit, SIGNAL( textChanged( const QString& ) ), SLOT( modified() ) ); connect( mCountryCombo, SIGNAL( textChanged( const QString& ) ), SLOT( modified() ) ); connect( mPreferredCheckBox, SIGNAL( toggled( bool ) ), SLOT( modified() ) ); KAcceleratorManager::manage( this ); mChanged = false; bool state = (mAddressList.count() > 0); mRemoveButton->setEnabled( state ); mChangeTypeButton->setEnabled( state ); }
TransactionView::TransactionView(const PlatformStyle *platformStyle, QWidget *parent) : QWidget(parent), model(0), transactionProxyModel(0), transactionView(0), abandonAction(0) { // Build filter row setContentsMargins(0,0,0,0); QHBoxLayout *hlayout = new QHBoxLayout(); hlayout->setContentsMargins(0,0,0,0); if (platformStyle->getUseExtraSpacing()) { hlayout->setSpacing(5); hlayout->addSpacing(26); } else { hlayout->setSpacing(0); hlayout->addSpacing(23); } watchOnlyWidget = new QComboBox(this); watchOnlyWidget->setFixedWidth(24); watchOnlyWidget->addItem("", TransactionFilterProxy::WatchOnlyFilter_All); watchOnlyWidget->addItem(platformStyle->SingleColorIcon(":/icons/eye_plus"), "", TransactionFilterProxy::WatchOnlyFilter_Yes); watchOnlyWidget->addItem(platformStyle->SingleColorIcon(":/icons/eye_minus"), "", TransactionFilterProxy::WatchOnlyFilter_No); hlayout->addWidget(watchOnlyWidget); dateWidget = new QComboBox(this); if (platformStyle->getUseExtraSpacing()) { dateWidget->setFixedWidth(121); } else { dateWidget->setFixedWidth(120); } dateWidget->addItem(tr("All"), All); dateWidget->addItem(tr("Today"), Today); dateWidget->addItem(tr("This week"), ThisWeek); dateWidget->addItem(tr("This month"), ThisMonth); dateWidget->addItem(tr("Last month"), LastMonth); dateWidget->addItem(tr("This year"), ThisYear); dateWidget->addItem(tr("Range..."), Range); hlayout->addWidget(dateWidget); typeWidget = new QComboBox(this); if (platformStyle->getUseExtraSpacing()) { typeWidget->setFixedWidth(121); } else { typeWidget->setFixedWidth(120); } typeWidget->addItem(tr("All"), TransactionFilterProxy::ALL_TYPES); typeWidget->addItem(tr("Received with"), TransactionFilterProxy::TYPE(TransactionRecord::RecvWithAddress) | TransactionFilterProxy::TYPE(TransactionRecord::RecvFromOther)); typeWidget->addItem(tr("Sent to"), TransactionFilterProxy::TYPE(TransactionRecord::SendToAddress) | TransactionFilterProxy::TYPE(TransactionRecord::SendToOther)); typeWidget->addItem(tr("To yourself"), TransactionFilterProxy::TYPE(TransactionRecord::SendToSelf)); typeWidget->addItem(tr("Mined"), TransactionFilterProxy::TYPE(TransactionRecord::Generated)); typeWidget->addItem(tr("Other"), TransactionFilterProxy::TYPE(TransactionRecord::Other)); hlayout->addWidget(typeWidget); addressWidget = new QLineEdit(this); #if QT_VERSION >= 0x040700 addressWidget->setPlaceholderText(tr("Enter address or label to search")); #endif hlayout->addWidget(addressWidget); amountWidget = new QLineEdit(this); #if QT_VERSION >= 0x040700 amountWidget->setPlaceholderText(tr("Min amount")); #endif if (platformStyle->getUseExtraSpacing()) { amountWidget->setFixedWidth(97); } else { amountWidget->setFixedWidth(100); } amountWidget->setValidator(new QDoubleValidator(0, 1e20, 8, this)); hlayout->addWidget(amountWidget); QVBoxLayout *vlayout = new QVBoxLayout(this); vlayout->setContentsMargins(0,0,0,0); vlayout->setSpacing(0); QTableView *view = new QTableView(this); vlayout->addLayout(hlayout); vlayout->addWidget(createDateRangeWidget()); vlayout->addWidget(view); vlayout->setSpacing(0); int width = view->verticalScrollBar()->sizeHint().width(); // Cover scroll bar width with spacing if (platformStyle->getUseExtraSpacing()) { hlayout->addSpacing(width+2); } else { hlayout->addSpacing(width); } // Always show scroll bar view->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn); view->setTabKeyNavigation(false); view->setContextMenuPolicy(Qt::CustomContextMenu); view->installEventFilter(this); transactionView = view; // Actions abandonAction = new QAction(tr("Abandon transaction"), this); QAction *copyAddressAction = new QAction(tr("Copy address"), this); QAction *copyLabelAction = new QAction(tr("Copy label"), this); QAction *copyAmountAction = new QAction(tr("Copy amount"), this); QAction *copyTxIDAction = new QAction(tr("Copy transaction ID"), this); QAction *copyTxHexAction = new QAction(tr("Copy raw transaction"), this); QAction *copyTxPlainText = new QAction(tr("Copy full transaction details"), this); QAction *editLabelAction = new QAction(tr("Edit label"), this); QAction *showDetailsAction = new QAction(tr("Show transaction details"), this); contextMenu = new QMenu(); contextMenu->addAction(copyAddressAction); contextMenu->addAction(copyLabelAction); contextMenu->addAction(copyAmountAction); contextMenu->addAction(copyTxIDAction); contextMenu->addAction(copyTxHexAction); contextMenu->addAction(copyTxPlainText); contextMenu->addAction(showDetailsAction); contextMenu->addSeparator(); contextMenu->addAction(abandonAction); contextMenu->addAction(editLabelAction); mapperThirdPartyTxUrls = new QSignalMapper(this); // Connect actions connect(mapperThirdPartyTxUrls, SIGNAL(mapped(QString)), this, SLOT(openThirdPartyTxUrl(QString))); connect(dateWidget, SIGNAL(activated(int)), this, SLOT(chooseDate(int))); connect(typeWidget, SIGNAL(activated(int)), this, SLOT(chooseType(int))); connect(watchOnlyWidget, SIGNAL(activated(int)), this, SLOT(chooseWatchonly(int))); connect(addressWidget, SIGNAL(textChanged(QString)), this, SLOT(changedPrefix(QString))); connect(amountWidget, SIGNAL(textChanged(QString)), this, SLOT(changedAmount(QString))); connect(view, SIGNAL(doubleClicked(QModelIndex)), this, SIGNAL(doubleClicked(QModelIndex))); connect(view, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(contextualMenu(QPoint))); connect(abandonAction, SIGNAL(triggered()), this, SLOT(abandonTx())); connect(copyAddressAction, SIGNAL(triggered()), this, SLOT(copyAddress())); connect(copyLabelAction, SIGNAL(triggered()), this, SLOT(copyLabel())); connect(copyAmountAction, SIGNAL(triggered()), this, SLOT(copyAmount())); connect(copyTxIDAction, SIGNAL(triggered()), this, SLOT(copyTxID())); connect(copyTxHexAction, SIGNAL(triggered()), this, SLOT(copyTxHex())); connect(copyTxPlainText, SIGNAL(triggered()), this, SLOT(copyTxPlainText())); connect(editLabelAction, SIGNAL(triggered()), this, SLOT(editLabel())); connect(showDetailsAction, SIGNAL(triggered()), this, SLOT(showDetails())); }
TransactionView::TransactionView(QWidget *parent) : QWidget(parent), model(0), transactionProxyModel(0), transactionView(0) { QSettings settings; // Build filter row setContentsMargins(0,0,0,0); QHBoxLayout *hlayout = new QHBoxLayout(); hlayout->setContentsMargins(0,0,0,0); #ifdef Q_OS_MAC hlayout->setSpacing(5); hlayout->addSpacing(26); #else hlayout->setSpacing(0); hlayout->addSpacing(23); #endif watchOnlyWidget = new QComboBox(this); watchOnlyWidget->setFixedWidth(24); watchOnlyWidget->addItem("", TransactionFilterProxy::WatchOnlyFilter_All); watchOnlyWidget->addItem(QIcon(":/icons/eye_plus"), "", TransactionFilterProxy::WatchOnlyFilter_Yes); watchOnlyWidget->addItem(QIcon(":/icons/eye_minus"), "", TransactionFilterProxy::WatchOnlyFilter_No); hlayout->addWidget(watchOnlyWidget); dateWidget = new QComboBox(this); #ifdef Q_OS_MAC dateWidget->setFixedWidth(121); #else dateWidget->setFixedWidth(120); #endif dateWidget->addItem(tr("All"), All); dateWidget->addItem(tr("Today"), Today); dateWidget->addItem(tr("This week"), ThisWeek); dateWidget->addItem(tr("This month"), ThisMonth); dateWidget->addItem(tr("Last month"), LastMonth); dateWidget->addItem(tr("This year"), ThisYear); dateWidget->addItem(tr("Range..."), Range); dateWidget->setCurrentIndex(settings.value("transactionDate").toInt()); hlayout->addWidget(dateWidget); typeWidget = new QComboBox(this); #ifdef Q_OS_MAC typeWidget->setFixedWidth(TYPE_COLUMN_WIDTH+1); #else typeWidget->setFixedWidth(TYPE_COLUMN_WIDTH); #endif typeWidget->addItem(tr("All"), TransactionFilterProxy::ALL_TYPES); typeWidget->addItem(tr("Most Common"), TransactionFilterProxy::COMMON_TYPES); typeWidget->addItem(tr("Received with"), TransactionFilterProxy::TYPE(TransactionRecord::RecvWithAddress) | TransactionFilterProxy::TYPE(TransactionRecord::RecvFromOther)); typeWidget->addItem(tr("Sent to"), TransactionFilterProxy::TYPE(TransactionRecord::SendToAddress) | TransactionFilterProxy::TYPE(TransactionRecord::SendToOther)); typeWidget->addItem(tr("Darksent"), TransactionFilterProxy::TYPE(TransactionRecord::Darksent)); typeWidget->addItem(tr("Obfuscation Make Collateral Inputs"), TransactionFilterProxy::TYPE(TransactionRecord::ObfuscationMakeCollaterals)); typeWidget->addItem(tr("Obfuscation Create Denominations"), TransactionFilterProxy::TYPE(TransactionRecord::ObfuscationCreateDenominations)); typeWidget->addItem(tr("Obfuscation Denominate"), TransactionFilterProxy::TYPE(TransactionRecord::ObfuscationDenominate)); typeWidget->addItem(tr("Obfuscation Collateral Payment"), TransactionFilterProxy::TYPE(TransactionRecord::ObfuscationCollateralPayment)); typeWidget->addItem(tr("To yourself"), TransactionFilterProxy::TYPE(TransactionRecord::SendToSelf)); typeWidget->addItem(tr("Mined"), TransactionFilterProxy::TYPE(TransactionRecord::Generated)); typeWidget->addItem(tr("Other"), TransactionFilterProxy::TYPE(TransactionRecord::Other)); typeWidget->setCurrentIndex(settings.value("transactionType").toInt()); hlayout->addWidget(typeWidget); addressWidget = new QLineEdit(this); #if QT_VERSION >= 0x040700 addressWidget->setPlaceholderText(tr("Enter address or label to search")); #endif hlayout->addWidget(addressWidget); amountWidget = new QLineEdit(this); #if QT_VERSION >= 0x040700 amountWidget->setPlaceholderText(tr("Min amount")); #endif #ifdef Q_OS_MAC amountWidget->setFixedWidth(97); #else amountWidget->setFixedWidth(100); #endif amountWidget->setValidator(new QDoubleValidator(0, 1e20, 8, this)); hlayout->addWidget(amountWidget); QVBoxLayout *vlayout = new QVBoxLayout(this); vlayout->setContentsMargins(0,0,0,0); vlayout->setSpacing(0); QTableView *view = new QTableView(this); vlayout->addLayout(hlayout); vlayout->addWidget(createDateRangeWidget()); vlayout->addWidget(view); vlayout->setSpacing(0); int width = view->verticalScrollBar()->sizeHint().width(); // Cover scroll bar width with spacing #ifdef Q_OS_MAC hlayout->addSpacing(width+2); #else hlayout->addSpacing(width); #endif // Always show scroll bar view->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn); view->setTabKeyNavigation(false); view->setContextMenuPolicy(Qt::CustomContextMenu); view->installEventFilter(this); transactionView = view; // Actions QAction *copyAddressAction = new QAction(tr("Copy address"), this); QAction *copyLabelAction = new QAction(tr("Copy label"), this); QAction *copyAmountAction = new QAction(tr("Copy amount"), this); QAction *copyTxIDAction = new QAction(tr("Copy transaction ID"), this); QAction *editLabelAction = new QAction(tr("Edit label"), this); QAction *showDetailsAction = new QAction(tr("Show transaction details"), this); contextMenu = new QMenu(); contextMenu->addAction(copyAddressAction); contextMenu->addAction(copyLabelAction); contextMenu->addAction(copyAmountAction); contextMenu->addAction(copyTxIDAction); contextMenu->addAction(editLabelAction); contextMenu->addAction(showDetailsAction); mapperThirdPartyTxUrls = new QSignalMapper(this); // Connect actions connect(mapperThirdPartyTxUrls, SIGNAL(mapped(QString)), this, SLOT(openThirdPartyTxUrl(QString))); connect(dateWidget, SIGNAL(activated(int)), this, SLOT(chooseDate(int))); connect(typeWidget, SIGNAL(activated(int)), this, SLOT(chooseType(int))); connect(watchOnlyWidget, SIGNAL(activated(int)), this, SLOT(chooseWatchonly(int))); connect(addressWidget, SIGNAL(textChanged(QString)), this, SLOT(changedPrefix(QString))); connect(amountWidget, SIGNAL(textChanged(QString)), this, SLOT(changedAmount(QString))); connect(view, SIGNAL(doubleClicked(QModelIndex)), this, SIGNAL(doubleClicked(QModelIndex))); connect(view, SIGNAL(clicked(QModelIndex)), this, SLOT(computeSum())); connect(view, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(contextualMenu(QPoint))); connect(copyAddressAction, SIGNAL(triggered()), this, SLOT(copyAddress())); connect(copyLabelAction, SIGNAL(triggered()), this, SLOT(copyLabel())); connect(copyAmountAction, SIGNAL(triggered()), this, SLOT(copyAmount())); connect(copyTxIDAction, SIGNAL(triggered()), this, SLOT(copyTxID())); connect(editLabelAction, SIGNAL(triggered()), this, SLOT(editLabel())); connect(showDetailsAction, SIGNAL(triggered()), this, SLOT(showDetails())); }
TransactionView::TransactionView(QWidget *parent) : QWidget(parent), model(0), transactionProxyModel(0), transactionView(0) { // Build filter row setContentsMargins(0,0,0,0); QHBoxLayout *hlayout = new QHBoxLayout(); hlayout->setContentsMargins(0,0,0,0); #ifdef Q_OS_MAC hlayout->setSpacing(5); hlayout->addSpacing(0); #else hlayout->setSpacing(0); hlayout->addSpacing(0); #endif dateWidget = new QComboBox(this); #ifdef Q_OS_MAC dateWidget->setFixedWidth(121); #else dateWidget->setFixedWidth(120); #endif dateWidget->setStyleSheet("background: black; font-size: 14px; selection-background-color: rgb(255, 170, 0, 145);"); dateWidget->addItem(tr("All"), All); dateWidget->addItem(tr("Today"), Today); dateWidget->addItem(tr("This week"), ThisWeek); dateWidget->addItem(tr("This month"), ThisMonth); dateWidget->addItem(tr("Last month"), LastMonth); dateWidget->addItem(tr("This year"), ThisYear); dateWidget->addItem(tr("Range..."), Range); hlayout->addWidget(dateWidget); typeWidget = new QComboBox(this); #ifdef Q_OS_MAC typeWidget->setFixedWidth(121); #else typeWidget->setFixedWidth(120); #endif typeWidget->setStyleSheet("background: black; font-size: 14px; selection-background-color: rgb(255, 170, 0, 145);"); typeWidget->addItem(tr("All"), TransactionFilterProxy::ALL_TYPES); typeWidget->addItem(tr("Received with"), TransactionFilterProxy::TYPE(TransactionRecord::RecvWithAddress) | TransactionFilterProxy::TYPE(TransactionRecord::RecvFromOther)); typeWidget->addItem(tr("Sent to"), TransactionFilterProxy::TYPE(TransactionRecord::SendToAddress) | TransactionFilterProxy::TYPE(TransactionRecord::SendToOther)); typeWidget->addItem(tr("To yourself"), TransactionFilterProxy::TYPE(TransactionRecord::SendToSelf)); typeWidget->addItem(tr("Mined"), TransactionFilterProxy::TYPE(TransactionRecord::Generated)); typeWidget->addItem(tr("Other"), TransactionFilterProxy::TYPE(TransactionRecord::Other)); hlayout->addWidget(typeWidget); addressWidget = new QLineEdit(this); #if QT_VERSION >= 0x040700 /* Do not move this to the XML file, Qt before 4.7 will choke on it */ addressWidget->setStyleSheet("background: black; font-size: 14px; selection-background-color: rgb(255, 170, 0, 145);"); addressWidget->setPlaceholderText(tr("Enter address or label to search")); addressWidget->setContentsMargins(0,0,0,0); #endif hlayout->addWidget(addressWidget); amountWidget = new QLineEdit(this); #if QT_VERSION >= 0x040700 /* Do not move this to the XML file, Qt before 4.7 will choke on it */ amountWidget->setStyleSheet("background: black; font-size: 14px; selection-background-color: rgb(255, 170, 0, 145);"); amountWidget->setPlaceholderText(tr("Min amount")); amountWidget->setContentsMargins(0,0,0,0); #endif #ifdef Q_OS_MAC amountWidget->setFixedWidth(97); #else amountWidget->setFixedWidth(100); #endif amountWidget->setValidator(new QDoubleValidator(0, 1e20, 8, this)); hlayout->addWidget(amountWidget); QVBoxLayout *vlayout = new QVBoxLayout(this); vlayout->setContentsMargins(0,0,0,0); vlayout->setSpacing(0); QTableView *view = new QTableView(this); vlayout->addLayout(hlayout); vlayout->addWidget(createDateRangeWidget()); vlayout->addWidget(view); vlayout->setSpacing(0); view->setAlternatingRowColors(false); int width = view->verticalScrollBar()->sizeHint().width(); // Cover scroll bar width with spacing #ifdef Q_OS_MAC hlayout->addSpacing(width+2); #else hlayout->addSpacing(width); #endif // Always show scroll bar view->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn); view->setTabKeyNavigation(false); view->setContextMenuPolicy(Qt::CustomContextMenu); transactionView = view; setStyleSheet("background: url(:/images/res/images/home-background.png); background-attachment: fixed; color: #ffaa00; selection-background-color: rgb(255, 170, 0, 145); selection-color: white; font-family: Plantagenet Cherokee; font-size: 14px;"); // Actions QAction *copyAddressAction = new QAction(tr("Copy address"), this); QAction *copyLabelAction = new QAction(tr("Copy label"), this); QAction *copyAmountAction = new QAction(tr("Copy amount"), this); QAction *copyTxIDAction = new QAction(tr("Copy transaction ID"), this); QAction *editLabelAction = new QAction(tr("Edit label"), this); QAction *showDetailsAction = new QAction(tr("Show transaction details"), this); QAction *viewOnPandachain = new QAction(tr("Show transaction on the Netcoin Block Explorer"), this); contextMenu = new QMenu(); contextMenu->setStyleSheet("background: url(:/images/res/images/dialogBackground.jpg); background-attachment: fixed; color: #ffaa00; selection-background-color: rgb(255, 170, 0, 145); font-family: Plantagenet Cherokee; font-size: 14px; selection-color: white;"); contextMenu->addAction(copyAddressAction); contextMenu->addAction(copyLabelAction); contextMenu->addAction(copyAmountAction); contextMenu->addAction(copyTxIDAction); contextMenu->addSeparator(); contextMenu->addAction(editLabelAction); contextMenu->addAction(showDetailsAction); contextMenu->addSeparator(); contextMenu->addAction(viewOnPandachain); // Connect actions connect(dateWidget, SIGNAL(activated(int)), this, SLOT(chooseDate(int))); connect(typeWidget, SIGNAL(activated(int)), this, SLOT(chooseType(int))); connect(addressWidget, SIGNAL(textChanged(QString)), this, SLOT(changedPrefix(QString))); connect(amountWidget, SIGNAL(textChanged(QString)), this, SLOT(changedAmount(QString))); connect(view, SIGNAL(doubleClicked(QModelIndex)), this, SIGNAL(doubleClicked(QModelIndex))); connect(view, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(contextualMenu(QPoint))); connect(copyAddressAction, SIGNAL(triggered()), this, SLOT(copyAddress())); connect(copyLabelAction, SIGNAL(triggered()), this, SLOT(copyLabel())); connect(copyAmountAction, SIGNAL(triggered()), this, SLOT(copyAmount())); connect(copyTxIDAction, SIGNAL(triggered()), this, SLOT(copyTxID())); connect(editLabelAction, SIGNAL(triggered()), this, SLOT(editLabel())); connect(showDetailsAction, SIGNAL(triggered()), this, SLOT(showDetails())); connect(viewOnPandachain, SIGNAL(triggered()), this, SLOT(viewOnPandachain())); }