示例#1
0
void MadsPlayer::idle() {
	if (_direction != _newDirection) {
		// The direction has changed, so reset for new direction
		dirChanged();
		return;
	}

	SpriteAsset &spriteSet = _madsVm->scene()->_spriteSlots.getSprite(_spriteListStart + _spriteListIdx);
	assert(spriteSet._charInfo);
	if (spriteSet._charInfo->_numEntries == 0)
		// No entries, so exit immediately
		return;

	int frameIndex = ABS(_frameListIndex);
	int direction = (_frameListIndex < 0) ? -1 : 1;

	if (frameIndex >= spriteSet._charInfo->_numEntries)
		// Reset back to the start of the list
		_frameListIndex = 0;
	else {
		_frameNum += direction;
		_forceRefresh = true;

		if (spriteSet._charInfo->_frameList2[frameIndex] < _frameNum) {
			_unk3 = _unk2;
			updateFrame();
		}
		if (spriteSet._charInfo->_frameList[frameIndex] < _frameNum) {
			_unk3 = _unk2;
			updateFrame();
		}
	}
}
示例#2
0
bool
BrowseModel::list_cb (const Xmms::List< Xmms::Dict > &res)
{
	while (!m_list.isEmpty ()) {
		delete m_list.takeFirst ();
	}

	for (res.first (); res.isValid (); ++res) {
		Xmms::Dict d = *res;

		if (!d.contains ("path"))
			continue;

		QString path = QString::fromStdString (d.get<std::string> ("path"));

		QString name;
		if (d.contains ("name")) {
			name = QString::fromStdString (d.get<std::string> ("name"));
		} else {
			if (d.contains ("title")) {
				if (d.contains ("artist")) {
					name += QString::fromStdString (d.get<std::string> ("artist"));
					name += " - ";
				}
				if (d.contains ("album")) {
					name += QString::fromStdString (d.get<std::string> ("album"));
					name += " - ";
				}
				if (d.contains ("tracknr")) {
					name += QString::number (d.get<uint32_t>
											 ("tracknr")).rightJustified(2, '0');
					name += " - ";
				}
				name += QString::fromStdString (d.get<std::string> ("title"));
			} else {
				std::string tmp;
				QString tmp2 = path.mid (path.lastIndexOf ("/")+1);
				tmp = Xmms::decodeUrl (tmp2.toAscii ());
				name = QString::fromUtf8 (tmp.c_str ());
			}
		}

		bool isdir = d.get<int32_t> ("isdir");

		if (m_filter_dot && name.startsWith ("."))
			// skip these files 
			continue;

		m_list.append (new BrowseModelItem (path, name, isdir));
	}

	qSort (m_list.begin (), m_list.end (), BrowseModelItem::itemCompare);

	reset ();

	emit dirChanged (m_current_dir);

	return true;
}
void QextFileSystemController::refresh()
{
    Q_D(QextFileSystemController);
    QDir oldPath = d->fsModel->rootDirectory();
    d->doChDir(d->currentLocation);
    if (oldPath!=d->currentLocation)
        emit dirChanged(d->currentLocation);
    emit canBackward(d->canGoPrev());
    emit canFordward(d->canGoNext());
    emit canUp(d->canGoUp());
}
示例#4
0
void
BrowseModel::list_root ()
{
	while (!m_list.isEmpty ()) {
		delete m_list.takeFirst ();
	}

	m_list.append (new BrowseModelItem ("file:///", "Files", true));
	m_list.append (new BrowseModelItem ("daap://", "DAAP", true));
	emit dirChanged ("");

	reset ();

	m_current_dir = "";
}
JulyMoveDialog::JulyMoveDialog(QWidget *parent)
	: QWidget(parent)
{
	wasDropboxStarted=false;
	dropBoxAppFile=QDesktopServices::storageLocation(QDesktopServices::ApplicationsLocation).replace("\\","/")+"/Dropbox/Dropbox.lnk";
	if(QFile::exists(dropBoxAppFile))
	{
		dropBoxAppFile=QFileInfo(dropBoxAppFile).symLinkTarget();
		if(!QFile::exists(dropBoxAppFile))dropBoxAppFile="";
	}	else	dropBoxAppFile="";

	ui.setupUi(this);
	setWindowModality(Qt::ApplicationModal);
	setWindowFlags(Qt::Tool);

	scanDir = new JulyScanDir(this);
	scanDir->setFilesFilter("*");
    scanDir->setSearchSubFolders(true);
    scanDir->setSearchHidden(true);
	connect(scanDir,SIGNAL(fileChanged(QString)),this,SLOT(fileChanged(QString)));
	connect(scanDir,SIGNAL(loadedList(QStringList)),this,SLOT(loadedList(QStringList)));
	connect(scanDir,SIGNAL(dirChanged(QString)),this,SLOT(dirChanged(QString)));
	connect(scanDir,SIGNAL(errorHeppend(int)),this,SLOT(errorHeppend(int)));
}
示例#6
0
///Constructor
tetgen_options::tetgen_options(SoPath *path, QWidget *p, Qt::WindowFlags f) : QDialog(p, f)
{
	Ui.setupUi(this);

	input = path;
	output = NULL;

	//Conecta todos los controles y actualiza los argumentos por primera vez
	connect(Ui.spinBox_q, SIGNAL(valueChanged(double)),this,SLOT(argsChanged()));
	connect(Ui.spinBox_a, SIGNAL(valueChanged(double)),this,SLOT(argsChanged()));
	Ui.outputDirectory->setText(QDir::currentPath());
	connect(Ui.outputDirectoryButton, SIGNAL(pressed()),this,SLOT(dirChanged()));

	argsChanged();
}
示例#7
0
void
BrowseModel::list_root ()
{
	while (!m_list.isEmpty ()) {
		delete m_list.takeFirst ();
	}

	m_list.append (new BrowseModelItem ("file:///", "Files", true));
	// FIXME: removed for now, crashes application
//	m_list.append (new BrowseModelItem ("daap://", "DAAP", true));
	emit dirChanged ("");

	reset ();

	m_current_dir = "";
}
示例#8
0
void FileModel::setDir(QString dir)
{
    if (m_dir == dir)
        return;

    // update watcher to watch the new directory
    if (!m_dir.isEmpty())
        m_watcher->removePath(m_dir);
    if (!dir.isEmpty())
        m_watcher->addPath(dir);

    m_dir = dir;

    readDirectory();
    m_dirty = false;

    emit dirChanged();
}
示例#9
0
PMainWindow::PMainWindow(QWidget* wid, const char* name, WFlags style)
    : QMainWindow( wid, name, style ), m_info( 0 ), m_disp( 0 )
{
    setCaption( QObject::tr("Opie Eye" ) );
    m_cfg = new Opie::Core::OConfig("opie-eye");
    m_cfg->setGroup("main" );
    readConfig();
    m_setDocCalled = false;
    m_polishDone = false;
    m_SmallWindow = QApplication::desktop()->size().width()<330;

    m_storage = new StorageInfo();
    connect(m_storage, SIGNAL(disksChanged() ),
            this, SLOT( dirChanged() ) );

    m_stack = new Opie::Ui::OWidgetStack( this );
    setCentralWidget( m_stack );

    m_view = new PIconView( m_stack, m_cfg );
    m_stack->addWidget( m_view, IconView );
    m_stack->raiseWidget( IconView );

    connect(m_view, SIGNAL(sig_display(const QString&)),
            this, SLOT(slotDisplay(const QString&)));
    connect(m_view, SIGNAL(sig_updateDisplay(const QString&)),
            this, SLOT(slotUpdateDisplay(const QString&)));
    connect(m_view, SIGNAL(sig_showInfo(const QString&)),
            this, SLOT(slotShowInfo(const QString&)) );
    connect(this,SIGNAL(changeListMode(int)),m_view,SLOT(slotChangeMode(int)));

    listviewMenu = 0;
    /* setup menu and toolbar */
    setupActions();
    setupToolbar();
    setupMenu();
    m_aHideToolbar->setOn(m_cfg->readBoolEntry("showtoolbar",true));
    m_aAutoRotate->setEnabled(!m_aUnscaled->isOn());
    if (m_aForceSmall) {
        m_aForceSmall->setOn(m_cfg->readBoolEntry("dontshowseperate",true));
    }
    odebug << "mainwindow constructor done" << oendl;
}
/*!
    \internal
    \brief Records point to list with timestamp.
    \param point Point to be recorded.
    \param time Time to be recorded.
    \return Nothing.

*/
void HbPointRecorder::record(qreal point, const QTime &time)
{
    // Empty list always accepts first point without tests.
    if ( !isEmpty() ) {
        // No point to record a point, if timestamp is less or equal with previous.
        if ( lastTime().msecsTo(time) == 0 ) {
            DEBUG() << "Ignoring point, because no difference in time stamps.";
            return;
        }

        // Don't tolerate points, which are too close to previously recorded point.
        if ( qAbs(lastPoint() - point) < mThreshold ) {
            DEBUG() << "Ignoring point, because it is withing threshold of previous point";
            return;
        }
    }

    // In case the list contains two or more points, direction can be
    // determined. Each new point added needs to be checked for direction
    // change.
    if ( length() > 1 ) {
        // Clear list, on direction change. Leave the last recorded point
        // to the list, as it can be considered as first point for new direction.
        if ( dirChanged( point ) ) {
            HbPointTime temp = last();
            clear();
            append(temp);
        }
    }

    // Finally check, if the position has changed. Don't record point, when no position
    // change.
    if ( isEmpty() || point != lastPoint() ) {
        // Add point and time to list.
        append(HbPointTime(point, time));
    } else {
        DEBUG() << "Ignoring point, because it equals previous.";
    }
}
示例#11
0
FileInfoThread::FileInfoThread(QObject *parent)
    : QThread(parent),
      abort(false),
