AddressBookModel::AddressBookModel(QObject *parent, AddressBook *addressBook)
    : QAbstractListModel(parent) , m_addressBook(addressBook)
{
    qDebug(__FUNCTION__);
    connect(m_addressBook,SIGNAL(refreshStarted()),this,SLOT(startReset()));
    connect(m_addressBook,SIGNAL(refreshFinished()),this,SLOT(endReset()));

}
Exemple #2
0
O2Requestor::O2Requestor(QNetworkAccessManager *manager, O2 *authenticator, QObject *parent): QObject(parent), reply_(NULL), status_(Idle)
{
    manager_ = manager;
    authenticator_ = authenticator;
    if (authenticator) {
        timedReplies_.setIgnoreSslErrors(authenticator->ignoreSslErrors());
    }
    qRegisterMetaType<QNetworkReply::NetworkError>("QNetworkReply::NetworkError");
    connect(authenticator, SIGNAL(refreshFinished(QNetworkReply::NetworkError)), this, SLOT(onRefreshFinished(QNetworkReply::NetworkError)), Qt::QueuedConnection);
}
QList<TransactionInfo *> TransactionHistory::getAll(quint32 accountIndex) const
{
    // XXX this invalidates previously saved history that might be used by model
    emit refreshStarted();
    qDeleteAll(m_tinfo);
    m_tinfo.clear();

    QDateTime firstDateTime = QDateTime(QDate(2014, 4, 18)); // the genesis block
    QDateTime lastDateTime  = QDateTime::currentDateTime().addDays(1); // tomorrow (guard against jitter and timezones)
    quint64 lastTxHeight = 0;
    m_locked = false;
    m_minutesToUnlock = 0;
    TransactionHistory * parent = const_cast<TransactionHistory*>(this);
    for (const auto i : m_pimpl->getAll()) {
        TransactionInfo * ti = new TransactionInfo(i, parent);
        if (ti->subaddrAccount() != accountIndex) {
            delete ti;
            continue;
        }
        m_tinfo.append(ti);
        // looking for transactions timestamp scope
        if (ti->timestamp() >= lastDateTime) {
            lastDateTime = ti->timestamp();
        }
        if (ti->timestamp() <= firstDateTime) {
            firstDateTime = ti->timestamp();
        }
        quint64 requiredConfirmations = (ti->blockHeight() < ti->unlockTime()) ? ti->unlockTime() - ti->blockHeight() : 10;
        // store last tx height
        if (ti->confirmations() < requiredConfirmations && ti->blockHeight() >= lastTxHeight) {
            lastTxHeight = ti->blockHeight();
            // TODO: Fetch block time and confirmations needed from wallet2?
            m_minutesToUnlock = (requiredConfirmations - ti->confirmations()) * 2;
            m_locked = true;
        }

    }
    emit refreshFinished();

    if (m_firstDateTime != firstDateTime) {
        m_firstDateTime = firstDateTime;
        emit firstDateTimeChanged();
    }
    if (m_lastDateTime != lastDateTime) {
        m_lastDateTime = lastDateTime;
        emit lastDateTimeChanged();
    }

    return m_tinfo;
}
Exemple #4
0
MainWindow::MainWindow()
: KXmlGuiWindow()
{
    QWidget* mainWidget = new QWidget;
    setCentralWidget( mainWidget );

    QVBoxLayout* layout = new QVBoxLayout;
    layout->setMargin( 0 );
    layout->setSpacing( 0 );
    mainWidget->setLayout( layout );

    m_searchEdit = new KLineEdit;
    m_searchEdit->setClearButtonShown( true );
    m_searchEdit->setClickMessage( i18n( "Type here to start searching..." ) );
    layout->addWidget( m_searchEdit );

    m_listView = new QListView;
    m_proxyModel = new QSortFilterProxyModel( this );
    m_listModel = new CleanerModel( this );
    m_proxyModel->setFilterCaseSensitivity( Qt::CaseInsensitive );
    m_proxyModel->setSortRole( Qt::UserRole );
    m_proxyModel->setSourceModel( m_listModel );
    m_listView->setSelectionMode( QAbstractItemView::NoSelection );
    m_listView->setUniformItemSizes( true );
    m_listView->setHorizontalScrollBarPolicy( Qt::ScrollBarAlwaysOff );
    m_listView->setModel( m_proxyModel );
    layout->addWidget( m_listView );

    QHBoxLayout* buttonLayout = new QHBoxLayout;
    buttonLayout->setMargin( 0 );
    buttonLayout->setSpacing( 0 );
    layout->addLayout( buttonLayout );

    m_refreshButton = new KPushButton( i18n( "Refresh" ) );
    m_refreshButton->setIcon( KIcon( "view-refresh" ) );
    buttonLayout->addWidget( m_refreshButton );
    connect( m_refreshButton, SIGNAL(clicked()), m_listModel, SLOT(refresh()) );

    m_cleanupButton = new KPushButton( i18n( "Clean up..." ) );
    m_cleanupButton->setIcon( KIcon( "edit-clear" ) );
    buttonLayout->addWidget( m_cleanupButton );
    connect( m_cleanupButton, SIGNAL(clicked()), m_listModel, SLOT(saolaji()) );

    m_cancelProfileButton = new KPushButton( i18n( "Cancel" ) );
    buttonLayout->addWidget( m_cancelProfileButton );
    connect( m_cancelProfileButton, SIGNAL(clicked()), this, SLOT(cancelProfile()) );

    m_saveProfileButton = new KPushButton( i18n( "Save" ) );
    buttonLayout->addWidget( m_saveProfileButton );
    connect( m_saveProfileButton, SIGNAL(clicked()), this, SLOT(saveProfile()) );

    m_cancelProfileButton->hide();
    m_saveProfileButton->hide();
    m_editingProfile = 0;

    KAction* knsDownloadAction = actionCollection()->addAction( "kns_download" );
    knsDownloadAction->setText( i18n( "&Download scripts..." ) );
    knsDownloadAction->setIcon( KIcon( "get-hot-new-stuff" ) );
    connect( knsDownloadAction, SIGNAL(triggered()), this, SLOT(knsDownload()) );

    KAction* newProfileAction = actionCollection()->addAction( "new_profile" );
    newProfileAction->setText( i18n( "New profile..." ) );
    newProfileAction->setIcon( KIcon( "bookmark-new" ) );
    connect( newProfileAction, SIGNAL(triggered()), this, SLOT(newProfile()) );

    connect( m_searchEdit, SIGNAL(textChanged(QString)), this, SLOT(filterList(QString)) );
    connect( m_listModel, SIGNAL(refreshFinished()), this, SLOT(sortList()) );

    KStandardAction::selectAll( m_listModel, SLOT(selectAll()), actionCollection() );
    KStandardAction::deselect( m_listModel, SLOT(deselect()), actionCollection() );
    KStandardAction::quit( this, SLOT(close()), actionCollection() );

    setupGUI( KXmlGuiWindow::Keys | KXmlGuiWindow::Save | KXmlGuiWindow::Create );

    m_selectProfileSignalMapper = new QSignalMapper( this );
    connect( m_selectProfileSignalMapper, SIGNAL(mapped(QObject*)),
             this, SLOT(selectProfile(QObject*)) );
    m_editProfileSignalMapper = new QSignalMapper( this );
    connect( m_editProfileSignalMapper, SIGNAL(mapped(QObject*)),
             this, SLOT(editProfile(QObject*)) );
    m_deleteProfileSignalMapper = new QSignalMapper( this );
    connect( m_deleteProfileSignalMapper, SIGNAL(mapped(QObject*)),
             this, SLOT(deleteProfile(QObject*)) );

    QTimer::singleShot( 0, this, SLOT(setupProfileActions()) );
}