示例#1
0
void KACLEditWidget::setReadOnly( bool on )
{
    m_listView->setEnabled( !on );
    m_AddBtn->setEnabled( !on );
    if ( !on )
      slotUpdateButtons();
}
示例#2
0
void IntegrationPreferences::slotDecreasePriority()
{
    const int row = ui.list->currentIndex().row();
    m_model->moveItem(row, row + 2);
    slotUpdateButtons();
    emit changed();
}
示例#3
0
IntegrationPreferences::IntegrationPreferences(KConfigDialog *parent, Qt::WindowFlags f)
  : QWidget(parent, f)
{
    ui.setupUi(this);

    //AutoPaste stuff
    ui.type->addItem(KIcon("list-add"), i18n("Include"), AutoPasteModel::Include);
    ui.type->addItem(KIcon("list-remove"), i18n("Exclude"), AutoPasteModel::Exclude);

    ui.patternSyntax->addItem(i18n("Escape sequences"), AutoPasteModel::Wildcard);
    ui.patternSyntax->addItem(i18n("Regular expression"), AutoPasteModel::RegExp);

    ui.add->setGuiItem(KStandardGuiItem::add());
    ui.remove->setGuiItem(KStandardGuiItem::remove());
    ui.increase->setIcon(KIcon("arrow-up"));
    ui.decrease->setIcon(KIcon("arrow-down"));

    m_model = new AutoPasteModel(this);
    m_model->load();
    ui.list->setModel(m_model);
    AutoPasteDelegate *delegate = new AutoPasteDelegate(ui.type->model(), ui.patternSyntax->model(), this);
    ui.list->setItemDelegate(delegate);

    QByteArray loadedState = QByteArray::fromBase64(Settings::autoPasteHeaderState().toAscii());
    if (Settings::autoPasteHeaderState().isEmpty()) {
        ui.list->resizeColumnToContents(AutoPasteModel::Type);
    } else if (!loadedState.isNull()) {
        ui.list->header()->restoreState(loadedState);
    }

    connect(m_model, SIGNAL(dataChanged(QModelIndex,QModelIndex)), this, SIGNAL(changed()));
    connect(ui.list->selectionModel(), SIGNAL(selectionChanged(QItemSelection,QItemSelection)), this, SLOT(slotUpdateButtons()));
    connect(ui.pattern, SIGNAL(textChanged(QString)), this, SLOT(slotUpdateButtons()));
    connect(ui.pattern, SIGNAL(returnPressed(QString)), this, SLOT(slotAddItem()));
    connect(ui.add, SIGNAL(clicked()), this, SLOT(slotAddItem()));
    connect(ui.remove, SIGNAL(clicked()), this, SLOT(slotRemoveItem()));
    connect(ui.increase, SIGNAL(clicked()), this, SLOT(slotIncreasePriority()));
    connect(ui.decrease, SIGNAL(clicked()), this, SLOT(slotDecreasePriority()));
    connect(parent, SIGNAL(rejected()), m_model, SLOT(load()));
    connect(parent, SIGNAL(applyClicked()), m_model, SLOT(save()));
    connect(parent, SIGNAL(okClicked()), m_model, SLOT(save()));
    connect(parent, SIGNAL(defaultClicked()), m_model, SLOT(resetDefaults()));

    slotUpdateButtons();
}
示例#4
0
KACLEditWidget::KACLEditWidget(QWidget *parent, const char *name) : QWidget(parent, name)
{
    QHBox *hbox = new QHBox(parent);
    hbox->setSpacing(KDialog::spacingHint());
    m_listView = new KACLListView(hbox, "acl_listview");
    connect(m_listView, SIGNAL(selectionChanged()), this, SLOT(slotUpdateButtons()));
    QVBox *vbox = new QVBox(hbox);
    vbox->setSpacing(KDialog::spacingHint());
    m_AddBtn = new QPushButton(i18n("Add Entry..."), vbox, "add_entry_button");
    connect(m_AddBtn, SIGNAL(clicked()), m_listView, SLOT(slotAddEntry()));
    m_EditBtn = new QPushButton(i18n("Edit Entry..."), vbox, "edit_entry_button");
    connect(m_EditBtn, SIGNAL(clicked()), m_listView, SLOT(slotEditEntry()));
    m_DelBtn = new QPushButton(i18n("Delete Entry"), vbox, "delete_entry_button");
    connect(m_DelBtn, SIGNAL(clicked()), m_listView, SLOT(slotRemoveEntry()));
    QWidget *spacer = new QWidget(vbox);
    spacer->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Expanding);
    slotUpdateButtons();
}
示例#5
0
IMEditorDialog::IMEditorDialog(QWidget *parent)
    : QDialog(parent)
{
    setWindowTitle(i18nc("@title:window", "Edit Instant Messaging Addresses"));
    QVBoxLayout *mainLayout = new QVBoxLayout;
    setLayout(mainLayout);

    QWidget *widget = new QWidget(this);
    mainLayout->addWidget(widget);

    QGridLayout *layout = new QGridLayout(widget);
    layout->setMargin(0);

    mAddButton = new QPushButton(i18nc("@action:button", "Add..."));
    mEditButton = new QPushButton(i18nc("@action:button", "Edit..."));
    mRemoveButton = new QPushButton(i18nc("@action:button", "Remove"));
    mStandardButton = new QPushButton(i18nc("@action:button", "Set as Standard"));

    mView = new QTreeView;
    mView->setRootIsDecorated(false);

    layout->addWidget(mView, 0, 0, 5, 1);
    layout->addWidget(mAddButton, 0, 1);
    layout->addWidget(mEditButton, 1, 1);
    layout->addWidget(mRemoveButton, 2, 1);
    layout->addWidget(mStandardButton, 3, 1);
    layout->setRowStretch(4, 1);

    connect(mAddButton, &QPushButton::clicked, this, &IMEditorDialog::slotAdd);
    connect(mEditButton, &QPushButton::clicked, this, &IMEditorDialog::slotEdit);
    connect(mRemoveButton, &QPushButton::clicked, this, &IMEditorDialog::slotRemove);
    connect(mStandardButton, &QPushButton::clicked, this, &IMEditorDialog::slotSetStandard);

    mModel = new IMModel(this);

    mView->setModel(mModel);
    mView->setItemDelegate(new IMDelegate(this));

    connect(mView->selectionModel(), &QItemSelectionModel::currentChanged,
            this, &IMEditorDialog::slotUpdateButtons);
    connect(mView, &QTreeView::doubleClicked, this, &IMEditorDialog::slotEdit);
    QDialogButtonBox *buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
    QPushButton *okButton = buttonBox->button(QDialogButtonBox::Ok);
    okButton->setDefault(true);
    okButton->setShortcut(Qt::CTRL | Qt::Key_Return);
    connect(buttonBox, &QDialogButtonBox::accepted, this, &IMEditorDialog::accept);
    connect(buttonBox, &QDialogButtonBox::rejected, this, &IMEditorDialog::reject);
    mainLayout->addWidget(buttonBox);

    slotUpdateButtons();
    readConfig();
}
IMEditorWidget::IMEditorWidget( QWidget *parent, const QString &preferredIM )
  : KDialog( parent ), mReadOnly( false )
{
  setCaption( i18n( "Edit Instant Messaging Address" ) );
  setButtons( Help | Ok | Cancel );
  setDefaultButton( Ok );
  QWidget *w = new QWidget(this);
  mWidget = new Ui_IMEditorBase();
  mWidget->setupUi( w );
  setMainWidget(w);
  connect( mWidget->btnAdd, SIGNAL( clicked() ), SLOT( slotAdd() ) );
  connect( mWidget->btnEdit, SIGNAL( clicked() ), SLOT( slotEdit() ) );
  connect( mWidget->btnDelete, SIGNAL( clicked() ), SLOT( slotDelete() ) );
  connect( mWidget->btnSetStandard, SIGNAL( clicked()), SLOT( slotSetStandard() ) );
  connect( mWidget->lvAddresses, SIGNAL( itemSelectionChanged() ), SLOT( slotUpdateButtons() ) );

  connect( mWidget->lvAddresses, SIGNAL( itemDoubleClicked( QTreeWidgetItem *, int ) ),
           SLOT( slotEdit() ) );

  setHelp( "managing-contacts-im-addresses", "kaddressbook" );

  mWidget->btnEdit->setEnabled( false );
  mWidget->btnDelete->setEnabled( false );
  mWidget->btnSetStandard->setEnabled( false );
  // Disabled pending implementation
  //mWidget->btnUp->setEnabled( false );
  //mWidget->btnDown->setEnabled( false );
  mPreferred = preferredIM;
  mPreferred = mPreferred.replace( " on ", QString( QChar( 0xE120 ) ), Qt::CaseSensitive );
  mProtocols = KPluginInfo::fromServices(
    KServiceTypeTrader::self()->query( QString::fromLatin1( "KABC/IMProtocol" ) ) );

  // order the protocols by putting them in a qmap, then sorting
  // the set of keys and recreating the list
  QMap<QString, KPluginInfo> protocolMap;
  QList<KPluginInfo>::ConstIterator it;
  QList<KPluginInfo> sorted;
  for ( it = mProtocols.constBegin(); it != mProtocols.constEnd(); ++it ) {
    protocolMap.insert( it->name(), (*it) );
  }

  QStringList keys = protocolMap.keys();
  keys.sort();
  QStringList::ConstIterator keyIt = keys.constBegin();
  QStringList::ConstIterator end = keys.constEnd();
  for ( ; keyIt != end; ++keyIt ) {
    sorted.append( protocolMap[*keyIt] );
  }
  mProtocols = sorted;
}
CustomFieldsEditWidget::CustomFieldsEditWidget( QWidget *parent )
  : QWidget( parent ), mReadOnly( false )
{
  QGridLayout *layout = new QGridLayout( this );
  layout->setMargin( 0 );



  mView = new QTreeView;
  mView->setSortingEnabled(true);
  mView->setRootIsDecorated( false );
  mView->setItemDelegate( new CustomFieldsDelegate( this ) );

  mAddButton = new QPushButton( i18n( "Add..." ) );
  mEditButton = new QPushButton( i18n( "Edit..." ) );
  mRemoveButton = new QPushButton( i18n( "Remove" ) );

  layout->addWidget( mView, 0, 0, 4, 1 );
  layout->addWidget( mAddButton, 0, 1 );
  layout->addWidget( mEditButton, 1, 1 );
  layout->addWidget( mRemoveButton, 2, 1 );

  mModel = new CustomFieldsModel( this );
  QSortFilterProxyModel *proxyModel = new QSortFilterProxyModel;
  proxyModel->setDynamicSortFilter(true);
  proxyModel->setSourceModel(mModel);
  mView->setModel( proxyModel );
  mView->setColumnHidden( 2, true ); // hide the 'key' column

  connect( mView->selectionModel(), SIGNAL(currentChanged(QModelIndex,QModelIndex)),
           this, SLOT(slotUpdateButtons()) );
  connect( mAddButton, SIGNAL(clicked()), this, SLOT(slotAdd()) );
  connect( mEditButton, SIGNAL(clicked()), this, SLOT(slotEdit()) );
  connect( mRemoveButton, SIGNAL(clicked()), this, SLOT(slotRemove()) );
  slotUpdateButtons();
}
void IMEditorWidget::setReadOnly( bool readOnly )
{
  mReadOnly = readOnly;
  slotUpdateButtons();
}
示例#9
0
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()));
}
示例#10
0
void KSplitTransactionDlg::slotSetTransaction(const MyMoneyTransaction& t)
{
    m_transaction = t;
    slotUpdateButtons();
    updateSums();
}