#ifndef QT_NO_FILESYSTEMWATCHER
      watcher(0),
#endif
      sortFlags(QDir::Name),
      needUpdate(true),
      folderUpdate(false),
      sortUpdate(false),
      showFiles(true),
      showDirs(true),
      showDirsFirst(false),
      showDotAndDotDot(false),
      showHidden(false),
      showOnlyReadable(false)
{
#ifndef QT_NO_FILESYSTEMWATCHER
    watcher = new QFileSystemWatcher(this);
    connect(watcher, SIGNAL(directoryChanged(QString)), this, SLOT(dirChanged(QString)));
    connect(watcher, SIGNAL(fileChanged(QString)), this, SLOT(updateFile(QString)));
#endif // !QT_NO_FILESYSTEMWATCHER
}
示例#12
0
void FileWatcher::checkFiles()
{
	m_stateFlags |= AddRemoveBlocked;
	m_stateFlags |= FileCheckRunning;
	watchTimer->stop();
	m_stateFlags |= TimerStopped;
	QDateTime time;
	QStringList toRemove;
	
	QMap<QString, fileMod>::Iterator it;
	for ( it = watchedFiles.begin(); !(m_stateFlags & FileCheckMustStop) && it != watchedFiles.end(); ++it )
	{
		it.value().info.refresh();
		if (!it.value().info.exists())
		{
			if (m_stateFlags & FileCheckMustStop)
				break;
			if (!it.value().pending)
			{
				if (it.value().fast)
				{
					if (it.value().isDir)
						emit dirDeleted(it.key());
					else
						emit fileDeleted(it.key());
					if (m_stateFlags & FileCheckMustStop)
						break;
					it.value().refCount--;
					if (it.value().refCount == 0)
						toRemove.append(it.key());
					continue;
				}
				else
				{
					it.value().pendingCount = 5;
					it.value().pending = true;
					emit statePending(it.key());
					continue;
				}
			}
			else
			{
				if (it.value().pendingCount != 0)
				{
					it.value().pendingCount--;
					continue;
				}
				else
				{
					it.value().pending = false;
					if (it.value().isDir)
						emit dirDeleted(it.key());
					else
						emit fileDeleted(it.key());
					if (m_stateFlags & FileCheckMustStop)
						break;
					it.value().refCount--;
					if (it.value().refCount == 0)
						toRemove.append(it.key());
					continue;
				}
			}
		}
		else
		 {
			it.value().pending = false;
			time = it.value().info.lastModified();
			if (time != it.value().timeInfo)
			{
				if (it.value().isDir)
				{
					it.value().timeInfo = time;
					if (!(m_stateFlags & FileCheckMustStop))
						emit dirChanged(it.key());
				}
				else
				{
					uint sizeo = it.value().info.size();
					usleep(100);
					it.value().info.refresh();
					uint sizen = it.value().info.size();
					while (sizen != sizeo)
					{
						sizeo = sizen;
						usleep(100);
						it.value().info.refresh();
						sizen = it.value().info.size();
					}
					it.value().timeInfo = time;
					if (m_stateFlags & FileCheckMustStop)
						break;
					emit fileChanged(it.key());
				}
			}
		}
	}
	if (m_stateFlags & Dying)
		watchedFiles.clear();
	else
	{
		for( int i=0; i<toRemove.count(); ++i)
			watchedFiles.remove(toRemove[i]);
		m_stateFlags &= ~AddRemoveBlocked;
		m_stateFlags &= ~TimerStopped;
		watchTimer->start(m_timeOut);
	}
	m_stateFlags &= ~FileCheckRunning;
}
示例#13
0
void MadsPlayer::move() {
	bool routeFlag = false;

	if (_moving) {
		int idx = _routeCount; 
		while (!_v844C0 && (_destPos.x == _playerPos.x) && (_destPos.y == _playerPos.y)) {
			if (idx != 0) {
				--idx;
				SceneNode &node = _madsVm->scene()->getSceneResources()._nodes[_routeIndexes[idx]];
				_destPos = node.pt;
				routeFlag = true;
			} else if (_v844BE == idx) {
				// End of walking path
				_routeCount = 0;
				_moving = false;
				turnToDestFacing();
				routeFlag = true;
				idx = _routeCount;
			} else {
				_v844C0 = _v844BE;
				_v844BC = true;
				_v844BE = 0;
				_stepEnabled = true;
				routeFlag = false;
			}

			if (!_moving)
				break;
		}
		_routeCount = idx;
	}

	if (routeFlag && _moving)
		startMovement();

	if (_newDirection != _direction)
		dirChanged();
	else if (!_moving)
		updateFrame();

	int var1 = _unk1;
	if (_unk4 && (_hypotenuse > 0)) {
		int v1 = -(_currentScale - 100) * (_posDiff.x - 1) / _hypotenuse + _currentScale;
		var1 = MAX(1, 10000 / (v1 * _currentScale * var1));
	}

	if (!_moving || (_direction != _newDirection))
		return;

	Common::Point newPos = _playerPos;

	if (_v8452E < var1) {
		do {
			if (_v8452C < _posDiff.x)
				_v8452C += _posDiff.y;
			if (_v8452C >= _posDiff.x) {
				if ((_posChange.y > 0) || (_v844C0 != 0))
					newPos.y += _yDirection;
				--_posChange.y;
				_v8452C -= _posDiff.x;
			}

			if (_v8452C < _posDiff.x) {
				if ((_posChange.x > 0) || (_v844C0 != 0))
					newPos.x += _xDirection;
				--_posChange.x;
			}

			if ((_v844BC == 0) && (_v844C0 == 0) && (_v844BE == 0)) {
				routeFlag = _madsVm->scene()->getDepthHighBit(newPos);

				if (_special == 0)
					_special = _madsVm->scene()->getDepthHighBits(newPos);
			}

			_v8452E += _v84530;

		} while ((_v8452E < var1) && !routeFlag && ((_posChange.x > 0) || (_posChange.y > 0) || (_v844C0 != 0)));
	}

	_v8452E -= var1;

	if (routeFlag)
		moveComplete();
	else {
		if (!_v844C0) {
			// If the move is complete, make sure the position is exactly on the given destination
			if (_posChange.x == 0)
				newPos.x = _destPos.x;
			if (_posChange.y == 0)
				newPos.y = _destPos.y;
		}

		_playerPos = newPos;
	}
}
示例#14
0
HPicSync::HPicSync(QWidget *parent)
    : QMainWindow(parent), ui(new Ui::HPicSync),mOptionWidget(NULL),mThreadManager(this),mDirManager(mThreadManager,mDatabaseHandler,mOption),
      mThumbManager(mDatabaseHandler, mOption),mMoreThanOneSelected(false)

