MoodLineEdit::MoodLineEdit(QWidget *parent) : QAbstractButton( parent ) { setText(""); setToolTip(""); lineEdit = new QLineEdit("", this ); lineEdit->hide(); lineEdit->installEventFilter( this ); this->setSizePolicy( lineEdit->sizePolicy() ); connect( this, SIGNAL(clicked()), this, SLOT(slotEditStarted()) ); connect( lineEdit, SIGNAL(editingFinished()), this, SLOT(slotEditFinished()) ); }
KSplitTransactionDlg::KSplitTransactionDlg(const MyMoneyTransaction& t, const MyMoneySplit& s, const MyMoneyAccount& acc, const bool amountValid, const bool deposit, const MyMoneyMoney& calculatedValue, const QMap<QString, MyMoneyMoney>& priceInfo, QWidget* parent) : KSplitTransactionDlgDecl(parent), m_account(acc), m_split(s), m_precision(2), m_amountValid(amountValid), m_isDeposit(deposit), m_calculatedValue(calculatedValue) { setModal(true); QHBoxLayout *mainLayout = new QHBoxLayout; setLayout(mainLayout); mainLayout->addWidget(horizontalLayoutWidget); m_buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok|QDialogButtonBox::Cancel); QPushButton *okButton = m_buttonBox->button(QDialogButtonBox::Ok); okButton->setDefault(true); okButton->setShortcut(Qt::CTRL | Qt::Key_Return); QPushButton *user1Button = new QPushButton; m_buttonBox->addButton(user1Button, QDialogButtonBox::ActionRole); QPushButton *user2Button = new QPushButton; m_buttonBox->addButton(user2Button, QDialogButtonBox::ActionRole); QPushButton *user3Button = new QPushButton; m_buttonBox->addButton(user3Button, QDialogButtonBox::ActionRole); connect(m_buttonBox, SIGNAL(accepted()), this, SLOT(accept())); connect(m_buttonBox, SIGNAL(rejected()), this, SLOT(reject())); m_buttonBox->setOrientation(Qt::Vertical); mainLayout->addWidget(m_buttonBox); //set custom buttons //clearAll button user1Button->setText(i18n("Clear &All")); user1Button->setToolTip(i18n("Clear all splits")); user1Button->setWhatsThis(i18n("Use this to clear all splits of this transaction")); user1Button->setIcon(QIcon::fromTheme("edit-clear")); //clearZero button user2Button->setText(i18n("Clear &Zero")); user2Button->setToolTip(i18n("Removes all splits that have a value of zero")); user2Button->setIcon(QIcon::fromTheme("edit-clear")); //merge button user3Button->setText(i18n("&Merge")); user3Button->setToolTip(i18n("Merges splits with the same category to one split")); user3Button->setWhatsThis(i18n("In case you have multiple split entries to the same category and you like to keep them as a single split")); // make finish the default m_buttonBox->button(QDialogButtonBox::Cancel)->setDefault(true); // setup the focus m_buttonBox->button(QDialogButtonBox::Cancel)->setFocusPolicy(Qt::NoFocus); okButton->setFocusPolicy(Qt::NoFocus); user1Button->setFocusPolicy(Qt::NoFocus); // connect signals with slots connect(transactionsTable, SIGNAL(transactionChanged(MyMoneyTransaction)), this, SLOT(slotSetTransaction(MyMoneyTransaction))); connect(transactionsTable, SIGNAL(createCategory(QString,QString&)), this, SLOT(slotCreateCategory(QString,QString&))); connect(transactionsTable, SIGNAL(objectCreation(bool)), this, SIGNAL(objectCreation(bool))); connect(transactionsTable, SIGNAL(returnPressed()), this, SLOT(accept())); connect(transactionsTable, SIGNAL(escapePressed()), this, SLOT(reject())); connect(transactionsTable, SIGNAL(editStarted()), this, SLOT(slotEditStarted())); connect(transactionsTable, SIGNAL(editFinished()), this, SLOT(slotUpdateButtons())); connect(m_buttonBox->button(QDialogButtonBox::Cancel), SIGNAL(clicked()), this, SLOT(reject())); connect(m_buttonBox->button(QDialogButtonBox::Ok), SIGNAL(clicked()), this, SLOT(accept())); connect(user1Button, SIGNAL(clicked()), this, SLOT(slotClearAllSplits())); connect(user3Button, SIGNAL(clicked()), this, SLOT(slotMergeSplits())); connect(user2Button, SIGNAL(clicked()), this, SLOT(slotClearUnusedSplits())); // setup the precision try { MyMoneySecurity currency = MyMoneyFile::instance()->currency(t.commodity()); m_precision = MyMoneyMoney::denomToPrec(m_account.fraction(currency)); } catch (const MyMoneyException &) { } slotSetTransaction(t); // pass on those vars transactionsTable->setup(priceInfo, m_precision); QSize size(width(), height()); KConfigGroup grp = KSharedConfig::openConfig()->group("SplitTransactionEditor"); size = grp.readEntry("Geometry", size); size.setHeight(size.height() - 1); QDialog::resize(size.expandedTo(minimumSizeHint())); // Trick: it seems, that the initial sizing of the dialog does // not work correctly. At least, the columns do not get displayed // correct. Reason: the return value of transactionsTable->visibleWidth() // is incorrect. If the widget is visible, resizing works correctly. // So, we let the dialog show up and resize it then. It's not really // clean, but the only way I got the damned thing working. QTimer::singleShot(10, this, SLOT(initSize())); }