KSelectTransactionsDlg::KSelectTransactionsDlg(const MyMoneyAccount& _account, QWidget* parent) : KSelectTransactionsDlgDecl(parent), m_account(_account) { // setup descriptive texts setWindowTitle(i18n("Select Transaction")); m_description->setText(i18n("Select a transaction and press the OK button or use Cancel to select none.")); // clear current register contents m_register->clear(); // no selection possible m_register->setSelectionMode(QTableWidget::SingleSelection); // setup header font QFont font = KMyMoneyGlobalSettings::listHeaderFont(); QFontMetrics fm(font); int height = fm.lineSpacing() + 6; m_register->horizontalHeader()->setMinimumHeight(height); m_register->horizontalHeader()->setMaximumHeight(height); m_register->horizontalHeader()->setFont(font); // setup cell font font = KMyMoneyGlobalSettings::listCellFont(); m_register->setFont(font); // ... setup the register columns ... m_register->setupRegister(m_account); // setup buttons m_helpButton->setGuiItem(KStandardGuiItem::help()); buttonOk->setGuiItem(KStandardGuiItem::ok()); buttonCancel->setGuiItem(KStandardGuiItem::cancel()); // default is to need at least one transaction selected buttonOk->setDisabled(true); // catch some events from the register m_register->installEventFilter(this); connect(m_register, SIGNAL(transactionsSelected(KMyMoneyRegister::SelectedTransactions)), this, SLOT(slotEnableOk(KMyMoneyRegister::SelectedTransactions))); connect(m_register, SIGNAL(editTransaction()), this, SLOT(accept())); connect(m_helpButton, SIGNAL(clicked()), this, SLOT(slotHelp())); }
KTagsView::KTagsView(QWidget *parent) : QWidget(parent), m_needReload(false), m_inSelection(false), m_allowEditing(true), m_tagFilterType(0) { setupUi(this); m_filterProxyModel = new AccountNamesFilterProxyModel(this); m_filterProxyModel->addAccountGroup(MyMoneyAccount::Asset); m_filterProxyModel->addAccountGroup(MyMoneyAccount::Liability); m_filterProxyModel->addAccountGroup(MyMoneyAccount::Income); m_filterProxyModel->addAccountGroup(MyMoneyAccount::Expense); m_filterProxyModel->setSourceModel(Models::instance()->accountsModel()); m_filterProxyModel->sort(0); // create the searchline widget // and insert it into the existing layout m_searchWidget = new KListWidgetSearchLine(this, m_tagsList); m_searchWidget->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed)); m_tagsList->setContextMenuPolicy(Qt::CustomContextMenu); m_listTopHLayout->insertWidget(0, m_searchWidget); //load the filter type m_filterBox->addItem(i18nc("@item Show all tags", "All")); m_filterBox->addItem(i18nc("@item Show only used tags", "Used")); m_filterBox->addItem(i18nc("@item Show only unused tags", "Unused")); m_filterBox->addItem(i18nc("@item Show only opened tags", "Opened")); m_filterBox->addItem(i18nc("@item Show only closed tags", "Closed")); m_filterBox->setSizeAdjustPolicy(QComboBox::AdjustToContents); KGuiItem newButtonItem(QString(""), QIcon::fromTheme("list-add-tag"), i18n("Creates a new tag"), i18n("Use this to create a new tag.")); KGuiItem::assign(m_newButton, newButtonItem); m_newButton->setToolTip(newButtonItem.toolTip()); KGuiItem renameButtonItem(QString(""), QIcon::fromTheme("edit-rename"), i18n("Rename the current selected tag"), i18n("Use this to start renaming the selected tag.")); KGuiItem::assign(m_renameButton, renameButtonItem); m_renameButton->setToolTip(renameButtonItem.toolTip()); KGuiItem deleteButtonItem(QString(""), QIcon::fromTheme("list-remove-tag"), i18n("Delete the current selected tag"), i18n("Use this to delete the selected tag.")); KGuiItem::assign(m_deleteButton, deleteButtonItem); m_deleteButton->setToolTip(deleteButtonItem.toolTip()); KGuiItem updateButtonItem(i18nc("Update tag", "Update"), QIcon::fromTheme("dialog-ok"), i18n("Accepts the entered data and stores it"), i18n("Use this to accept the modified data.")); KGuiItem::assign(m_updateButton, updateButtonItem); m_updateButton->setEnabled(false); QList<KMyMoneyRegister::Column> cols; cols << KMyMoneyRegister::DateColumn; cols << KMyMoneyRegister::AccountColumn; cols << KMyMoneyRegister::DetailColumn; cols << KMyMoneyRegister::ReconcileFlagColumn; cols << KMyMoneyRegister::PaymentColumn; cols << KMyMoneyRegister::DepositColumn; m_register->setupRegister(MyMoneyAccount(), cols); m_register->setSelectionMode(QTableWidget::SingleSelection); m_register->setDetailsColumnType(KMyMoneyRegister::AccountFirst); m_balanceLabel->hide(); connect(m_tagsList, SIGNAL(currentItemChanged(QListWidgetItem*,QListWidgetItem*)), this, SLOT(slotSelectTag(QListWidgetItem*,QListWidgetItem*))); connect(m_tagsList, SIGNAL(itemSelectionChanged()), this, SLOT(slotSelectTag())); connect(m_tagsList, SIGNAL(itemDoubleClicked(QListWidgetItem*)), this, SLOT(slotStartRename(QListWidgetItem*))); connect(m_tagsList, SIGNAL(itemChanged(QListWidgetItem*)), this, SLOT(slotRenameTag(QListWidgetItem*))); connect(m_tagsList, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(slotOpenContextMenu(QPoint))); connect(m_renameButton, SIGNAL(clicked()), this, SLOT(slotRenameButtonCliked())); connect(m_deleteButton, SIGNAL(clicked()), kmymoney->action("tag_delete"), SLOT(trigger())); connect(m_newButton, SIGNAL(clicked()), this, SLOT(slotTagNew())); connect(m_colorbutton, SIGNAL(changed(QColor)), this, SLOT(slotTagDataChanged())); connect(m_closed, SIGNAL(stateChanged(int)), this, SLOT(slotTagDataChanged())); connect(m_notes, SIGNAL(textChanged()), this, SLOT(slotTagDataChanged())); connect(m_updateButton, SIGNAL(clicked()), this, SLOT(slotUpdateTag())); connect(m_helpButton, SIGNAL(clicked()), this, SLOT(slotHelp())); connect(m_register, SIGNAL(editTransaction()), this, SLOT(slotSelectTransaction())); connect(MyMoneyFile::instance(), SIGNAL(dataChanged()), this, SLOT(slotLoadTags())); connect(m_filterBox, SIGNAL(currentIndexChanged(int)), this, SLOT(slotChangeFilter(int))); // use the size settings of the last run (if any) KConfigGroup grp = KSharedConfig::openConfig()->group("Last Use Settings"); m_splitter->restoreState(grp.readEntry("KTagsViewSplitterSize", QByteArray())); m_splitter->setChildrenCollapsible(false); // At start we haven't any tag selected m_tabWidget->setEnabled(false); // disable tab widget m_deleteButton->setEnabled(false); // disable delete and rename button m_renameButton->setEnabled(false); m_tag = MyMoneyTag(); // make sure we don't access an undefined tag clearItemData(); }