File: installedversionplugin.cpp

package info (click to toggle)
packagesearch 2.10.1
  • links: PTS
  • area: main
  • in suites: forky, sid, trixie
  • size: 2,704 kB
  • sloc: cpp: 9,176; perl: 248; makefile: 15; sh: 11
file content (71 lines) | stat: -rw-r--r-- 1,703 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
//
// C++ Implementation: %{MODULE}
//
// Description:
//
//
// Author: %{AUTHOR} <%{EMAIL}>, (C) %{YEAR}
//
// Copyright: See COPYING file that comes with this distribution
//
//
#include "installedversionplugin.h"

#include <packagenotfoundexception.h>

#include "ipackage.h"
#include "ipackagedb.h"

namespace NPlugin {

const QString InstalledVersionPlugin::PLUGIN_NAME = "InstalledVersionPlugin";


InstalledVersionPlugin::InstalledVersionPlugin(NApt::IPackageDB* pPackageDB) :
	_title(tr("Installed Version Plugin")),
	_briefDescription(tr("Shows the version of the installed package in the package list")),
	_description(tr("Shows the version of the installed package in the package list")),
	_pPackageDB(pPackageDB)
{
}


InstalledVersionPlugin::~InstalledVersionPlugin()
{
}


/////////////////////////////////////////////////////
// Plugin Interface
/////////////////////////////////////////////////////
 
void InstalledVersionPlugin::init(IProvider*)
{
}

/////////////////////////////////////////////////////
// ShortInformationPlugin Interface
/////////////////////////////////////////////////////

const QString InstalledVersionPlugin::shortInformationText(const string& package)
{
	try 
	{
        auto& packageStruct = _pPackageDB->getPackageRecord(package);
        if (packageStruct.installedState() == NApt::IPackage::INSTALLED)
            return QString(packageStruct.installedVersion());
        else
            return packageStruct.installedVersion();
	}
	catch (const PackageNotFoundException& e)
	{
		return _emptyString;
	}
}

/////////////////////////////////////////////////////
// InstalledVersionPlugin functions
/////////////////////////////////////////////////////


};