Esempio n. 1
0
CountrySelect::CountrySelect() : QWidget(App::wnd()),
	_result("none"),
    _filter(this, st::inpCountry, lang(lng_country_ph)), _scroll(this, st::scrollCountries), _list(&_scroll),
    _doneButton(this, lang(lng_country_done), st::btnSelectDone),
    _cancelButton(this, lang(lng_cancel), st::btnSelectCancel),
    _innerLeft(0), _innerTop(0), _innerWidth(0), _innerHeight(0),
	a_alpha(0), a_bgAlpha(0), a_coord(st::countriesSlideShift), _shadow(st::boxShadow) {
	setGeometry(App::wnd()->rect());
	
	App::wnd()->topWidget(this);

	connect(App::wnd(), SIGNAL(resized(const QSize &)), this, SLOT(onParentResize(const QSize &)));
	connect(&_doneButton, SIGNAL(clicked()), this, SLOT(onCountryChoose()));
	connect(&_cancelButton, SIGNAL(clicked()), this, SLOT(onCountryCancel()));
	connect(&_scroll, SIGNAL(scrollFinished()), this, SLOT(onScrollFinished()));
	connect(&_scroll, SIGNAL(geometryChanged()), &_list, SLOT(onParentGeometryChanged()));
	connect(&_scroll, SIGNAL(scrolled()), &_list, SLOT(onUpdateSelected()));
	connect(&_list, SIGNAL(countrySelected()), this, SLOT(onCountryChoose()));
	connect(&_filter, SIGNAL(changed()), this, SLOT(onFilterUpdate()));
	connect(&_list, SIGNAL(mustScrollTo(int, int)), &_scroll, SLOT(scrollToY(int, int)));

	show();
	setFocus();
	_scroll.setWidget(&_list);
	_scroll.setFocusPolicy(Qt::NoFocus);

	prepareAnimation(0);
}
Esempio n. 2
0
void CountryList::mousePressEvent(QMouseEvent *e) {
	_mouseSel = true;
	_mousePos = mapToGlobal(e->pos());
	onUpdateSelected(true);

	emit countrySelected();
}
Esempio n. 3
0
void CountryList::onParentGeometryChanged() {
	_mousePos = QCursor::pos();
	if (rect().contains(mapFromGlobal(_mousePos))) {
		setMouseTracking(true);
		onUpdateSelected(true);
	}
}
Esempio n. 4
0
MainWindow::MainWindow( KDUpdater::Target * target, QWidget * parent )
    : QMainWindow(parent),
      m_target( target ),
      m_lastId(0),
      m_appDir( QFile::decodeName( EXAMPLE_APP_DIR ) )
{
    m_appDir.mkpath( QLatin1String("objects") );
    m_objectsDir = m_appDir;
    m_objectsDir.cd( QLatin1String("objects") );

    QToolBar *bar = addToolBar(tr("Actions"));
    bar->addAction(tr("Add Object 1"), this, SLOT(onAdd1()));
    bar->addAction(tr("Add Object 2"), this, SLOT(onAdd2()));
    bar->addAction(tr("Update Objects"), this, SLOT(onUpdateSelected()));
    bar->addAction( tr( "Update" ), this, SLOT(onUpdate()) );
    bar->addAction( tr( "Update Compat" ), this, SLOT(onUpdateCompat()) );

    m_table = new QTableWidget(this);
    m_table->verticalHeader()->hide();
    m_table->setSelectionBehavior(QTableWidget::SelectRows);
    setCentralWidget(m_table);

    loadApplicationData();

    QStringList devices = m_objectsDir.entryList();
    Q_FOREACH( const QString & object, devices ) {
        if ( object.contains( QLatin1Char('.') ) ) continue;

        bool ok;
        int id = object.toInt(&ok);

        if (!ok) continue;

        if (id>m_lastId) m_lastId = id;

        int row = m_table->rowCount();
        m_table->insertRow(m_table->rowCount());
        displayObject(id, row);
    }
}