{
    ui->setupUi(this);

    ui->listWidgetNew->setItemDelegate(new HPSListViewDelegate(mOption.getThumbSize(),&mMoreThanOneSelected,this));
    ui->listWidgetOld->setItemDelegate(new HPSOldListDelegate(mOption.getThumbSize(),this));

    mDirManager.setModel( ui->comboBox->standardModel());
    initCBOrdner(mOption.getComboBoxView(),mOption.getComboBoxCurrentDir());


    QStatusBar *bar = ui->statusbar;
    mConnectLabel = new QLabel(tr("nicht verbunden"));
    mConnectPixGruenLabel = new QLabel();
    mConnectPixGruenLabel->setPixmap(QPixmap(":/knopfGruen").scaled(QSize(17,17),Qt::KeepAspectRatio));
    mConnectPixRotLabel = new QLabel();
    mConnectPixRotLabel->setPixmap(QPixmap(":/knopfRot").scaled(QSize(17,17),Qt::KeepAspectRatio));
    mBar = new HPSProgressBar;
    // this->mPixOldLoadCountLabel = new QLabel("");
    //this->mPixOldLoadCountLabel->setVisible(false);
    mBar->setVisible(false);
    mBar->setValue(0);
    mBar->setTextVisible(false);
    bar->addWidget(this->mConnectPixGruenLabel);
    bar->addWidget(this->mConnectPixRotLabel);
    bar->addWidget(this->mConnectLabel);
    bar->addPermanentWidget( mBar);
ui->progressBar->hide();
    /*
    this->connect(this->mCloseButton,SIGNAL(clicked()),this,SLOT(close()));
    this->connect(this->mOptionButton,SIGNAL(clicked()),this,SLOT(showOption()));
    this->connect(this->mRefreshButton,SIGNAL(clicked()),this,SLOT(test()));
    this->connect(this->mCopyButton,SIGNAL(clicked()),this,SLOT(test2()));

    connect(mPlusButton,SIGNAL(clicked()),this,SLOT(clickedPlus()));
    connect( &mThumbManager,SIGNAL(thumbsReady(int)),this,SLOT(refreshBar(int)));
    connect( &mThumbManager,SIGNAL(startThumbCreation(QString,int)),this,SLOT(initBar(QString,int)));
    connect( &mThumbManager,SIGNAL(dirCreationReady(QString)),&mDirManager,SLOT(finishAddDir(QString)));
    //connect( &mThumbManager,SIGNAL(startCreation()),this,SLOT(startBar()));
    connect( &mThumbManager,SIGNAL(creationReady()),this,SLOT(finishBar()));
    connect( mMinusButton,SIGNAL(clicked()),this,SLOT(clickedMinus()));

*/
    connect( ui->comboBox,SIGNAL(dirChanged(QString)),this,SLOT(comboBoxDirClicked(QString)));
    setGeometry(mOption.getGeometry());
    if(!mDatabaseHandler.openDatabase("picsync.db"))
        QMessageBox::critical(this, trUtf8("Fehler"), trUtf8("Verbindeung mit der Datenbank konnte nicht hergestellt werden."),QMessageBox::Ok);

    QDir dir( QApplication::applicationDirPath());
    if(!dir.exists(".thumbs")){
        dir.mkdir(".thumbs");
    }

    initThumbManager();
    qDebug() << Q_FUNC_INFO << mOption.dirFromDirlister();
    if(!mOption.dirFromDirlister().isEmpty()){
        mDirManager.startAddDir(mOption.dirFromDirlister(),true);
    }
    mThreadManager.initDirWatcher(mOption,mDirManager,mDatabaseHandler);
   HPSDirWatcher *dirWatcher =  mThreadManager.dirWatcher();
   connect(this,SIGNAL(startFirstRun()),dirWatcher,SLOT(startFirstRun()));
   emit startFirstRun();

}
示例#15
0
void FileWatcher::checkFiles()
{
	m_stateFlags |= AddRemoveBlocked;
	m_stateFlags |= FileCheckRunning;
	m_watchTimer->stop();
	m_stateFlags |= TimerStopped;
	QDateTime time;
	QStringList toRemove;
	
	QMap<QString, fileMod>::Iterator it;
//	qDebug()<<files();
	for ( it = m_watchedFiles.begin(); !(m_stateFlags & FileCheckMustStop) && it != m_watchedFiles.end(); ++it )
	{
		it.value().info.refresh();
		if (!it.value().info.exists())
		{
			if (m_stateFlags & FileCheckMustStop)
				break;
			if (!it.value().pending)
			{
				if (it.value().fast)
				{
					if (it.value().isDir)
						emit dirDeleted(it.key());
					else
						emit fileDeleted(it.key());
					if (m_stateFlags & FileCheckMustStop)
						break;
					it.value().refCount--;
					if (it.value().refCount == 0)
						toRemove.append(it.key());
					continue;
				}
				it.value().pendingCount = 5;
				it.value().pending = true;
				emit statePending(it.key());
				continue;
			}
			if (it.value().pendingCount != 0)
			{
				it.value().pendingCount--;
				continue;
			}
			it.value().pending = false;
			if (it.value().isDir)
				emit dirDeleted(it.key());
			else
				emit fileDeleted(it.key());
			if (m_stateFlags & FileCheckMustStop)
				break;
			it.value().refCount--;
			if (it.value().refCount == 0)
				toRemove.append(it.key());
			continue;
		}
		//qDebug()<<it.key();
		it.value().pending = false;
		time = it.value().info.lastModified();
		if (time != it.value().timeInfo)
		{
			//				qDebug()<<"Times different: last modified:"<<time<<"\t recorded time:"<<it.value().timeInfo;
			if (it.value().isDir)
			{
				//					qDebug()<<"dir, ignoring"<<it.key();
				it.value().timeInfo = time;
				if (!(m_stateFlags & FileCheckMustStop))
					emit dirChanged(it.key());
			}
			else
			{
				qint64 sizeo = it.value().info.size();
				std::this_thread::sleep_for(std::chrono::milliseconds(1));
				it.value().info.refresh();
				qint64 sizen = it.value().info.size();
				//					qDebug()<<"Size comparison"<<sizeo<<sizen<<it.key();
				while (sizen != sizeo)
				{
					sizeo = sizen;
					std::this_thread::sleep_for(std::chrono::milliseconds(1));
					it.value().info.refresh();
					sizen = it.value().info.size();
				}
				it.value().timeInfo = time;
				if (m_stateFlags & FileCheckMustStop)
					break;
				emit fileChanged(it.key());
			}
		}
	}
	if (m_stateFlags & Dying)
		m_watchedFiles.clear();
	else
	{
		for (int i=0; i<toRemove.count(); ++i)
			m_watchedFiles.remove(toRemove[i]);
		m_stateFlags &= ~AddRemoveBlocked;
		m_stateFlags &= ~TimerStopped;
		m_watchTimer->start(m_timeOut);
	}
	m_stateFlags &= ~FileCheckRunning;
}
示例#16
0
bool
BrowseModel::list_cb (const Xmms::List< Xmms::Dict > &res)
{
	while (!m_list.isEmpty ()) {
		delete m_list.takeFirst ();
	}

#if HAVE_XMMSV
	for (Xmms::List< Xmms::Dict >::const_iterator iter = res.begin();
	     iter != res.end(); ++iter) {
		Xmms::Dict d = *iter;
#else
	for (res.first (); res.isValid (); ++res) {
		Xmms::Dict d = *res;
#endif

		if (!d.contains ("path"))
			continue;

		QString path = QString::fromStdString (d.get<std::string> ("path"));

		QString name;
		if (d.contains ("name")) {
			name = QString::fromStdString (d.get<std::string> ("name"));
		} else {
			if (d.contains ("title")) {
				if (d.contains ("artist")) {
					name += QString::fromStdString (d.get<std::string> ("artist"));
					name += " - ";
				}
				if (d.contains ("album")) {
					name += QString::fromStdString (d.get<std::string> ("album"));
					name += " - ";
				}
				if (d.contains ("tracknr")) {
					name += QString::number (d.get<int32_t>
											 ("tracknr")).rightJustified(2, '0');
					name += " - ";
				}
				name += QString::fromStdString (d.get<std::string> ("title"));
			} else {
				QString tmp2 = path.mid (path.lastIndexOf ("/")+1);
				name = decodeXmmsUrl (tmp2);
			}
		}

		bool isdir = d.get<int32_t> ("isdir");

		if (m_filter_dot && name.startsWith ("."))
			// skip these files 
			continue;

		m_list.append (new BrowseModelItem (path, name, isdir));
	}

	qSort (m_list.begin (), m_list.end (), BrowseModelItem::itemCompare);

	//qDebug ("%s", m_list.size() > 0 ? qPrintable(m_list.at(0)->data("name")) : "none");

	reset ();

	emit dirChanged (m_current_dir);

	return true;
}

/* QModel overrides */
int
BrowseModel::rowCount (const QModelIndex &parent) const
{
	if (parent.isValid())
		return 0;

	return m_list.size ();
}

int
BrowseModel::columnCount (const QModelIndex &parent) const
{
	return m_columns.size ();
}

QVariant
BrowseModel::data (const QModelIndex &index,
						 int role) const
{
	if (!index.isValid ())
		return QVariant ();

	if (index.column () == 0 && role == Qt::DecorationRole)
		return fileIcon(index);

	if (role != Qt::DisplayRole)
		return QVariant ();

	QString h = m_columns[index.column ()].toLower ();

	return QVariant (m_list.at (index.row ())->data (h));
}

QVariant
BrowseModel::headerData (int section,
						 Qt::Orientation orientation,
						 int role) const
{
	if (role == Qt::DisplayRole)
		return QVariant (m_columns[section]);
	return QVariant ();
}

QIcon
BrowseModel::fileIcon (const QModelIndex &index) const
{
    if (!index.isValid())
		return QIcon ();

	BrowseModelItem *item = m_list.at (index.row ());
	if (item && item->isDir ())
    	return QIcon (m_style->standardPixmap (QStyle::SP_DirClosedIcon));

	return QIcon (m_style->standardPixmap (QStyle::SP_FileIcon));
}
SaveStreamDialog::SaveStreamDialog(StreamTableModel *model, const QHash<QString, QVariant> &settings, const QString &streamTitle, QWidget *parent):
    QDialog(parent)
{
    this->settings = settings;

    QVBoxLayout *mainLayout = new QVBoxLayout(this);
    QHBoxLayout *buttonLayout = new QHBoxLayout();
    QFormLayout *formLayout = new QFormLayout();

    QDataWidgetMapper *dataMapper = new QDataWidgetMapper(this);

    editFileName = new FilePathEdit(this);
    QLabel *suffixHint = new QLabel(this);
    checkSubtitles = new QCheckBox("Ladda ner undertexter till:", this);
    checkSubtitles->hide();
    editSubFileName = new FilePathEdit(this);
    editSubFileName->setEnabled(false);
    editSubFileName->hide();
    comboQuality = new QComboBox(this);
    editStreamUrl = new QLineEdit(this);
    editStreamUrl->hide();
    editSubUrl = new QLineEdit(this);
    editSubUrl->hide();
    editSubUrl->setEnabled(false);

    QFrame *line = new QFrame(this);
    line->setFrameShape(QFrame::HLine);
    line->setGeometry(QRect(320, 150, 118, 3));
    line->setFrameShadow(QFrame::Sunken);
    QCheckBox *checkEdit = new QCheckBox(QString::fromUtf8("Redigera addresser"), this);
    QPushButton *buttonPlay = new QPushButton("Spela upp", this);
    buttonSubmit = new QPushButton("Ladda ner", this);
    buttonSubmit->setDefault(true);
    QPushButton *buttonCancel = new QPushButton("Avbryt", this);

    connect(checkEdit, SIGNAL(clicked(bool)), editStreamUrl, SLOT(setVisible(bool)));
    connect(checkEdit, SIGNAL(clicked(bool)), editSubUrl, SLOT(setVisible(bool)));
    connect(buttonSubmit, SIGNAL(clicked()), this, SLOT(checkOverWrite()));
    connect(buttonCancel, SIGNAL(clicked()), this, SLOT(reject()));
    connect(comboQuality, SIGNAL(currentIndexChanged(int)), dataMapper, SLOT(setCurrentIndex(int)));
    connect(comboQuality, SIGNAL(currentIndexChanged(int)), this, SLOT(comboActivated(int)));
    connect(checkSubtitles, SIGNAL(clicked(bool)), editSubFileName, SLOT(setEnabled(bool)));
    connect(checkSubtitles, SIGNAL(clicked(bool)), editSubUrl, SLOT(setEnabled(bool)));
    connect(checkSubtitles, SIGNAL(clicked(bool)), this, SLOT(enableSubmit()));
    connect(editFileName, SIGNAL(pathValid(bool)), this, SLOT(enableSubmit()));
    connect(editFileName, SIGNAL(dirChanged(QString)), editSubFileName, SLOT(setDir(QString)));
    connect(editSubFileName, SIGNAL(pathValid(bool)), this, SLOT(enableSubmit()));
    connect(buttonPlay, SIGNAL(clicked()), this, SLOT(play()));

    QString filenameTemplate = settings.value("filename_template").toString();
    const QStringList templateVars = QStringList() << "title" << "name" << "time" << "season" << "description";
    for (int i=0; i<templateVars.count(); i++)
        filenameTemplate.replace("%" % templateVars.at(i) % "%", "%" % QString::number(i));
    QString fileName = filenameTemplate;
    QVariantMap metaData = model->metaData();
    for (int i=0; i<templateVars.count(); i++)
        fileName = fileName.arg(metaData.value(templateVars.at(i), "").toString());
    QString nullFileName = filenameTemplate;
    for (int i=0; i<templateVars.count(); i++)
        nullFileName = nullFileName.arg("");
    if (fileName != nullFileName) {
        QString suffix = model->data(model->index(0, StreamTableModel::SuffixHintColumn), Qt::UserRole).toString();
        suffix = !suffix.isEmpty() ? '.' % suffix : suffix;
        bool addSlash = !settings["start_dir"].toString().endsWith(QDir::separator());
        editFileName->setFilePath(settings["start_dir"].toString() % (addSlash ? (QString)QDir::separator() : "") % fileName % suffix);
        editSubFileName->setFilePath(settings["start_dir"].toString() % (addSlash ? (QString)QDir::separator() : "") % fileName);
    }
    else {
        editFileName->setFilePath(settings["start_dir"].toString());
        editSubFileName->setFilePath(settings["start_dir"].toString());
    }

    dataMapper->setModel(model);
    dataMapper->setCurrentIndex(comboQuality->currentIndex());
    dataMapper->addMapping(editStreamUrl, StreamTableModel::UrlColumn);
    dataMapper->addMapping(editSubUrl, StreamTableModel::SubtitlesColumn);
    dataMapper->addMapping(suffixHint, StreamTableModel::SuffixHintColumn, "text");

    comboQuality->setModel(model);

    formLayout->addRow("Ladda ner till:", editFileName);
    formLayout->addRow("", suffixHint);
    formLayout->addRow("Kvalitet:", comboQuality);
    formLayout->addRow("", editStreamUrl);
    formLayout->addRow(checkSubtitles, editSubFileName);
    formLayout->addRow("", editSubUrl);

    buttonLayout->addWidget(checkEdit);
    buttonLayout->addStretch(1);
    buttonLayout->addWidget(buttonPlay);
    buttonLayout->addWidget(buttonSubmit);
    buttonLayout->addWidget(buttonCancel);

    mainLayout->addLayout(formLayout);
    mainLayout->addWidget(line);
    mainLayout->addLayout(buttonLayout);

    setLayout(mainLayout);
    setWindowTitle(QString::fromUtf8("Spara ström - ") + streamTitle);
    setMinimumWidth(500);
}
示例#18
0
void HPSComboBox::onMPopupItemClicked(QString str)
{
    lineEdit()->setText(QDir::toNativeSeparators(str));
    emit dirChanged(str);
}