void DeviceProperties::ShowDevice(int row) {
  if (ui_->icon->count() == 0) {
    // Only load the icons the first time the dialog is shown
    QStringList icon_names = QStringList()
                             << "drive-removable-media-usb-pendrive"
                             << "multimedia-player-ipod-mini-blue"
                             << "multimedia-player-ipod-mini-gold"
                             << "multimedia-player-ipod-mini-green"
                             << "multimedia-player-ipod-mini-pink"
                             << "multimedia-player-ipod-mini-silver"
                             << "multimedia-player-ipod-nano-black"
                             << "multimedia-player-ipod-nano-white"
                             << "multimedia-player-ipod-nano-green"
                             << "multimedia-player-ipod-shuffle"
                             << "multimedia-player-ipod-standard-color"
                             << "multimedia-player-ipod-standard-monochrome"
                             << "multimedia-player-ipod-U2-color"
                             << "multimedia-player-ipod-U2-monochrome"
                             << "ipodtouchicon"
                             << "phone"
                             << "phone-google-nexus-one"
                             << "phone-htc-g1-white"
                             << "phone-nokia-n900"
                             << "phone-palm-pre";

    for (const QString& icon_name : icon_names) {
      QListWidgetItem* item = new QListWidgetItem(IconLoader::Load(icon_name, 
                                                  IconLoader::Base),
                                                  QString(), ui_->icon);
      item->setData(Qt::UserRole, icon_name);
    }

    // Load the transcode formats the first time the dialog is shown
    for (const TranscoderPreset& preset : Transcoder::GetAllPresets()) {
      ui_->transcode_format->addItem(preset.name_, preset.type_);
    }
    ui_->transcode_format->model()->sort(0);
  }

  index_ = manager_->index(row);

  // Basic information
  ui_->name->setText(index_.data(DeviceManager::Role_FriendlyName).toString());

  // Find the right icon
  QString icon_name = index_.data(DeviceManager::Role_IconName).toString();
  for (int i = 0; i < ui_->icon->count(); ++i) {
    if (ui_->icon->item(i)->data(Qt::UserRole).toString() == icon_name) {
      ui_->icon->setCurrentRow(i);
      break;
    }
  }

  UpdateHardwareInfo();
  UpdateFormats();

  show();
}
Example #2
0
void DeviceProperties::ModelChanged() {
    if (!isVisible()) return;

    if (!index_.isValid())
        reject();  // Device went away
    else {
        UpdateHardwareInfo();
        UpdateFormats();
    }
}
void UpdatePlugins(FarDialog* D, ArchiveModule* pModule, ArchiveFilterEntry* pFE)
{
	int index = 0;

	D->ListDelete(ID_FOF_PLUGINLIST, NULL);
	
	index = D->ListAddStr(ID_FOF_PLUGINLIST, _T("All"));
	D->ListSetDataEx(ID_FOF_PLUGINLIST, index, (void*)0, sizeof(void*));

	FarListPos pos;

	pos.SelectPos = 0; //all
	pos.TopPos = -1;

	if ( pModule )
	{
		Array<ArchivePlugin*>& plugins = pModule->GetPlugins();

		if ( pModule->QueryCapability(AMF_SUPPORT_SINGLE_PLUGIN_QUERY) )
		{
			for (unsigned int i = 0; i < plugins.count(); i++)
			{
				ArchivePlugin* pPlugin = plugins[i];

				index = D->ListAddStr(ID_FOF_PLUGINLIST, FSF.PointToName(pPlugin->GetModuleName()));
				D->ListSetDataEx(ID_FOF_PLUGINLIST, index, (void*)pPlugin, sizeof(void*));

				if ( pFE && !pFE->IsAllPlugins() && pFE->GetPlugin() && (pFE->GetPlugin()->GetUID() == pPlugin->GetUID()) )
					pos.SelectPos = index;
			}
		}
	}


	D->ListSetCurrentPos(ID_FOF_PLUGINLIST, &pos);
	ArchivePlugin* pPlugin = (ArchivePlugin*)D->ListGetData(ID_FOF_PLUGINLIST, pos.SelectPos);

	UpdateFormats(D, pPlugin, pFE);
}
LONG_PTR __stdcall hndFilterOneFormat(FarDialog* D, int nMsg, int nParam1, LONG_PTR nParam2)
{
	ArchiveFilterEntry* pFE = (ArchiveFilterEntry*)D->GetDlgData();

	if ( (nMsg == DN_LISTCHANGE) && (nParam1 == ID_FOF_ACTIONLIST) )
	{
		if ( nParam2 == 1 ) //do block
		{	
			FarListPos pos;

			D->ListGetCurrentPos(ID_FOF_MODULELIST, &pos);


			FarListInsert ins;

			ins.Index = 0;
			ins.Item.Flags = 0;
#ifdef UNICODE
			ins.Item.Text = _T("All");
#else
			strcpy(ins.Item.Text, _T("All"));
#endif

			int index = D->ListInsert(ID_FOF_MODULELIST, &ins);
			D->ListSetDataEx(ID_FOF_MODULELIST, index, (void*)0, sizeof(void*));

			pos.SelectPos++;
			D->ListSetCurrentPos(ID_FOF_MODULELIST, &pos);

		}
		else
		{
			FarListDelete del;

			del.StartIndex = 0;
			del.Count = 1;

			D->ListDelete(ID_FOF_MODULELIST, &del);
////////////
			FarListPos pos;
			D->ListGetCurrentPos(ID_FOF_MODULELIST, &pos);

			if ( pos.SelectPos != -1 )
			{
				ArchiveModule* pModule = (ArchiveModule*)D->ListGetData(ID_FOF_MODULELIST, pos.SelectPos);

				UpdatePlugins(D, pModule, NULL);
			}

			return TRUE;
//////////////


		}

		return TRUE;
	}
	else

	if ( (nMsg == DN_LISTCHANGE) && (nParam1 == ID_FOF_MODULELIST) )
	{
		FarListPos pos;
		D->ListGetCurrentPos(ID_FOF_MODULELIST, &pos);

		if ( pos.SelectPos != -1 )
		{
			ArchiveModule* pModule = (ArchiveModule*)D->ListGetData(ID_FOF_MODULELIST, pos.SelectPos);

			UpdatePlugins(D, pModule, NULL);
		}

		return TRUE;
	}
	else

	if ( (nMsg == DN_LISTCHANGE) && (nParam1 == ID_FOF_PLUGINLIST) )
	{
		FarListPos pos;
		D->ListGetCurrentPos(ID_FOF_PLUGINLIST, &pos);

		if ( pos.SelectPos != -1 )
		{
			ArchivePlugin* pPlugin = (ArchivePlugin*)D->ListGetData(ID_FOF_PLUGINLIST, pos.SelectPos);

			UpdateFormats(D, pPlugin, NULL);
		}

		return TRUE;
	}
	else

	if ( nMsg == DN_INITDIALOG )
	{
		FarListPos pos;

		D->ListAddStr(ID_FOF_ACTIONLIST, _T("Process"));
		D->ListAddStr(ID_FOF_ACTIONLIST, _T("Block"));

		pos.SelectPos = pFE->IsExclude()?1:0;

		D->ListSetCurrentPos(ID_FOF_ACTIONLIST, &pos);
		
		pos.SelectPos = 0;
		pos.TopPos = -1;

		Array<ArchiveModule*> modules;
		
		pManager->GetModules(modules);

		for (unsigned int i = 0; i < modules.count(); i++)
		{
			const ArchiveModule* pModule = modules[i];

			int index = D->ListAddStr(ID_FOF_MODULELIST, FSF.PointToName(pModule->GetModuleName()));
			D->ListSetDataEx(ID_FOF_MODULELIST, index, (void*)pModule, sizeof(void*));

			if ( pFE && !pFE->IsAllModules() && pFE->GetModule() && (pFE->GetModule()->GetUID() == pModule->GetUID()) )
				pos.SelectPos = index;
		}

		D->ListSetCurrentPos(ID_FOF_MODULELIST, &pos); 

		ArchiveModule* pModule = (ArchiveModule*)D->ListGetData(ID_FOF_MODULELIST, pos.SelectPos);
		UpdatePlugins(D, pModule, pFE); 

		//return TRUE; hmm
	}
	else

	if ( (nMsg == DN_CLOSE) && (nParam1 == D->FirstButton()) )
	{
		string strName = D->GetConstTextPtr(ID_FOF_NAMEEDIT);

		if ( strName.IsEmpty() )
		{
			msgError(_T("name empty"));
			return FALSE;
		}

		string strMask = D->GetConstTextPtr(ID_FOF_MASKEDIT);

		if ( strMask.IsEmpty() )
		{
			msgError(_T("mask empty"));
			return FALSE;
		}

		FarListPos pos;

		D->ListGetCurrentPos(ID_FOF_ACTIONLIST, &pos);

		pFE->SetExclude(pos.SelectPos == 1);
		pFE->SetName(strName);
		pFE->SetMask(strMask);

		pFE->SetAllFormats(true);
		pFE->SetAllModules(true);
		pFE->SetAllPlugins(true);

		D->ListGetCurrentPos(ID_FOF_MODULELIST, &pos);
		ArchiveModule* pModule = (ArchiveModule*)D->ListGetData(ID_FOF_MODULELIST, pos.SelectPos);

		if ( pModule )
		{
			pFE->SetModule(pModule);

			D->ListGetCurrentPos(ID_FOF_PLUGINLIST, &pos);
			ArchivePlugin* pPlugin = (ArchivePlugin*)D->ListGetData(ID_FOF_PLUGINLIST, pos.SelectPos);

			if ( pPlugin )
			{
				pFE->SetPlugin(pPlugin);

				D->ListGetCurrentPos(ID_FOF_FORMATLIST, &pos);
				ArchiveFormat* pFormat = (ArchiveFormat*)D->ListGetData(ID_FOF_FORMATLIST, pos.SelectPos);

				if ( pFormat )
					pFE->SetFormat(pFormat);
			}
		}

		return TRUE;
	}
	
	return D->DefDlgProc(nMsg, nParam1, nParam2);
}